diff options
author | George Hazan <ghazan@miranda.im> | 2018-07-13 21:25:58 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-07-13 21:25:58 +0300 |
commit | 49fd24b153e3b7def24acbd873eb52e6b0fef55f (patch) | |
tree | f83d0cbc755ef403d13be85771b91c84851ff26d /plugins/Clist_nicer | |
parent | 520fca8c13037c9077e7d372c0d20a2364964ffb (diff) |
fixes #1471 completely (Clist_nicer: some elements cannot be translated on the fly)
Diffstat (limited to 'plugins/Clist_nicer')
-rw-r--r-- | plugins/Clist_nicer/src/cluiframes.cpp | 51 | ||||
-rw-r--r-- | plugins/Clist_nicer/src/cluiframes.h | 1 | ||||
-rw-r--r-- | plugins/Clist_nicer/src/version.h | 2 | ||||
-rw-r--r-- | plugins/Clist_nicer/src/viewmodes.cpp | 146 |
4 files changed, 105 insertions, 95 deletions
diff --git a/plugins/Clist_nicer/src/cluiframes.cpp b/plugins/Clist_nicer/src/cluiframes.cpp index 32609d0055..56ac254013 100644 --- a/plugins/Clist_nicer/src/cluiframes.cpp +++ b/plugins/Clist_nicer/src/cluiframes.cpp @@ -464,18 +464,16 @@ int LocateStorePosition(int Frameid, int maxstored) int CLUIFramesLoadFrameSettings(int Frameid) { - int storpos, maxstored; - if (FramesSysNotStarted) return -1; if (Frameid < 0 || Frameid >= nFramescount) return -1; - maxstored = db_get_w(NULL, CLUIFrameModule, "StoredFrames", -1); + int maxstored = db_get_w(NULL, CLUIFrameModule, "StoredFrames", -1); if (maxstored == -1) return 0; - storpos = LocateStorePosition(Frameid, maxstored); + int storpos = LocateStorePosition(Frameid, maxstored); if (storpos == -1) return 0; @@ -485,19 +483,17 @@ int CLUIFramesLoadFrameSettings(int Frameid) int CLUIFramesStoreFrameSettings(int Frameid) { - int maxstored, storpos; - if (FramesSysNotStarted) return -1; if (Frameid < 0 || Frameid >= nFramescount) return -1; - maxstored = db_get_w(NULL, CLUIFrameModule, "StoredFrames", -1); + int maxstored = db_get_w(NULL, CLUIFrameModule, "StoredFrames", -1); if (maxstored == -1) maxstored = 0; - storpos = LocateStorePosition(Frameid, maxstored); + int storpos = LocateStorePosition(Frameid, maxstored); if (storpos == -1) { storpos = maxstored; maxstored++; @@ -510,8 +506,6 @@ int CLUIFramesStoreFrameSettings(int Frameid) int CLUIFramesStoreAllFrames() { - int i; - if (FramesSysNotStarted) return -1; @@ -519,7 +513,7 @@ int CLUIFramesStoreAllFrames() return -1; mir_cslock lck(csFrameHook); - for (i = 0; i < nFramescount; i++) + for (int i = 0; i < nFramescount; i++) CLUIFramesStoreFrameSettings(i); return 0; } @@ -527,21 +521,18 @@ int CLUIFramesStoreAllFrames() // Get client frame int CLUIFramesGetalClientFrame(void) { - int i; if (FramesSysNotStarted) return -1; if (alclientFrame != -1) { /* this value could become invalid if RemoveItemFromList was called, * so we double-check */ - if (alclientFrame < nFramescount) { - if (Frames[alclientFrame].align == alClient) { + if (alclientFrame < nFramescount) + if (Frames[alclientFrame].align == alClient) return alclientFrame; - } - } } - for (i = 0; i < nFramescount; i++) + for (int i = 0; i < nFramescount; i++) if (Frames[i].align == alClient) { alclientFrame = i; return i; @@ -553,7 +544,6 @@ int CLUIFramesGetalClientFrame(void) static HGENMENU addFrameMenuItem(TMO_MenuItem *pmi, int frameid, bool bMain) { - pmi->pPlugin = &g_plugin; HGENMENU res = (bMain) ? Menu_AddMainMenuItem(pmi) : Menu_AddContextFrameMenuItem(pmi); if (pmi->pszService != nullptr) Menu_ConfigureItem(res, MCI_OPT_EXECPARAM, frameid); @@ -568,7 +558,7 @@ HMENU CLUIFramesCreateMenuForFrame(int frameid, HGENMENU root, int popuppos, boo int framepos = id2pos(frameid); FrameMenuHandles &fmh = (frameid == -1) ? cont : Frames[framepos].MenuHandles; - CMenuItem mi(&g_plugin); + CMenuItem mi((frameid == -1) ? &g_plugin : Frames[framepos].pPlugin); mi.hIcolibItem = Skin_GetIconHandle(SKINICON_OTHER_MIRANDA); mi.root = root; mi.position = popuppos++; @@ -1526,7 +1516,7 @@ static int CLUIFramesReSort() } //wparam=(CLISTFrame*)clfrm -INT_PTR CLUIFramesAddFrame(WPARAM wParam, LPARAM) +INT_PTR CLUIFramesAddFrame(WPARAM wParam, LPARAM lParam) { int style; CLISTFrame *clfrm = (CLISTFrame *)wParam; @@ -1550,8 +1540,8 @@ INT_PTR CLUIFramesAddFrame(WPARAM wParam, LPARAM) Frames[nFramescount].hWnd = clfrm->hWnd; Frames[nFramescount].height = clfrm->height; Frames[nFramescount].TitleBar.hicon = clfrm->hIcon; - //Frames[nFramescount].TitleBar.BackColour; - Frames[nFramescount].floating = FALSE; + Frames[nFramescount].floating = false; + Frames[nFramescount].pPlugin = (HPLUGIN)lParam; if (clfrm->Flags & F_NO_SUBCONTAINER) Frames[nFramescount].OwnerWindow = (HWND)-2; @@ -2202,14 +2192,17 @@ static int DrawTitleBar(HDC dc, RECT rect, int Frameid) SetTextColor(hdcMem, GetSysColor(COLOR_BTNTEXT)); } + const wchar_t *pwszTitle = TranslateW_LP(Frames[pos].TitleBar.tbname, Frames[pos].pPlugin); + int iTitleLen = (int)mir_wstrlen(pwszTitle); + if (!AlignCOLLIconToLeft) { if (Frames[pos].TitleBar.hicon != nullptr) { DrawIconEx(hdcMem, 6 + cfg::dat.bClipBorder, ((TitleBarH >> 1) - 8), Frames[pos].TitleBar.hicon, 16, 16, 0, nullptr, DI_NORMAL); - TextOut(hdcMem, 24 + cfg::dat.bClipBorder, fontTop, Frames[pos].TitleBar.tbname, (int)mir_wstrlen(Frames[pos].TitleBar.tbname)); + TextOut(hdcMem, 24 + cfg::dat.bClipBorder, fontTop, pwszTitle, iTitleLen); } - else TextOut(hdcMem, 6 + cfg::dat.bClipBorder, fontTop, Frames[pos].TitleBar.tbname, (int)mir_wstrlen(Frames[pos].TitleBar.tbname)); + else TextOut(hdcMem, 6 + cfg::dat.bClipBorder, fontTop, pwszTitle, iTitleLen); } - else TextOut(hdcMem, 18 + cfg::dat.bClipBorder, fontTop, Frames[pos].TitleBar.tbname, (int)mir_wstrlen(Frames[pos].TitleBar.tbname)); + else TextOut(hdcMem, 18 + cfg::dat.bClipBorder, fontTop, pwszTitle, iTitleLen); if (!AlignCOLLIconToLeft) DrawIconEx(hdcMem, Frames[pos].TitleBar.wndSize.right - 22, ((TitleBarH >> 1) - 8), Frames[pos].collapsed ? Skin_LoadIcon(SKINICON_OTHER_GROUPOPEN) : Skin_LoadIcon(SKINICON_OTHER_GROUPSHUT), 16, 16, 0, nullptr, DI_NORMAL); @@ -2886,6 +2879,13 @@ static int CLUIFrameOnModulesLoad(WPARAM, LPARAM) return 0; } +static int CLUIFrameLangChanged(WPARAM, LPARAM) +{ + ApplyViewMode(0); + g_clistApi.pfnInvalidateRect(g_clistApi.hwndContactList, nullptr, TRUE); + return 0; +} + static int CLUIFrameOnModulesUnload(WPARAM, LPARAM) { mf_updatethread_running = FALSE; @@ -2976,6 +2976,7 @@ int LoadCLUIFramesModule(void) HookEvent(ME_CLIST_PREBUILDFRAMEMENU, CLUIFramesModifyContextMenuForFrame); HookEvent(ME_CLIST_PREBUILDMAINMENU, CLUIFrameOnMainMenuBuild); HookEvent(ME_SYSTEM_PRESHUTDOWN, CLUIFrameOnModulesUnload); + HookEvent(ME_LANGPACK_CHANGED, CLUIFrameLangChanged); CreateServiceFunction(MS_CLIST_FRAMES_ADDFRAME, CLUIFramesAddFrame); CreateServiceFunction(MS_CLIST_FRAMES_REMOVEFRAME, CLUIFramesRemoveFrame); diff --git a/plugins/Clist_nicer/src/cluiframes.h b/plugins/Clist_nicer/src/cluiframes.h index 60e9ce7948..4716f0d4cd 100644 --- a/plugins/Clist_nicer/src/cluiframes.h +++ b/plugins/Clist_nicer/src/cluiframes.h @@ -110,6 +110,7 @@ struct FRAMEWND int order;
DockOpt dockOpt;
HWND OwnerWindow;
+ HPLUGIN pPlugin;
bool Skinned;
RECT oldWndSize;
WNDPROC wndProc;
diff --git a/plugins/Clist_nicer/src/version.h b/plugins/Clist_nicer/src/version.h index ede11e58e7..10004985db 100644 --- a/plugins/Clist_nicer/src/version.h +++ b/plugins/Clist_nicer/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0
#define __MINOR_VERSION 9
#define __RELEASE_NUM 3
-#define __BUILD_NUM 1
+#define __BUILD_NUM 2
#include <stdver.h>
diff --git a/plugins/Clist_nicer/src/viewmodes.cpp b/plugins/Clist_nicer/src/viewmodes.cpp index 35a700855d..bd46542ed9 100644 --- a/plugins/Clist_nicer/src/viewmodes.cpp +++ b/plugins/Clist_nicer/src/viewmodes.cpp @@ -393,7 +393,7 @@ void SaveState() BOOL translated;
DWORD lmdat = MAKELONG(GetDlgItemInt(sttClvmHwnd, IDC_LASTMSGVALUE, &translated, FALSE),
MAKEWORD(SendDlgItemMessage(sttClvmHwnd, IDC_LASTMESSAGEOP, CB_GETCURSEL, 0, 0),
- SendDlgItemMessage(sttClvmHwnd, IDC_LASTMESSAGEUNIT, CB_GETCURSEL, 0, 0)));
+ SendDlgItemMessage(sttClvmHwnd, IDC_LASTMESSAGEUNIT, CB_GETCURSEL, 0, 0)));
SaveViewMode(szModeName, newGroupFilter, newProtoFilter, statusMask, dwGlobalMask, options, stickies, operators, lmdat);
free(szModeName);
@@ -428,26 +428,26 @@ void UpdateFilters() mir_snwprintf(szTemp, TranslateT("Current view mode: %S"), sttModeName);
SetDlgItemText(sttClvmHwnd, IDC_CURVIEWMODE2, szTemp);
}
-
+
mir_snprintf(szSetting, "%c%s_PF", 246, szBuf);
if (db_get(NULL, CLVM_MODULE, szSetting, &dbv_pf))
goto cleanup;
-
+
mir_snprintf(szSetting, "%c%s_GF", 246, szBuf);
if (db_get_ws(NULL, CLVM_MODULE, szSetting, &dbv_gf))
goto cleanup;
-
+
mir_snprintf(szSetting, "%c%s_OPT", 246, szBuf);
if ((opt = db_get_dw(NULL, CLVM_MODULE, szSetting, -1)) != -1) {
SendDlgItemMessage(sttClvmHwnd, IDC_AUTOCLEARSPIN, UDM_SETPOS, 0, MAKELONG(LOWORD(opt), 0));
}
-
+
mir_snprintf(szSetting, "%c%s_SM", 246, szBuf);
statusMask = db_get_dw(NULL, CLVM_MODULE, szSetting, -1);
-
+
mir_snprintf(szSetting, "%c%s_SSM", 246, szBuf);
sttStickyStatusMask = db_get_dw(NULL, CLVM_MODULE, szSetting, -1);
-
+
dwFlags = db_get_dw(NULL, CLVM_MODULE, szBuf, 0);
{
char szMask[256];
@@ -500,7 +500,7 @@ void UpdateFilters() if ((1 << (i - ID_STATUS_OFFLINE)) & statusMask)
ListView_SetCheckState(hwndList, i - ID_STATUS_OFFLINE, TRUE)
else
- ListView_SetCheckState(hwndList, i - ID_STATUS_OFFLINE, FALSE);
+ ListView_SetCheckState(hwndList, i - ID_STATUS_OFFLINE, FALSE);
}
}
@@ -587,7 +587,7 @@ INT_PTR CALLBACK DlgProcViewModesSetup(HWND hwndDlg, UINT msg, WPARAM wParam, LP UpdateFilters();
}
else sttClvm_curItem = -1;
-
+
g_ViewModeOptDlg = TRUE;
for (int i = 0; _page2Controls[i] != 0; i++)
@@ -848,7 +848,7 @@ LRESULT CALLBACK ViewModeFrameWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM }
case WM_SIZE:
- RECT rcCLVMFrame;
+ RECT rcCLVMFrame;
{
HDWP PosBatch = BeginDeferWindowPos(3);
GetClientRect(hwnd, &rcCLVMFrame);
@@ -1013,7 +1013,7 @@ void CreateViewModeFrame() frame.align = alBottom;
frame.hWnd = CreateWindowEx(0, L"CLVMFrameWindow", L"CLVM", WS_VISIBLE | WS_CHILD | WS_TABSTOP | WS_CLIPCHILDREN, 0, 0, 20, 20, g_clistApi.hwndContactList, (HMENU)nullptr, g_plugin.getInst(), nullptr);
g_hwndViewModeFrame = frame.hWnd;
-
+
int hCLVMFrame = g_plugin.addFrame(&frame);
CallService(MS_CLIST_FRAMES_UPDATEFRAME, hCLVMFrame, FU_FMPOS);
}
@@ -1022,75 +1022,77 @@ void ApplyViewMode(const char *name) {
cfg::dat.bFilterEffective = 0;
- char szSetting[256];
- mir_snprintf(szSetting, "%c%s_PF", 246, name);
- ptrA szProtos(db_get_sa(NULL, CLVM_MODULE, szSetting));
- if (mir_strlen(szProtos) >= 2) {
- strncpy_s(cfg::dat.protoFilter, szProtos, _TRUNCATE);
- cfg::dat.bFilterEffective |= CLVM_FILTER_PROTOS;
- }
+ if (name != nullptr) {
+ char szSetting[256];
+ mir_snprintf(szSetting, "%c%s_PF", 246, name);
+ ptrA szProtos(db_get_sa(NULL, CLVM_MODULE, szSetting));
+ if (mir_strlen(szProtos) >= 2) {
+ strncpy_s(cfg::dat.protoFilter, szProtos, _TRUNCATE);
+ cfg::dat.bFilterEffective |= CLVM_FILTER_PROTOS;
+ }
- mir_snprintf(szSetting, "%c%s_GF", 246, name);
- ptrW tszGroups(db_get_wsa(NULL, CLVM_MODULE, szSetting));
- if (mir_wstrlen(tszGroups) >= 2) {
- wcsncpy_s(cfg::dat.groupFilter, tszGroups, _TRUNCATE);
- cfg::dat.bFilterEffective |= CLVM_FILTER_GROUPS;
- }
+ mir_snprintf(szSetting, "%c%s_GF", 246, name);
+ ptrW tszGroups(db_get_wsa(NULL, CLVM_MODULE, szSetting));
+ if (mir_wstrlen(tszGroups) >= 2) {
+ wcsncpy_s(cfg::dat.groupFilter, tszGroups, _TRUNCATE);
+ cfg::dat.bFilterEffective |= CLVM_FILTER_GROUPS;
+ }
- mir_snprintf(szSetting, "%c%s_SM", 246, name);
- cfg::dat.statusMaskFilter = db_get_dw(NULL, CLVM_MODULE, szSetting, -1);
- if (cfg::dat.statusMaskFilter >= 1)
- cfg::dat.bFilterEffective |= CLVM_FILTER_STATUS;
+ mir_snprintf(szSetting, "%c%s_SM", 246, name);
+ cfg::dat.statusMaskFilter = db_get_dw(NULL, CLVM_MODULE, szSetting, -1);
+ if (cfg::dat.statusMaskFilter >= 1)
+ cfg::dat.bFilterEffective |= CLVM_FILTER_STATUS;
- mir_snprintf(szSetting, "%c%s_SSM", 246, name);
- cfg::dat.stickyMaskFilter = db_get_dw(NULL, CLVM_MODULE, szSetting, -1);
- if (cfg::dat.stickyMaskFilter != -1)
- cfg::dat.bFilterEffective |= CLVM_FILTER_STICKYSTATUS;
+ mir_snprintf(szSetting, "%c%s_SSM", 246, name);
+ cfg::dat.stickyMaskFilter = db_get_dw(NULL, CLVM_MODULE, szSetting, -1);
+ if (cfg::dat.stickyMaskFilter != -1)
+ cfg::dat.bFilterEffective |= CLVM_FILTER_STICKYSTATUS;
- cfg::dat.filterFlags = db_get_dw(NULL, CLVM_MODULE, name, 0);
+ cfg::dat.filterFlags = db_get_dw(NULL, CLVM_MODULE, name, 0);
- KillTimer(g_hwndViewModeFrame, TIMERID_VIEWMODEEXPIRE);
+ KillTimer(g_hwndViewModeFrame, TIMERID_VIEWMODEEXPIRE);
- if (cfg::dat.filterFlags & CLVM_AUTOCLEAR) {
- DWORD timerexpire;
- mir_snprintf(szSetting, "%c%s_OPT", 246, name);
- timerexpire = LOWORD(db_get_dw(NULL, CLVM_MODULE, szSetting, 0));
- strncpy(cfg::dat.old_viewmode, cfg::dat.current_viewmode, 256);
- cfg::dat.old_viewmode[255] = 0;
- SetTimer(g_hwndViewModeFrame, TIMERID_VIEWMODEEXPIRE, timerexpire * 1000, nullptr);
- }
- strncpy_s(cfg::dat.current_viewmode, name, _TRUNCATE);
+ if (cfg::dat.filterFlags & CLVM_AUTOCLEAR) {
+ DWORD timerexpire;
+ mir_snprintf(szSetting, "%c%s_OPT", 246, name);
+ timerexpire = LOWORD(db_get_dw(NULL, CLVM_MODULE, szSetting, 0));
+ strncpy(cfg::dat.old_viewmode, cfg::dat.current_viewmode, 256);
+ cfg::dat.old_viewmode[255] = 0;
+ SetTimer(g_hwndViewModeFrame, TIMERID_VIEWMODEEXPIRE, timerexpire * 1000, nullptr);
+ }
+ strncpy_s(cfg::dat.current_viewmode, name, _TRUNCATE);
- if (cfg::dat.filterFlags & CLVM_USELASTMSG) {
- BYTE bSaved = cfg::dat.sortOrder[0];
+ if (cfg::dat.filterFlags & CLVM_USELASTMSG) {
+ BYTE bSaved = cfg::dat.sortOrder[0];
- cfg::dat.sortOrder[0] = SORTBY_LASTMSG;
- for (auto &p : cfg::arCache)
- p->dwLastMsgTime = INTSORT_GetLastMsgTime(p->hContact);
+ cfg::dat.sortOrder[0] = SORTBY_LASTMSG;
+ for (auto &p : cfg::arCache)
+ p->dwLastMsgTime = INTSORT_GetLastMsgTime(p->hContact);
- cfg::dat.sortOrder[0] = bSaved;
+ cfg::dat.sortOrder[0] = bSaved;
- cfg::dat.bFilterEffective |= CLVM_FILTER_LASTMSG;
- mir_snprintf(szSetting, "%c%s_LM", 246, name);
- cfg::dat.lastMsgFilter = db_get_dw(NULL, CLVM_MODULE, szSetting, 0);
- if (LOBYTE(HIWORD(cfg::dat.lastMsgFilter)))
- cfg::dat.bFilterEffective |= CLVM_FILTER_LASTMSG_NEWERTHAN;
- else
- cfg::dat.bFilterEffective |= CLVM_FILTER_LASTMSG_OLDERTHAN;
+ cfg::dat.bFilterEffective |= CLVM_FILTER_LASTMSG;
+ mir_snprintf(szSetting, "%c%s_LM", 246, name);
+ cfg::dat.lastMsgFilter = db_get_dw(NULL, CLVM_MODULE, szSetting, 0);
+ if (LOBYTE(HIWORD(cfg::dat.lastMsgFilter)))
+ cfg::dat.bFilterEffective |= CLVM_FILTER_LASTMSG_NEWERTHAN;
+ else
+ cfg::dat.bFilterEffective |= CLVM_FILTER_LASTMSG_OLDERTHAN;
- DWORD unit = LOWORD(cfg::dat.lastMsgFilter);
- switch (HIBYTE(HIWORD(cfg::dat.lastMsgFilter))) {
- case 0:
- unit *= 60;
- break;
- case 1:
- unit *= 3600;
- break;
- case 2:
- unit *= 86400;
- break;
+ DWORD unit = LOWORD(cfg::dat.lastMsgFilter);
+ switch (HIBYTE(HIWORD(cfg::dat.lastMsgFilter))) {
+ case 0:
+ unit *= 60;
+ break;
+ case 1:
+ unit *= 3600;
+ break;
+ case 2:
+ unit *= 86400;
+ break;
+ }
+ cfg::dat.lastMsgFilter = unit;
}
- cfg::dat.lastMsgFilter = unit;
}
if (HIWORD(cfg::dat.filterFlags) > 0)
@@ -1100,7 +1102,13 @@ void ApplyViewMode(const char *name) cfg::dat.boldHideOffline = db_get_b(NULL, "CList", "HideOffline", 0);
g_clistApi.pfnSetHideOffline(false);
- SetWindowTextA(hwndSelector, name);
+ if (name == nullptr) {
+ if (cfg::dat.current_viewmode[0])
+ SetWindowTextA(hwndSelector, cfg::dat.current_viewmode);
+ else
+ SetWindowTextW(hwndSelector, TranslateT("No view mode"));
+ }
+ else SetWindowTextA(hwndSelector, name);
Clist_Broadcast(CLM_AUTOREBUILD, 0, 0);
SetButtonStates();
|