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 /plugins/Dbx_mdbx | |
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 'plugins/Dbx_mdbx')
-rw-r--r-- | plugins/Dbx_mdbx/src/ui.h | 56 |
1 files changed, 25 insertions, 31 deletions
diff --git a/plugins/Dbx_mdbx/src/ui.h b/plugins/Dbx_mdbx/src/ui.h index 29eed1c792..8ed9c0b1c3 100644 --- a/plugins/Dbx_mdbx/src/ui.h +++ b/plugins/Dbx_mdbx/src/ui.h @@ -17,20 +17,22 @@ class COptionsDialog : public CDlgBase CCtrlButton m_btnChangePass;
CDbxMDBX *m_db;
- void OnInitDialog()
+ bool OnInitDialog() override
{
m_chkStandart.SetState(!m_db->isEncrypted());
m_chkTotal.SetState(m_db->isEncrypted());
m_btnChangePass.SetTextA(Translate(m_db->GetMenuTitle()));
+ return true;
}
- void OnApply()
+ bool OnApply() override
{
SetCursor(LoadCursor(nullptr, IDC_WAIT));
m_db->EnableEncryption(m_chkTotal.GetState() != 0);
SetCursor(LoadCursor(nullptr, IDC_ARROW));
m_chkStandart.SetState(!m_db->isEncrypted());
m_chkTotal.SetState(m_db->isEncrypted());
+ return true;
}
void ChangePass(CCtrlButton*)
@@ -60,21 +62,22 @@ class CSelectCryptoDialog : public CDlgBase CRYPTO_PROVIDER *m_selected;
bool m_bTotalEncryption;
- void OnInitDialog()
+ bool OnInitDialog() override
{
- for (size_t i = 0; i < m_provscount; i++)
- {
+ for (size_t i = 0; i < m_provscount; i++) {
CRYPTO_PROVIDER *prov = m_provs[i];
m_combo.AddStringA(prov->pszName, i);
}
m_combo.SetCurSel(0);
m_descr.SetText(m_provs[0]->szDescr.w);
+ return true;
}
- void OnClose()
+ bool OnClose() override
{
- m_selected = m_provs[ m_combo.GetItemData(m_combo.GetCurSel()) ];
+ m_selected = m_provs[m_combo.GetItemData(m_combo.GetCurSel())];
m_bTotalEncryption = m_chkTotalCrypt.GetState() != 0;
+ return true;
}
void OnComboChanged(CCtrlCombo*)
@@ -121,10 +124,9 @@ class CEnterPasswordDialog : public CDlgBase DlgChangePassParam *m_param;
- INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
+ INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override
{
- if (msg == WM_TIMER)
- {
+ if (msg == WM_TIMER) {
UINT_PTR LangID = (UINT_PTR)GetKeyboardLayout(0);
char Lang[3] = { 0 };
GetLocaleInfoA(MAKELCID((LangID & 0xffffffff), SORT_DEFAULT), LOCALE_SABBREVLANGNAME, Lang, 2);
@@ -133,8 +135,7 @@ class CEnterPasswordDialog : public CDlgBase m_language.SetTextA(Lang);
return FALSE;
}
- else if (msg == WM_CTLCOLORSTATIC)
- {
+ else if (msg == WM_CTLCOLORSTATIC) {
if ((HWND)lParam == m_language.GetHwnd()) {
SetTextColor((HDC)wParam, GetSysColor(COLOR_HIGHLIGHTTEXT));
SetBkMode((HDC)wParam, TRANSPARENT);
@@ -144,38 +145,32 @@ class CEnterPasswordDialog : public CDlgBase return CDlgBase::DlgProc(msg, wParam, lParam);
}
- void OnInitDialog()
+ bool OnInitDialog() override
{
m_header.SendMsg(WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(iconList[0].defIconID)));
- if (m_param->wrongPass)
- {
- if (m_param->wrongPass > 2)
- {
+ if (m_param->wrongPass) {
+ if (m_param->wrongPass > 2) {
m_passwordEdit.Disable();
m_buttonOK.Disable();
m_header.SetText(TranslateT("Too many errors!"));
}
- else
- {
- m_header.SetText(TranslateT("Password is not correct!"));
- }
- }
- else
- {
- m_header.SetText(TranslateT("Please type in your password"));
+ else m_header.SetText(TranslateT("Password is not correct!"));
}
+ else m_header.SetText(TranslateT("Please type in your password"));
+
SetTimer(m_hwnd, 1, 200, nullptr);
+ return true;
}
- void OnOK(CCtrlButton*)
+ void OnDestroy() override
{
- m_passwordEdit.GetText(m_param->newPass, _countof(m_param->newPass));
- EndDialog(m_hwnd, -128);
+ KillTimer(m_hwnd, 1);
}
- void OnDestroy()
+ void OnOK(CCtrlButton*)
{
- KillTimer(m_hwnd, 1);
+ m_passwordEdit.GetText(m_param->newPass, _countof(m_param->newPass));
+ EndDialog(m_hwnd, -128);
}
public:
@@ -189,5 +184,4 @@ public: {
m_buttonOK.OnClick = Callback(this, &CEnterPasswordDialog::OnOK);
}
-
};
|