summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-05-08 16:05:26 +0200
committerGeorge Hazan <ghazan@miranda.im>2018-05-08 16:05:26 +0200
commit365d30042349ef1ca77c0b9acbef59cd7fa57c69 (patch)
tree48421c352f4770cb8f3807e63f463067abc3ee67
parent55b6b9fa425a602a44e660c29d07e783e4f37967 (diff)
fixes #1334 (after unloading tabSRMM its fonts & colors are still visible in the Options)
-rw-r--r--src/mir_app/src/FontOptions.cpp71
-rw-r--r--src/mir_app/src/FontService.cpp27
2 files changed, 66 insertions, 32 deletions
diff --git a/src/mir_app/src/FontOptions.cpp b/src/mir_app/src/FontOptions.cpp
index 9d42904807..f3a417ae9f 100644
--- a/src/mir_app/src/FontOptions.cpp
+++ b/src/mir_app/src/FontOptions.cpp
@@ -28,6 +28,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// *_w2 is working copy of list
// *_w3 is stores initial configuration
+HWND hwndFontOptions = nullptr;
+
static int sttCompareFont(const FontInternal* p1, const FontInternal* p2)
{
int result = mir_wstrcmp(p1->group, p2->group);
@@ -113,7 +115,6 @@ int __inline DrawTextWithEffect(HDC hdc, LPCTSTR lpchText, int cchText, RECT * l
}
#define UM_SETFONTGROUP (WM_USER + 101)
-#define TIMER_ID 11015
#define FSUI_COLORBOXWIDTH 50
#define FSUI_COLORBOXLEFT 5
@@ -540,6 +541,36 @@ static void sttSaveFontData(HWND hwndDlg, FontInternal &F)
db_set_w(0, F.dbSettingsGroup, str, (WORD)F.flags);
}
+static void RebuildTree(HWND hwndDlg)
+{
+ font_id_list_w2 = font_id_list;
+ font_id_list_w3 = font_id_list;
+
+ colour_id_list_w2 = colour_id_list;
+ colour_id_list_w3 = colour_id_list;
+
+ effect_id_list_w2 = effect_id_list;
+ effect_id_list_w3 = effect_id_list;
+
+ for (auto &F : font_id_list_w2) {
+ // sync settings with database
+ UpdateFontSettings(F, &F->value);
+ sttFsuiCreateSettingsTreeNode(GetDlgItem(hwndDlg, IDC_FONTGROUP), F->group, F->hLangpack);
+ }
+
+ for (auto &C : colour_id_list_w2) {
+ // sync settings with database
+ UpdateColourSettings(C, &C->value);
+ sttFsuiCreateSettingsTreeNode(GetDlgItem(hwndDlg, IDC_FONTGROUP), C->group, C->hLangpack);
+ }
+
+ for (auto &E : effect_id_list_w2) {
+ // sync settings with database
+ UpdateEffectSettings(E, &E->value);
+ sttFsuiCreateSettingsTreeNode(GetDlgItem(hwndDlg, IDC_FONTGROUP), E->group, E->hLangpack);
+ }
+}
+
static INT_PTR CALLBACK DlgProcLogOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
int selCount;
@@ -550,33 +581,9 @@ static INT_PTR CALLBACK DlgProcLogOptions(HWND hwndDlg, UINT msg, WPARAM wParam,
switch (msg) {
case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
+ hwndFontOptions = hwndDlg;
- font_id_list_w2 = font_id_list;
- font_id_list_w3 = font_id_list;
-
- colour_id_list_w2 = colour_id_list;
- colour_id_list_w3 = colour_id_list;
-
- effect_id_list_w2 = effect_id_list;
- effect_id_list_w3 = effect_id_list;
-
- for (auto &F : font_id_list_w2) {
- // sync settings with database
- UpdateFontSettings(F, &F->value);
- sttFsuiCreateSettingsTreeNode(GetDlgItem(hwndDlg, IDC_FONTGROUP), F->group, F->hLangpack);
- }
-
- for (auto &C : colour_id_list_w2) {
- // sync settings with database
- UpdateColourSettings(C, &C->value);
- sttFsuiCreateSettingsTreeNode(GetDlgItem(hwndDlg, IDC_FONTGROUP), C->group, C->hLangpack);
- }
-
- for (auto &E : effect_id_list_w2) {
- // sync settings with database
- UpdateEffectSettings(E, &E->value);
- sttFsuiCreateSettingsTreeNode(GetDlgItem(hwndDlg, IDC_FONTGROUP), E->group, E->hLangpack);
- }
+ RebuildTree(hwndDlg);
SendDlgItemMessage(hwndDlg, IDC_BKGCOLOUR, CPM_SETDEFAULTCOLOUR, 0, (LPARAM)GetSysColor(COLOR_WINDOW));
return TRUE;
@@ -1151,8 +1158,16 @@ static INT_PTR CALLBACK DlgProcLogOptions(HWND hwndDlg, UINT msg, WPARAM wParam,
}
break;
+ case WM_TIMER:
+ if (wParam == 1) {
+ KillTimer(hwndDlg, wParam);
+ TreeView_DeleteAllItems(GetDlgItem(hwndDlg, IDC_FONTGROUP));
+ RebuildTree(hwndDlg);
+ }
+ break;
+
case WM_DESTROY:
- KillTimer(hwndDlg, TIMER_ID);
+ hwndFontOptions = nullptr;
sttSaveCollapseState(GetDlgItem(hwndDlg, IDC_FONTGROUP));
DeleteObject(hBkgColourBrush);
font_id_list_w2.destroy();
diff --git a/src/mir_app/src/FontService.cpp b/src/mir_app/src/FontService.cpp
index 8e07db3829..7acc62ac0b 100644
--- a/src/mir_app/src/FontService.cpp
+++ b/src/mir_app/src/FontService.cpp
@@ -27,6 +27,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
int code_page = CP_ACP;
HANDLE hFontReloadEvent, hColourReloadEvent;
+extern HWND hwndFontOptions;
+
+static void notifyOptions()
+{
+ if (hwndFontOptions)
+ SetTimer(hwndFontOptions, 1, 100, nullptr);
+}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -266,6 +273,8 @@ static int sttRegisterFontWorker(FontIDW *font_id, int _hLang)
UpdateFontSettings(font_id, &newItem->value);
font_id_list.insert(newItem);
+
+ notifyOptions();
return 0;
}
@@ -327,9 +336,12 @@ static INT_PTR ReloadFonts(WPARAM, LPARAM)
MIR_APP_DLL(void) KillModuleFonts(int _hLang)
{
auto T = font_id_list.rev_iter();
- for (auto &it : T)
- if (it->hLangpack == _hLang)
+ for (auto &it : T) {
+ if (it->hLangpack == _hLang) {
font_id_list.remove(T.indexOf(&it));
+ notifyOptions();
+ }
+ }
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -355,6 +367,8 @@ static INT_PTR sttRegisterColourWorker(ColourIDW *colour_id, int _hLang)
newItem->hLangpack = _hLang;
UpdateColourSettings(colour_id, &newItem->value);
colour_id_list.insert(newItem);
+
+ notifyOptions();
return 0;
}
@@ -403,9 +417,12 @@ static INT_PTR ReloadColours(WPARAM, LPARAM)
MIR_APP_DLL(void) KillModuleColours(int _hLang)
{
auto T = colour_id_list.rev_iter();
- for (auto &it : T)
- if (it->hLangpack == _hLang)
+ for (auto &it : T) {
+ if (it->hLangpack == _hLang) {
colour_id_list.remove(T.indexOf(&it));
+ notifyOptions();
+ }
+ }
}
//////////////////////////////////////////////////////////////////////////
@@ -442,6 +459,8 @@ static int sttRegisterEffectWorker(EffectIDW *effect_id, int _hLang)
newItem->hLangpack = _hLang;
UpdateEffectSettings(effect_id, &newItem->value);
effect_id_list.insert(newItem);
+
+ notifyOptions();
return 0;
}