diff options
author | George Hazan <george.hazan@gmail.com> | 2024-11-05 19:23:27 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2024-11-05 19:23:31 +0300 |
commit | a716ef2bcd976387000014ad2bdd7c94df396624 (patch) | |
tree | 5bb777e6fedd092e026cf6275e8a5eb8aed8298e | |
parent | 8b9c5a4f77a35712d5bf54aa5cf44c261f8ecadc (diff) |
fixes #3091 (StdMsg/Scriver: Get rid of all hardcoded hotkeys)
-rw-r--r-- | include/m_srmm_int.h | 2 | ||||
-rw-r--r-- | libs/win32/mir_app.lib | bin | 300878 -> 301234 bytes | |||
-rw-r--r-- | libs/win64/mir_app.lib | bin | 300926 -> 301292 bytes | |||
-rw-r--r-- | plugins/TabSRMM/src/hotkeyhandler.cpp | 4 | ||||
-rw-r--r-- | plugins/TabSRMM/src/msgdialog.cpp | 16 | ||||
-rw-r--r-- | plugins/TabSRMM/src/msgs.h | 5 | ||||
-rw-r--r-- | src/mir_app/src/chat.h | 12 | ||||
-rw-r--r-- | src/mir_app/src/mir_app.def | 1 | ||||
-rw-r--r-- | src/mir_app/src/mir_app64.def | 1 | ||||
-rw-r--r-- | src/mir_app/src/srmm_base.cpp | 52 | ||||
-rw-r--r-- | src/mir_app/src/srmm_log_rtf.cpp | 2 | ||||
-rw-r--r-- | src/mir_app/src/srmm_main.cpp | 16 | ||||
-rw-r--r-- | src/mir_app/src/srmm_toolbar.cpp | 105 |
13 files changed, 118 insertions, 98 deletions
diff --git a/include/m_srmm_int.h b/include/m_srmm_int.h index 2c2bc53c5a..7ebfa731a8 100644 --- a/include/m_srmm_int.h +++ b/include/m_srmm_int.h @@ -288,6 +288,8 @@ class MIR_APP_EXPORT CSrmmBaseDialog : public CDlgBase void OnNickListTimer(CTimer *);
void OnRedrawTimer(CTimer *);
+ void ProcessToolbarHotkey(INT_PTR iButtonFrom);
+
std::vector<MEVENT> m_arDisplayedEvents;
protected:
diff --git a/libs/win32/mir_app.lib b/libs/win32/mir_app.lib Binary files differindex cb8c94e86e..d344e2ff96 100644 --- a/libs/win32/mir_app.lib +++ b/libs/win32/mir_app.lib diff --git a/libs/win64/mir_app.lib b/libs/win64/mir_app.lib Binary files differindex e551a9b2a6..5f02ca0258 100644 --- a/libs/win64/mir_app.lib +++ b/libs/win64/mir_app.lib diff --git a/plugins/TabSRMM/src/hotkeyhandler.cpp b/plugins/TabSRMM/src/hotkeyhandler.cpp index 54b77c5bb5..06360ceaba 100644 --- a/plugins/TabSRMM/src/hotkeyhandler.cpp +++ b/plugins/TabSRMM/src/hotkeyhandler.cpp @@ -60,10 +60,6 @@ static HOTKEYDESC _hotkeydescs[] = { { "tabsrmm_msend", LPGEN("Toggle multi send"), TABSRMM_HK_SECTION_IM, nullptr, HOTKEYCODE(HOTKEYF_ALT | HOTKEYF_CONTROL, 'M'), 0, TABSRMM_HK_TOGGLEMULTISEND },
{ "tabsrmm_clearlog", LPGEN("Clear message log"), TABSRMM_HK_SECTION_GENERIC, nullptr, HOTKEYCODE(HOTKEYF_CONTROL, 'L'), 0, TABSRMM_HK_CLEARLOG },
{ "tabsrmm_sbar", LPGEN("Collapse side bar"), TABSRMM_HK_SECTION_GENERIC, nullptr, HOTKEYCODE(0, VK_F9), 0, TABSRMM_HK_TOGGLESIDEBAR },
- { "tabsrmm_muc_cmgr", LPGEN("Channel manager"), TABSRMM_HK_SECTION_GC, nullptr, HOTKEYCODE(HOTKEYF_SHIFT | HOTKEYF_CONTROL, 'C'), 0, TABSRMM_HK_CHANNELMGR },
- { "tabsrmm_muc_filter", LPGEN("Toggle filter"), TABSRMM_HK_SECTION_GC, nullptr, HOTKEYCODE(HOTKEYF_SHIFT | HOTKEYF_CONTROL, 'F'), 0, TABSRMM_HK_FILTERTOGGLE },
- { "tabsrmm_muc_nick", LPGEN("Toggle nick list"), TABSRMM_HK_SECTION_GC, nullptr, HOTKEYCODE(HOTKEYF_SHIFT | HOTKEYF_CONTROL, 'N'), 0, TABSRMM_HK_LISTTOGGLE },
- { "tabsrmm_muc_server_show", LPGEN("Show server window"), TABSRMM_HK_SECTION_GC, nullptr, HOTKEYCODE(HOTKEYF_SHIFT | HOTKEYF_CONTROL, '1'), 0, TABSRMM_HK_MUC_SHOWSERVER },
{ "tabsrmm_close_other", LPGEN("Close other tabs"), TABSRMM_HK_SECTION_GENERIC, nullptr, HOTKEYCODE(HOTKEYF_ALT | HOTKEYF_CONTROL, 'W'), 0, TABSRMM_HK_CLOSE_OTHER },
};
diff --git a/plugins/TabSRMM/src/msgdialog.cpp b/plugins/TabSRMM/src/msgdialog.cpp index b213fa3964..6502f247dd 100644 --- a/plugins/TabSRMM/src/msgdialog.cpp +++ b/plugins/TabSRMM/src/msgdialog.cpp @@ -1413,25 +1413,11 @@ int CMsgDialog::OnFilter(MSGFILTER *pFilter) if ((msg == WM_KEYDOWN || msg == WM_SYSKEYDOWN) && !(GetKeyState(VK_RMENU) & 0x8000)) {
MSG message = { m_hwnd, msg, wp, lp };
- LRESULT mim_hotkey_check = Hotkey_Check(&message, isChat() ? TABSRMM_HK_SECTION_GC : TABSRMM_HK_SECTION_IM);
+ LRESULT mim_hotkey_check = Hotkey_Check(&message, TABSRMM_HK_SECTION_IM);
if (mim_hotkey_check)
m_bkeyProcessed = true;
switch (mim_hotkey_check) {
- case TABSRMM_HK_CHANNELMGR:
- m_btnChannelMgr.Click();
- return _dlgReturn(m_hwnd, 1);
- case TABSRMM_HK_FILTERTOGGLE:
- m_btnFilter.Click();
- InvalidateRect(m_btnFilter.GetHwnd(), nullptr, TRUE);
- return _dlgReturn(m_hwnd, 1);
- case TABSRMM_HK_LISTTOGGLE:
- m_btnNickList.Click();
- return _dlgReturn(m_hwnd, 1);
- case TABSRMM_HK_MUC_SHOWSERVER:
- if (m_si->iType != GCW_SERVER)
- Chat_DoEventHook(m_si, GC_USER_MESSAGE, nullptr, L"/servershow", 0);
- return _dlgReturn(m_hwnd, 1);
case TABSRMM_HK_SETUSERPREFS:
CallService(MS_TABMSG_SETUSERPREFS, m_hContact, 0);
return _dlgReturn(m_hwnd, 1);
diff --git a/plugins/TabSRMM/src/msgs.h b/plugins/TabSRMM/src/msgs.h index 87f700e74e..7e50a8bf61 100644 --- a/plugins/TabSRMM/src/msgs.h +++ b/plugins/TabSRMM/src/msgs.h @@ -994,17 +994,12 @@ struct SIDEBARITEM #define TABSRMM_HK_CLEARLOG 24
#define TABSRMM_HK_TOGGLESENDLATER 25
#define TABSRMM_HK_TOGGLESIDEBAR 26
-#define TABSRMM_HK_CHANNELMGR 27
-#define TABSRMM_HK_FILTERTOGGLE 28
-#define TABSRMM_HK_LISTTOGGLE 29
-#define TABSRMM_HK_MUC_SHOWSERVER 30
#define TABSRMM_HK_CLOSE_OTHER 31
#define TABSRMM_HK_SENDMENU 32
#define TABSRMM_HK_PROTOMENU 33
#define TABSRMM_HK_SECTION_IM LPGEN("Message windows - IM")
#define TABSRMM_HK_SECTION_GENERIC LPGEN("Message windows - all")
-#define TABSRMM_HK_SECTION_GC LPGEN("Message windows - group chats")
// encryption status bar indicator
#define MSG_ICON_MODULE " TabSrmm"
diff --git a/src/mir_app/src/chat.h b/src/mir_app/src/chat.h index 60c4af86e0..7334aae921 100644 --- a/src/mir_app/src/chat.h +++ b/src/mir_app/src/chat.h @@ -32,13 +32,23 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define STREAMSTAGE_TAIL 2
#define STREAMSTAGE_STOP 3
+#define SRMM_HK_BOLD 40001
+#define SRMM_HK_ITALIC 40002
+#define SRMM_HK_UNDERLINE 40003
+#define SRMM_HK_BKCOLOR 40004
+#define SRMM_HK_COLOR 40005
+#define SRMM_HK_CLEAR 40006
+#define SRMM_HK_HISTORY 40007
+#define SRMM_HK_CHANNELMGR 40008
+#define SRMM_HK_FILTERTOGGLE 40009
+#define SRMM_HK_LISTTOGGLE 40010
+
#define N_CUSTOM_BBCODES 3
extern wchar_t *wszBbcodes[N_CUSTOM_BBCODES];
#define DM_OPTIONSAPPLIED (WM_USER+14)
void Srmm_CreateToolbarIcons(CSrmmBaseDialog *pDlg, int flags);
-void Srmm_ProcessToolbarHotkey(MCONTACT hContact, INT_PTR iButtonFrom, HWND hwndDlg);
void CheckChatCompatibility();
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index 7d909a5ab8..8fe34eac7d 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -993,3 +993,4 @@ _Proto_CanDeleteHistory@8 @1124 NONAME ?markRead@SESSION_INFO@@QAEX_N@Z @1130 NONAME
?Srmm_NotifyRemoteRead@@YGXII@Z @1131 NONAME
?RemakeLog@CSrmmBaseDialog@@UAEXXZ @1132 NONAME
+?ProcessToolbarHotkey@CSrmmBaseDialog@@AAEXH@Z @1133 NONAME
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index 7e5827cbcf..0d48f71055 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -993,3 +993,4 @@ Proto_CanDeleteHistory @1118 NONAME ?markRead@SESSION_INFO@@QEAAX_N@Z @1124 NONAME
?Srmm_NotifyRemoteRead@@YAXII@Z @1125 NONAME
?RemakeLog@CSrmmBaseDialog@@UEAAXXZ @1126 NONAME
+?ProcessToolbarHotkey@CSrmmBaseDialog@@AEAAX_J@Z @1129 NONAME
diff --git a/src/mir_app/src/srmm_base.cpp b/src/mir_app/src/srmm_base.cpp index b53ca52b13..700026399d 100644 --- a/src/mir_app/src/srmm_base.cpp +++ b/src/mir_app/src/srmm_base.cpp @@ -249,7 +249,7 @@ LRESULT CSrmmBaseDialog::WndProc_Message(UINT msg, WPARAM wParam, LPARAM lParam) MSG message = { m_hwnd, msg, wParam, lParam };
LRESULT iButtonFrom = Hotkey_Check(&message, BB_HK_SECTION);
if (iButtonFrom) {
- Srmm_ProcessToolbarHotkey(m_hContact, iButtonFrom, m_hwnd);
+ ProcessToolbarHotkey(iButtonFrom);
return TRUE;
}
}
@@ -1102,50 +1102,9 @@ bool CSrmmBaseDialog::ProcessHotkeys(int key, bool isShift, bool isCtrl, bool is return true;
}
- if (isCtrl && !isAlt) {
- switch (key) {
- case VK_SPACE: // ctrl-space (paste clean text)
- m_btnBold.Push(false); m_btnBold.Click();
- m_btnItalic.Push(false); m_btnItalic.Click();
- m_btnUnderline.Push(false); m_btnUnderline.Click();
-
- m_btnColor.Push(false); m_btnColor.Click();
- m_btnBkColor.Push(false); m_btnBkColor.Click();
- return true;
-
- case 0x42: // ctrl-b (bold)
- m_btnBold.Push(!m_btnBold.IsPushed());
- m_btnBold.Click();
- return true;
-
- case 0x48: // ctrl-h (history)
- m_btnHistory.Click();
- return true;
-
- case 0x49: // ctrl-i (italics)
- m_btnItalic.Push(!m_btnItalic.IsPushed());
- m_btnItalic.Click();
- return true;
-
- case 0x4b: // ctrl-k (text color)
- m_btnColor.Push(!m_btnColor.IsPushed());
- m_btnColor.Click();
- return true;
-
- case 0x4c: // ctrl-l (back color)
- m_btnBkColor.Push(!m_btnBkColor.IsPushed());
- m_btnBkColor.Click();
- return true;
-
- case 0x55: // ctrl-u (underlining)
- m_btnUnderline.Push(!m_btnUnderline.IsPushed());
- m_btnUnderline.Click();
- return true;
-
- case VK_F4: // ctrl-F4
- CloseTab();
- return true;
- }
+ if (isCtrl && !isAlt && key == VK_F4) { // ctrl-F4
+ CloseTab();
+ return true;
}
return false;
@@ -1153,9 +1112,6 @@ bool CSrmmBaseDialog::ProcessHotkeys(int key, bool isShift, bool isCtrl, bool is void CSrmmBaseDialog::RefreshButtonStatus()
{
- if (m_si == nullptr)
- return;
-
CHARFORMAT2 cf;
cf.cbSize = sizeof(CHARFORMAT2);
cf.dwMask = CFM_BOLD | CFM_ITALIC | CFM_UNDERLINE | CFM_BACKCOLOR | CFM_COLOR;
diff --git a/src/mir_app/src/srmm_log_rtf.cpp b/src/mir_app/src/srmm_log_rtf.cpp index 4e4615667f..75583cf1de 100644 --- a/src/mir_app/src/srmm_log_rtf.cpp +++ b/src/mir_app/src/srmm_log_rtf.cpp @@ -467,7 +467,7 @@ INT_PTR CRtfLogWindow::WndProc(UINT msg, WPARAM wParam, LPARAM lParam) MSG message = { m_pDlg.m_hwnd, msg, wParam, lParam };
LRESULT iButtonFrom = Hotkey_Check(&message, BB_HK_SECTION);
if (iButtonFrom) {
- Srmm_ProcessToolbarHotkey(m_pDlg.m_hContact, iButtonFrom, m_pDlg.m_hwnd);
+ m_pDlg.ProcessToolbarHotkey(iButtonFrom);
return TRUE;
}
}
diff --git a/src/mir_app/src/srmm_main.cpp b/src/mir_app/src/srmm_main.cpp index b8c0a4cc3c..be3b847489 100644 --- a/src/mir_app/src/srmm_main.cpp +++ b/src/mir_app/src/srmm_main.cpp @@ -176,8 +176,24 @@ void SrmmModulesLoaded() ///////////////////////////////////////////////////////////////////////////////////////// +static HOTKEYDESC srmmHotkeys[] = { + { "srmm_bold", LPGEN("Toggle bold formatting"), BB_HK_SECTION, nullptr, HOTKEYCODE(HOTKEYF_CONTROL, 'B'), 0, SRMM_HK_BOLD }, + { "srmm_italic", LPGEN("Toggle italic formatting"), BB_HK_SECTION, nullptr, HOTKEYCODE(HOTKEYF_CONTROL, 'I'), 0, SRMM_HK_ITALIC }, + { "srmm_under", LPGEN("Toggle underline formatting"), BB_HK_SECTION, nullptr, HOTKEYCODE(HOTKEYF_CONTROL, 'U'), 0, SRMM_HK_UNDERLINE }, + { "srmm_color", LPGEN("Toggle text color"), BB_HK_SECTION, nullptr, HOTKEYCODE(HOTKEYF_CONTROL, 'K'), 0, SRMM_HK_COLOR }, + { "srmm_bkcolor", LPGEN("Toggle back color"), BB_HK_SECTION, nullptr, HOTKEYCODE(HOTKEYF_CONTROL, 'L'), 0, SRMM_HK_BKCOLOR }, + { "srmm_clear", LPGEN("Clear formatting"), BB_HK_SECTION, nullptr, HOTKEYCODE(HOTKEYF_CONTROL, VK_SPACE), 0, SRMM_HK_CLEAR }, + { "srmm_history", LPGEN("Open history window"), BB_HK_SECTION, nullptr, HOTKEYCODE(HOTKEYF_CONTROL, 'H'), 0, SRMM_HK_HISTORY}, + { "srmm_cmgr", LPGEN("Channel manager"), BB_HK_SECTION, nullptr, HOTKEYCODE(HOTKEYF_SHIFT | HOTKEYF_CONTROL, 'C'), 0, SRMM_HK_CHANNELMGR }, + { "srmm_filter", LPGEN("Toggle filter"), BB_HK_SECTION, nullptr, HOTKEYCODE(HOTKEYF_SHIFT | HOTKEYF_CONTROL, 'F'), 0, SRMM_HK_FILTERTOGGLE }, + { "srmm_nicklist", LPGEN("Toggle nick list"), BB_HK_SECTION, nullptr, HOTKEYCODE(HOTKEYF_SHIFT | HOTKEYF_CONTROL, 'N'), 0, SRMM_HK_LISTTOGGLE }, +}; + int LoadSrmmModule() { + for (auto &it : srmmHotkeys) + g_plugin.addHotkey(&it); + g_hCurHyperlinkHand = LoadCursor(nullptr, IDC_HAND); LoadSrmmToolbarModule(); diff --git a/src/mir_app/src/srmm_toolbar.cpp b/src/mir_app/src/srmm_toolbar.cpp index 76b9fa0882..bddeef51d4 100644 --- a/src/mir_app/src/srmm_toolbar.cpp +++ b/src/mir_app/src/srmm_toolbar.cpp @@ -219,39 +219,96 @@ MIR_APP_DLL(void) Srmm_ClickToolbarIcon(MCONTACT hContact, int idFrom, HWND hwnd NotifyEventHooks(hHookButtonPressedEvt, hContact, (LPARAM)&cbcd);
}
-void Srmm_ProcessToolbarHotkey(MCONTACT hContact, INT_PTR iButtonFrom, HWND hwndDlg)
-{
- HWND hwndFrom = nullptr;
+/////////////////////////////////////////////////////////////////////////////////////////
- CustomButtonClickData cbcd = {};
+void CSrmmBaseDialog::ProcessToolbarHotkey(INT_PTR iButtonFrom)
+{
+ switch (iButtonFrom) {
+ case SRMM_HK_CLEAR:
+ m_btnBold.Push(false); m_btnBold.Click();
+ m_btnItalic.Push(false); m_btnItalic.Click();
+ m_btnUnderline.Push(false); m_btnUnderline.Click();
+
+ m_btnColor.Push(false); m_btnColor.Click();
+ m_btnBkColor.Push(false); m_btnBkColor.Click();
+ break;
+
+ case SRMM_HK_BOLD:
+ m_btnBold.Push(!m_btnBold.IsPushed());
+ m_btnBold.Click();
+ break;
+
+ case SRMM_HK_ITALIC:
+ m_btnItalic.Push(!m_btnItalic.IsPushed());
+ m_btnItalic.Click();
+ break;
+
+ case SRMM_HK_UNDERLINE:
+ m_btnUnderline.Push(!m_btnUnderline.IsPushed());
+ m_btnUnderline.Click();
+ break;
+
+ case SRMM_HK_COLOR:
+ m_btnColor.Push(!m_btnColor.IsPushed());
+ m_btnColor.Click();
+ break;
+
+ case SRMM_HK_BKCOLOR:
+ m_btnBkColor.Push(!m_btnBkColor.IsPushed());
+ m_btnBkColor.Click();
+ break;
+
+ case SRMM_HK_HISTORY:
+ m_btnHistory.Click();
+ break;
+
+ case SRMM_HK_CHANNELMGR:
+ m_btnChannelMgr.Click();
+ break;
+
+ case SRMM_HK_FILTERTOGGLE:
+ m_btnFilter.Click();
+ InvalidateRect(m_btnFilter.GetHwnd(), nullptr, TRUE);
+ break;
+
+ case SRMM_HK_LISTTOGGLE:
+ m_btnNickList.Click();
+ break;
+
+ default:
+ HWND hwndFrom = nullptr;
+
+ CustomButtonClickData cbcd = {};
- for (auto &cbd : arButtonsList) {
- if (cbd->m_hotkey == nullptr || cbd->m_bDisabled)
- continue;
+ for (auto &cbd : arButtonsList) {
+ if (cbd->m_hotkey == nullptr || cbd->m_bDisabled)
+ continue;
- if (cbd->m_hotkey->lParam == iButtonFrom) {
- cbcd.pszModule = cbd->m_pszModuleName;
- cbcd.dwButtonId = cbd->m_dwButtonID;
- hwndFrom = GetDlgItem(hwndDlg, cbd->m_dwButtonCID);
- break;
+ if (cbd->m_hotkey->lParam == iButtonFrom) {
+ cbcd.pszModule = cbd->m_pszModuleName;
+ cbcd.dwButtonId = cbd->m_dwButtonID;
+ hwndFrom = GetDlgItem(m_hwnd, cbd->m_dwButtonCID);
+ break;
+ }
}
- }
- if (hwndFrom == nullptr)
- return;
-
- RECT rc;
- GetWindowRect(hwndFrom, &rc);
- cbcd.pt.x = rc.left;
- cbcd.pt.y = rc.bottom;
+ if (hwndFrom) {
+ RECT rc;
+ GetWindowRect(hwndFrom, &rc);
+ cbcd.pt.x = rc.left;
+ cbcd.pt.y = rc.bottom;
- cbcd.hwndFrom = GetParent(hwndFrom);
- cbcd.hContact = hContact;
- cbcd.flags = (GetKeyState(VK_SHIFT) & 0x8000 ? BBCF_SHIFTPRESSED : 0) | (GetKeyState(VK_CONTROL) & 0x8000 ? BBCF_CONTROLPRESSED : 0);
+ cbcd.hwndFrom = GetParent(hwndFrom);
+ cbcd.hContact = m_hContact;
+ cbcd.flags = (GetKeyState(VK_SHIFT) & 0x8000 ? BBCF_SHIFTPRESSED : 0) | (GetKeyState(VK_CONTROL) & 0x8000 ? BBCF_CONTROLPRESSED : 0);
- NotifyEventHooks(hHookButtonPressedEvt, hContact, (LPARAM)&cbcd);
+ NotifyEventHooks(hHookButtonPressedEvt, m_hContact, (LPARAM)&cbcd);
+ }
+ }
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
MIR_APP_DLL(void) Srmm_ResetToolbar()
{
for (auto &cbd : arButtonsList) {
|