summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-07-11 17:09:17 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-07-11 17:09:17 +0300
commitb2c91edc9646daa331de71d589e4fec6bdef4945 (patch)
tree847a77d0686d26e25b126313fbaa8262c81f8d1a /src/core
parentae081843e9663b3cb36b17309fbce1d2967315f1 (diff)
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)
Diffstat (limited to 'src/core')
-rw-r--r--src/core/stdautoaway/src/options.cpp6
-rw-r--r--src/core/stdmsg/src/chat_options.cpp20
-rw-r--r--src/core/stdmsg/src/chat_window.cpp3
-rw-r--r--src/core/stdmsg/src/msgdialog.cpp3
-rw-r--r--src/core/stdmsg/src/msgoptions.cpp26
-rw-r--r--src/core/stdmsg/src/msgs.h4
-rw-r--r--src/core/stdmsg/src/stdafx.h8
-rw-r--r--src/core/stdmsg/src/tabs.cpp5
8 files changed, 47 insertions, 28 deletions
diff --git a/src/core/stdautoaway/src/options.cpp b/src/core/stdautoaway/src/options.cpp
index e8ee0669da..79f6795174 100644
--- a/src/core/stdautoaway/src/options.cpp
+++ b/src/core/stdautoaway/src/options.cpp
@@ -87,7 +87,7 @@ public:
chkShortIdle.OnChange = chkShort.OnChange = Callback(this, &COptionsDlg::onChange);
}
- virtual void OnInitDialog() override
+ bool OnInitDialog() override
{
chkOnWindows.SetState(!g_plugin.bIdleMethod);
@@ -99,9 +99,10 @@ public:
cmbAAStatus.SetCurSel(IdleGetStatusIndex(g_plugin.bAAStatus));
ShowHide();
+ return true;
}
- virtual void OnApply() override
+ bool OnApply() override
{
g_plugin.iIdleTime1st = spinIdle.GetPosition();
@@ -112,6 +113,7 @@ public:
// destroy any current idle and reset settings.
IdleObject_Destroy();
IdleObject_Create();
+ return true;
}
void onChange(CCtrlCheck*)
diff --git a/src/core/stdmsg/src/chat_options.cpp b/src/core/stdmsg/src/chat_options.cpp
index 272b75ef6c..fc7258ce76 100644
--- a/src/core/stdmsg/src/chat_options.cpp
+++ b/src/core/stdmsg/src/chat_options.cpp
@@ -342,7 +342,7 @@ public:
checkBoxes.OnItemChanged = Callback(this, &COptMainDlg::onChange_Tree);
}
- virtual void OnInitDialog() override
+ bool OnInitDialog() override
{
SetWindowLongPtr(checkBoxes.GetHwnd(), GWL_STYLE, GetWindowLongPtr(checkBoxes.GetHwnd(), GWL_STYLE) | TVS_NOHSCROLL | TVS_CHECKBOXES);
@@ -363,9 +363,10 @@ public:
FillBranch(hListHeading6, branch6, _countof(branch6), 0x0000);
}
FixHeadings();
+ return true;
}
- virtual void OnApply() override
+ bool OnApply() override
{
SaveBranch(branch1, _countof(branch1));
SaveBranch(branch2, _countof(branch2));
@@ -377,9 +378,10 @@ public:
g_chatApi.ReloadSettings();
Chat_UpdateOptions();
+ return true;
}
- virtual void OnDestroy() override
+ void OnDestroy() override
{
BYTE b = checkBoxes.GetItemState(hListHeading1, TVIS_EXPANDED) & TVIS_EXPANDED ? 1 : 0;
db_set_b(0, CHAT_MODULE, "Branch1Exp", b);
@@ -464,7 +466,7 @@ public:
btnFontChoose.OnClick = Callback(this, &COptLogDlg::onClick_Font);
}
- virtual void OnInitDialog() override
+ bool OnInitDialog() override
{
spin2.SetRange(5000);
spin2.SetPosition(db_get_w(0, CHAT_MODULE, "LogLimit", 100));
@@ -493,9 +495,10 @@ public:
chkLogging.SetState(g_Settings.bLoggingEnabled);
onChange_Logging(nullptr);
+ return true;
}
- virtual void OnApply() override
+ bool OnApply() override
{
ptrW pszText(rtrimw(edtHighlight.GetText()));
if (*pszText) {
@@ -555,6 +558,7 @@ public:
g_chatApi.ReloadSettings();
Chat_UpdateOptions();
+ return true;
}
void onChange_Logging(CCtrlCheck*)
@@ -610,7 +614,7 @@ public:
chkRadio1.OnChange = chkRadio2.OnChange = chkRadio3.OnChange = Callback(this, &COptPopupDlg::onChange_Radio);
}
- virtual void OnInitDialog() override
+ bool OnInitDialog() override
{
SendDlgItemMessage(m_hwnd, IDC_BKG, CPM_SETCOLOUR, 0, g_Settings.crPUBkgColour);
SendDlgItemMessage(m_hwnd, IDC_TEXT, CPM_SETCOLOUR, 0, g_Settings.crPUTextColour);
@@ -627,9 +631,10 @@ public:
SendDlgItemMessage(m_hwnd, IDC_SPIN1, UDM_SETRANGE, 0, MAKELONG(100, -1));
SendDlgItemMessage(m_hwnd, IDC_SPIN1, UDM_SETPOS, 0, MAKELONG(g_Settings.iPopupTimeout, 0));
+ return true;
}
- virtual void OnApply() override
+ bool OnApply() override
{
int iLen;
if (IsDlgButtonChecked(m_hwnd, IDC_RADIO2) == BST_CHECKED)
@@ -649,6 +654,7 @@ public:
db_set_dw(0, CHAT_MODULE, "PopupColorBG", (DWORD)SendDlgItemMessage(m_hwnd, IDC_BKG, CPM_GETCOLOUR, 0, 0));
g_Settings.crPUTextColour = SendDlgItemMessage(m_hwnd, IDC_TEXT, CPM_GETCOLOUR, 0, 0);
db_set_dw(0, CHAT_MODULE, "PopupColorText", (DWORD)SendDlgItemMessage(m_hwnd, IDC_TEXT, CPM_GETCOLOUR, 0, 0));
+ return true;
}
void onChange_Radio(CCtrlCheck*)
diff --git a/src/core/stdmsg/src/chat_window.cpp b/src/core/stdmsg/src/chat_window.cpp
index 459bb6575d..3f513be937 100644
--- a/src/core/stdmsg/src/chat_window.cpp
+++ b/src/core/stdmsg/src/chat_window.cpp
@@ -47,7 +47,7 @@ CChatRoomDlg::CChatRoomDlg(CTabbedWindow *pOwner, SESSION_INFO *si) :
m_iSplitterY = g_Settings.iSplitterY;
}
-void CChatRoomDlg::OnInitDialog()
+bool CChatRoomDlg::OnInitDialog()
{
CSuper::OnInitDialog();
m_si->pDlg = this;
@@ -71,6 +71,7 @@ void CChatRoomDlg::OnInitDialog()
UpdateTitle();
NotifyEvent(MSG_WINDOW_EVT_OPEN);
+ return true;
}
void CChatRoomDlg::OnDestroy()
diff --git a/src/core/stdmsg/src/msgdialog.cpp b/src/core/stdmsg/src/msgdialog.cpp
index 3b402181b5..cfb4c8d556 100644
--- a/src/core/stdmsg/src/msgdialog.cpp
+++ b/src/core/stdmsg/src/msgdialog.cpp
@@ -97,7 +97,7 @@ CSrmmWindow::CSrmmWindow(CTabbedWindow *pOwner, MCONTACT hContact) :
m_splitter.OnChange = Callback(this, &CSrmmWindow::OnSplitterMoved);
}
-void CSrmmWindow::OnInitDialog()
+bool CSrmmWindow::OnInitDialog()
{
CSuper::OnInitDialog();
@@ -251,6 +251,7 @@ void CSrmmWindow::OnInitDialog()
SendMessage(m_hwnd, DM_GETAVATAR, 0, 0);
NotifyEvent(MSG_WINDOW_EVT_OPEN);
+ return true;
}
void CSrmmWindow::OnDestroy()
diff --git a/src/core/stdmsg/src/msgoptions.cpp b/src/core/stdmsg/src/msgoptions.cpp
index f8d60c6be2..d8c88d0327 100644
--- a/src/core/stdmsg/src/msgoptions.cpp
+++ b/src/core/stdmsg/src/msgoptions.cpp
@@ -245,7 +245,7 @@ public:
CreateLink(chkDoNotStealFocus, g_dat.bDoNotStealFocus);
}
- virtual void OnInitDialog() override
+ bool OnInitDialog() override
{
FillCheckBoxTree(g_dat.popupFlags);
@@ -256,9 +256,10 @@ public:
chkCascade.Enable(!g_dat.bSavePerContact);
chkCtrlSupport.Enable(!g_dat.bAutoClose);
+ return true;
}
- virtual void OnApply() override
+ bool OnApply() override
{
g_dat.popupFlags = MakeCheckBoxTreeFlags();
@@ -268,6 +269,7 @@ public:
g_dat.msgTimeout = msgTimeout;
Srmm_Broadcast(DM_OPTIONSAPPLIED, TRUE, 0);
+ return true;
}
void onChange_AutoMin(CCtrlCheck*)
@@ -342,7 +344,7 @@ public:
CreateLink(chkShowNames, g_dat.bShowNames);
}
- virtual void OnInitDialog() override
+ bool OnInitDialog() override
{
switch (g_dat.iLoadHistory) {
case LOADHISTORY_UNREAD:
@@ -366,9 +368,10 @@ public:
spinTime.SetPosition(g_dat.nLoadTime);
onChange_Time(nullptr);
+ return true;
}
- virtual void OnApply() override
+ bool OnApply() override
{
if (chkLoadCount.GetState())
g_dat.iLoadHistory = LOADHISTORY_COUNT;
@@ -382,9 +385,10 @@ public:
FreeMsgLogIcons();
LoadMsgLogIcons();
Srmm_Broadcast(DM_OPTIONSAPPLIED, TRUE, 0);
+ return true;
}
- virtual void OnDestroy() override
+ void OnDestroy() override
{
DeleteObject(hBkgColourBrush);
}
@@ -474,7 +478,7 @@ public:
}
}
- virtual void OnInitDialog() override
+ bool OnInitDialog() override
{
CLCINFOITEM cii = { sizeof(cii) };
cii.flags = CLCIIF_GROUPFONT | CLCIIF_CHECKBOX;
@@ -491,12 +495,14 @@ public:
clist.OnOptionsChanged = Callback(this, &COptionTypingDlg::ResetCList);
onChange_ShowNotify(nullptr);
+ return true;
}
- virtual void OnApply() override
+ bool OnApply() override
{
SaveList();
Srmm_Broadcast(DM_OPTIONSAPPLIED, TRUE, 0);
+ return true;
}
void onChange_Clist(CCtrlClc::TEventInfo*)
@@ -539,15 +545,16 @@ public:
m_chkTabs.OnChange = Callback(this, &COptionsTabDlg::onChange_Tabs);
}
- virtual void OnInitDialog() override
+ bool OnInitDialog() override
{
m_chkTabs.SetState(g_Settings.bTabsEnable);
m_chkTabsBottom.SetState(g_Settings.bTabsAtBottom);
m_chkTabsClose.SetState(g_Settings.bTabCloseOnDblClick);
onChange_Tabs(&m_chkTabs);
+ return true;
}
- virtual void OnApply() override
+ bool OnApply() override
{
BYTE bOldValue = db_get_b(0, CHAT_MODULE, "Tabs", 1);
@@ -563,6 +570,7 @@ public:
g_Settings.bTabsEnable = db_get_b(0, CHAT_MODULE, "Tabs", 1) != 0;
}
else Chat_UpdateOptions();
+ return true;
}
void onChange_Tabs(CCtrlCheck *pCheck)
diff --git a/src/core/stdmsg/src/msgs.h b/src/core/stdmsg/src/msgs.h
index 2322ca2c99..6dfe7f31af 100644
--- a/src/core/stdmsg/src/msgs.h
+++ b/src/core/stdmsg/src/msgs.h
@@ -126,7 +126,7 @@ public:
public:
CSrmmWindow(CTabbedWindow*, MCONTACT hContact);
- void OnInitDialog() override;
+ bool OnInitDialog() override;
void OnDestroy() override;
void OnActivate() override;
@@ -183,7 +183,7 @@ class CChatRoomDlg : public CMsgDialog
public:
CChatRoomDlg(CTabbedWindow*, SESSION_INFO*);
- void OnInitDialog() override;
+ bool OnInitDialog() override;
void OnDestroy() override;
void OnActivate() override;
diff --git a/src/core/stdmsg/src/stdafx.h b/src/core/stdmsg/src/stdafx.h
index 344b40992a..67c98ec5f5 100644
--- a/src/core/stdmsg/src/stdafx.h
+++ b/src/core/stdmsg/src/stdafx.h
@@ -173,11 +173,11 @@ public:
void SetTabHighlight(CMsgDialog*);
void TabClicked();
- virtual void OnInitDialog() override;
- virtual void OnDestroy() override;
+ bool OnInitDialog() override;
+ void OnDestroy() override;
- virtual INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override;
- virtual int Resizer(UTILRESIZECONTROL *urc) override;
+ INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override;
+ int Resizer(UTILRESIZECONTROL *urc) override;
};
extern CTabbedWindow *g_pTabDialog;
diff --git a/src/core/stdmsg/src/tabs.cpp b/src/core/stdmsg/src/tabs.cpp
index 5a0537b45d..cf8c187512 100644
--- a/src/core/stdmsg/src/tabs.cpp
+++ b/src/core/stdmsg/src/tabs.cpp
@@ -144,7 +144,7 @@ CTabbedWindow::CTabbedWindow() :
{
}
-void CTabbedWindow::OnInitDialog()
+bool CTabbedWindow::OnInitDialog()
{
SetWindowLongPtr(m_tab.GetHwnd(), GWLP_USERDATA, LPARAM(this));
mir_subclassWindow(m_tab.GetHwnd(), ::TabSubclassProc);
@@ -156,7 +156,7 @@ void CTabbedWindow::OnInitDialog()
if (!g_Settings.bTabsEnable) {
m_tab.Hide();
- return;
+ return false;
}
LONG_PTR mask = GetWindowLongPtr(m_tab.GetHwnd(), GWL_STYLE);
@@ -168,6 +168,7 @@ void CTabbedWindow::OnInitDialog()
TabCtrl_SetMinTabWidth(m_tab.GetHwnd(), 80);
TabCtrl_SetImageList(m_tab.GetHwnd(), Clist_GetImageList());
+ return true;
}
void CTabbedWindow::OnDestroy()