diff options
author | George Hazan <george.hazan@gmail.com> | 2023-11-21 19:24:23 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2023-11-21 19:24:23 +0300 |
commit | 0af92c332862c3d326384967f4b306b1f296d23e (patch) | |
tree | a2c520ca67c1fa342198a4b69ca4d7a1ef3fe133 | |
parent | a4c4e3fc08395be5fc83b6f36fc1be07dbe5b245 (diff) |
fixes #3944 (NewStory: добавить для скачанного облачного файла пункт меню "Показать в папке")
-rw-r--r-- | plugins/NewStory/src/history_control.cpp | 15 | ||||
-rw-r--r-- | plugins/NewStory/src/history_control.h | 1 | ||||
-rw-r--r-- | 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 <http://www.gnu.org/licenses/>. 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,17 +224,21 @@ 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); |