From d387ed11456e40f36f359cb3aa9f74a54b8f369b Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 9 Mar 2022 16:01:24 +0300 Subject: popup control moved from main menu to Options - Popups - Enabled items --- .../ClientChangeNotify/src/ClientChangeNotify.cpp | 47 +++++----------------- 1 file changed, 9 insertions(+), 38 deletions(-) (limited to 'plugins/ClientChangeNotify/src/ClientChangeNotify.cpp') diff --git a/plugins/ClientChangeNotify/src/ClientChangeNotify.cpp b/plugins/ClientChangeNotify/src/ClientChangeNotify.cpp index c489ddd1d9..95068d4ce1 100644 --- a/plugins/ClientChangeNotify/src/ClientChangeNotify.cpp +++ b/plugins/ClientChangeNotify/src/ClientChangeNotify.cpp @@ -19,8 +19,6 @@ #include "stdafx.h" -HGENMENU g_hTogglePopupsMenuItem; - CMPlugin g_plugin; COptPage *g_PreviewOptPage; // we need to show popup even for the NULL contact if g_PreviewOptPage is not NULL (used for popup preview) @@ -42,8 +40,10 @@ PLUGININFOEX pluginInfoEx = { }; CMPlugin::CMPlugin() : - PLUGIN(MODULENAME, pluginInfoEx) -{} + PLUGIN(MODULENAME, pluginInfoEx), + bPopups(MODULENAME, "PopupNotify", true) +{ +} ///////////////////////////////////////////////////////////////////////////////////////// @@ -241,7 +241,7 @@ int ContactSettingChanged(WPARAM hContact, LPARAM lParam) _ASSERT(hContact); return 0; } - if (PerContactSetting == NOTIFY_ALWAYS || (PopupOptPage.GetValue(IDC_POPUPOPTDLG_POPUPNOTIFY) && (g_PreviewOptPage || PerContactSetting == NOTIFY_ALMOST_ALWAYS || -1 == PcreCheck(sd.MirVer)))) { + if (PerContactSetting == NOTIFY_ALWAYS || (g_plugin.bPopups && (g_PreviewOptPage || PerContactSetting == NOTIFY_ALMOST_ALWAYS || -1 == PcreCheck(sd.MirVer)))) { ShowPopup(&sd); Skin_PlaySound(CLIENTCHANGED_SOUND); } @@ -259,22 +259,6 @@ int ContactSettingChanged(WPARAM hContact, LPARAM lParam) return 0; } -static INT_PTR srvTogglePopups(WPARAM, LPARAM) -{ - g_PopupOptPage.SetDBValueCopy(IDC_POPUPOPTDLG_POPUPNOTIFY, !g_PopupOptPage.GetDBValueCopy(IDC_POPUPOPTDLG_POPUPNOTIFY)); - return 0; -} - -static int PrebuildMainMenu(WPARAM, LPARAM) -{ - // we have to use ME_CLIST_PREBUILDMAINMENU instead of updating menu items only on settings change, because "popup_enabled" and "popup_disabled" icons are not always available yet in ModulesLoaded - if (g_PopupOptPage.GetDBValueCopy(IDC_POPUPOPTDLG_POPUPNOTIFY)) - Menu_ModifyItem(g_hTogglePopupsMenuItem, LPGENW("Disable c&lient change notification"), IcoLib_GetIconHandle("popup_enabled")); - else - Menu_ModifyItem(g_hTogglePopupsMenuItem, LPGENW("Enable c&lient change notification"), IcoLib_GetIconHandle("popup_disabled")); - return 0; -} - INT_PTR CALLBACK CCNErrorDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM) { switch (uMsg) { @@ -311,23 +295,6 @@ static int MirandaLoaded(WPARAM, LPARAM) PopupOptPage.DBToMem(); RecompileRegexps(*(TCString*)PopupOptPage.GetValue(IDC_POPUPOPTDLG_IGNORESTRINGS)); - g_plugin.addSound(CLIENTCHANGED_SOUND, nullptr, LPGENW("ClientChangeNotify: Client changed")); - - CreateServiceFunction(MS_CCN_TOGGLEPOPUPS, srvTogglePopups); - HookEvent(ME_CLIST_PREBUILDMAINMENU, PrebuildMainMenu); - - CMenuItem mi(&g_plugin); - SET_UID(mi, 0xfabb9181, 0xdb92, 0x43f4, 0x86, 0x40, 0xca, 0xb6, 0x4c, 0x93, 0x34, 0x27); - mi.root = g_plugin.addRootMenu(MO_MAIN, LPGENW("Popups"), 0); - mi.flags = CMIF_UNICODE; - if (g_PopupOptPage.GetDBValueCopy(IDC_POPUPOPTDLG_POPUPNOTIFY)) - mi.name.w = LPGENW("Disable c&lient change notification"); - else - mi.name.w = LPGENW("Enable c&lient change notification"); - - mi.pszService = MS_CCN_TOGGLEPOPUPS; - g_hTogglePopupsMenuItem = Menu_AddMainMenuItem(&mi); - // seems that Fingerprint is not installed if (!bFingerprintExists && !g_plugin.getByte(DB_NO_FINGERPRINT_ERROR, 0)) CreateDialog(g_plugin.getInst(), MAKEINTRESOURCE(IDD_CCN_ERROR), nullptr, CCNErrorDlgProc); @@ -343,6 +310,10 @@ int CMPlugin::Load() HookEvent(ME_SYSTEM_MODULEUNLOAD, ModuleLoad); HookEvent(ME_SYSTEM_MODULESLOADED, MirandaLoaded); + addPopupOption(LPGEN("Client change notifications"), bPopups); + + addSound(CLIENTCHANGED_SOUND, nullptr, LPGENW("ClientChangeNotify: Client changed")); + InitOptions(); if (g_plugin.getByte(DB_SETTINGSVER, 0) < 1) { -- cgit v1.2.3