diff options
author | George Hazan <ghazan@miranda.im> | 2023-04-28 14:01:31 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2023-04-28 14:01:40 +0300 |
commit | 0999f2e0525dffdd53c25dcd7cea47f5e5c9b7d9 (patch) | |
tree | bada2d76fefcd508a0a3c08ed8b6d606462744a6 /plugins/Clist_modern/src | |
parent | 579ed77dab547aa695dd98b1e96e241236462861 (diff) |
code cleaning
Diffstat (limited to 'plugins/Clist_modern/src')
-rw-r--r-- | plugins/Clist_modern/src/modern_clcitems.cpp | 4 | ||||
-rw-r--r-- | plugins/Clist_modern/src/modern_commonprototypes.h | 3 | ||||
-rw-r--r-- | plugins/Clist_modern/src/modern_statusbar.cpp | 2 | ||||
-rw-r--r-- | plugins/Clist_modern/src/modern_viewmodebar.cpp | 79 |
4 files changed, 36 insertions, 52 deletions
diff --git a/plugins/Clist_modern/src/modern_clcitems.cpp b/plugins/Clist_modern/src/modern_clcitems.cpp index a2472b99d8..4e33e9843d 100644 --- a/plugins/Clist_modern/src/modern_clcitems.cpp +++ b/plugins/Clist_modern/src/modern_clcitems.cpp @@ -420,12 +420,12 @@ int CLVM_GetContactHiddenStatus(MCONTACT hContact, char *szProto, ClcData *dat) szProto = Proto_GetBaseAccountName(hContact);
// check stickies first (priority), only if we really have stickies defined (CLVM_STICKY_CONTACTS is set).
if (g_CluiData.bFilterEffective & CLVM_STICKY_CONTACTS) {
- if (uint32_t dwLocalMask = db_get_dw(hContact, CLVM_MODULE, g_CluiData.current_viewmode, 0)) {
+ if (uint32_t dwLocalMask = db_get_dw(hContact, CLVM_MODULE, g_CluiData.current_viewmode)) {
if (g_CluiData.bFilterEffective & CLVM_FILTER_STICKYSTATUS) {
uint16_t wStatus = db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE);
return !((1 << (wStatus - ID_STATUS_OFFLINE)) & HIWORD(dwLocalMask)) | searchResult;
}
- return 0 | searchResult;
+ return searchResult;
}
}
diff --git a/plugins/Clist_modern/src/modern_commonprototypes.h b/plugins/Clist_modern/src/modern_commonprototypes.h index f195c29ad7..78cc984508 100644 --- a/plugins/Clist_modern/src/modern_commonprototypes.h +++ b/plugins/Clist_modern/src/modern_commonprototypes.h @@ -190,7 +190,8 @@ void UnLoadContactListModule(); / void UpdateAllAvatars(ClcData *dat); //cache_func.c
void ApplyViewMode(const char *Name);
-void SaveViewMode(const char *name, const wchar_t *szGroupFilter, const char *szProtoFilter, uint32_t statusMask, uint32_t stickyStatusMask, unsigned int options, unsigned int operators, unsigned int lmdat);
+void SaveViewMode(const char *name, const wchar_t *szGroupFilter, const char *szProtoFilter, unsigned dwStatusMask, unsigned dwStickyStatusMask,
+ unsigned stickies, unsigned options, unsigned operators, unsigned lmdat);
// cluiframes.c
int ExtraImage_ExtraIDToColumnNum(int extra);
diff --git a/plugins/Clist_modern/src/modern_statusbar.cpp b/plugins/Clist_modern/src/modern_statusbar.cpp index a837731805..87f004fe4d 100644 --- a/plugins/Clist_modern/src/modern_statusbar.cpp +++ b/plugins/Clist_modern/src/modern_statusbar.cpp @@ -810,7 +810,7 @@ LRESULT CALLBACK ModernStatusProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPa }
}
- SaveViewMode(szFilterName, L"", g_CluiData.protoFilter, 0, -1, 0, 0, 0);
+ SaveViewMode(szFilterName, L"", g_CluiData.protoFilter, 0, -1, 0, 0, 0, 0);
ApplyViewMode(szFilterName);
}
Clist_Broadcast(CLM_AUTOREBUILD, 0, 0);
diff --git a/plugins/Clist_modern/src/modern_viewmodebar.cpp b/plugins/Clist_modern/src/modern_viewmodebar.cpp index 8fe23159dc..0d87f55bf5 100644 --- a/plugins/Clist_modern/src/modern_viewmodebar.cpp +++ b/plugins/Clist_modern/src/modern_viewmodebar.cpp @@ -36,13 +36,13 @@ HWND g_ViewModeOptDlg = nullptr; static HWND hwndSelector = nullptr;
static BOOL sttDrawViewModeBackground(HWND hwnd, HDC hdc, RECT *rect);
-static void DeleteViewMode(char * szName);
+static void DeleteViewMode(char *szName);
/////////////////////////////////////////////////////////////////////////////////////////
// enumerate all view modes, call the callback function with the mode name
// useful for filling lists, menus and so on..
-typedef int (__cdecl *pfnEnumCallback)(char *szName);
+typedef int(__cdecl *pfnEnumCallback)(char *szName);
static int CLVM_EnumProc(const char *szSetting, void *lParam)
{
@@ -66,8 +66,8 @@ static int DeleteAutoModesCallback(char *szsetting) return 1;
}
-void SaveViewMode(const char *name, const wchar_t *szGroupFilter, const char *szProtoFilter, uint32_t dwStatusMask, uint32_t dwStickyStatusMask,
- unsigned int options, unsigned int operators, unsigned int lmdat)
+void SaveViewMode(const char *name, const wchar_t *szGroupFilter, const char *szProtoFilter, unsigned dwStatusMask, unsigned dwStickyStatusMask,
+ unsigned stickies, unsigned options, unsigned operators, unsigned lmdat)
{
CLVM_EnumModes(DeleteAutoModesCallback);
@@ -85,7 +85,7 @@ void SaveViewMode(const char *name, const wchar_t *szGroupFilter, const char *sz mir_snprintf(szSetting, "%c%s_LM", 246, name);
db_set_dw(0, CLVM_MODULE, szSetting, lmdat);
- db_set_dw(0, CLVM_MODULE, name, MAKELONG((unsigned short)operators, 0));
+ db_set_dw(0, CLVM_MODULE, name, MAKELONG((unsigned short)operators, (unsigned short)stickies));
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -133,7 +133,7 @@ public: CMStringW newGroupFilter;
CMStringA newProtoFilter, szModeName;
- uint32_t statusMask, operators, lmdat, options, dwGlobalMask;
+ unsigned statusMask, operators, lmdat, options, iStickies, iStickiesMask;
CViewModeSetupDlg();
@@ -369,7 +369,7 @@ public: int iNewItem = cmbModes.AddString(es.ptszResult);
if (iNewItem != LB_ERR) {
cmbModes.SetCurSel(iNewItem);
- SaveViewMode(szUTF8Buf, L"", "", 0, -1, 0, 0, 0);
+ SaveViewMode(szUTF8Buf, L"", "", 0, -1, 0, 0, 0, 0);
m_iCurrItem = iNewItem;
cmbProtoGroup.SetCurSel(0);
cmbGroupStatus.SetCurSel(0);
@@ -433,7 +433,7 @@ public: switch (IsDlgButtonChecked(m_hwnd, iCtrlId)) {
case BST_CHECKED: return ifChecked;
case BST_UNCHECKED: return ifUnchecked;
- default:
+ default:
return 0;
}
}
@@ -622,7 +622,7 @@ class CViewModeSetupDlg2 : public CViewModePage {
CCtrlClc clist;
CCtrlButton btnClearAll;
-
+
int nullImage;
uint32_t stickyStatusMask = 0;
HANDLE hInfoItem = nullptr;
@@ -750,7 +750,8 @@ public: void SaveState() override
{
- pOwner->dwGlobalMask = GetMaskForItem(hInfoItem);
+ pOwner->iStickiesMask = GetMaskForItem(hInfoItem);
+ pOwner->iStickies = 0;
for (auto &hContact : Contacts()) {
HANDLE hItem = clist.FindContact(hContact);
@@ -760,11 +761,9 @@ public: if (clist.GetCheck(hItem)) {
uint32_t dwLocalMask = GetMaskForItem(hItem);
db_set_dw(hContact, CLVM_MODULE, pOwner->szModeName, MAKELONG(1, (unsigned short)dwLocalMask));
+ pOwner->iStickies++;
}
- else {
- if (db_get_dw(hContact, CLVM_MODULE, pOwner->szModeName, 0))
- db_set_dw(hContact, CLVM_MODULE, pOwner->szModeName, 0);
- }
+ else db_unset(hContact, CLVM_MODULE, pOwner->szModeName);
}
}
@@ -860,13 +859,13 @@ bool CViewModeSetupDlg::OnApply() {
newGroupFilter.Empty();
newProtoFilter.Empty();
- statusMask = dwGlobalMask = options = operators = lmdat = 0;
+ statusMask = iStickiesMask = options = operators = lmdat = iStickies = 0;
for (auto &it : m_pages)
it->SaveState();
if (!szModeName.IsEmpty()) {
- SaveViewMode(szModeName, newGroupFilter, newProtoFilter, statusMask, dwGlobalMask, options, operators, lmdat);
+ SaveViewMode(szModeName, newGroupFilter, newProtoFilter, statusMask, iStickiesMask, iStickies, options, operators, lmdat);
if (g_CluiData.bFilterEffective)
ApplyViewMode(g_CluiData.current_viewmode);
@@ -1124,25 +1123,13 @@ clvm_config_command: return TRUE;
}
-static int hCLVMFrame;
HWND g_hwndViewModeFrame;
-struct view_mode_t
-{
- HBITMAP hBmpBackground;
- COLORREF bkColour;
- int useWinColors;
- int backgroundBmpUse;
-
- view_mode_t() :
- hBmpBackground(nullptr),
- bkColour(CLCDEFAULT_BKCOLOUR),
- useWinColors(CLCDEFAULT_USEWINDOWSCOLOURS),
- backgroundBmpUse(CLCDEFAULT_USEBITMAP)
- {}
-};
-
-static view_mode_t view_mode;
+static int hCLVMFrame;
+static int g_useWinColors = CLCDEFAULT_USEWINDOWSCOLOURS;
+static int g_backgroundBmpUse = CLCDEFAULT_USEBITMAP;
+static HBITMAP g_hBmpBackground = nullptr;
+static COLORREF g_bkColour = CLCDEFAULT_BKCOLOUR;
static BOOL sttDrawViewModeBackground(HWND hwnd, HDC hdc, RECT *rect)
{
@@ -1154,32 +1141,32 @@ static BOOL sttDrawViewModeBackground(HWND hwnd, HDC hdc, RECT *rect) else
GetClientRect(hwnd, &rc);
- if (!view_mode.hBmpBackground && !view_mode.useWinColors) {
- HBRUSH hbr = CreateSolidBrush(view_mode.bkColour);
+ if (!g_hBmpBackground && !g_useWinColors) {
+ HBRUSH hbr = CreateSolidBrush(g_bkColour);
FillRect(hdc, &rc, hbr);
DeleteObject(hbr);
}
- else DrawBackGround(hwnd, hdc, view_mode.hBmpBackground, view_mode.bkColour, view_mode.backgroundBmpUse);
+ else DrawBackGround(hwnd, hdc, g_hBmpBackground, g_bkColour, g_backgroundBmpUse);
}
return TRUE;
}
static int ehhViewModeBackgroundSettingsChanged(WPARAM, LPARAM)
{
- if (view_mode.hBmpBackground) {
- DeleteObject(view_mode.hBmpBackground);
- view_mode.hBmpBackground = nullptr;
+ if (g_hBmpBackground) {
+ DeleteObject(g_hBmpBackground);
+ g_hBmpBackground = nullptr;
}
if (g_CluiData.fDisableSkinEngine) {
- view_mode.bkColour = cliGetColor("ViewMode", "BkColour", CLCDEFAULT_BKCOLOUR);
+ g_bkColour = cliGetColor("ViewMode", "BkColour", CLCDEFAULT_BKCOLOUR);
if (db_get_b(0, "ViewMode", "UseBitmap", CLCDEFAULT_USEBITMAP)) {
ptrW tszBitmapName(db_get_wsa(0, "ViewMode", "BkBitmap"));
if (tszBitmapName)
- view_mode.hBmpBackground = Bitmap_Load(tszBitmapName);
+ g_hBmpBackground = Bitmap_Load(tszBitmapName);
}
- view_mode.useWinColors = db_get_b(0, "ViewMode", "UseWinColours", CLCDEFAULT_USEWINDOWSCOLOURS);
- view_mode.backgroundBmpUse = db_get_w(0, "ViewMode", "BkBmpUse", CLCDEFAULT_BKBMPUSE);
+ g_useWinColors = db_get_b(0, "ViewMode", "UseWinColours", CLCDEFAULT_USEWINDOWSCOLOURS);
+ g_backgroundBmpUse = db_get_w(0, "ViewMode", "BkBmpUse", CLCDEFAULT_BKBMPUSE);
}
PostMessage(g_clistApi.hwndContactList, WM_SIZE, 0, 0);
return 0;
@@ -1187,7 +1174,7 @@ static int ehhViewModeBackgroundSettingsChanged(WPARAM, LPARAM) static int ViewModePaintCallbackProc(HWND hWnd, HDC hDC, RECT *, HRGN, uint32_t, void *)
{
- RECT MyRect = { 0 };
+ RECT MyRect;
GetWindowRect(hWnd, &MyRect);
SkinDrawGlyph(hDC, &MyRect, &MyRect, "ViewMode,ID=Background");
@@ -1240,8 +1227,6 @@ void CreateViewModeFrame() void ApplyViewMode(const char *szName)
{
- DBVARIANT dbv = { 0 };
-
g_CluiData.bFilterEffective = 0;
char szSetting[256];
@@ -1260,7 +1245,6 @@ void ApplyViewMode(const char *szName) g_CluiData.bFilterEffective = 0;
// remove last applied view mode
- mir_snprintf(szSetting, "%c_LastMode", 246);
db_unset(0, CLVM_MODULE, szSetting);
if (g_CluiData.bOldUseGroups != -1)
@@ -1300,7 +1284,6 @@ void ApplyViewMode(const char *szName) wcsncpy_s(g_CluiData.groupFilter, wszGroupFilter.get(), _TRUNCATE);
g_CluiData.bFilterEffective |= CLVM_FILTER_GROUPS;
}
- mir_free(dbv.pwszVal);
mir_snprintf(szSetting, "%c%s_SM", 246, szName);
g_CluiData.statusMaskFilter = db_get_dw(0, CLVM_MODULE, szSetting, -1);
|