summaryrefslogtreecommitdiff
path: root/plugins/QuickReplies
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2016-10-28 16:18:50 +0300
committerGeorge Hazan <ghazan@miranda.im>2016-10-28 16:18:50 +0300
commitcf9de21af3073e29cb7b149fbd8427241de70729 (patch)
tree2a0b17f49d14d4a51bc942f15bf3747509f0c3cf /plugins/QuickReplies
parent3de431cc811a1fbf9cd0d520fe33b6163c73e919 (diff)
- old useless helpers removed from the Options module;
- mir_app functions introduced instead of them; - OPENOPTIONSDIALOG structure removed from m_options.h
Diffstat (limited to 'plugins/QuickReplies')
-rw-r--r--plugins/QuickReplies/src/events.cpp77
-rw-r--r--plugins/QuickReplies/src/options.cpp6
2 files changed, 35 insertions, 48 deletions
diff --git a/plugins/QuickReplies/src/events.cpp b/plugins/QuickReplies/src/events.cpp
index f64b329dc5..b84d89eed9 100644
--- a/plugins/QuickReplies/src/events.cpp
+++ b/plugins/QuickReplies/src/events.cpp
@@ -72,14 +72,9 @@ int OnModulesLoaded(WPARAM, LPARAM)
int OnButtonPressed(WPARAM wParam, LPARAM lParam)
{
- char key[64];
- int count = 0;
- HMENU hMenu = NULL;
- char buttonName[32];
- CMStringW replies;
- LIST<wchar_t> replyList(1);
CustomButtonClickData *cbcd = (CustomButtonClickData *)lParam;
+ char buttonName[32];
mir_snprintf(buttonName, MODULE" %x", iNumber + 1);
if (mir_strcmp(cbcd->pszModule, buttonName))
return 0;
@@ -87,59 +82,51 @@ int OnButtonPressed(WPARAM wParam, LPARAM lParam)
if (cbcd->dwButtonId != iNumber)
return 1;
+ char key[64];
mir_snprintf(key, "RepliesCount_%x", iNumber);
- count = db_get_w(NULL, MODULE, key, 0);
+ int count = db_get_w(NULL, MODULE, key, 0);
+ if (count == 0 || cbcd->flags & BBCF_RIGHTBUTTON)
{
- if (count == 0 || cbcd->flags & BBCF_RIGHTBUTTON)
- {
- mir_snprintf(buttonName, "%s %x", Translate("Button"), iNumber + 1);
-
- OPENOPTIONSDIALOG ood = {0};
- ood.cbSize = sizeof(ood);
- ood.pszGroup = "Message Sessions";
- ood.pszPage = "Quick Replies";
- ood.pszTab = buttonName;
- Options_Open(&ood);
- return 0;
- }
+ mir_snprintf(buttonName, "%s %x", Translate("Button"), iNumber + 1);
+ Options_Open(L"Message Sessions", L"Quick Replies", _A2T(buttonName));
+ return 0;
+ }
- hMenu = CreatePopupMenu();
+ HMENU hMenu = CreatePopupMenu();
- for (int i = 0; i < count; i++)
- {
- mir_snprintf(key, "Reply_%x_%x", iNumber, i);
- wchar_t *value = db_get_wsa(NULL, MODULE, key);
+ LIST<wchar_t> replyList(1);
+ for (int i = 0; i < count; i++)
+ {
+ mir_snprintf(key, "Reply_%x_%x", iNumber, i);
+ wchar_t *value = db_get_wsa(NULL, MODULE, key);
- if (!value)
- replyList.insert(mir_wstrdup(L""));
- else
- replyList.insert(variables_parsedup(value, 0, wParam));
+ if (!value)
+ replyList.insert(mir_wstrdup(L""));
+ else
+ replyList.insert(variables_parsedup(value, 0, wParam));
- if (!mir_wstrcmp(value, L"---"))
- AppendMenu((HMENU)hMenu, MF_SEPARATOR, i + 1, NULL);
- else
- AppendMenu((HMENU)hMenu, MF_STRING, i + 1, replyList[i]);
+ if (!mir_wstrcmp(value, L"---"))
+ AppendMenu((HMENU)hMenu, MF_SEPARATOR, i + 1, NULL);
+ else
+ AppendMenu((HMENU)hMenu, MF_STRING, i + 1, replyList[i]);
- mir_free(value);
- }
+ mir_free(value);
}
+ int index = TrackPopupMenu(hMenu, TPM_RETURNCMD, cbcd->pt.x, cbcd->pt.y, 0, cbcd->hwndFrom, NULL);
+ if (index > 0)
{
- int index = TrackPopupMenu(hMenu, TPM_RETURNCMD, cbcd->pt.x, cbcd->pt.y, 0, cbcd->hwndFrom, NULL);
- if (index > 0)
+ if (mir_wstrcmp(replyList[index - 1], L""))
{
- if (mir_wstrcmp(replyList[index - 1], L""))
- {
- HWND hEdit = GetDlgItem(cbcd->hwndFrom, IDC_MESSAGE);
- if (!hEdit) hEdit = GetDlgItem(cbcd->hwndFrom, IDC_CHATMESSAGE);
+ HWND hEdit = GetDlgItem(cbcd->hwndFrom, IDC_MESSAGE);
+ if (!hEdit) hEdit = GetDlgItem(cbcd->hwndFrom, IDC_CHATMESSAGE);
- SendMessage(hEdit, EM_REPLACESEL, TRUE, (LPARAM)replyList[index - 1]);
+ SendMessage(hEdit, EM_REPLACESEL, TRUE, (LPARAM)replyList[index - 1]);
- mir_snprintf(key, "ImmediatelySend_%x", iNumber);
- if ((BYTE)db_get_b(NULL, MODULE, key, 1) || cbcd->flags & BBCF_CONTROLPRESSED)
- SendMessage(cbcd->hwndFrom, WM_COMMAND, IDOK, 0);
- }
+ mir_snprintf(key, "ImmediatelySend_%x", iNumber);
+ if ((BYTE)db_get_b(NULL, MODULE, key, 1) || cbcd->flags & BBCF_CONTROLPRESSED)
+ SendMessage(cbcd->hwndFrom, WM_COMMAND, IDOK, 0);
}
}
diff --git a/plugins/QuickReplies/src/options.cpp b/plugins/QuickReplies/src/options.cpp
index 3356a012b0..4f2b3ffd2c 100644
--- a/plugins/QuickReplies/src/options.cpp
+++ b/plugins/QuickReplies/src/options.cpp
@@ -172,9 +172,9 @@ int OnOptInitialized(WPARAM wParam, LPARAM)
mir_snprintf(tabName, "%s %x", Translate("Button"), iNumber + 1);
OPTIONSDIALOGPAGE odp = { 0 };
- odp.pszGroup = LPGEN("Message sessions");
- odp.pszTitle = LPGEN("Quick Replies");
- odp.pszTab = tabName;
+ odp.szGroup.a = LPGEN("Message sessions");
+ odp.szTitle.a = LPGEN("Quick Replies");
+ odp.szTab.a = tabName;
odp.position = iNumber;
odp.hInstance = hInstance;
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS_PAGE);