summaryrefslogtreecommitdiff
path: root/protocols/IRCG/src
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 /protocols/IRCG/src
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 'protocols/IRCG/src')
-rw-r--r--protocols/IRCG/src/irc_dlg.h70
-rw-r--r--protocols/IRCG/src/options.cpp42
-rw-r--r--protocols/IRCG/src/windows.cpp39
3 files changed, 87 insertions, 64 deletions
diff --git a/protocols/IRCG/src/irc_dlg.h b/protocols/IRCG/src/irc_dlg.h
index 0d74f61258..f4d7d1363b 100644
--- a/protocols/IRCG/src/irc_dlg.h
+++ b/protocols/IRCG/src/irc_dlg.h
@@ -38,10 +38,10 @@ struct CCoolIrcDlg : public CProtoDlgBase < CIrcProto >
{
CCoolIrcDlg(CIrcProto* _pro, int dlgId);
- virtual INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam);
+ INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override;
- virtual void OnInitDialog();
- virtual void OnDestroy();
+ bool OnInitDialog() override;
+ void OnDestroy() override;
};
struct CWhoisDlg : public CCoolIrcDlg
@@ -65,9 +65,9 @@ struct CWhoisDlg : public CCoolIrcDlg
void OnTime(CCtrlButton*);
void OnVersion(CCtrlButton*);
- virtual void OnInitDialog();
- virtual void OnClose();
- virtual void OnDestroy();
+ bool OnInitDialog() override;
+ bool OnClose() override;
+ void OnDestroy() override;
};
struct CNickDlg : public CCoolIrcDlg
@@ -77,8 +77,8 @@ struct CNickDlg : public CCoolIrcDlg
CCtrlCombo m_Enick;
CCtrlButton m_Ok;
- virtual void OnInitDialog();
- virtual void OnDestroy();
+ bool OnInitDialog() override;
+ void OnDestroy() override;
void OnOk(CCtrlButton*);
};
@@ -87,10 +87,11 @@ struct CListDlg : public CProtoDlgBase < CIrcProto >
{
CListDlg(CIrcProto* _pro);
- virtual void OnInitDialog();
- virtual INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam);
- virtual void OnDestroy();
- virtual int Resizer(UTILRESIZECONTROL *urc);
+ bool OnInitDialog() override;
+ void OnDestroy() override;
+ int Resizer(UTILRESIZECONTROL *urc) override;
+
+ INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override;
CCtrlListView m_list, m_list2;
CCtrlEdit m_filter, m_status;
@@ -109,8 +110,8 @@ struct CJoinDlg : public CCoolIrcDlg
{
CJoinDlg(CIrcProto* _pro);
- virtual void OnInitDialog();
- virtual void OnDestroy();
+ bool OnInitDialog() override;
+ void OnDestroy() override;
CCtrlButton m_Ok;
void OnOk(CCtrlButton*);
@@ -120,8 +121,8 @@ struct CQuickDlg : public CCoolIrcDlg
{
CQuickDlg(CIrcProto* _pro);
- virtual void OnInitDialog();
- virtual void OnDestroy();
+ bool OnInitDialog() override;
+ void OnDestroy() override;
CCtrlCombo m_serverCombo;
void OnServerCombo(CCtrlData*);
@@ -144,9 +145,9 @@ struct CManagerDlg : public CCoolIrcDlg
CCtrlMButton m_add, m_edit, m_remove, m_applyTopic, m_applyModes;
CCtrlListBox m_list;
- virtual void OnInitDialog();
- virtual void OnClose();
- virtual void OnDestroy();
+ bool OnInitDialog() override;
+ bool OnClose() override;
+ void OnDestroy() override;
void OnCheck(CCtrlData*);
void OnCheck5(CCtrlData*);
@@ -174,8 +175,8 @@ struct CQuestionDlg : public CCoolIrcDlg
{
CQuestionDlg(CIrcProto* _pro, CManagerDlg* owner = nullptr);
- virtual void OnInitDialog();
- virtual void OnClose();
+ bool OnInitDialog() override;
+ bool OnClose() override;
CCtrlButton m_Ok;
void OnOk(CCtrlButton*);
@@ -211,8 +212,8 @@ struct CConnectPrefsDlg : public CProtoDlgBase < CIrcProto >
CConnectPrefsDlg(CIrcProto* _pro);
- virtual void OnInitDialog();
- virtual void OnApply();
+ bool OnInitDialog() override;
+ bool OnApply() override;
void OnServerCombo(CCtrlData*);
void OnAddServer(CCtrlButton*);
@@ -223,7 +224,6 @@ struct CConnectPrefsDlg : public CProtoDlgBase < CIrcProto >
void OnUseServer(CCtrlData*);
void OnOnlineNotif(CCtrlData*);
void OnChannelAway(CCtrlData*);
- void OnRetry(CCtrlData*);
};
//---- the second property page: DCC/CTCP -----------------------------------------------
@@ -237,8 +237,8 @@ struct CCtcpPrefsDlg : public CProtoDlgBase < CIrcProto >
CCtcpPrefsDlg(CIrcProto* _pro);
- virtual void OnInitDialog();
- virtual void OnApply();
+ bool OnInitDialog() override;
+ bool OnApply() override;
void OnClicked(CCtrlData*);
};
@@ -257,9 +257,9 @@ struct COtherPrefsDlg : public CProtoDlgBase < CIrcProto >
COtherPrefsDlg(CIrcProto* _pro);
- virtual void OnInitDialog();
- virtual void OnApply();
- virtual void OnDestroy();
+ bool OnInitDialog() override;
+ bool OnApply() override;
+ void OnDestroy() override;
void OnPerformCombo(CCtrlData*);
void OnCodePage(CCtrlData*);
@@ -281,11 +281,11 @@ struct CIgnorePrefsDlg : public CProtoDlgBase < CIrcProto >
CIgnorePrefsDlg(CIrcProto* _pro);
- virtual void OnInitDialog();
- virtual void OnDestroy();
- virtual void OnApply();
+ bool OnInitDialog() override;
+ void OnDestroy() override;
+ bool OnApply() override;
- virtual INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam);
+ INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override;
void List_OnColumnClick(CCtrlListView::TEventInfo*);
void OnEnableIgnore(CCtrlData*);
@@ -308,8 +308,8 @@ struct CAddIgnoreDlg : public CProtoDlgBase < CIrcProto >
CAddIgnoreDlg(CIrcProto* _pro, const wchar_t* mask, CIgnorePrefsDlg* parent);
- virtual void OnInitDialog();
- virtual void OnClose();
+ bool OnInitDialog() override;
+ bool OnClose() override;
void OnOk(CCtrlButton*);
};
diff --git a/protocols/IRCG/src/options.cpp b/protocols/IRCG/src/options.cpp
index 8160d70e30..e84d0d00e2 100644
--- a/protocols/IRCG/src/options.cpp
+++ b/protocols/IRCG/src/options.cpp
@@ -300,7 +300,7 @@ struct CServerDlg : public CProtoDlgBase<CIrcProto>
m_autoClose = CLOSE_ON_CANCEL;
}
- virtual void OnInitDialog()
+ bool OnInitDialog() override
{
int i = m_owner->m_serverCombo.GetCount();
for (int index = 0; index < i; index++) {
@@ -340,14 +340,16 @@ struct CServerDlg : public CProtoDlgBase<CIrcProto>
EnableWindow(GetDlgItem(m_hwnd, IDC_AUTO), bEnableSsl);
SetFocus(m_groupCombo.GetHwnd());
+ return true;
}
- virtual void OnClose()
+ bool OnClose() override
{
m_owner->m_serverCombo.Enable();
m_owner->m_add.Enable();
m_owner->m_edit.Enable();
m_owner->m_del.Enable();
+ return true;
}
void OnOk(CCtrlButton*)
@@ -480,7 +482,7 @@ CConnectPrefsDlg::CConnectPrefsDlg(CIrcProto* _pro)
m_channelAway.OnChange = Callback(this, &CConnectPrefsDlg::OnChannelAway);
}
-void CConnectPrefsDlg::OnInitDialog()
+bool CConnectPrefsDlg::OnInitDialog()
{
m_proto->m_hwndConnect = m_hwnd;
@@ -556,6 +558,7 @@ void CConnectPrefsDlg::OnInitDialog()
m_port.Enable(!m_proto->m_disableDefaultServer);
m_port2.Enable(!m_proto->m_disableDefaultServer);
m_pass.Enable(!m_proto->m_disableDefaultServer);
+ return true;
}
void CConnectPrefsDlg::OnServerCombo(CCtrlData*)
@@ -676,7 +679,7 @@ void CConnectPrefsDlg::OnChannelAway(CCtrlData*)
m_limit.Enable(m_onlineNotif.GetState() && m_channelAway.GetState());
}
-void CConnectPrefsDlg::OnApply()
+bool CConnectPrefsDlg::OnApply()
{
//Save the setting in the CONNECT dialog
if (m_enableServer.GetState()) {
@@ -772,6 +775,7 @@ void CConnectPrefsDlg::OnApply()
}
m_proto->WriteSettings(ConnectSettings, _countof(ConnectSettings));
+ return true;
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -811,7 +815,7 @@ CCtcpPrefsDlg::CCtcpPrefsDlg(CIrcProto* _pro)
m_fromServer.OnChange = Callback(this, &CCtcpPrefsDlg::OnClicked);
}
-void CCtcpPrefsDlg::OnInitDialog()
+bool CCtcpPrefsDlg::OnInitDialog()
{
m_userInfo.SetText(m_proto->m_userInfo);
@@ -863,6 +867,7 @@ void CCtcpPrefsDlg::OnInitDialog()
else m_ip.SetText(TranslateT("<Automatic>"));
}
}
+ return true;
}
void CCtcpPrefsDlg::OnClicked(CCtrlData*)
@@ -890,7 +895,7 @@ void CCtcpPrefsDlg::OnClicked(CCtrlData*)
}
}
-void CCtcpPrefsDlg::OnApply()
+bool CCtcpPrefsDlg::OnApply()
{
m_userInfo.GetText(m_proto->m_userInfo, _countof(m_proto->m_userInfo));
@@ -919,6 +924,7 @@ void CCtcpPrefsDlg::OnApply()
m_proto->m_DCCChatAccept = 3;
m_proto->WriteSettings(CtcpSettings, _countof(CtcpSettings));
+ return true;
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -993,7 +999,7 @@ COtherPrefsDlg::COtherPrefsDlg(CIrcProto* _pro)
m_delete.OnClick = Callback(this, &COtherPrefsDlg::OnDelete);
}
-void COtherPrefsDlg::OnInitDialog()
+bool COtherPrefsDlg::OnInitDialog()
{
mir_subclassWindow(m_alias.GetHwnd(), EditSubclassProc);
mir_subclassWindow(m_quitMessage.GetHwnd(), EditSubclassProc);
@@ -1039,6 +1045,7 @@ void COtherPrefsDlg::OnInitDialog()
m_performCombo.SetCurSel(0);
OnPerformCombo(nullptr);
m_autodetect.SetState(m_proto->m_utfAutodetect);
+ return true;
}
void COtherPrefsDlg::OnPerformCombo(CCtrlData*)
@@ -1128,7 +1135,7 @@ void COtherPrefsDlg::OnDestroy()
}
}
-void COtherPrefsDlg::OnApply()
+bool COtherPrefsDlg::OnApply()
{
mir_free(m_proto->m_alias);
m_proto->m_alias = m_alias.GetText();
@@ -1159,6 +1166,7 @@ void COtherPrefsDlg::OnApply()
}
}
m_proto->WriteSettings(OtherSettings, _countof(OtherSettings));
+ return true;
}
void COtherPrefsDlg::addPerformComboValue(int idx, const char* szValueName)
@@ -1194,7 +1202,7 @@ CAddIgnoreDlg::CAddIgnoreDlg(CIrcProto* _pro, const wchar_t* mask, CIgnorePrefsD
m_Ok.OnClick = Callback(this, &CAddIgnoreDlg::OnOk);
}
-void CAddIgnoreDlg::OnInitDialog()
+bool CAddIgnoreDlg::OnInitDialog()
{
if (szOldMask[0] == 0) {
if (m_proto->IsConnected())
@@ -1205,6 +1213,7 @@ void CAddIgnoreDlg::OnInitDialog()
CheckDlgButton(m_hwnd, IDC_D, BST_CHECKED);
CheckDlgButton(m_hwnd, IDC_C, BST_CHECKED);
}
+ return true;
}
void CAddIgnoreDlg::OnOk(CCtrlButton*)
@@ -1235,9 +1244,10 @@ void CAddIgnoreDlg::OnOk(CCtrlButton*)
}
}
-void CAddIgnoreDlg::OnClose()
+bool CAddIgnoreDlg::OnClose()
{
m_owner->FixButtons();
+ return true;
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -1400,7 +1410,7 @@ CIgnorePrefsDlg::CIgnorePrefsDlg(CIrcProto* _pro)
m_list.OnColumnClick = Callback(this, &CIgnorePrefsDlg::List_OnColumnClick);
}
-void CIgnorePrefsDlg::OnInitDialog()
+bool CIgnorePrefsDlg::OnInitDialog()
{
m_proto->m_ignoreDlg = this;
mir_subclassWindow(m_list.GetHwnd(), ListviewSubclassProc);
@@ -1437,6 +1447,7 @@ void CIgnorePrefsDlg::OnInitDialog()
ListView_SetExtendedListViewStyle(GetDlgItem(m_hwnd, IDC_INFO_LISTVIEW), LVS_EX_FULLROWSELECT);
RebuildList();
+ return true;
}
INT_PTR CIgnorePrefsDlg::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
@@ -1534,7 +1545,7 @@ void CIgnorePrefsDlg::List_OnColumnClick(CCtrlListView::TEventInfo*)
UpdateList();
}
-void CIgnorePrefsDlg::OnApply()
+bool CIgnorePrefsDlg::OnApply()
{
m_proto->m_DCCFileEnabled = !m_ignoreFile.GetState();
m_proto->m_DCCChatEnabled = !m_ignoreChat.GetState();
@@ -1542,6 +1553,7 @@ void CIgnorePrefsDlg::OnApply()
m_proto->m_ignoreChannelDefault = m_ignoreChannel.GetState();
m_proto->m_DCCChatIgnore = m_ignoreUnknown.GetState() ? 2 : 1;
m_proto->WriteSettings(IgnoreSettings, _countof(IgnoreSettings));
+ return true;
}
void CIgnorePrefsDlg::OnDestroy()
@@ -1741,7 +1753,7 @@ struct CDlgAccMgrUI : public CProtoDlgBase<CIrcProto>
m_serverCombo.OnChange = Callback(this, &CDlgAccMgrUI::OnChangeCombo);
}
- virtual void OnInitDialog()
+ bool OnInitDialog() override
{
for (auto &si : g_servers)
m_serverCombo.AddStringA(si->m_name, LPARAM(si));
@@ -1761,9 +1773,10 @@ struct CDlgAccMgrUI : public CProtoDlgBase<CIrcProto>
m_nick2.SetText(m_proto->m_alternativeNick);
m_userID.SetText(m_proto->m_userID);
m_name.SetText(m_proto->m_name);
+ return true;
}
- virtual void OnApply()
+ bool OnApply() override
{
m_proto->m_serverComboSelection = m_serverCombo.GetCurSel();
m_server.GetTextA(m_proto->m_serverName, _countof(m_proto->m_serverName));
@@ -1780,6 +1793,7 @@ struct CDlgAccMgrUI : public CProtoDlgBase<CIrcProto>
removeSpaces(m_proto->m_userID);
m_name.GetText(m_proto->m_name, _countof(m_proto->m_name));
m_proto->WriteSettings(ConnectSettings, _countof(ConnectSettings));
+ return true;
}
void OnChangeCombo(CCtrlCombo*)
diff --git a/protocols/IRCG/src/windows.cpp b/protocols/IRCG/src/windows.cpp
index 6810e439b8..6e402fcc40 100644
--- a/protocols/IRCG/src/windows.cpp
+++ b/protocols/IRCG/src/windows.cpp
@@ -76,7 +76,7 @@ CWhoisDlg::CWhoisDlg(CIrcProto *_pro)
m_Query.OnClick = Callback(this, &CWhoisDlg::OnQuery);
}
-void CWhoisDlg::OnInitDialog()
+bool CWhoisDlg::OnInitDialog()
{
LOGFONT lf;
HFONT hFont = (HFONT)m_AwayTime.SendMsg(WM_GETFONT, 0, 0);
@@ -88,12 +88,14 @@ void CWhoisDlg::OnInitDialog()
CCoolIrcDlg::OnInitDialog();
Window_SetIcon_IcoLib(m_hwnd, GetIconHandle(IDI_WHOIS));
+ return true;
}
-void CWhoisDlg::OnClose()
+bool CWhoisDlg::OnClose()
{
ShowWindow(m_hwnd, SW_HIDE);
SendMessage(m_hwnd, WM_SETREDRAW, FALSE, 0);
+ return true;
}
void CWhoisDlg::OnDestroy()
@@ -205,7 +207,7 @@ CNickDlg::CNickDlg(CIrcProto *_pro)
m_Ok.OnClick = Callback(this, &CNickDlg::OnOk);
}
-void CNickDlg::OnInitDialog()
+bool CNickDlg::OnInitDialog()
{
CCoolIrcDlg::OnInitDialog();
Window_SetIcon_IcoLib(m_hwnd, GetIconHandle(IDI_RENAME));
@@ -218,6 +220,7 @@ void CNickDlg::OnInitDialog()
db_free(&dbv);
}
+ return true;
}
void CNickDlg::OnDestroy()
@@ -263,7 +266,7 @@ CListDlg::CListDlg(CIrcProto *_pro)
m_filter.OnChange = Callback(this, &CListDlg::onChange_Filter);
}
-void CListDlg::OnInitDialog()
+bool CListDlg::OnInitDialog()
{
RECT screen;
@@ -295,6 +298,7 @@ void CListDlg::OnInitDialog()
m_list2.SetExtendedListViewStyle(LVS_EX_FULLROWSELECT);
Window_SetIcon_IcoLib(m_hwnd, GetIconHandle(IDI_LIST));
m_status.SetText(TranslateT("Please wait..."));
+ return true;
}
INT_PTR CListDlg::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
@@ -498,7 +502,7 @@ CJoinDlg::CJoinDlg(CIrcProto *_pro)
m_Ok.OnClick = Callback(this, &CJoinDlg::OnOk);
}
-void CJoinDlg::OnInitDialog()
+bool CJoinDlg::OnInitDialog()
{
CCoolIrcDlg::OnInitDialog();
@@ -513,6 +517,7 @@ void CJoinDlg::OnInitDialog()
}
db_free(&dbv);
}
+ return true;
}
void CJoinDlg::OnDestroy()
@@ -558,7 +563,7 @@ CQuickDlg::CQuickDlg(CIrcProto *_pro)
m_serverCombo.OnChange = Callback(this, &CQuickDlg::OnServerCombo);
}
-void CQuickDlg::OnInitDialog()
+bool CQuickDlg::OnInitDialog()
{
CCoolIrcDlg::OnInitDialog();
@@ -600,6 +605,7 @@ void CQuickDlg::OnInitDialog()
OnServerCombo(nullptr);
}
else EnableWindow(GetDlgItem(m_hwnd, IDOK), false);
+ return true;
}
void CQuickDlg::OnDestroy()
@@ -708,17 +714,19 @@ CQuestionDlg::CQuestionDlg(CIrcProto *_pro, CManagerDlg *owner)
m_Ok.OnClick = Callback(this, &CQuestionDlg::OnOk);
}
-void CQuestionDlg::OnInitDialog()
+bool CQuestionDlg::OnInitDialog()
{
CCoolIrcDlg::OnInitDialog();
Window_SetIcon_IcoLib(m_hwnd, GetIconHandle(IDI_IRCQUESTION));
+ return true;
}
-void CQuestionDlg::OnClose()
+bool CQuestionDlg::OnClose()
{
if (m_owner)
m_owner->CloseQuestion();
+ return true;
}
void CQuestionDlg::OnOk(CCtrlButton*)
@@ -861,7 +869,7 @@ LRESULT CALLBACK MgrEditSubclassProc(HWND m_hwnd, UINT msg, WPARAM wParam, LPARA
return mir_callNextSubclass(m_hwnd, MgrEditSubclassProc, msg, wParam, lParam);
}
-void CManagerDlg::OnInitDialog()
+bool CManagerDlg::OnInitDialog()
{
CCoolIrcDlg::OnInitDialog();
@@ -886,16 +894,15 @@ void CManagerDlg::OnInitDialog()
if (!strchr(modes, 'p')) m_check7.Disable();
if (!strchr(modes, 's')) m_check8.Disable();
if (!strchr(modes, 'c')) m_check9.Disable();
+ return true;
}
-void CManagerDlg::OnClose()
+bool CManagerDlg::OnClose()
{
if (m_applyModes.Enabled() || m_applyTopic.Enabled()) {
int i = MessageBox(nullptr, TranslateT("You have not applied all changes!\n\nApply before exiting?"), TranslateT("IRC warning"), MB_YESNOCANCEL | MB_ICONWARNING | MB_DEFBUTTON3);
- if (i == IDCANCEL) {
- m_lresult = TRUE;
- return;
- }
+ if (i == IDCANCEL)
+ return false;
if (i == IDYES) {
if (m_applyModes.Enabled())
@@ -927,6 +934,7 @@ void CManagerDlg::OnClose()
mir_free(p);
}
DestroyWindow(m_hwnd);
+ return true;
}
void CManagerDlg::OnDestroy()
@@ -1373,7 +1381,7 @@ CCoolIrcDlg::CCoolIrcDlg(CIrcProto* _pro, int dlgId)
: CProtoDlgBase<CIrcProto>(_pro, dlgId)
{}
-void CCoolIrcDlg::OnInitDialog()
+bool CCoolIrcDlg::OnInitDialog()
{
HFONT hFont = (HFONT)SendDlgItemMessage(m_hwnd, IDC_CAPTION, WM_GETFONT, 0, 0);
@@ -1385,6 +1393,7 @@ void CCoolIrcDlg::OnInitDialog()
SendDlgItemMessage(m_hwnd, IDC_CAPTION, WM_SETFONT, (WPARAM)hFont, 0);
SendDlgItemMessage(m_hwnd, IDC_LOGO, STM_SETICON, (LPARAM)(HICON)LoadIconEx(IDI_LOGO), 0);
+ return true;
}
void CCoolIrcDlg::OnDestroy()