summaryrefslogtreecommitdiff
path: root/src/mir_app
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-05-08 20:40:49 +0200
committerGeorge Hazan <ghazan@miranda.im>2018-05-08 20:47:39 +0200
commit6a6f2b9e3b2749f16b513dfc98d5d5038b5628fb (patch)
treef0bc709157a49e0cff4ac436e60c0e098739b00c /src/mir_app
parentc575dc94be9630240b7377a2e05011630bb8eb1e (diff)
merge from master
Diffstat (limited to 'src/mir_app')
-rw-r--r--src/mir_app/src/FontOptions.cpp74
-rw-r--r--src/mir_app/src/FontService.cpp27
-rw-r--r--src/mir_app/src/chat_opts.cpp3
-rw-r--r--src/mir_app/src/clui.cpp3
-rw-r--r--src/mir_app/src/findadd.cpp2
-rw-r--r--src/mir_app/src/ignore.cpp2
-rw-r--r--src/mir_app/src/netliblog.cpp3
-rw-r--r--src/mir_app/src/visibility.cpp3
8 files changed, 77 insertions, 40 deletions
diff --git a/src/mir_app/src/FontOptions.cpp b/src/mir_app/src/FontOptions.cpp
index 9d42904807..6e3b97709a 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;
@@ -906,8 +913,7 @@ static INT_PTR CALLBACK DlgProcLogOptions(HWND hwndDlg, UINT msg, WPARAM wParam,
if (HIWORD(wParam) != LBN_DBLCLK)
return TRUE;
-
- //fall through
+ __fallthrough;
case IDC_CHOOSEFONT:
if (selCount = SendDlgItemMessage(hwndDlg, IDC_FONTLIST, LB_GETSELCOUNT, 0, 0)) {
@@ -1151,8 +1157,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;
}
diff --git a/src/mir_app/src/chat_opts.cpp b/src/mir_app/src/chat_opts.cpp
index 705d74a125..2282f53374 100644
--- a/src/mir_app/src/chat_opts.cpp
+++ b/src/mir_app/src/chat_opts.cpp
@@ -166,7 +166,8 @@ void RegisterFonts(void)
FO.szDefFace = L"Webdings";
FO.defColour = RGB(170, 170, 170);
FO.defCharset = SYMBOL_CHARSET;
- // fall through
+ __fallthrough;
+
default:
wcsncpy_s(fontid.backgroundName, LPGENW("Group chat log background"), _TRUNCATE);
break;
diff --git a/src/mir_app/src/clui.cpp b/src/mir_app/src/clui.cpp
index 75c66b3b25..5da831c9de 100644
--- a/src/mir_app/src/clui.cpp
+++ b/src/mir_app/src/clui.cpp
@@ -141,7 +141,8 @@ static INT_PTR CALLBACK AskForConfirmationDlgProc(HWND hWnd, UINT msg, WPARAM wP
EndDialog(hWnd, IDC_HIDE);
break;
}
- //fall through
+ __fallthrough;
+
case IDCANCEL:
case IDNO:
EndDialog(hWnd, LOWORD(wParam));
diff --git a/src/mir_app/src/findadd.cpp b/src/mir_app/src/findadd.cpp
index 19caaf101a..fdadcd9b7c 100644
--- a/src/mir_app/src/findadd.cpp
+++ b/src/mir_app/src/findadd.cpp
@@ -439,7 +439,7 @@ static INT_PTR CALLBACK DlgProcFindAdd(HWND hwndDlg, UINT msg, WPARAM wParam, LP
GetClientRect(hwndList, &rc);
ListView_SetColumnWidth(hwndList, 0, rc.right);
}
- // fall through
+ __fallthrough;
case WM_MOVE:
if (dat && dat->hwndAdvSearch) {
diff --git a/src/mir_app/src/ignore.cpp b/src/mir_app/src/ignore.cpp
index bf7e23e659..86d60be867 100644
--- a/src/mir_app/src/ignore.cpp
+++ b/src/mir_app/src/ignore.cpp
@@ -253,7 +253,7 @@ static INT_PTR CALLBACK DlgProcIgnoreOpts(HWND hwndDlg, UINT msg, WPARAM, LPARAM
case CLN_NEWCONTACT:
case CLN_LISTREBUILT:
SetAllContactIcons(GetDlgItem(hwndDlg, IDC_LIST));
- //fall through
+ __fallthrough;
case CLN_CONTACTMOVED:
SetListGroupIcons(GetDlgItem(hwndDlg, IDC_LIST), (HANDLE)SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_GETNEXTITEM, CLGN_ROOT, 0), hItemAll, nullptr);
break;
diff --git a/src/mir_app/src/netliblog.cpp b/src/mir_app/src/netliblog.cpp
index c0d17d7b3c..392f8dc4f3 100644
--- a/src/mir_app/src/netliblog.cpp
+++ b/src/mir_app/src/netliblog.cpp
@@ -247,7 +247,8 @@ static INT_PTR CALLBACK LogOptionsDlgProc(HWND hwndDlg, UINT message, WPARAM wPa
}
}
InitLog();
- // fall through
+ __fallthrough;
+
case IDCANCEL:
DestroyWindow(hwndDlg);
}
diff --git a/src/mir_app/src/visibility.cpp b/src/mir_app/src/visibility.cpp
index e90fd88e05..77536c2c94 100644
--- a/src/mir_app/src/visibility.cpp
+++ b/src/mir_app/src/visibility.cpp
@@ -171,7 +171,8 @@ static INT_PTR CALLBACK DlgProcVisibilityOpts(HWND hwndDlg, UINT msg, WPARAM, LP
case CLN_NEWCONTACT:
case CLN_LISTREBUILT:
SetAllContactIcons(GetDlgItem(hwndDlg, IDC_LIST));
- //fall through
+ __fallthrough;
+
case CLN_CONTACTMOVED:
SetListGroupIcons(GetDlgItem(hwndDlg, IDC_LIST), (HANDLE)SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_GETNEXTITEM, CLGN_ROOT, 0), hItemAll, nullptr);
break;