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 --- plugins/TabSRMM/res/resource.rc | 1 - plugins/TabSRMM/src/resource.h | 1 - plugins/TabSRMM/src/typingnotify.cpp | 70 +++++++++++------------------------- plugins/TabSRMM/src/typingnotify.h | 2 -- 4 files changed, 20 insertions(+), 54 deletions(-) (limited to 'plugins/TabSRMM') diff --git a/plugins/TabSRMM/res/resource.rc b/plugins/TabSRMM/res/resource.rc index dc5fdca0c8..57c98765d9 100644 --- a/plugins/TabSRMM/res/resource.rc +++ b/plugins/TabSRMM/res/resource.rc @@ -408,7 +408,6 @@ BEGIN CONTROL "Use &default colors",IDC_USEPOPUPCOLORS,"Button",BS_AUTOCHECKBOX | BS_NOTIFY | WS_TABSTOP,11,71,235,13 CONTROL "Use &Windows colors",IDC_USEWINCOLORS,"Button",BS_AUTOCHECKBOX | BS_NOTIFY | WS_TABSTOP,11,84,242,13 CONTROL "Only &one popup for each contact",IDC_ONEPOPUP,"Button",BS_AUTOCHECKBOX | BS_NOTIFY | WS_TABSTOP,11,109,250,13 - CONTROL "Show &entry in the main menu",IDC_SHOWMENU,"Button",BS_AUTOCHECKBOX | BS_NOTIFY | WS_TABSTOP,11,122,247,13 GROUPBOX "...is typing",IDC_STATIC,8,151,148,58,WS_GROUP CONTROL "Default",IDC_TIMEOUT_POPUP,"Button",BS_AUTORADIOBUTTON,16,161,130,10 CONTROL "From protocol",IDC_TIMEOUT_PROTO,"Button",BS_AUTORADIOBUTTON,16,172,130,10 diff --git a/plugins/TabSRMM/src/resource.h b/plugins/TabSRMM/src/resource.h index b5e82e0f2e..139650fe6c 100644 --- a/plugins/TabSRMM/src/resource.h +++ b/plugins/TabSRMM/src/resource.h @@ -661,7 +661,6 @@ #define IDC_WO 31617 #define IDC_TIMEOUT_PERMANENT1 31618 #define IDC_TIMEOUT_PERMANENT 31618 -#define IDC_SHOWMENU 31619 #define IDC_DISABLED 31620 #define IDC_ONEPOPUP 31621 #define IDC_WOCL 31622 diff --git a/plugins/TabSRMM/src/typingnotify.cpp b/plugins/TabSRMM/src/typingnotify.cpp index 14b00bea61..0480a23afe 100644 --- a/plugins/TabSRMM/src/typingnotify.cpp +++ b/plugins/TabSRMM/src/typingnotify.cpp @@ -1,24 +1,24 @@ #include "stdafx.h" +static CMOption g_bPopups(TypigModule, "TypingPopup", true); + static HGENMENU hDisableMenu = nullptr; static MWindowList hPopupsList = nullptr; -static uint8_t OnePopup; -static uint8_t ShowMenu; -static uint8_t StartDisabled; -static uint8_t StopDisabled; -static uint8_t Disabled; -static uint8_t ColorMode; -static uint8_t TimeoutMode; -static uint8_t TimeoutMode2; -static int Timeout; -static int Timeout2; -static int newTimeout; -static int newTimeout2; -static uint8_t newTimeoutMode; -static uint8_t newTimeoutMode2; -static uint8_t newColorMode; +static uint8_t OnePopup; +static uint8_t StartDisabled; +static uint8_t StopDisabled; +static uint8_t ColorMode; +static uint8_t TimeoutMode; +static uint8_t TimeoutMode2; +static int Timeout; +static int Timeout2; +static int newTimeout; +static int newTimeout2; +static uint8_t newTimeoutMode; +static uint8_t newTimeoutMode2; +static uint8_t newColorMode; static HANDLE hntfStarted = nullptr; static HANDLE hntfStopped = nullptr; @@ -37,21 +37,6 @@ static colorPicker[4] = { IDC_TYPEOFF_TX, "OFF_TX", RGB(0, 0, 0) } }; -static void UpdateMenuItems() -{ - if (!Disabled) - Menu_ModifyItem(hDisableMenu, LPGENW("Disable &typing notification"), Skin_LoadIcon(SKINICON_OTHER_POPUP)); - else - Menu_ModifyItem(hDisableMenu, LPGENW("Enable &typing notification"), Skin_LoadIcon(SKINICON_OTHER_NOPOPUP)); -} - -static INT_PTR EnableDisableMenuCommand(WPARAM, LPARAM) -{ - Disabled = !Disabled; - UpdateMenuItems(); - return 0; -} - static LRESULT CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { @@ -84,7 +69,7 @@ void TN_TypingMessage(MCONTACT hContact, int iMode) if (Contact_IsHidden(hContact) || (db_get_dw(hContact, "Ignore", "Mask1", 0) & 1)) // 9 - online notification return; - if (Disabled) + if (!g_bPopups) return; wchar_t *szContactName = Clist_GetContactDisplayName(hContact); @@ -211,7 +196,6 @@ static INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA CheckDlgButton(hwndDlg, IDC_STOP, (StopDisabled) ? BST_UNCHECKED : BST_CHECKED); CheckDlgButton(hwndDlg, IDC_ONEPOPUP, (OnePopup) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_SHOWMENU, (ShowMenu) ? BST_CHECKED : BST_UNCHECKED); newTimeout = Timeout; newTimeoutMode = TimeoutMode; @@ -276,7 +260,6 @@ static INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA case IDC_ONEPOPUP: case IDC_CLIST: case IDC_DISABLED: - case IDC_SHOWMENU: case IDC_START: case IDC_STOP: case IDC_WOCL: @@ -455,16 +438,11 @@ static INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA Timeout2 = newTimeout2; TimeoutMode2 = newTimeoutMode2; ColorMode = newColorMode; - if (Disabled != IsDlgButtonChecked(hwndDlg, IDC_DISABLED)) - EnableDisableMenuCommand(0, 0); - StartDisabled = IsDlgButtonChecked(hwndDlg, IDC_START) ? 0 : 2; StopDisabled = IsDlgButtonChecked(hwndDlg, IDC_STOP) ? 0 : 4; OnePopup = IsDlgButtonChecked(hwndDlg, IDC_ONEPOPUP); - ShowMenu = IsDlgButtonChecked(hwndDlg, IDC_SHOWMENU); db_set_b(0, TypigModule, SET_ONEPOPUP, OnePopup); - db_set_b(0, TypigModule, SET_SHOWDISABLEMENU, ShowMenu); db_set_b(0, TypigModule, SET_DISABLED, (uint8_t)(StartDisabled | StopDisabled)); db_set_b(0, TypigModule, SET_COLOR_MODE, ColorMode); db_set_b(0, TypigModule, SET_TIMEOUT_MODE, TimeoutMode); @@ -497,10 +475,10 @@ int TN_ModuleInit() hPopupsList = WindowList_Create(); OnePopup = db_get_b(0, TypigModule, SET_ONEPOPUP, DEF_ONEPOPUP); - ShowMenu = db_get_b(0, TypigModule, SET_SHOWDISABLEMENU, DEF_SHOWDISABLEMENU); int i = db_get_b(0, TypigModule, SET_DISABLED, DEF_DISABLED); - Disabled = i & 1; + if (i & 1) + g_bPopups = false; StartDisabled = i & 2; StopDisabled = i & 4; @@ -514,15 +492,7 @@ int TN_ModuleInit() for (auto &it : colorPicker) it.color = db_get_dw(0, TypigModule, it.desc, 0); - if (ShowMenu) { - CMenuItem mi(&g_plugin); - SET_UID(mi, 0xe18fd2cf, 0xcf90, 0x459e, 0xb6, 0xe6, 0x70, 0xec, 0xad, 0xc6, 0x73, 0xef); - mi.pszService = "TypingNotify/EnableDisableMenuCommand"; - mi.root = g_plugin.addRootMenu(MO_MAIN, LPGENW("Popups"), 0); - hDisableMenu = Menu_AddMainMenuItem(&mi); - UpdateMenuItems(); - CreateServiceFunction(mi.pszService, EnableDisableMenuCommand); - } + g_plugin.addPopupOption(LPGEN("Typing notifications"), g_bPopups); g_plugin.addSound("TNStart", LPGENW("Instant messages"), LPGENW("Contact started typing")); g_plugin.addSound("TNStop", LPGENW("Instant messages"), LPGENW("Contact stopped typing")); @@ -532,6 +502,6 @@ int TN_ModuleInit() int TN_ModuleDeInit() { WindowList_Destroy(hPopupsList); - db_set_b(0, TypigModule, SET_DISABLED, (uint8_t)(Disabled | StartDisabled | StopDisabled)); + db_set_b(0, TypigModule, SET_DISABLED, (uint8_t)(StartDisabled | StopDisabled)); return 0; } diff --git a/plugins/TabSRMM/src/typingnotify.h b/plugins/TabSRMM/src/typingnotify.h index 3d298dae8b..92a33a3d27 100644 --- a/plugins/TabSRMM/src/typingnotify.h +++ b/plugins/TabSRMM/src/typingnotify.h @@ -30,7 +30,5 @@ #define DEF_COLOR_MODE COLOR_OWN #define SET_ICON_SETID "IconSet" #define DEF_ICON_SETID 0 -#define SET_SHOWDISABLEMENU "ShowDisableMenu" -#define DEF_SHOWDISABLEMENU 1 #define SET_ONEPOPUP "OnePopup" #define DEF_ONEPOPUP 1 -- cgit v1.2.3