summaryrefslogtreecommitdiff
path: root/protocols/VKontakte
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/VKontakte
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/VKontakte')
-rw-r--r--protocols/VKontakte/src/vk_dialogs.cpp15
-rw-r--r--protocols/VKontakte/src/vk_dialogs.h23
-rw-r--r--protocols/VKontakte/src/vk_options.cpp32
-rw-r--r--protocols/VKontakte/src/vk_options.h21
4 files changed, 57 insertions, 34 deletions
diff --git a/protocols/VKontakte/src/vk_dialogs.cpp b/protocols/VKontakte/src/vk_dialogs.cpp
index fafc0bcd69..fd394cd67c 100644
--- a/protocols/VKontakte/src/vk_dialogs.cpp
+++ b/protocols/VKontakte/src/vk_dialogs.cpp
@@ -32,13 +32,14 @@ CVkCaptchaForm::CVkCaptchaForm(CVkProto *proto, CAPTCHA_FORM_PARAMS *param) :
m_edtValue.OnChange = Callback(this, &CVkCaptchaForm::On_edtValue_Change);
}
-void CVkCaptchaForm::OnInitDialog()
+bool CVkCaptchaForm::OnInitDialog()
{
Window_SetIcon_IcoLib(m_hwnd, GetIconHandle(IDI_KEYS));
m_btnOk.Disable();
m_btnOpenInBrowser.Enable((m_param->bmp != nullptr));
m_instruction.SetText(TranslateT("Enter the text you see"));
+ return true;
}
INT_PTR CVkCaptchaForm::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
@@ -115,7 +116,7 @@ CVkWallPostForm::CVkWallPostForm(CVkProto *proto, WALLPOST_FORM_PARAMS *param) :
m_edtUrl.OnChange = Callback(this, &CVkWallPostForm::On_edtValue_Change);
}
-void CVkWallPostForm::OnInitDialog()
+bool CVkWallPostForm::OnInitDialog()
{
Window_SetIcon_IcoLib(m_hwnd, GetIconHandle(IDI_WALL));
@@ -123,6 +124,7 @@ void CVkWallPostForm::OnInitDialog()
SetCaption(wszTitle);
m_btnShare.Disable();
+ return true;
}
void CVkWallPostForm::OnDestroy()
@@ -155,11 +157,12 @@ CVkInviteChatForm::CVkInviteChatForm(CVkProto *proto) :
m_btnOk.OnClick = Callback(this, &CVkInviteChatForm::btnOk_OnOk);
}
-void CVkInviteChatForm::OnInitDialog()
+bool CVkInviteChatForm::OnInitDialog()
{
for (auto &hContact : m_proto->AccContacts())
if (!m_proto->isChatRoom(hContact))
m_cbxCombo.AddString(Clist_GetContactDisplayName(hContact), hContact);
+ return true;
}
void CVkInviteChatForm::btnOk_OnOk(CCtrlButton*)
@@ -180,13 +183,14 @@ CVkGCCreateForm::CVkGCCreateForm(CVkProto *proto) :
m_clCList.OnListRebuilt = Callback(this, &CVkGCCreateForm::FilterList);
}
-void CVkGCCreateForm::OnInitDialog()
+bool CVkGCCreateForm::OnInitDialog()
{
SetWindowLongPtr(m_clCList.GetHwnd(), GWL_STYLE, GetWindowLongPtr(m_clCList.GetHwnd(), GWL_STYLE)
| CLS_CHECKBOXES | CLS_HIDEEMPTYGROUPS | CLS_USEGROUPS | CLS_GREYALTERNATE);
m_clCList.SendMsg(CLM_SETEXSTYLE, CLS_EX_DISABLEDRAGDROP | CLS_EX_TRACKSELECT, 0);
ResetListOptions(&m_clCList);
+ return true;
}
void CVkGCCreateForm::btnOk_OnOk(CCtrlButton*)
@@ -253,7 +257,7 @@ CVkContactDeleteForm::CVkContactDeleteForm(CVkProto *proto, CONTACTDELETE_FORM_P
m_btnOk.OnClick = Callback(this, &CVkContactDeleteForm::btnOk_OnOk);
}
-void CVkContactDeleteForm::OnInitDialog()
+bool CVkContactDeleteForm::OnInitDialog()
{
CMStringW szText(FORMAT, TranslateT("You delete %s from the contact list.\nWhat needs to be done additionally?"),
m_param->pwszNick);
@@ -271,6 +275,7 @@ void CVkContactDeleteForm::OnInitDialog()
szText.Format(TranslateT("Deleting %s from contact list"), m_param->pwszNick);
SetCaption(szText.c_str());
+ return true;
}
void CVkContactDeleteForm::btnOk_OnOk(CCtrlButton*)
diff --git a/protocols/VKontakte/src/vk_dialogs.h b/protocols/VKontakte/src/vk_dialogs.h
index 51bbdfa433..ba77fc52db 100644
--- a/protocols/VKontakte/src/vk_dialogs.h
+++ b/protocols/VKontakte/src/vk_dialogs.h
@@ -39,9 +39,12 @@ class CVkCaptchaForm : public CVkDlgBase
public:
CVkCaptchaForm(CVkProto *proto, CAPTCHA_FORM_PARAMS *param);
- void OnInitDialog();
- INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam);
- void OnDestroy();
+
+ bool OnInitDialog() override;
+ void OnDestroy() override;
+
+ INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override;
+
void On_btnOpenInBrowser_Click(CCtrlButton*);
void On_btnOk_Click(CCtrlButton*);
void On_edtValue_Change(CCtrlEdit*);
@@ -83,8 +86,10 @@ class CVkWallPostForm : public CVkDlgBase
public:
CVkWallPostForm(CVkProto *proto, WALLPOST_FORM_PARAMS *param);
- void OnInitDialog();
+
+ bool OnInitDialog() override;
void OnDestroy();
+
void On_btnShare_Click(CCtrlButton*);
void On_edtValue_Change(CCtrlEdit*);
};
@@ -100,7 +105,9 @@ public:
MCONTACT m_hContact;
CVkInviteChatForm(CVkProto *proto);
- void OnInitDialog();
+
+ bool OnInitDialog() override;
+
void btnOk_OnOk(CCtrlButton*);
};
@@ -114,7 +121,8 @@ class CVkGCCreateForm : public CVkDlgBase
public:
CVkGCCreateForm(CVkProto *proto);
- void OnInitDialog();
+ bool OnInitDialog() override;
+
void btnOk_OnOk(CCtrlButton*);
void FilterList(CCtrlClc*);
void ResetListOptions(CCtrlClc*);
@@ -150,6 +158,7 @@ class CVkContactDeleteForm : public CVkDlgBase
public:
CVkContactDeleteForm(CVkProto *proto, CONTACTDELETE_FORM_PARAMS *param);
- void OnInitDialog();
+ bool OnInitDialog() override;
+
void btnOk_OnOk(CCtrlButton*);
}; \ No newline at end of file
diff --git a/protocols/VKontakte/src/vk_options.cpp b/protocols/VKontakte/src/vk_options.cpp
index beb9171e58..36e4d7f73a 100644
--- a/protocols/VKontakte/src/vk_options.cpp
+++ b/protocols/VKontakte/src/vk_options.cpp
@@ -39,7 +39,7 @@ CVkAccMgrForm::CVkAccMgrForm(CVkProto *proto, HWND hwndParent) :
CreateLink(m_edtLogin, "Login", L"");
}
-void CVkAccMgrForm::OnInitDialog()
+bool CVkAccMgrForm::OnInitDialog()
{
CSuper::OnInitDialog();
@@ -49,9 +49,10 @@ void CVkAccMgrForm::OnInitDialog()
m_pwszOldPass = m_proto->GetUserStoredPassword();
m_edtPassword.SetText(m_pwszOldPass);
m_edtPassword.SendMsg(EM_LIMITTEXT, 1024, 0);
+ return true;
}
-void CVkAccMgrForm::OnApply()
+bool CVkAccMgrForm::OnApply()
{
pass_ptrW pwszNewPass(m_edtPassword.GetText());
bool bPassChanged = mir_wstrcmp(m_pwszOldPass, pwszNewPass) != 0;
@@ -66,6 +67,7 @@ void CVkAccMgrForm::OnApply()
if (bPassChanged || mir_wstrcmpi(m_pwszOldLogin, pwszNewLogin))
m_proto->ClearAccessToken();
m_pwszOldLogin = pwszNewLogin;
+ return true;
}
////////////////////// Options ///////////////////////////////////////////////
@@ -157,7 +159,7 @@ CVkOptionAccountForm::CVkOptionAccountForm(CVkProto *proto) :
CreateLink(m_cbLoadOnlyFriends, m_proto->m_vkOptions.bLoadOnlyFriends);
}
-void CVkOptionAccountForm::OnInitDialog()
+bool CVkOptionAccountForm::OnInitDialog()
{
m_pwszOldLogin = m_edtLogin.GetText();
m_edtLogin.SendMsg(EM_LIMITTEXT, 1024, 0);
@@ -191,10 +193,10 @@ void CVkOptionAccountForm::OnInitDialog()
iListIndex = i;
}
m_cbxVKLang.SetCurSel(iListIndex);
-
+ return true;
}
-void CVkOptionAccountForm::OnApply()
+bool CVkOptionAccountForm::OnApply()
{
m_proto->m_vkOptions.iSyncHistoryMetod = m_cbxSyncHistory.GetItemData(m_cbxSyncHistory.GetCurSel());
m_proto->m_vkOptions.iMarkMessageReadOn = m_cbxMarkAsRead.GetItemData(m_cbxMarkAsRead.GetCurSel());
@@ -219,7 +221,7 @@ void CVkOptionAccountForm::OnApply()
if (bPassChanged || mir_wstrcmpi(m_pwszOldLogin, pwszNewLogin))
m_proto->ClearAccessToken();
m_pwszOldLogin = pwszNewLogin;
-
+ return true;
}
////////////////////// Advanced page /////////////////////////////////////////
@@ -263,7 +265,7 @@ CVkOptionAdvancedForm::CVkOptionAdvancedForm(CVkProto *proto) :
m_cbSendVKLinksAsAttachments.OnChange = Callback(this, &CVkOptionAdvancedForm::On_cbSendVKLinksAsAttachmentsChange);
}
-void CVkOptionAdvancedForm::OnInitDialog()
+bool CVkOptionAdvancedForm::OnInitDialog()
{
m_cbMusicSendOff.SetState(m_proto->m_vkOptions.iMusicSendMetod == MusicSendMetod::sendNone);
m_cbMusicSendBroadcastAndStatus.SetState(m_proto->m_vkOptions.iMusicSendMetod == MusicSendMetod::sendBroadcastAndStatus);
@@ -275,9 +277,10 @@ void CVkOptionAdvancedForm::OnInitDialog()
On_cbForceInvisibleStatusChange(&m_cbForceInvisibleStatus);
On_cbSendVKLinksAsAttachmentsChange(&m_cbSendVKLinksAsAttachments);
+ return true;
}
-void CVkOptionAdvancedForm::OnApply()
+bool CVkOptionAdvancedForm::OnApply()
{
if (m_cbMusicSendOff.GetState())
m_proto->m_vkOptions.iMusicSendMetod = MusicSendMetod::sendNone;
@@ -290,6 +293,7 @@ void CVkOptionAdvancedForm::OnApply()
if (m_cbSendVKLinksAsAttachments.GetState() == 0)
m_proto->m_vkOptions.bLoadSentAttachments = false;
+ return true;
}
void CVkOptionAdvancedForm::On_cbForceInvisibleStatusChange(CCtrlCheck *)
@@ -364,7 +368,7 @@ CVkOptionFeedsForm::CVkOptionFeedsForm(CVkProto *proto) :
}
-void CVkOptionFeedsForm::OnInitDialog()
+bool CVkOptionFeedsForm::OnInitDialog()
{
m_spNewsInterval.SetRange(60 * 24, 1);
m_spNewsInterval.SetPosition(m_proto->m_vkOptions.iNewsInterval);
@@ -374,6 +378,7 @@ void CVkOptionFeedsForm::OnInitDialog()
On_cbNewsEnabledChange(&m_cbNewsEnabled);
On_cbNotificationsEnabledChange(&m_cbNotificationsEnabled);
+ return true;
}
void CVkOptionFeedsForm::On_cbNewsEnabledChange(CCtrlCheck*)
@@ -436,7 +441,7 @@ CVkOptionViewForm::CVkOptionViewForm(CVkProto *proto) :
CreateLink(m_cbUseNonStandardNotifications, m_proto->m_vkOptions.bUseNonStandardNotifications);
}
-void CVkOptionViewForm::OnInitDialog()
+bool CVkOptionViewForm::OnInitDialog()
{
m_cbIMGBBCSupportOff.SetState(m_proto->m_vkOptions.iIMGBBCSupport == IMGBBCSypport::imgNo);
m_cbIMGBBCSupportFullSize.SetState(m_proto->m_vkOptions.iIMGBBCSupport == IMGBBCSypport::imgFullSize);
@@ -450,9 +455,10 @@ void CVkOptionViewForm::OnInitDialog()
m_cbBBCForAttachmentsOff.SetState(m_proto->m_vkOptions.iBBCForAttachments == BBCSupport::bbcNo);
m_cbBBCForAttachmentsBasic.SetState(m_proto->m_vkOptions.iBBCForAttachments == BBCSupport::bbcBasic);
m_cbBBCForAttachmentsAdvanced.SetState(m_proto->m_vkOptions.iBBCForAttachments == BBCSupport::bbcAdvanced);
+ return true;
}
-void CVkOptionViewForm::OnApply()
+bool CVkOptionViewForm::OnApply()
{
if (m_cbIMGBBCSupportOff.GetState())
m_proto->m_vkOptions.iIMGBBCSupport = IMGBBCSypport::imgNo;
@@ -476,6 +482,7 @@ void CVkOptionViewForm::OnApply()
m_proto->m_vkOptions.iBBCForAttachments = BBCSupport::bbcBasic;
if (m_cbBBCForAttachmentsAdvanced.GetState())
m_proto->m_vkOptions.iBBCForAttachments = BBCSupport::bbcAdvanced;
+ return true;
}
////////////////////// Menu page /////////////////////////////////////////////
@@ -499,10 +506,11 @@ CVkOptionMenuForm::CVkOptionMenuForm(CVkProto *proto) :
CreateLink(m_cbMenuEnabled6, m_proto->m_vkOptions.bShowProtoMenuItem6);
}
-void CVkOptionMenuForm::OnApply()
+bool CVkOptionMenuForm::OnApply()
{
if (MessageBoxW(nullptr,
TranslateT("These changes will take effect after Miranda NG restart.\nWould you like to restart it now?"),
TranslateT("VKontakte protocol"), MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON2) == IDYES)
CallServiceSync(MS_SYSTEM_RESTART, 1, 0);
+ return true;
} \ No newline at end of file
diff --git a/protocols/VKontakte/src/vk_options.h b/protocols/VKontakte/src/vk_options.h
index 8e91336848..c40d658adc 100644
--- a/protocols/VKontakte/src/vk_options.h
+++ b/protocols/VKontakte/src/vk_options.h
@@ -35,8 +35,8 @@ class CVkAccMgrForm : public CVkDlgBase
public:
CVkAccMgrForm(CVkProto *proto, HWND hwndParent);
- void OnInitDialog();
- void OnApply();
+ bool OnInitDialog() override;
+ bool OnApply() override;
};
////////////////////// Account page //////////////////////////////////////////
@@ -61,8 +61,8 @@ class CVkOptionAccountForm : public CVkDlgBase
public:
CVkOptionAccountForm(CVkProto *proto);
- void OnInitDialog();
- void OnApply();
+ bool OnInitDialog() override;
+ bool OnApply() override;
};
////////////////////// Advanced page /////////////////////////////////////////
@@ -95,8 +95,8 @@ class CVkOptionAdvancedForm : public CVkDlgBase
public:
CVkOptionAdvancedForm(CVkProto *proto);
- void OnInitDialog();
- void OnApply();
+ bool OnInitDialog() override;
+ bool OnApply() override;
void On_cbForceInvisibleStatusChange(CCtrlCheck*);
void On_cbSendVKLinksAsAttachmentsChange(CCtrlCheck*);
};
@@ -140,7 +140,8 @@ class CVkOptionFeedsForm : public CVkDlgBase
public:
CVkOptionFeedsForm(CVkProto *proto);
- void OnInitDialog();
+
+ bool OnInitDialog() override;
void On_cbNewsEnabledChange(CCtrlCheck*);
void On_cbNotificationsEnabledChange(CCtrlCheck*);
@@ -172,8 +173,8 @@ class CVkOptionViewForm : public CVkDlgBase
public:
CVkOptionViewForm(CVkProto *proto);
- void OnInitDialog();
- void OnApply();
+ bool OnInitDialog() override;
+ bool OnApply() override;
};
////////////////////// Menu page /////////////////////////////////////////////
@@ -190,5 +191,5 @@ class CVkOptionMenuForm : public CVkDlgBase
public:
CVkOptionMenuForm(CVkProto *proto);
- void OnApply();
+ bool OnApply() override;
}; \ No newline at end of file