From 0af92c332862c3d326384967f4b306b1f296d23e Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 21 Nov 2023 19:24:23 +0300 Subject: =?UTF-8?q?fixes=20#3944=20(NewStory:=20=D0=B4=D0=BE=D0=B1=D0=B0?= =?UTF-8?q?=D0=B2=D0=B8=D1=82=D1=8C=20=D0=B4=D0=BB=D1=8F=20=D1=81=D0=BA?= =?UTF-8?q?=D0=B0=D1=87=D0=B0=D0=BD=D0=BD=D0=BE=D0=B3=D0=BE=20=D0=BE=D0=B1?= =?UTF-8?q?=D0=BB=D0=B0=D1=87=D0=BD=D0=BE=D0=B3=D0=BE=20=D1=84=D0=B0=D0=B9?= =?UTF-8?q?=D0=BB=D0=B0=20=D0=BF=D1=83=D0=BD=D0=BA=D1=82=20=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=D1=8E=20"=D0=9F=D0=BE=D0=BA=D0=B0=D0=B7=D0=B0=D1=82?= =?UTF-8?q?=D1=8C=20=D0=B2=20=D0=BF=D0=B0=D0=BF=D0=BA=D0=B5")?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/NewStory/src/history_control.cpp | 15 +++++++++++++++ plugins/NewStory/src/history_control.h | 1 + plugins/NewStory/src/history_menus.cpp | 18 ++++++++++++++---- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/plugins/NewStory/src/history_control.cpp b/plugins/NewStory/src/history_control.cpp index 0909b186cc..a208d62312 100644 --- a/plugins/NewStory/src/history_control.cpp +++ b/plugins/NewStory/src/history_control.cpp @@ -533,6 +533,21 @@ ItemData* NewstoryListData::LoadItem(int idx) return (bSortAscending) ? items.get(idx, true) : items.get(totalCount - 1 - idx, true); } +void NewstoryListData::OpenFolder() +{ + if (auto *pItem = GetItem(caret)) { + if (pItem->m_bOfflineDownloaded) { + DB::EventInfo dbei(pItem->hEvent); + DB::FILE_BLOB blob(dbei); + CMStringW wszFile(blob.getLocalName()); + int idx = wszFile.ReverseFind('\\'); + if (idx != -1) + wszFile.Truncate(idx); + ::ShellExecute(nullptr, L"open", wszFile, nullptr, nullptr, SW_SHOWNORMAL); + } + } +} + int NewstoryListData::PaintItem(HDC hdc, int index, int top, int width) { auto *item = LoadItem(index); diff --git a/plugins/NewStory/src/history_control.h b/plugins/NewStory/src/history_control.h index 6736b63171..e11b74db5d 100644 --- a/plugins/NewStory/src/history_control.h +++ b/plugins/NewStory/src/history_control.h @@ -83,6 +83,7 @@ struct NewstoryListData : public MZeroedObject void LineUp(); void LineDown(); ItemData* LoadItem(int idx); + void OpenFolder(); void PageUp(); void PageDown(); int PaintItem(HDC hdc, int index, int top, int width); diff --git a/plugins/NewStory/src/history_menus.cpp b/plugins/NewStory/src/history_menus.cpp index 2fd82c16e7..e520ee636b 100644 --- a/plugins/NewStory/src/history_menus.cpp +++ b/plugins/NewStory/src/history_menus.cpp @@ -20,7 +20,7 @@ along with this program. If not, see . enum { - MENU_COPY, MENU_COPYTEXT, MENU_COPYURL, MENU_QUOTE, + MENU_COPY, MENU_COPYTEXT, MENU_COPYURL, MENU_OPENFOLDER, MENU_QUOTE, MENU_SAVEAS, MENU_DOWNLOAD, MENU_EDIT, MENU_DELETE, MENU_SELECTALL, MENU_BOOKMARK, @@ -28,7 +28,7 @@ enum static int hMenuObject; static HANDLE hEventPreBuildMenu; -static HGENMENU hmiHistory, hmiCopy, hmiCopyUrl, hmiSaveAs, hmiDownload, hmiQuote; +static HGENMENU hmiHistory, hmiOpenFolder, hmiCopyUrl, hmiSaveAs, hmiDownload, hmiQuote; static HGENMENU hmiEdit, hmiBookmark, hmiDelete; HMENU NSMenu_Build(NewstoryListData *data, ItemData *item) @@ -37,6 +37,7 @@ HMENU NSMenu_Build(NewstoryListData *data, ItemData *item) Menu_ShowItem(hmiSaveAs, false); Menu_ShowItem(hmiCopyUrl, false); Menu_ShowItem(hmiDownload, false); + Menu_ShowItem(hmiOpenFolder, false); bool bShowEventActions; if (item != nullptr) { @@ -45,6 +46,7 @@ HMENU NSMenu_Build(NewstoryListData *data, ItemData *item) Menu_ShowItem(hmiCopyUrl, true); Menu_ShowItem(hmiSaveAs, true); Menu_ShowItem(hmiDownload, !item->m_bOfflineDownloaded); + Menu_ShowItem(hmiOpenFolder, item->m_bOfflineDownloaded); } bShowEventActions = item->hEvent != 0; @@ -99,6 +101,10 @@ static INT_PTR NSMenuHelper(WPARAM wParam, LPARAM lParam) pData->CopyUrl(); break; + case MENU_OPENFOLDER: + pData->OpenFolder(); + break; + case MENU_QUOTE: pData->Quote(); break; @@ -218,16 +224,20 @@ void InitMenus() mi.position = 100000; mi.name.a = LPGEN("Copy"); - hmiCopy = Menu_AddNewStoryMenuItem(&mi, MENU_COPY); + Menu_AddNewStoryMenuItem(&mi, MENU_COPY); mi.position++; mi.name.a = LPGEN("Copy text"); - hmiCopy = Menu_AddNewStoryMenuItem(&mi, MENU_COPYTEXT); + Menu_AddNewStoryMenuItem(&mi, MENU_COPYTEXT); mi.position++; mi.name.a = LPGEN("Copy URL"); hmiCopyUrl = Menu_AddNewStoryMenuItem(&mi, MENU_COPYURL); + mi.position++; + mi.name.a = LPGEN("Show in folder"); + hmiOpenFolder = Menu_AddNewStoryMenuItem(&mi, MENU_OPENFOLDER); + mi.position++; mi.name.a = LPGEN("Quote"); hmiQuote = Menu_AddNewStoryMenuItem(&mi, MENU_QUOTE); -- cgit v1.2.3