From 6ad5d8b11e4b93df8a9deff1f784b4b75018a3d6 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 28 Dec 2020 21:56:44 +0300 Subject: =?UTF-8?q?fixes=20#2657=20(=D0=9D=D0=B5=D0=B2=D0=BE=D0=B7=D0=BC?= =?UTF-8?q?=D0=BE=D0=B6=D0=BD=D0=BE=20=D1=83=D0=B1=D0=B8=D1=82=D1=8C=20?= =?UTF-8?q?=D0=BA=D0=B0=D1=81=D1=82=D0=BE=D0=BC=D0=BD=D1=8B=D0=B9=20=D0=BF?= =?UTF-8?q?=D1=83=D0=BD=D0=BA=D1=82=20=D0=BC=D0=B5=D0=BD=D1=8E)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mir_app/res/resource.rc | 10 +++++++-- src/mir_app/src/menu_options.cpp | 44 ++++++++++++++++++++++++++++++++++------ src/mir_app/src/resource.h | 3 ++- 3 files changed, 48 insertions(+), 9 deletions(-) diff --git a/src/mir_app/res/resource.rc b/src/mir_app/res/resource.rc index fcf22c2dd8..8e88a2c601 100644 --- a/src/mir_app/res/resource.rc +++ b/src/mir_app/res/resource.rc @@ -477,10 +477,11 @@ BEGIN EDITTEXT IDC_GENMENU_SERVICE,36,199,108,14,ES_AUTOHSCROLL | ES_READONLY LTEXT "Name:",IDC_STATIC,4,218,29,8 EDITTEXT IDC_GENMENU_CUSTOMNAME,36,215,108,14,ES_AUTOHSCROLL | WS_DISABLED - PUSHBUTTON "Default",IDC_GENMENU_DEFAULT,18,234,55,15,WS_DISABLED - PUSHBUTTON "Set",IDC_GENMENU_SET,78,234,55,15,WS_DISABLED + PUSHBUTTON "Default",IDC_GENMENU_DEFAULT,7,233,39,15,WS_DISABLED + PUSHBUTTON "Set",IDC_GENMENU_SET,50,233,45,15,WS_DISABLED CONTROL "Enable icons",IDC_DISABLEMENUICONS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,156,234,91,10 PUSHBUTTON "Reset",IDC_RESETMENU,254,230,50,14 + PUSHBUTTON "Delete",IDC_GENMENU_DELETE,100,233,39,15,WS_DISABLED END IDD_OPT_PROTOCOLORDER DIALOGEX 0, 0, 315, 242 @@ -1502,6 +1503,11 @@ BEGIN 0 END +IDD_OPT_GENMENU AFX_DIALOG_LAYOUT +BEGIN + 0 +END + #endif // English (United States) resources ///////////////////////////////////////////////////////////////////////////// diff --git a/src/mir_app/src/menu_options.cpp b/src/mir_app/src/menu_options.cpp index fa8330a13e..a3cbd30929 100644 --- a/src/mir_app/src/menu_options.cpp +++ b/src/mir_app/src/menu_options.cpp @@ -77,6 +77,7 @@ static int SortMenuItems(const MenuItemOptData *p1, const MenuItemOptData *p2) class CGenMenuOptionsPage : public CDlgBase { int iInitMenuValue; + LIST m_arDeleted; wchar_t idstr[100]; @@ -99,7 +100,7 @@ class CGenMenuOptionsPage : public CDlgBase while (tvi.hItem != nullptr) { m_menuItems.GetItem(&tvi); - MenuItemOptData *iod = (MenuItemOptData*)tvi.lParam; + auto *iod = (MenuItemOptData*)tvi.lParam; if (TMO_IntMenuItem *pimi = iod->pimi) { if (pimi->mi.uid != miid_last) { char menuItemName[256]; @@ -279,12 +280,13 @@ class CGenMenuOptionsPage : public CDlgBase CCtrlTreeView m_menuItems; CCtrlCheck m_radio1, m_radio2, m_enableIcons; CCtrlEdit m_customName, m_service, m_module; - CCtrlButton m_btnInsSeparator, m_btnInsMenu, m_btnReset, m_btnSet, m_btnDefault; + CCtrlButton m_btnInsSeparator, m_btnInsMenu, m_btnReset, m_btnSet, m_btnDefault, m_btnDelete; CCtrlBase m_warning; public: CGenMenuOptionsPage() : CDlgBase(g_plugin, IDD_OPT_GENMENU), + m_arDeleted(1), m_menuItems(this, IDC_MENUITEMS), m_menuObjects(this, IDC_MENUOBJECTS), m_radio1(this, IDC_RADIO1), @@ -294,6 +296,7 @@ public: m_btnInsMenu(this, IDC_INSERTSUBMENU), m_btnReset(this, IDC_RESETMENU), m_btnSet(this, IDC_GENMENU_SET), + m_btnDelete(this, IDC_GENMENU_DELETE), m_btnDefault(this, IDC_GENMENU_DEFAULT), m_customName(this, IDC_GENMENU_CUSTOMNAME), m_service(this, IDC_GENMENU_SERVICE), @@ -305,6 +308,7 @@ public: m_btnInsSeparator.OnClick = Callback(this, &CGenMenuOptionsPage::btnInsSep_Clicked); m_btnInsMenu.OnClick = Callback(this, &CGenMenuOptionsPage::btnInsMenu_Clicked); m_btnDefault.OnClick = Callback(this, &CGenMenuOptionsPage::btnDefault_Clicked); + m_btnDelete.OnClick = Callback(this, &CGenMenuOptionsPage::btnDelete_Clicked); m_menuObjects.OnSelChange = Callback(this, &CGenMenuOptionsPage::onMenuObjectChanged); @@ -345,6 +349,9 @@ public: db_set_b(0, "CList", "DisableMenuIcons", bIconsDisabled); SaveTree(); + for (auto &pimi : m_arDeleted) + Menu_RemoveItem(pimi); + int iNewMenuValue = !m_radio1.GetState(); if (iNewMenuValue != iInitMenuValue) { db_set_b(0, "CList", "MoveProtoMenus", iNewMenuValue); @@ -483,6 +490,29 @@ public: NotifyChange(); } + void btnDelete_Clicked(CCtrlButton *) + { + HTREEITEM hti = m_menuItems.GetSelection(); + if (hti == nullptr) + return; + + TVITEMEX tvi; + tvi.mask = TVIF_PARAM; + tvi.hItem = hti; + m_menuItems.GetItem(&tvi); + + MenuItemOptData *iod = (MenuItemOptData *)tvi.lParam; + if (!(iod->pimi->mi.flags & CMIF_CUSTOM)) + return; + + if (IDYES == MessageBoxW(m_hwnd, TranslateT("Do you really want to delete this menu item?"), TranslateT("Miranda"), MB_YESNO | MB_ICONQUESTION)) { + m_arDeleted.insert(iod->pimi); + m_menuItems.DeleteItem(hti); + delete iod; + NotifyChange(); + } + } + void onMenuObjectChanged(void*) { m_bInitialized = false; @@ -496,10 +526,11 @@ public: m_service.SetTextA(""); m_module.SetTextA(""); - m_btnInsMenu.Enable(false); - m_btnDefault.Enable(false); - m_btnSet.Enable(false); - m_customName.Enable(false); + m_btnInsMenu.Disable(); + m_btnDefault.Disable(); + m_btnSet.Disable(); + m_btnDelete.Disable(); + m_customName.Disable(); HTREEITEM hti = m_menuItems.GetSelection(); if (hti == nullptr) @@ -529,6 +560,7 @@ public: m_btnInsMenu.Enable(iod->pimi->mi.root == nullptr); m_btnDefault.Enable(mir_wstrcmp(iod->name, iod->defname) != 0); + m_btnDelete.Enable(iod->pimi->mi.flags & CMIF_CUSTOM); m_btnSet.Enable(true); m_customName.Enable(true); } diff --git a/src/mir_app/src/resource.h b/src/mir_app/src/resource.h index 3db6ef8de1..3879595446 100644 --- a/src/mir_app/src/resource.h +++ b/src/mir_app/src/resource.h @@ -284,6 +284,7 @@ #define IDC_REVERSE_ORDER 1088 #define IDC_GENMENU_DEFAULT 1089 #define IDC_ICON1 1090 +#define IDC_GENMENU_DELETE 1090 #define IDC_ICON2 1091 #define IDC_ICON3 1092 #define IDC_ICON4 1093 @@ -674,7 +675,7 @@ // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 333 +#define _APS_NEXT_RESOURCE_VALUE 334 #define _APS_NEXT_COMMAND_VALUE 40018 #define _APS_NEXT_CONTROL_VALUE 1753 #define _APS_NEXT_SYMED_VALUE 101 -- cgit v1.2.3