From 88f2e70d10031e5ffc2a2682d99d53d27f83addf Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 4 Feb 2024 12:54:23 +0300 Subject: =?UTF-8?q?fixes=20#4166=20(=D0=9C=D0=B5=D0=BD=D0=B5=D0=B4=D0=B6?= =?UTF-8?q?=D0=B5=D1=80=20=D0=BF=D1=80=D0=BE=D1=84=D0=B8=D0=BB=D0=B5=D0=B9?= =?UTF-8?q?:=20=D0=BD=D0=B5=20=D0=BB=D0=BE=D0=BA=D0=B0=D0=BB=D0=B8=D0=B7?= =?UTF-8?q?=D0=BE=D0=B2=D0=B0=D0=BD=D0=B0=20=D0=B4=D0=B0=D1=82=D0=B0=20?= =?UTF-8?q?=D1=81=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD=D0=B8=D1=8F=20=D0=BF=D1=80?= =?UTF-8?q?=D0=BE=D1=84=D0=B8=D0=BB=D1=8F)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mir_app/src/profilemanager.cpp | 139 +++++++++++++++++-------------------- 1 file changed, 63 insertions(+), 76 deletions(-) diff --git a/src/mir_app/src/profilemanager.cpp b/src/mir_app/src/profilemanager.cpp index 47b0461521..d89363706c 100644 --- a/src/mir_app/src/profilemanager.cpp +++ b/src/mir_app/src/profilemanager.cpp @@ -339,76 +339,6 @@ class CChooseProfileDlg : public CDlgBase m_pd->m_profile = tmpPath; } - void ExecuteMenu(LPARAM lParam) - { - LVHITTESTINFO lvht = { 0 }; - lvht.pt.x = GET_X_LPARAM(lParam); - lvht.pt.y = GET_Y_LPARAM(lParam); - ScreenToClient(m_profileList.GetHwnd(), &lvht.pt); - - if (m_profileList.HitTest(&lvht) == -1) - return; - - if (lvht.iItem == -1) - return; - - wchar_t profile[MAX_PATH]; - LVITEM item = { 0 }; - item.mask = LVIF_IMAGE | LVIF_PARAM | LVIF_TEXT; - item.iItem = lvht.iItem; - item.pszText = profile; - item.cchTextMax = _countof(profile); - if (!m_profileList.GetItem(&item)) - return; - - lvht.pt.x = GET_X_LPARAM(lParam); - lvht.pt.y = GET_Y_LPARAM(lParam); - - HMENU hMenu = CreatePopupMenu(); - if (item.iImage < 2) { - AppendMenu(hMenu, MF_STRING, 1, TranslateT("Run")); - AppendMenu(hMenu, MF_SEPARATOR, 0, nullptr); - } - - DATABASELINK *dblink = (DATABASELINK*)item.lParam; - if (dblink != nullptr) { - bool bAdded = false; - if (dblink->capabilities & MDB_CAPS_COMPACT) { - AppendMenu(hMenu, MF_STRING, 3, TranslateT("Compact database")); - bAdded = true; - } - - if (plugin_checker && (dblink->capabilities & MDB_CAPS_CHECK)) { - AppendMenu(hMenu, MF_STRING, 4, TranslateT("Check database")); - bAdded = true; - } - - if (bAdded) - AppendMenu(hMenu, MF_SEPARATOR, 0, nullptr); - } - - AppendMenu(hMenu, MF_STRING, 2, TranslateT("Delete")); - int index = TrackPopupMenu(hMenu, TPM_RETURNCMD, lvht.pt.x, lvht.pt.y, 0, m_hwnd, nullptr); - switch (index) { - case 1: - SendMessage(GetParent(m_hwndParent), WM_COMMAND, IDOK, 0); - break; - - case 2: - DeleteProfile(item); - break; - - case 3: - CompactProfile(dblink, profile); - break; - - case 4: - CheckProfile(profile); - break; - } - DestroyMenu(hMenu); - } - void FindProfiles(const wchar_t *szProfile) { // find in Miranda NG profile subfolders @@ -441,10 +371,11 @@ public: { timerCheck.OnEvent = Callback(this, &CChooseProfileDlg::onTimer_Check); - m_profileList.OnItemChanged = Callback(this, &CChooseProfileDlg::list_OnItemChanged); m_profileList.OnKeyDown = Callback(this, &CChooseProfileDlg::list_OnKeyDown); + m_profileList.OnBuildMenu = Callback(this, &CChooseProfileDlg::list_OnContextMenu); m_profileList.OnGetInfoTip = Callback(this, &CChooseProfileDlg::list_OnGetTip); m_profileList.OnDoubleClick = Callback(this, &CChooseProfileDlg::list_OnDblClick); + m_profileList.OnItemChanged = Callback(this, &CChooseProfileDlg::list_OnItemChanged); } bool OnInitDialog() override @@ -520,7 +451,11 @@ public: m_profileList.GetItemText(pTip->iItem, 0, profilename, _countof(profilename)); mir_snwprintf(tszFullPath, L"%s\\%s\\%s.dat", g_profileDir, profilename, profilename); _wstat(tszFullPath, &statbuf); - mir_snwprintf(pTip->pszText, pTip->cchTextMax, L"%s\n%s: %s\n%s: %s", tszFullPath, TranslateT("Created"), rtrimw(NEWWSTR_ALLOCA(_wctime(&statbuf.st_ctime))), TranslateT("Modified"), rtrimw(NEWWSTR_ALLOCA(_wctime(&statbuf.st_mtime)))); + + wchar_t buf1[100], buf2[100]; + TimeZone_PrintTimeStamp(0, statbuf.st_ctime, L"D t", buf1, _countof(buf1), 0); + TimeZone_PrintTimeStamp(0, statbuf.st_mtime, L"D t", buf2, _countof(buf2), 0); + mir_snwprintf(pTip->pszText, pTip->cchTextMax, L"%s\n%s: %s\n%s: %s", tszFullPath, TranslateT("Created"), buf1, TranslateT("Modified"), buf2); } } @@ -530,6 +465,62 @@ public: EndDialog(GetParent(m_hwndParent), 1); } + void list_OnContextMenu(CContextMenuPos *pos) + { + wchar_t profile[MAX_PATH]; + LVITEM item = {}; + item.mask = LVIF_IMAGE | LVIF_PARAM | LVIF_TEXT; + item.iItem = pos->iCurr; + item.pszText = profile; + item.cchTextMax = _countof(profile); + if (!m_profileList.GetItem(&item)) + return; + + HMENU hMenu = CreatePopupMenu(); + if (item.iImage < 2) { + AppendMenu(hMenu, MF_STRING, 1, TranslateT("Run")); + AppendMenu(hMenu, MF_SEPARATOR, 0, nullptr); + } + + DATABASELINK *dblink = (DATABASELINK *)item.lParam; + if (dblink != nullptr) { + bool bAdded = false; + if (dblink->capabilities & MDB_CAPS_COMPACT) { + AppendMenu(hMenu, MF_STRING, 3, TranslateT("Compact database")); + bAdded = true; + } + + if (plugin_checker && (dblink->capabilities & MDB_CAPS_CHECK)) { + AppendMenu(hMenu, MF_STRING, 4, TranslateT("Check database")); + bAdded = true; + } + + if (bAdded) + AppendMenu(hMenu, MF_SEPARATOR, 0, nullptr); + } + + AppendMenu(hMenu, MF_STRING, 2, TranslateT("Delete")); + int index = TrackPopupMenu(hMenu, TPM_RETURNCMD, pos->pt.x, pos->pt.y, 0, m_hwnd, nullptr); + switch (index) { + case 1: + SendMessage(GetParent(m_hwndParent), WM_COMMAND, IDOK, 0); + break; + + case 2: + DeleteProfile(item); + break; + + case 3: + CompactProfile(dblink, profile); + break; + + case 4: + CheckProfile(profile); + break; + } + DestroyMenu(hMenu); + } + void onTimer_Check(CTimer *) { if (WaitForSingleObject(m_hFileNotify, 0) == WAIT_OBJECT_0) { @@ -546,10 +537,6 @@ public: if (wParam) CheckRun(); break; - - case WM_CONTEXTMENU: - ExecuteMenu(lParam); - break; } return CDlgBase::DlgProc(msg, wParam, lParam); -- cgit v1.2.3