From 4f118eb8d179db54f9c1224593a12693ed14152a Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 28 Nov 2019 18:16:07 +0300 Subject: fixes #2126 (Notes & Reminders hotkeys) --- plugins/NotesAndReminders/src/hotkeys.cpp | 19 ++++++++---- plugins/NotesAndReminders/src/main.cpp | 47 +++++++++-------------------- plugins/NotesAndReminders/src/miscutils.cpp | 12 -------- plugins/NotesAndReminders/src/stdafx.h | 10 ++++-- plugins/NotesAndReminders/src/version.h | 2 +- 5 files changed, 36 insertions(+), 54 deletions(-) (limited to 'plugins/NotesAndReminders/src') diff --git a/plugins/NotesAndReminders/src/hotkeys.cpp b/plugins/NotesAndReminders/src/hotkeys.cpp index 905faca305..122b4b1a7e 100644 --- a/plugins/NotesAndReminders/src/hotkeys.cpp +++ b/plugins/NotesAndReminders/src/hotkeys.cpp @@ -4,7 +4,7 @@ HWND HKHwnd; -enum KB_ACTIONS {KB_NEW_NOTE = 1, KB_TOGGLE_NOTES, KB_NEW_REMINDER}; +enum KB_ACTIONS {KB_NEW_NOTE = 1, KB_TOGGLE_NOTES, KB_VIEW_NOTES, KB_NEW_REMINDER, KB_VIEW_REMINDERS }; void RegisterKeyBindings() { @@ -16,28 +16,35 @@ void RegisterKeyBindings() desc.szDescription.w = LPGENW("New Note"); desc.lParam = KB_NEW_NOTE; desc.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL|HOTKEYF_SHIFT, VK_INSERT); - desc.pszService = MODULENAME"/MenuCommandAddNew"; + desc.pszService = MS_NOTES_NEW; g_plugin.addHotkey(&desc); desc.pszName = MODULENAME"/ToggleNotesVis"; desc.szDescription.w = LPGENW("Toggle Notes Visibility"); desc.lParam = KB_TOGGLE_NOTES; desc.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL|HOTKEYF_SHIFT, VK_ADD); - desc.pszService = MODULENAME"/MenuCommandShowHide"; + desc.pszService = MS_NOTES_SHOWHIDE; g_plugin.addHotkey(&desc); desc.pszName = MODULENAME"/BringNotesFront"; desc.szDescription.w = LPGENW("Bring All Notes to Front"); - desc.lParam = KB_TOGGLE_NOTES; + desc.lParam = KB_VIEW_NOTES; desc.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL|HOTKEYF_SHIFT, VK_HOME); - desc.pszService = MODULENAME"/MenuCommandBringAllFront"; + desc.pszService = MS_NOTES_DISPLAY; g_plugin.addHotkey(&desc); desc.pszName = MODULENAME"/NewReminder"; desc.szDescription.w = LPGENW("New Reminder"); desc.lParam = KB_NEW_REMINDER; desc.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL|HOTKEYF_SHIFT, VK_SUBTRACT); - desc.pszService = MODULENAME"/MenuCommandNewReminder"; + desc.pszService = MS_REMINDER_NEW; + g_plugin.addHotkey(&desc); + + desc.pszName = MODULENAME"/ViewReminders"; + desc.szDescription.w = LPGENW("View Reminders"); + desc.lParam = KB_VIEW_REMINDERS; + desc.DefHotKey = HOTKEYCODE(HOTKEYF_CONTROL | HOTKEYF_SHIFT, VK_DIVIDE); + desc.pszService = MS_REMINDER_VIEW; g_plugin.addHotkey(&desc); } diff --git a/plugins/NotesAndReminders/src/main.cpp b/plugins/NotesAndReminders/src/main.cpp index 203467633b..857cd06334 100644 --- a/plugins/NotesAndReminders/src/main.cpp +++ b/plugins/NotesAndReminders/src/main.cpp @@ -3,8 +3,6 @@ CMPlugin g_plugin; HINSTANCE hmiranda = nullptr; -HMODULE hRichedDll = nullptr; - ///////////////////////////////////////////////////////////////////////////////////////// static PLUGININFOEX pluginInfoEx = @@ -59,12 +57,12 @@ int OnTopToolBarInit(WPARAM, LPARAM) ttb.dwFlags = TTBBF_VISIBLE | TTBBF_SHOWTOOLTIP; ttb.hIconHandleUp = iconList[14].hIcolib; - ttb.pszService = MODULENAME"/MenuCommandAddNew"; + ttb.pszService = MS_NOTES_NEW; ttb.name = ttb.pszTooltipUp = LPGEN("Add New Note"); g_plugin.addTTB(&ttb); ttb.hIconHandleUp = iconList[15].hIcolib; - ttb.pszService = MODULENAME"/MenuCommandNewReminder"; + ttb.pszService = MS_REMINDER_NEW; ttb.name = ttb.pszTooltipUp = LPGEN("Add New Reminder"); g_plugin.addTTB(&ttb); return 0; @@ -96,56 +94,56 @@ int OnModulesLoaded(WPARAM, LPARAM) mi.position = 1600000000; mi.hIcolibItem = iconList[2].hIcolib; - mi.name.w = LPGENW("New &Note"); - mi.pszService = MODULENAME"/MenuCommandAddNew"; + mi.name.w = LPGENW("New Note"); + mi.pszService = MS_NOTES_NEW; addMenuItem(mi); CreateServiceFunction(mi.pszService, PluginMenuCommandAddNew); mi.position = 1600000001; mi.hIcolibItem = iconList[0].hIcolib; - mi.name.w = LPGENW("New &Reminder"); - mi.pszService = MODULENAME"/MenuCommandNewReminder"; + mi.name.w = LPGENW("New Reminder"); + mi.pszService = MS_REMINDER_NEW; addMenuItem(mi); CreateServiceFunction(mi.pszService, PluginMenuCommandNewReminder); mi.position = 1600100000; mi.hIcolibItem = iconList[3].hIcolib; - mi.name.w = LPGENW("&Show / Hide Notes"); - mi.pszService = MODULENAME"/MenuCommandShowHide"; + mi.name.w = LPGENW("Toggle Notes Visibility"); + mi.pszService = MS_NOTES_SHOWHIDE; addMenuItem(mi); CreateServiceFunction(mi.pszService, PluginMenuCommandShowHide); mi.position = 1600100001; mi.hIcolibItem = iconList[13].hIcolib; - mi.name.w = LPGENW("Vie&w Notes"); + mi.name.w = LPGENW("View Notes"); mi.pszService = MODULENAME"/MenuCommandViewNotes"; addMenuItem(mi); CreateServiceFunction(mi.pszService, PluginMenuCommandViewNotes); mi.position = 1600100002; mi.hIcolibItem = iconList[1].hIcolib; - mi.name.w = LPGENW("&Delete All Notes"); + mi.name.w = LPGENW("Delete All Notes"); mi.pszService = MODULENAME"/MenuCommandDeleteAll"; addMenuItem(mi); CreateServiceFunction(mi.pszService, PluginMenuCommandDeleteNotes); mi.position = 1600100003; mi.hIcolibItem = iconList[11].hIcolib; - mi.name.w = LPGENW("&Bring All to Front"); - mi.pszService = MODULENAME"/MenuCommandBringAllFront"; + mi.name.w = LPGENW("Bring All to Front"); + mi.pszService = MS_NOTES_DISPLAY; addMenuItem(mi); CreateServiceFunction(mi.pszService, PluginMenuCommandAllBringFront); mi.position = 1600200000; mi.hIcolibItem = iconList[6].hIcolib; - mi.name.w = LPGENW("&View Reminders"); - mi.pszService = MODULENAME"/MenuCommandViewReminders"; + mi.name.w = LPGENW("View Reminders"); + mi.pszService = MS_REMINDER_VIEW; addMenuItem(mi); CreateServiceFunction(mi.pszService, PluginMenuCommandViewReminders); mi.position = 1600200001; mi.hIcolibItem = iconList[5].hIcolib; - mi.name.w = LPGENW("D&elete All Reminders"); + mi.name.w = LPGENW("Delete All Reminders"); mi.pszService = MODULENAME"/MenuCommandDeleteReminders"; addMenuItem(mi); CreateServiceFunction(mi.pszService, PluginMenuCommandDeleteReminders); @@ -185,13 +183,6 @@ int CMPlugin::Load() ctrls.dwICC = ICC_DATE_CLASSES; InitCommonControlsEx(&ctrls); - hRichedDll = LoadLibraryA("Msftedit.dll"); - if (!hRichedDll) { - if (MessageBox(nullptr, TranslateT("Miranda could not load the Notes & Reminders plugin, Msftedit.dll is missing. If you are using WINE, please make sure you have Msftedit.dll installed. Press 'Yes' to continue loading Miranda."), _A2W(SECTIONNAME), MB_YESNO | MB_ICONINFORMATION) != IDYES) - return 1; - return 0; - } - CreateServiceFunction(MODULENAME"/OpenTriggeredReminder", OpenTriggeredReminder); // register sounds @@ -199,12 +190,9 @@ int CMPlugin::Load() g_plugin.addSound("AlertReminder2", LPGENW("Alerts"), LPGENW("Reminder triggered (Alternative 1)")); g_plugin.addSound("AlertReminder3", LPGENW("Alerts"), LPGENW("Reminder triggered (Alternative 2)")); - WS_Init(); - HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded); HookEvent(ME_OPT_INITIALISE, OnOptInitialise); InitIcons(); - return 0; } @@ -217,15 +205,10 @@ int CMPlugin::Unload() SaveNotes(); SaveReminders(); DestroyMsgWindow(); - WS_CleanUp(); TermSettings(); IcoLib_ReleaseIcon(g_hReminderIcon); DeleteObject(hBodyFont); DeleteObject(hCaptionFont); - - if (hRichedDll) - FreeLibrary(hRichedDll); - return 0; } diff --git a/plugins/NotesAndReminders/src/miscutils.cpp b/plugins/NotesAndReminders/src/miscutils.cpp index 5f46db337a..058b93e263 100644 --- a/plugins/NotesAndReminders/src/miscutils.cpp +++ b/plugins/NotesAndReminders/src/miscutils.cpp @@ -3,18 +3,6 @@ ///////////////////////////////////////////////////////////////////// // Email/SMS and WinSock functions -BOOL WS_Init() -{ - WSADATA wsd; - if (WSAStartup(MAKEWORD(2, 2), &wsd) != 0) return FALSE; - return TRUE; -} - -void WS_CleanUp() -{ - WSACleanup(); -} - int WS_Send(SOCKET s, const char *data, int datalen) { int rlen; diff --git a/plugins/NotesAndReminders/src/stdafx.h b/plugins/NotesAndReminders/src/stdafx.h index fa985d12a5..e5d1ddc3ad 100644 --- a/plugins/NotesAndReminders/src/stdafx.h +++ b/plugins/NotesAndReminders/src/stdafx.h @@ -29,6 +29,13 @@ #define MODULENAME "StickyNotes" #define SECTIONNAME LPGEN("Notes & Reminders") +#define MS_NOTES_NEW MODULENAME"/MenuCommandAddNew" +#define MS_NOTES_SHOWHIDE MODULENAME"/MenuCommandShowHide" +#define MS_NOTES_DISPLAY MODULENAME"/MenuCommandBringAllFront" + +#define MS_REMINDER_NEW MODULENAME"/MenuCommandNewReminder" +#define MS_REMINDER_VIEW MODULENAME"/MenuCommandViewReminders" + struct CMPlugin : public PLUGIN { CMPlugin(); @@ -69,9 +76,6 @@ void InitSettings(void); void TermSettings(void); void LoadNRFont(int i, LOGFONT *lf, COLORREF *colour); -BOOL WS_Init(); -void WS_CleanUp(); - wchar_t* GetDateFormatStr(); wchar_t* GetTimeFormatStr(); diff --git a/plugins/NotesAndReminders/src/version.h b/plugins/NotesAndReminders/src/version.h index cc46754d46..b11916b763 100644 --- a/plugins/NotesAndReminders/src/version.h +++ b/plugins/NotesAndReminders/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0 #define __MINOR_VERSION 2 #define __RELEASE_NUM 0 -#define __BUILD_NUM 4 +#define __BUILD_NUM 5 #include -- cgit v1.2.3