From ab440290c6fd84ca1c9b7240ac9c90147d4660eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Mon, 23 Jan 2023 01:05:37 +0100 Subject: Add Show In Explorer context menu item. --- c/episodelistview.cpp | 4 ++++ c/ext.cpp | 23 +++++++++++++++++++++++ c/ext.h | 1 + c/main.cpp | 1 + c/res.h | 27 ++++++++++++++------------- c/res.rc | 1 + 6 files changed, 44 insertions(+), 13 deletions(-) diff --git a/c/episodelistview.cpp b/c/episodelistview.cpp index 320f98f..e6ff288 100644 --- a/c/episodelistview.cpp +++ b/c/episodelistview.cpp @@ -74,6 +74,10 @@ void EpisodeListView::HandleContextMenu(const WORD command) OpenOnline(parent.cfg, lvi.lParam); break; + case IDM_SHOW_IN_EXPLORER: + ShowInExplorer(parent.cfg, parent.fvElv.At(lvi.lParam-1)); + break; + case IDM_TOGGLE: e.bWatched = !e.bWatched; break; diff --git a/c/ext.cpp b/c/ext.cpp index 3c9542b..33218d2 100644 --- a/c/ext.cpp +++ b/c/ext.cpp @@ -1,4 +1,5 @@ #include +#include #include #include @@ -119,3 +120,25 @@ bool OpenLocally(CfgA& cfg, const ElvDataA& e) } else return false; } + +bool ShowInExplorer(CfgA& cfg, const ElvDataA& e) +{ + wchar_t file[MAX_PATH]; + if (FindMatchingFile(file, cfg.root, e.siEp)) { + /* ILCreateFromPath does not support forward slashes. */ + for (wchar_t *f = file; *f; f++) + if (*f == L'/') + *f = L'\\'; + + if (ITEMIDLIST* idl = ILCreateFromPath(file)) { + HRESULT r = SHOpenFolderAndSelectItems(idl, 0, 0, 0); + ILFree(idl); + if (FAILED(r)) { + SetLastError(r); + throw Err(WINDOWS, L"File "s + file + L" could not be shown in Explorer"); + } + } + return true; + } else + return false; +} diff --git a/c/ext.h b/c/ext.h index 5925206..c1e477b 100644 --- a/c/ext.h +++ b/c/ext.h @@ -6,5 +6,6 @@ bool OpenOnline(const CfgA& cfg, int iEp); bool OpenWiki(const DlvDataA& d); bool OpenLocally(CfgA& cfg, const ElvDataA& e); +bool ShowInExplorer(CfgA& cfg, const ElvDataA& e); #endif diff --git a/c/main.cpp b/c/main.cpp index 3219bd7..0ebfc0b 100644 --- a/c/main.cpp +++ b/c/main.cpp @@ -351,6 +351,7 @@ LRESULT CALLBACK Window::WndProc(const HWND hWnd, const UINT uMsg, const WPARAM const wchar_t* vTipCtx[] = { /*IDM_WATCH_LOCALLY*/L"Open local copy of episode, if available.", /*IDM_WATCH_ONLINE*/L"Open episode in the web browser.", + /*IDM_SHOW_IN_EXPLORER*/L"Show episode in Explorer.", /*IDM_TOGGLE*/L"Toggle watched/unwatched status.", /*IDM_WIKI*/L"Show Detective Conan Wiki entry for episode.", /*IDM_RATE0*/L"Remove episode rating.", diff --git a/c/res.h b/c/res.h index a0b7f8a..63c64ad 100644 --- a/c/res.h +++ b/c/res.h @@ -47,19 +47,20 @@ /* Context menu items. */ #define IDM_WATCH_LOCALLY 0x0400 #define IDM_WATCH_ONLINE 0x0401 -#define IDM_TOGGLE 0x0402 -#define IDM_WIKI 0x0403 -#define IDM_RATE0 0x1404 -#define IDM_RATE1 0x1405 -#define IDM_RATE2 0x1406 -#define IDM_RATE3 0x1407 -#define IDM_RATE4 0x1408 -#define IDM_RATE5 0x1409 -#define IDM_RATE6 0x140a -#define IDM_RATE7 0x140b -#define IDM_RATE8 0x140c -#define IDM_RATE9 0x140d -#define IDM_RATE10 0x140e +#define IDM_SHOW_IN_EXPLORER 0x0402 +#define IDM_TOGGLE 0x0403 +#define IDM_WIKI 0x0404 +#define IDM_RATE0 0x1405 +#define IDM_RATE1 0x1406 +#define IDM_RATE2 0x1407 +#define IDM_RATE3 0x1408 +#define IDM_RATE4 0x1409 +#define IDM_RATE5 0x140a +#define IDM_RATE6 0x140b +#define IDM_RATE7 0x140c +#define IDM_RATE8 0x140d +#define IDM_RATE9 0x140e +#define IDM_RATE10 0x140f #define ID_RATING(i) ((i) - IDM_RATE0) diff --git a/c/res.rc b/c/res.rc index d5696e4..a0fde3d 100644 --- a/c/res.rc +++ b/c/res.rc @@ -35,6 +35,7 @@ BEGIN BEGIN MENUITEM "&Watch Locally", IDM_WATCH_LOCALLY MENUITEM "Watch &Online", IDM_WATCH_ONLINE + MENUITEM "&Show In Explorer", IDM_SHOW_IN_EXPLORER MENUITEM "&Toggle", IDM_TOGGLE MENUITEM "Wi&ki", IDM_WIKI POPUP "&Rate" -- cgit v1.2.3