diff options
author | George Hazan <ghazan@miranda.im> | 2018-07-11 17:09:17 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-07-11 17:09:17 +0300 |
commit | b2c91edc9646daa331de71d589e4fec6bdef4945 (patch) | |
tree | 847a77d0686d26e25b126313fbaa8262c81f8d1a /protocols/Steam | |
parent | ae081843e9663b3cb36b17309fbce1d2967315f1 (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/Steam')
-rw-r--r-- | protocols/Steam/src/steam_dialogs.cpp | 24 | ||||
-rw-r--r-- | protocols/Steam/src/steam_dialogs.h | 23 | ||||
-rw-r--r-- | protocols/Steam/src/steam_options.cpp | 9 | ||||
-rw-r--r-- | protocols/Steam/src/steam_options.h | 6 |
4 files changed, 38 insertions, 24 deletions
diff --git a/protocols/Steam/src/steam_dialogs.cpp b/protocols/Steam/src/steam_dialogs.cpp index 569ee3de8f..7e5cd0f93d 100644 --- a/protocols/Steam/src/steam_dialogs.cpp +++ b/protocols/Steam/src/steam_dialogs.cpp @@ -7,7 +7,7 @@ CSteamPasswordEditor::CSteamPasswordEditor(CSteamProto *proto) m_ok.OnClick = Callback(this, &CSteamPasswordEditor::OnOk);
}
-void CSteamPasswordEditor::OnInitDialog()
+bool CSteamPasswordEditor::OnInitDialog()
{
char iconName[100];
mir_snprintf(iconName, "%s_%s", MODULE, "main");
@@ -16,6 +16,7 @@ void CSteamPasswordEditor::OnInitDialog() SendMessage(m_password.GetHwnd(), EM_LIMITTEXT, 64, 0);
Utils_RestoreWindowPosition(m_hwnd, NULL, m_proto->m_szModuleName, "PasswordWindow");
+ return true;
}
void CSteamPasswordEditor::OnOk(CCtrlButton*)
@@ -27,9 +28,10 @@ void CSteamPasswordEditor::OnOk(CCtrlButton*) EndDialog(m_hwnd, DIALOG_RESULT_OK);
}
-void CSteamPasswordEditor::OnClose()
+bool CSteamPasswordEditor::OnClose()
{
Utils_SaveWindowPosition(m_hwnd, NULL, m_proto->m_szModuleName, "PasswordWindow");
+ return true;
}
/////////////////////////////////////////////////////////////////////////////////
@@ -45,7 +47,7 @@ CSteamGuardDialog::CSteamGuardDialog(CSteamProto *proto, const char *domain) m_ok.OnClick = Callback(this, &CSteamGuardDialog::OnOk);
}
-void CSteamGuardDialog::OnInitDialog()
+bool CSteamGuardDialog::OnInitDialog()
{
char iconName[100];
mir_snprintf(iconName, "%s_%s", MODULE, "main");
@@ -54,6 +56,7 @@ void CSteamGuardDialog::OnInitDialog() SendMessage(m_text.GetHwnd(), EM_LIMITTEXT, 5, 0);
Utils_RestoreWindowPosition(m_hwnd, NULL, m_proto->m_szModuleName, "GuardWindow");
+ return true;
}
void CSteamGuardDialog::OnOk(CCtrlButton*)
@@ -62,9 +65,10 @@ void CSteamGuardDialog::OnOk(CCtrlButton*) EndDialog(m_hwnd, DIALOG_RESULT_OK);
}
-void CSteamGuardDialog::OnClose()
+bool CSteamGuardDialog::OnClose()
{
Utils_SaveWindowPosition(m_hwnd, NULL, m_proto->m_szModuleName, "GuardWindow");
+ return true;
}
const char* CSteamGuardDialog::GetGuardCode()
@@ -83,7 +87,7 @@ m_text(this, IDC_TEXT) m_ok.OnClick = Callback(this, &CSteamTwoFactorDialog::OnOk);
}
-void CSteamTwoFactorDialog::OnInitDialog()
+bool CSteamTwoFactorDialog::OnInitDialog()
{
char iconName[100];
mir_snprintf(iconName, "%s_%s", MODULE, "main");
@@ -92,6 +96,7 @@ void CSteamTwoFactorDialog::OnInitDialog() SendMessage(m_text.GetHwnd(), EM_LIMITTEXT, 5, 0);
Utils_RestoreWindowPosition(m_hwnd, NULL, m_proto->m_szModuleName, "TwoFactorWindow");
+ return true;
}
void CSteamTwoFactorDialog::OnOk(CCtrlButton*)
@@ -100,9 +105,10 @@ void CSteamTwoFactorDialog::OnOk(CCtrlButton*) EndDialog(m_hwnd, DIALOG_RESULT_OK);
}
-void CSteamTwoFactorDialog::OnClose()
+bool CSteamTwoFactorDialog::OnClose()
{
Utils_SaveWindowPosition(m_hwnd, NULL, m_proto->m_szModuleName, "TwoFactorWindow");
+ return true;
}
const char* CSteamTwoFactorDialog::GetTwoFactorCode()
@@ -130,7 +136,7 @@ CSteamCaptchaDialog::~CSteamCaptchaDialog() mir_free(m_captchaImage);
}
-void CSteamCaptchaDialog::OnInitDialog()
+bool CSteamCaptchaDialog::OnInitDialog()
{
char iconName[100];
mir_snprintf(iconName, "%s_%s", MODULE, "main");
@@ -139,6 +145,7 @@ void CSteamCaptchaDialog::OnInitDialog() SendMessage(m_text.GetHwnd(), EM_LIMITTEXT, 6, 0);
Utils_RestoreWindowPosition(m_hwnd, NULL, m_proto->m_szModuleName, "CaptchaWindow");
+ return true;
}
void CSteamCaptchaDialog::OnOk(CCtrlButton*)
@@ -147,9 +154,10 @@ void CSteamCaptchaDialog::OnOk(CCtrlButton*) EndDialog(m_hwnd, DIALOG_RESULT_OK);
}
-void CSteamCaptchaDialog::OnClose()
+bool CSteamCaptchaDialog::OnClose()
{
Utils_SaveWindowPosition(m_hwnd, NULL, m_proto->m_szModuleName, "CaptchaWindow");
+ return true;
}
INT_PTR CSteamCaptchaDialog::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
diff --git a/protocols/Steam/src/steam_dialogs.h b/protocols/Steam/src/steam_dialogs.h index 20d6a60f48..8086114c42 100644 --- a/protocols/Steam/src/steam_dialogs.h +++ b/protocols/Steam/src/steam_dialogs.h @@ -16,9 +16,10 @@ private: CCtrlButton m_ok;
protected:
- void OnInitDialog();
+ bool OnInitDialog() override;
+ bool OnClose() override;
+
void OnOk(CCtrlButton*);
- void OnClose();
public:
CSteamPasswordEditor(CSteamProto *proto);
@@ -37,9 +38,10 @@ private: CCtrlHyperlink m_link;
protected:
- void OnInitDialog();
+ bool OnInitDialog() override;
+ bool OnClose() override;
+
void OnOk(CCtrlButton*);
- void OnClose();
public:
CSteamGuardDialog(CSteamProto *proto, const char *domain);
@@ -58,9 +60,10 @@ private: CCtrlButton m_ok;
protected:
- void OnInitDialog();
+ bool OnInitDialog() override;
+ bool OnClose() override;
+
void OnOk(CCtrlButton*);
- void OnClose();
public:
CSteamTwoFactorDialog(CSteamProto *proto);
@@ -82,11 +85,11 @@ private: CCtrlButton m_ok;
protected:
- void OnInitDialog();
- void OnOk(CCtrlButton*);
- void OnClose();
+ bool OnInitDialog() override;
+ bool OnClose() override;
+ INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override;
- INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam);
+ void OnOk(CCtrlButton*);
public:
CSteamCaptchaDialog(CSteamProto *proto, const uint8_t *captchaImage, int captchaImageSize);
diff --git a/protocols/Steam/src/steam_options.cpp b/protocols/Steam/src/steam_options.cpp index 92fd87152e..74c51a82c5 100644 --- a/protocols/Steam/src/steam_options.cpp +++ b/protocols/Steam/src/steam_options.cpp @@ -19,7 +19,7 @@ CSteamOptionsMain::CSteamOptionsMain(CSteamProto *proto, int idDialog, HWND hwnd }
}
-void CSteamOptionsMain::OnInitDialog()
+bool CSteamOptionsMain::OnInitDialog()
{
CSteamDlgBase::OnInitDialog();
@@ -28,9 +28,10 @@ void CSteamOptionsMain::OnInitDialog() SendMessage(m_group.GetHwnd(), EM_LIMITTEXT, 64, 0);
m_pollingErrorLimit.SetRange(255, 0);
+ return true;
}
-void CSteamOptionsMain::OnApply()
+bool CSteamOptionsMain::OnApply()
{
ptrW group(m_group.GetText());
if (mir_wstrcmp(group, m_proto->m_defaultGroup)) {
@@ -46,6 +47,7 @@ void CSteamOptionsMain::OnApply() }
if (m_password.IsChanged())
m_proto->delSetting("TokenSecret");
+ return true;
}
/////////////////////////////////////////////////////////////////////////////////
@@ -59,12 +61,13 @@ CSteamOptionsBlockList::CSteamOptionsBlockList(CSteamProto *proto) m_add.OnClick = Callback(this, &CSteamOptionsBlockList::OnBlock);
}
-void CSteamOptionsBlockList::OnInitDialog()
+bool CSteamOptionsBlockList::OnInitDialog()
{
m_list.SetExtendedListViewStyle(LVS_EX_SUBITEMIMAGES | LVS_EX_FULLROWSELECT | LVS_EX_LABELTIP);
m_list.AddColumn(0, TranslateT("Name"), 220);
m_list.AddColumn(1, L"", 32 - GetSystemMetrics(SM_CXVSCROLL));
+ return true;
}
void CSteamOptionsBlockList::OnBlock(CCtrlButton*)
diff --git a/protocols/Steam/src/steam_options.h b/protocols/Steam/src/steam_options.h index d0aaf03bd9..a71e6ae2fa 100644 --- a/protocols/Steam/src/steam_options.h +++ b/protocols/Steam/src/steam_options.h @@ -16,8 +16,8 @@ private: protected:
CSteamOptionsMain(CSteamProto *proto, int idDialog, HWND hwndParent = NULL);
- void OnInitDialog();
- void OnApply();
+ bool OnInitDialog() override;
+ bool OnApply() override;
public:
static CDlgBase *CreateAccountManagerPage(void *param, HWND owner)
@@ -42,7 +42,7 @@ private: CCtrlButton m_add;
protected:
- void OnInitDialog();
+ bool OnInitDialog() override;
void OnBlock(CCtrlButton*);
public:
|