summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2020-06-04 17:03:28 +0300
committerGeorge Hazan <ghazan@miranda.im>2020-06-04 17:03:28 +0300
commitf531ff887729783a7fe7a3e12ad12f658eefc7b0 (patch)
tree9e1844429448b6527ef7ca87163e44eafce250d8 /plugins
parent1c2e5d128a7176ae827dda1e2a8fcc64e772a148 (diff)
UI classes:
- CDlgBase::m_bSucceeded variable introduced to check whether IDOK was pressed or not; - unused/useless buttons with id=IDOK or IDCANCEL removed; - brnOk.OnClick replaced with OnApply calls; - unused/useless calls of EndDialog/EndModal removed; - minor code cleaning
Diffstat (limited to 'plugins')
-rw-r--r--plugins/CrashDumper/src/ui.cpp13
-rw-r--r--plugins/Dbx_mdbx/src/dbcrypt.cpp64
-rw-r--r--plugins/Import/src/ui.cpp9
-rw-r--r--plugins/MyDetails/src/services.cpp36
-rwxr-xr-xplugins/New_GPG/src/ui.cpp25
-rwxr-xr-xplugins/New_GPG/src/ui.h6
-rw-r--r--plugins/PluginUpdater/src/DlgListNew.cpp17
-rw-r--r--plugins/Scriver/src/msgtimedout.cpp9
-rw-r--r--plugins/StopSpamPlus/src/options.cpp2
9 files changed, 66 insertions, 115 deletions
diff --git a/plugins/CrashDumper/src/ui.cpp b/plugins/CrashDumper/src/ui.cpp
index ff3a18e49f..7018e90521 100644
--- a/plugins/CrashDumper/src/ui.cpp
+++ b/plugins/CrashDumper/src/ui.cpp
@@ -22,13 +22,12 @@ class CViewVersionInfo : public CDlgBase
{
DWORD m_flags;
- CCtrlButton m_btnCancel, m_btnCopyClip, m_btnCopyFile;
+ CCtrlButton m_btnCopyClip, m_btnCopyFile;
CCtrlRichEdit m_redtViewVersionInfo;
public:
CViewVersionInfo(DWORD flags) :
CDlgBase(g_plugin, IDD_VIEWVERSION),
- m_btnCancel(this, IDCANCEL),
m_btnCopyClip(this, IDC_CLIPVER),
m_btnCopyFile(this, IDC_FILEVER),
m_redtViewVersionInfo(this, IDC_VIEWVERSIONINFO)
@@ -38,7 +37,6 @@ public:
m_flags = flags;
m_forceResizable = true;
- m_btnCancel.OnClick = Callback(this, &CViewVersionInfo::OnCancelClick);
m_btnCopyClip.OnClick = Callback(this, &CViewVersionInfo::OnCopyClipClick);
m_btnCopyFile.OnClick = Callback(this, &CViewVersionInfo::OnCopyFileClick);
m_redtViewVersionInfo.OnBuildMenu = Callback(this, &CViewVersionInfo::OnViewVersionInfoBuildMenu);
@@ -78,7 +76,7 @@ public:
return true;
}
- int Resizer(UTILRESIZECONTROL * urc) override
+ int Resizer(UTILRESIZECONTROL *urc) override
{
switch (urc->wId) {
case IDC_VIEWVERSIONINFO:
@@ -97,11 +95,6 @@ public:
return RD_ANCHORX_LEFT | RD_ANCHORY_TOP;
}
- void OnCancelClick(CCtrlBase*)
- {
- Close();
- }
-
void OnCopyClipClick(CCtrlBase*)
{
CallService(MS_CRASHDUMPER_STORETOCLIP, 0, m_flags);
@@ -286,7 +279,7 @@ LRESULT CALLBACK DlgProcPopup(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
void ShowMessage(int type, const wchar_t *format, ...)
{
- switch(type) {
+ switch (type) {
case 1:
case 3:
if (!g_plugin.bSuccessPopups)
diff --git a/plugins/Dbx_mdbx/src/dbcrypt.cpp b/plugins/Dbx_mdbx/src/dbcrypt.cpp
index 75a630aa72..117c5e0af6 100644
--- a/plugins/Dbx_mdbx/src/dbcrypt.cpp
+++ b/plugins/Dbx_mdbx/src/dbcrypt.cpp
@@ -122,28 +122,29 @@ CRYPTO_PROVIDER* CDbxMDBX::SelectProvider()
class CEnterPasswordDialog : public CDlgBase
{
+ CTimer m_timer;
CCtrlData m_header;
CCtrlData m_language;
CCtrlEdit m_passwordEdit;
- CCtrlButton m_buttonOK;
friend class CDbxMDBX;
CDbxMDBX *m_db;
TCHAR m_newPass[100];
unsigned short m_wrongPass = 0;
+ void OnTimer(CTimer*)
+ {
+ UINT_PTR LangID = (UINT_PTR)GetKeyboardLayout(0);
+ char Lang[3] = { 0 };
+ GetLocaleInfoA(MAKELCID((LangID & 0xffffffff), SORT_DEFAULT), LOCALE_SABBREVLANGNAME, Lang, 2);
+ Lang[0] = toupper(Lang[0]);
+ Lang[1] = tolower(Lang[1]);
+ m_language.SetTextA(Lang);
+ }
+
INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override
{
- 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);
- Lang[0] = toupper(Lang[0]);
- Lang[1] = tolower(Lang[1]);
- m_language.SetTextA(Lang);
- return FALSE;
- }
- else if (msg == WM_CTLCOLORSTATIC) {
+ if (msg == WM_CTLCOLORSTATIC) {
if ((HWND)lParam == m_language.GetHwnd()) {
SetTextColor((HDC)wParam, GetSysColor(COLOR_HIGHLIGHTTEXT));
SetBkMode((HDC)wParam, TRANSPARENT);
@@ -153,6 +154,19 @@ class CEnterPasswordDialog : public CDlgBase
return CDlgBase::DlgProc(msg, wParam, lParam);
}
+public:
+ CEnterPasswordDialog(CDbxMDBX *db) :
+ CDlgBase(g_plugin, IDD_LOGIN),
+ m_timer(this, 1),
+ m_header(this, IDC_HEADERBAR),
+ m_language(this, IDC_LANG),
+ m_passwordEdit(this, IDC_USERPASS),
+ m_db(db)
+ {
+ m_newPass[0] = 0;
+ m_timer.OnEvent = Callback(this, &CEnterPasswordDialog::OnTimer);
+ }
+
bool OnInitDialog() override
{
m_header.SendMsg(WM_SETICON, ICON_SMALL, (LPARAM)g_plugin.getIcon(IDI_LOGO, true));
@@ -160,40 +174,26 @@ class CEnterPasswordDialog : public CDlgBase
if (m_wrongPass) {
if (m_wrongPass > 2) {
m_passwordEdit.Disable();
- m_buttonOK.Disable();
+ EnableWindow(GetDlgItem(m_hwnd, IDOK), false);
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"));
- SetTimer(m_hwnd, 1, 200, nullptr);
+ m_timer.Start(200);
return true;
}
- void OnDestroy() override
- {
- KillTimer(m_hwnd, 1);
- Window_FreeIcon_IcoLib(m_header.GetHwnd());
- }
-
- void OnOK(CCtrlButton*)
+ bool OnApply() override
{
m_passwordEdit.GetText(m_newPass, _countof(m_newPass));
- EndDialog(m_hwnd, -128);
+ return true;
}
-public:
- CEnterPasswordDialog(CDbxMDBX *db) :
- CDlgBase(g_plugin, IDD_LOGIN),
- m_header(this, IDC_HEADERBAR),
- m_language(this, IDC_LANG),
- m_passwordEdit(this, IDC_USERPASS),
- m_buttonOK(this, IDOK),
- m_db(db)
+ void OnDestroy() override
{
- m_newPass[0] = 0;
- m_buttonOK.OnClick = Callback(this, &CEnterPasswordDialog::OnOK);
+ Window_FreeIcon_IcoLib(m_header.GetHwnd());
}
};
@@ -233,7 +233,7 @@ int CDbxMDBX::InitCrypt()
if (!m_crypto->setKey((const BYTE*)value.iov_base, value.iov_len)) {
CEnterPasswordDialog dlg(this);
while (true) {
- if (-128 != dlg.DoModal())
+ if (!dlg.DoModal())
return 4;
m_crypto->setPassword(pass_ptrA(mir_utf8encodeW(dlg.m_newPass)));
if (m_crypto->setKey((const BYTE*)value.iov_base, value.iov_len)) {
diff --git a/plugins/Import/src/ui.cpp b/plugins/Import/src/ui.cpp
index 14e7122a20..c181adc415 100644
--- a/plugins/Import/src/ui.cpp
+++ b/plugins/Import/src/ui.cpp
@@ -31,7 +31,7 @@ class CContactImportDlg : public CDlgBase
CImportPattern *m_pPattern = 0;
wchar_t m_wszFileName[MAX_PATH];
- CCtrlButton m_btnOpenFile, m_btnOk;
+ CCtrlButton m_btnOpenFile;
CCtrlCombo m_cmbFileType;
CCtrlEdit edtFileName;
@@ -41,12 +41,10 @@ public:
m_hContact(hContact),
edtFileName(this, IDC_FILENAME),
m_cmbFileType(this, IDC_FILETYPE),
- m_btnOk(this, IDOK),
m_btnOpenFile(this, IDC_OPEN_FILE)
{
m_wszFileName[0] = 0;
- m_btnOk.OnClick = Callback(this, &CContactImportDlg::onClick_Ok);
m_btnOpenFile.OnClick = Callback(this, &CContactImportDlg::onClick_OpenFile);
}
@@ -76,11 +74,6 @@ public:
return true;
}
- void onClick_Ok(CCtrlButton*)
- {
- EndModal(1);
- }
-
void onClick_OpenFile(CCtrlButton*)
{
int iCur = m_cmbFileType.GetCurSel();
diff --git a/plugins/MyDetails/src/services.cpp b/plugins/MyDetails/src/services.cpp
index 04f3e795c2..1043d70898 100644
--- a/plugins/MyDetails/src/services.cpp
+++ b/plugins/MyDetails/src/services.cpp
@@ -28,17 +28,13 @@ class CSetNickDialog : public CDlgBase
int m_protonum;
CCtrlEdit m_edtNickname;
- CCtrlButton m_btnOk, m_btnCancel;
+
public:
CSetNickDialog(int protoparam) :
CDlgBase(g_plugin, IDD_SETNICKNAME),
- m_edtNickname(this, IDC_NICKNAME),
- m_btnOk(this, IDOK),
- m_btnCancel(this, IDCANCEL)
+ m_edtNickname(this, IDC_NICKNAME)
{
m_protonum = protoparam;
- m_btnOk.OnClick = Callback(this, &CSetNickDialog::OnOkClick);
- m_btnCancel.OnClick = Callback(this, &CSetNickDialog::OnCancelClick);
}
bool OnInitDialog() override
@@ -88,7 +84,7 @@ public:
return true;
}
- void OnOkClick(CCtrlBase*)
+ bool OnApply() override
{
wchar_t tmp[MS_MYDETAILS_GETMYNICKNAME_BUFFER_SIZE];
m_edtNickname.GetText(tmp, _countof(tmp));
@@ -97,11 +93,7 @@ public:
protocols->SetNicks(tmp);
else
protocols->Get(m_protonum)->SetNick(tmp);
- }
-
- void OnCancelClick(CCtrlBase*)
- {
- Close();
+ return true;
}
bool OnClose() override
@@ -298,20 +290,15 @@ class CSetStatusMessageDialog : public CDlgBase
SetStatusMessageData *m_data;
CCtrlEdit m_edtStatusMessage;
- CCtrlButton m_btnOk, m_btnCancel;
+
public:
CSetStatusMessageDialog(int protoparam, int statusparam) :
CDlgBase(g_plugin, IDD_SETSTATUSMESSAGE),
- m_edtStatusMessage(this, IDC_STATUSMESSAGE),
- m_btnOk(this, IDOK),
- m_btnCancel(this, IDCANCEL)
+ m_edtStatusMessage(this, IDC_STATUSMESSAGE)
{
m_data = (SetStatusMessageData *)mir_alloc(sizeof(SetStatusMessageData));
m_data->proto_num = protoparam;
m_data->status = statusparam;
-
- m_btnOk.OnClick = Callback(this, &CSetStatusMessageDialog::OnOkClick);
- m_btnCancel.OnClick = Callback(this, &CSetStatusMessageDialog::OnCancelClick);
}
bool OnInitDialog() override
@@ -351,7 +338,7 @@ public:
return true;
}
- void OnOkClick(CCtrlBase*)
+ bool OnApply() override
{
wchar_t tmp[MS_MYDETAILS_GETMYSTATUSMESSAGE_BUFFER_SIZE];
m_edtStatusMessage.GetText(tmp, _countof(tmp));
@@ -362,20 +349,15 @@ public:
protocols->SetStatusMsgs(tmp);
else
protocols->SetStatusMsgs(m_data->status, tmp);
+ return true;
}
- void OnCancelClick(CCtrlBase*)
- {
- Close();
- }
-
- bool OnClose() override
+ void OnDestroy() override
{
mir_free(m_data);
Window_FreeIcon_IcoLib(m_hwnd);
if (pSetStatusMessageDialog == this)
pSetStatusMessageDialog = nullptr;
- return true;
}
};
diff --git a/plugins/New_GPG/src/ui.cpp b/plugins/New_GPG/src/ui.cpp
index ebc2fa8fd6..3742d43b24 100755
--- a/plugins/New_GPG/src/ui.cpp
+++ b/plugins/New_GPG/src/ui.cpp
@@ -1192,13 +1192,9 @@ CDlgKeyPasswordMsgBox::CDlgKeyPasswordMsgBox(MCONTACT _hContact) :
lbl_KEYID(this, IDC_KEYID),
edit_KEY_PASSWORD(this, IDC_KEY_PASSWORD),
chk_DEFAULT_PASSWORD(this, IDC_DEFAULT_PASSWORD),
- chk_SAVE_PASSWORD(this, IDC_SAVE_PASSWORD),
- btn_OK(this, IDOK),
- btn_CANCEL(this, IDCANCEL)
+ chk_SAVE_PASSWORD(this, IDC_SAVE_PASSWORD)
{
hContact = _hContact;
- btn_OK.OnClick = Callback(this, &CDlgKeyPasswordMsgBox::onClick_OK);
- btn_CANCEL.OnClick = Callback(this, &CDlgKeyPasswordMsgBox::onClick_CANCEL);
}
bool CDlgKeyPasswordMsgBox::OnInitDialog()
@@ -1213,13 +1209,7 @@ bool CDlgKeyPasswordMsgBox::OnInitDialog()
return true;
}
-void CDlgKeyPasswordMsgBox::OnDestroy()
-{
- mir_free(inkeyid);
- Utils_SaveWindowPosition(m_hwnd, 0, MODULENAME, "PasswordWindow");
-}
-
-void CDlgKeyPasswordMsgBox::onClick_OK(CCtrlButton*)
+bool CDlgKeyPasswordMsgBox::OnApply()
{
ptrW tmp(edit_KEY_PASSWORD.GetText());
if (tmp && tmp[0]) {
@@ -1236,11 +1226,14 @@ void CDlgKeyPasswordMsgBox::onClick_OK(CCtrlButton*)
globals.wszPassword = tmp;
}
mir_free(inkeyid);
- DestroyWindow(m_hwnd);
+ return true;
}
-void CDlgKeyPasswordMsgBox::onClick_CANCEL(CCtrlButton*)
+void CDlgKeyPasswordMsgBox::OnDestroy()
{
- globals._terminate = true;
- DestroyWindow(m_hwnd);
+ if (!m_bSucceeded)
+ globals._terminate = true;
+
+ mir_free(inkeyid);
+ Utils_SaveWindowPosition(m_hwnd, 0, MODULENAME, "PasswordWindow");
}
diff --git a/plugins/New_GPG/src/ui.h b/plugins/New_GPG/src/ui.h
index 6ab8c7111c..e5c0c2c5ad 100755
--- a/plugins/New_GPG/src/ui.h
+++ b/plugins/New_GPG/src/ui.h
@@ -164,15 +164,13 @@ class CDlgKeyPasswordMsgBox : public CDlgBase //always modal
CCtrlData lbl_KEYID;
CCtrlEdit edit_KEY_PASSWORD;
CCtrlCheck chk_DEFAULT_PASSWORD, chk_SAVE_PASSWORD;
- CCtrlButton btn_OK, btn_CANCEL;
public:
CDlgKeyPasswordMsgBox(MCONTACT _hContact);
+
bool OnInitDialog() override;
+ bool OnApply() override;
void OnDestroy() override;
-
- void onClick_OK(CCtrlButton*);
- void onClick_CANCEL(CCtrlButton*);
};
#endif // UI_H \ No newline at end of file
diff --git a/plugins/PluginUpdater/src/DlgListNew.cpp b/plugins/PluginUpdater/src/DlgListNew.cpp
index b264635d05..53cf844391 100644
--- a/plugins/PluginUpdater/src/DlgListNew.cpp
+++ b/plugins/PluginUpdater/src/DlgListNew.cpp
@@ -128,11 +128,9 @@ public:
m_list(this, IDC_LIST_UPDATES),
m_filter(this, IDC_SEARCH)
{
- m_autoClose = CLOSE_ON_CANCEL;
SetParent(GetDesktopWindow());
SetMinSize(370, 300);
- btnOk.OnClick = Callback(this, &CMissingPLuginsDlg::onClick_Ok);
btnNone.OnClick = Callback(this, &CMissingPLuginsDlg::onClick_None);
m_filter.OnChange = Callback(this, &CMissingPLuginsDlg::onChange_Filter);
@@ -211,6 +209,14 @@ public:
return true;
}
+ bool OnApply() override
+ {
+ btnOk.Disable();
+ btnNone.Disable();
+ mir_forkthread(ApplyDownloads, this);
+ return false; // do not allow a dialog to close
+ }
+
void OnDestroy() override
{
Utils_SaveWindowPosition(m_hwnd, NULL, MODULENAME, "ListWindow");
@@ -260,13 +266,6 @@ public:
}
}
- void onClick_Ok(CCtrlButton *)
- {
- btnOk.Disable();
- btnNone.Disable();
- mir_forkthread(ApplyDownloads, this);
- }
-
void onClick_None(CCtrlButton *)
{
SelectAll(false);
diff --git a/plugins/Scriver/src/msgtimedout.cpp b/plugins/Scriver/src/msgtimedout.cpp
index ba621e4434..5595b5aaf6 100644
--- a/plugins/Scriver/src/msgtimedout.cpp
+++ b/plugins/Scriver/src/msgtimedout.cpp
@@ -25,7 +25,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
class CErrorDlg : public CDlgBase
{
- bool m_bRetry = false;
ptrW m_wszText;
CMStringW m_wszName, m_wszDescr;
CMsgDialog *m_pOwner;
@@ -71,16 +70,10 @@ public:
return true;
}
- bool OnApply() override
- {
- m_bRetry = true;
- return true;
- }
-
void OnDestroy() override
{
m_queueItem->hwndErrorDlg = nullptr;
- m_pOwner->HandleError(m_bRetry, m_queueItem);
+ m_pOwner->HandleError(m_bSucceeded, m_queueItem);
}
};
diff --git a/plugins/StopSpamPlus/src/options.cpp b/plugins/StopSpamPlus/src/options.cpp
index 15a05898fb..e2d18e72df 100644
--- a/plugins/StopSpamPlus/src/options.cpp
+++ b/plugins/StopSpamPlus/src/options.cpp
@@ -159,7 +159,7 @@ public:
void list_OnItemChanged(CCtrlListView::TEventInfo*)
{
- if (m_initialized)
+ if (m_bInitialized)
NotifyChange();
}
};