summaryrefslogtreecommitdiff
path: root/plugins/NewsAggregator
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 /plugins/NewsAggregator
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 'plugins/NewsAggregator')
-rw-r--r--plugins/NewsAggregator/Src/Authentication.cpp3
-rw-r--r--plugins/NewsAggregator/Src/Options.cpp28
-rw-r--r--plugins/NewsAggregator/Src/Options.h24
3 files changed, 36 insertions, 19 deletions
diff --git a/plugins/NewsAggregator/Src/Authentication.cpp b/plugins/NewsAggregator/Src/Authentication.cpp
index cc02d91bd9..04b70d4aa0 100644
--- a/plugins/NewsAggregator/Src/Authentication.cpp
+++ b/plugins/NewsAggregator/Src/Authentication.cpp
@@ -52,7 +52,7 @@ CAuthRequest::CAuthRequest(CFeedEditor *pDlg, MCONTACT hContact)
m_ok.OnClick = Callback(this, &CAuthRequest::OnOk);
}
-void CAuthRequest::OnInitDialog()
+bool CAuthRequest::OnInitDialog()
{
if (m_pDlg) {
ptrW strfeedtitle(m_pDlg->m_feedtitle.GetText());
@@ -78,6 +78,7 @@ void CAuthRequest::OnInitDialog()
}
}
}
+ return true;
}
void CAuthRequest::OnOk(CCtrlBase*)
diff --git a/plugins/NewsAggregator/Src/Options.cpp b/plugins/NewsAggregator/Src/Options.cpp
index f06e592de7..2413a64191 100644
--- a/plugins/NewsAggregator/Src/Options.cpp
+++ b/plugins/NewsAggregator/Src/Options.cpp
@@ -36,7 +36,7 @@ CExportFeed::CExportFeed()
m_feedsexportlist.OnDblClick = Callback(this, &CExportFeed::OnFeedsExportList);
}
-void CExportFeed::OnInitDialog()
+bool CExportFeed::OnInitDialog()
{
Utils_RestoreWindowPositionNoSize(m_hwnd, NULL, MODULENAME, "ExportDlg");
for (auto &hContact : Contacts(MODULENAME)) {
@@ -53,6 +53,7 @@ void CExportFeed::OnInitDialog()
m_addfeed.Disable();
m_addallfeeds.Disable();
}
+ return true;
}
void CExportFeed::OnAddFeed(CCtrlBase*)
@@ -243,13 +244,16 @@ void CExportFeed::OnOk(CCtrlBase*)
}
}
-void CExportFeed::OnClose()
+bool CExportFeed::OnClose()
{
Utils_SaveWindowPosition(m_hwnd, NULL, MODULENAME, "ExportDlg");
if (pExportDialog)
pExportDialog = nullptr;
+ return true;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
CImportFeed::CImportFeed(CCtrlListView *m_feeds)
: CSuper(g_plugin, IDD_FEEDIMPORT),
m_importfile(this, IDC_IMPORTFILEPATH), m_browsefile(this, IDC_BROWSEIMPORTFILE),
@@ -270,7 +274,7 @@ CImportFeed::CImportFeed(CCtrlListView *m_feeds)
m_feedsimportlist.OnDblClick = Callback(this, &CImportFeed::OnFeedsImportList);
}
-void CImportFeed::OnInitDialog()
+bool CImportFeed::OnInitDialog()
{
Utils_RestoreWindowPositionNoSize(m_hwnd, NULL, MODULENAME, "ImportDlg");
m_removefeed.Disable();
@@ -278,6 +282,7 @@ void CImportFeed::OnInitDialog()
m_ok.Disable();
m_addfeed.Disable();
m_addallfeeds.Disable();
+ return true;
}
void CImportFeed::OnBrowseFile(CCtrlBase*)
@@ -653,13 +658,16 @@ void CImportFeed::OnOk(CCtrlBase*)
}
}
-void CImportFeed::OnClose()
+bool CImportFeed::OnClose()
{
Utils_SaveWindowPosition(m_hwnd, NULL, MODULENAME, "ImportDlg");
if (pImportDialog)
pImportDialog = nullptr;
+ return true;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
CFeedEditor::CFeedEditor(int iItem, CCtrlListView *m_feeds, MCONTACT Contact)
: CSuper(g_plugin, IDD_ADDFEED),
m_feedtitle(this, IDC_FEEDTITLE), m_feedurl(this, IDC_FEEDURL),
@@ -678,7 +686,7 @@ CFeedEditor::CFeedEditor(int iItem, CCtrlListView *m_feeds, MCONTACT Contact)
m_ok.OnClick = Callback(this, &CFeedEditor::OnOk);
}
-void CFeedEditor::OnInitDialog()
+bool CFeedEditor::OnInitDialog()
{
if (m_iItem == -1 && m_hContact == NULL)
SetWindowText(m_hwnd, TranslateT("Add Feed"));
@@ -764,6 +772,7 @@ void CFeedEditor::OnInitDialog()
g_arFeeds.insert(this);
Utils_RestoreWindowPositionNoSize(m_hwnd, m_hContact, MODULENAME, "ChangeDlg");
}
+ return true;
}
void CFeedEditor::OnCheckFeed(CCtrlBase*)
@@ -858,12 +867,13 @@ void CFeedEditor::OnOk(CCtrlBase*)
}
}
-void CFeedEditor::OnClose()
+bool CFeedEditor::OnClose()
{
g_arFeeds.remove(this);
Utils_SaveWindowPosition(m_hwnd, NULL, MODULENAME, m_iItem == -1 ? "AddDlg" : "ChangeDlg");
if (pAddFeedDialog == this)
pAddFeedDialog = nullptr;
+ return true;
}
void CFeedEditor::OnUseAuth(CCtrlBase*)
@@ -915,7 +925,7 @@ COptionsMain::COptionsMain() :
}
-void COptionsMain::OnInitDialog()
+bool COptionsMain::OnInitDialog()
{
CDlgBase::OnInitDialog();
m_change.Disable();
@@ -924,9 +934,10 @@ void COptionsMain::OnInitDialog()
m_feeds.AddColumn(0, TranslateT("Feed"), 160);
m_feeds.AddColumn(1, TranslateT("URL"), 276);
UpdateList();
+ return true;
}
-void COptionsMain::OnApply()
+bool COptionsMain::OnApply()
{
for (auto &hContact : Contacts(MODULENAME)) {
ptrW dbNick(db_get_wsa(hContact, MODULENAME, "Nick"));
@@ -943,6 +954,7 @@ void COptionsMain::OnApply()
}
}
}
+ return true;
}
void COptionsMain::OnAddButtonClick(CCtrlBase*)
diff --git a/plugins/NewsAggregator/Src/Options.h b/plugins/NewsAggregator/Src/Options.h
index 1e73f898b4..2389eb9bb9 100644
--- a/plugins/NewsAggregator/Src/Options.h
+++ b/plugins/NewsAggregator/Src/Options.h
@@ -13,8 +13,8 @@ private:
CCtrlCheck m_checkonstartup;
protected:
- void OnInitDialog();
- void OnApply();
+ bool OnInitDialog() override;
+ bool OnApply() override;
void OnAddButtonClick(CCtrlBase*);
void OnChangeButtonClick(CCtrlBase*);
@@ -53,12 +53,13 @@ private:
CCtrlButton m_ok;
protected:
- void OnInitDialog();
+ bool OnInitDialog() override;
+ bool OnClose() override;
+
void OnCheckFeed(CCtrlBase*);
void OnReset(CCtrlBase*);
void OnHelp(CCtrlBase*);
void OnOk(CCtrlBase*);
- void OnClose();
void OnUseAuth(CCtrlBase*);
public:
@@ -89,14 +90,15 @@ private:
CCtrlButton m_ok;
protected:
- void OnInitDialog();
+ bool OnInitDialog() override;
+ bool OnClose() override;
+
void OnBrowseFile(CCtrlBase*);
void OnAddFeed(CCtrlBase*);
void OnRemoveFeed(CCtrlBase*);
void OnAddAllFeeds(CCtrlBase*);
void OnRemoveAllFeeds(CCtrlBase*);
void OnOk(CCtrlBase*);
- void OnClose();
void OnFeedsList(CCtrlBase*);
void OnFeedsImportList(CCtrlBase*);
@@ -119,14 +121,15 @@ private:
CCtrlButton m_ok;
protected:
- void OnInitDialog();
+ bool OnInitDialog() override;
+ bool OnClose() override;
+
void OnAddFeed(CCtrlBase*);
void OnRemoveFeed(CCtrlBase*);
void OnAddAllFeeds(CCtrlBase*);
void OnRemoveAllFeeds(CCtrlBase*);
void OnOk(CCtrlBase*);
- void OnClose();
-
+
void OnFeedsList(CCtrlBase*);
void OnFeedsExportList(CCtrlBase*);
@@ -148,7 +151,8 @@ private:
CCtrlButton m_ok;
protected:
- void OnInitDialog();
+ bool OnInitDialog() override;
+
void OnOk(CCtrlBase*);
public: