From b2c91edc9646daa331de71d589e4fec6bdef4945 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 11 Jul 2018 17:09:17 +0300 Subject: GUI change: - methods OnInitDialog, OnApply & OnClose of CDlgBase now return true if successful. return of false prevents a dialog from being loaded or left respectively; - massive code cleaning considering the 'virtual' attribute of overridden methods; - also fixes #1476 (Don't close "Create new account" window if user not set account name) --- plugins/StatusManager/src/options.cpp | 3 ++- plugins/StatusManager/src/ss_options.cpp | 21 ++++++++++++++------- 2 files changed, 16 insertions(+), 8 deletions(-) (limited to 'plugins/StatusManager') diff --git a/plugins/StatusManager/src/options.cpp b/plugins/StatusManager/src/options.cpp index 60b212d951..b2b28b0d81 100644 --- a/plugins/StatusManager/src/options.cpp +++ b/plugins/StatusManager/src/options.cpp @@ -24,7 +24,7 @@ public: CreateLink(m_enableAdvancedAutoAway, g_AAAEnabled); } - void OnApply() override + bool OnApply() override { bool bEnabled = m_enableKeepStatus.GetState(); if (bEnabled != g_KSEnabled) { @@ -49,6 +49,7 @@ public: else AdvancedAutoAwayUnload(); } + return true; } }; diff --git a/plugins/StatusManager/src/ss_options.cpp b/plugins/StatusManager/src/ss_options.cpp index 1a0ff8dbaf..833c6dd5f4 100644 --- a/plugins/StatusManager/src/ss_options.cpp +++ b/plugins/StatusManager/src/ss_options.cpp @@ -151,11 +151,12 @@ public: GetProfile(iProfileNo, ps); } - void OnInitDialog() override + bool OnInitDialog() override { char* cmdl = GetCMDL(ps); SetDlgItemTextA(m_hwnd, IDC_CMDL, cmdl); mir_free(cmdl); + return true; } void onClick_Copy(CCtrlButton*) @@ -320,7 +321,7 @@ public: chkSetWinLocation.OnChange = Callback(this, &CSSMainOptDlg::onChange_SetWinLocation); } - void OnInitDialog() override + bool OnInitDialog() override { CheckDlgButton(m_hwnd, IDC_SETPROFILE, db_get_b(0, SSMODULENAME, SETTING_SETPROFILE, 1) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(m_hwnd, IDC_OVERRIDE, db_get_b(0, SSMODULENAME, SETTING_OVERRIDE, 1) ? BST_CHECKED : BST_UNCHECKED); @@ -362,9 +363,10 @@ public: ReinitProfiles(); timer.Start(100); + return true; } - void OnApply() override + bool OnApply() override { bool bChecked = chkSetProfile.GetState(); db_set_b(0, SSMODULENAME, SETTING_SETPROFILE, bChecked); @@ -406,6 +408,7 @@ public: db_set_b(0, SSMODULENAME, SETTING_OFFLINECLOSE, (BYTE)IsDlgButtonChecked(m_hwnd, IDC_OFFLINECLOSE)); db_set_b(0, SSMODULENAME, SETTING_AUTODIAL, (BYTE)IsDlgButtonChecked(m_hwnd, IDC_AUTODIAL)); db_set_b(0, SSMODULENAME, SETTING_AUTOHANGUP, (BYTE)IsDlgButtonChecked(m_hwnd, IDC_AUTOHANGUP)); + return true; } INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override @@ -495,15 +498,17 @@ public: edtProfile.OnChange = Callback(this, &CAddProfileDlg::onChange_Edit); } - void OnInitDialog() override + bool OnInitDialog() override { btnOk.Disable(); + return true; } - void OnApply() override + bool OnApply() override { ptrW profileName(edtProfile.GetText()); SendMessage(m_hwndParent, UM_ADDPROFILE, 0, (LPARAM)profileName.get()); + return true; } void OnDestroy() override @@ -660,7 +665,7 @@ public: lstAccount.OnSelChange = Callback(this, &CSSAdvancedOptDlg::onChange_Account); } - virtual void OnInitDialog() override + bool OnInitDialog() override { chkCreateMMI.SetText(TranslateT("Create a status menu item")); @@ -705,9 +710,10 @@ public: ReinitProfiles(); ShowWindow(GetDlgItem(m_hwnd, IDC_VARIABLESHELP), ServiceExists(MS_VARS_SHOWHELPEX) ? SW_SHOW : SW_HIDE); + return true; } - virtual void OnApply() override + bool OnApply() override { int oldCount = db_get_w(0, SSMODULENAME, SETTING_PROFILECOUNT, 0); for (int i = 0; i < oldCount; i++) { @@ -747,6 +753,7 @@ public: // Rebuild status menu if (bNeedRebuildMenu) Menu_ReloadProtoMenus(); + return true; } // add a profile -- cgit v1.2.3