summaryrefslogtreecommitdiff
path: root/protocols/Tox/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/Tox/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/Tox/src')
-rw-r--r--protocols/Tox/src/tox_options.cpp19
-rw-r--r--protocols/Tox/src/tox_options.h13
-rw-r--r--protocols/Tox/src/tox_profile.cpp9
-rw-r--r--protocols/Tox/src/tox_profile.h9
4 files changed, 31 insertions, 19 deletions
diff --git a/protocols/Tox/src/tox_options.cpp b/protocols/Tox/src/tox_options.cpp
index 3cc61ec397..ef923e6fef 100644
--- a/protocols/Tox/src/tox_options.cpp
+++ b/protocols/Tox/src/tox_options.cpp
@@ -37,7 +37,7 @@ CToxOptionsMain::CToxOptionsMain(CToxProto *proto, int idDialog)
m_profileExport.OnClick = Callback(this, &CToxOptionsMain::ProfileExport_OnClick);
}
-void CToxOptionsMain::OnInitDialog()
+bool CToxOptionsMain::OnInitDialog()
{
CToxDlgBase::OnInitDialog();
@@ -68,6 +68,7 @@ void CToxOptionsMain::OnInitDialog()
m_maxConnectRetries.SetRange(255, 1);
m_maxReconnectRetries.SetRange(255, 1);
+ return true;
}
void CToxOptionsMain::PasswordCreate_OnClick(CCtrlButton*)
@@ -226,7 +227,7 @@ void CToxOptionsMain::ProfileExport_OnClick(CCtrlButton*)
CopyFile(defaultProfilePath, profilePath, FALSE);
}
-void CToxOptionsMain::OnApply()
+bool CToxOptionsMain::OnApply()
{
ptrW group(m_group.GetText());
if (mir_wstrcmp(group, m_proto->m_defaultGroup)) {
@@ -242,6 +243,7 @@ void CToxOptionsMain::OnApply()
m_proto->SaveToxProfile(m_proto->m_toxThread->Tox());
}
+ return true;
}
/////////////////////////////////////////////////////////////////////////////////
@@ -257,7 +259,7 @@ CToxNodeEditor::CToxNodeEditor(int iItem, CCtrlListView *m_nodes)
m_ok.OnClick = Callback(this, &CToxNodeEditor::OnOk);
}
-void CToxNodeEditor::OnInitDialog()
+bool CToxNodeEditor::OnInitDialog()
{
SetWindowText(m_hwnd, m_iItem == -1 ? TranslateT("Add node") : TranslateT("Change node"));
@@ -286,6 +288,7 @@ void CToxNodeEditor::OnInitDialog()
}
Utils_RestoreWindowPositionNoSize(m_hwnd, NULL, MODULE, "EditNodeDlg");
+ return true;
}
void CToxNodeEditor::OnOk(CCtrlBase*)
@@ -325,12 +328,12 @@ void CToxNodeEditor::OnOk(CCtrlBase*)
EndDialog(m_hwnd, 1);
}
-void CToxNodeEditor::OnClose()
+bool CToxNodeEditor::OnClose()
{
Utils_SaveWindowPosition(m_hwnd, NULL, MODULE, "EditNodeDlg");
+ return true;
}
-
/****************************************/
CToxOptionsNodeList::CToxOptionsNodeList(CToxProto *proto)
@@ -345,7 +348,7 @@ CToxOptionsNodeList::CToxOptionsNodeList(CToxProto *proto)
m_nodes.OnKeyDown = Callback(this, &CToxOptionsNodeList::OnNodeListKeyDown);
}
-void CToxOptionsNodeList::OnInitDialog()
+bool CToxOptionsNodeList::OnInitDialog()
{
m_nodes.SetExtendedListViewStyle(LVS_EX_SUBITEMIMAGES | LVS_EX_FULLROWSELECT | LVS_EX_LABELTIP);
@@ -367,6 +370,7 @@ void CToxOptionsNodeList::OnInitDialog()
m_nodes.AddGroup(1, TranslateT("User nodes"));
ReloadNodeList();
+ return true;
}
void CToxOptionsNodeList::OnAddNode(CCtrlBase*)
@@ -484,7 +488,7 @@ void CToxOptionsNodeList::ReloadNodeList()
}
}
-void CToxOptionsNodeList::OnApply()
+bool CToxOptionsNodeList::OnApply()
{
char setting[MAX_PATH];
wchar_t tszText[MAX_PATH];
@@ -543,6 +547,7 @@ void CToxOptionsNodeList::OnApply()
db_unset(NULL, module, setting);
}
db_set_b(NULL, module, TOX_SETTINGS_NODE_COUNT, itemCount);
+ return true;
}
/////////////////////////////////////////////////////////////////////////////////
diff --git a/protocols/Tox/src/tox_options.h b/protocols/Tox/src/tox_options.h
index 74987139da..374bfbb5af 100644
--- a/protocols/Tox/src/tox_options.h
+++ b/protocols/Tox/src/tox_options.h
@@ -28,7 +28,7 @@ private:
CCtrlSpin m_maxReconnectRetries;
protected:
- void OnInitDialog();
+ bool OnInitDialog() override;
void PasswordCreate_OnClick(CCtrlButton*);
void PasswordChange_OnClick(CCtrlButton*);
@@ -41,7 +41,7 @@ protected:
void ProfileImport_OnClick(CCtrlButton*);
void ProfileExport_OnClick(CCtrlButton*);
- void OnApply();
+ bool OnApply() override;
public:
CToxOptionsMain(CToxProto *proto, int idDialog);
@@ -75,9 +75,10 @@ private:
CCtrlButton m_ok;
protected:
- void OnInitDialog();
+ bool OnInitDialog() override;
+ bool OnClose() override;
+
void OnOk(CCtrlBase*);
- void OnClose();
public:
CToxNodeEditor(int iItem, CCtrlListView *m_list);
@@ -96,8 +97,8 @@ private:
CCtrlButton m_updateNodes;
protected:
- void OnInitDialog();
- void OnApply();
+ bool OnInitDialog() override;
+ bool OnApply() override;
void ReloadNodeList();
diff --git a/protocols/Tox/src/tox_profile.cpp b/protocols/Tox/src/tox_profile.cpp
index 76744445e5..d90c1a08f9 100644
--- a/protocols/Tox/src/tox_profile.cpp
+++ b/protocols/Tox/src/tox_profile.cpp
@@ -200,9 +200,10 @@ CToxEnterPasswordDlg::CToxEnterPasswordDlg(CToxProto *proto)
m_ok.OnClick = Callback(this, &CToxEnterPasswordDlg::OnOk);
}
-void CToxEnterPasswordDlg::OnInitDialog()
+bool CToxEnterPasswordDlg::OnInitDialog()
{
m_ok.Disable();
+ return true;
}
void CToxEnterPasswordDlg::Password_OnChange(CCtrlBase*)
@@ -230,7 +231,7 @@ CToxCreatePasswordDlg::CToxCreatePasswordDlg(CToxProto *proto)
m_ok.OnClick = Callback(this, &CToxCreatePasswordDlg::OnOk);
}
-void CToxCreatePasswordDlg::OnInitDialog()
+bool CToxCreatePasswordDlg::OnInitDialog()
{
LOGFONT lf;
HFONT hFont = (HFONT)m_passwordValidation.SendMsg(WM_GETFONT, 0, 0);
@@ -239,6 +240,7 @@ void CToxCreatePasswordDlg::OnInitDialog()
m_passwordValidation.SendMsg(WM_SETFONT, (WPARAM)CreateFontIndirect(&lf), 0);
m_ok.Disable();
+ return true;
}
void CToxCreatePasswordDlg::Password_OnChange(CCtrlBase*)
@@ -284,7 +286,7 @@ CToxChangePasswordDlg::CToxChangePasswordDlg(CToxProto *proto)
m_ok.OnClick = Callback(this, &CToxChangePasswordDlg::OnOk);
}
-void CToxChangePasswordDlg::OnInitDialog()
+bool CToxChangePasswordDlg::OnInitDialog()
{
LOGFONT lf;
HFONT hFont = (HFONT)m_passwordValidation.SendMsg(WM_GETFONT, 0, 0);
@@ -293,6 +295,7 @@ void CToxChangePasswordDlg::OnInitDialog()
m_passwordValidation.SendMsg(WM_SETFONT, (WPARAM)CreateFontIndirect(&lf), 0);
m_ok.Disable();
+ return true;
}
void CToxChangePasswordDlg::Password_OnChange(CCtrlBase*)
diff --git a/protocols/Tox/src/tox_profile.h b/protocols/Tox/src/tox_profile.h
index 4aedae071f..fd23665c90 100644
--- a/protocols/Tox/src/tox_profile.h
+++ b/protocols/Tox/src/tox_profile.h
@@ -11,7 +11,8 @@ private:
CCtrlButton m_ok;
protected:
- void OnInitDialog();
+ bool OnInitDialog() override;
+
void Password_OnChange(CCtrlBase*);
void OnOk(CCtrlButton*);
@@ -32,7 +33,8 @@ private:
CCtrlButton m_ok;
protected:
- void OnInitDialog();
+ bool OnInitDialog() override;
+
void Password_OnChange(CCtrlBase*);
void OnOk(CCtrlButton*);
@@ -55,7 +57,8 @@ private:
CCtrlButton m_ok;
protected:
- void OnInitDialog();
+ bool OnInitDialog() override;
+
void Password_OnChange(CCtrlBase*);
void OnOk(CCtrlButton*);