aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2023-01-23 01:05:37 +0100
committerJohn Ankarström <john@ankarstrom.se>2023-01-23 01:06:58 +0100
commitab440290c6fd84ca1c9b7240ac9c90147d4660eb (patch)
treea96a66bdabb8e69cceade174c17faa6a2d768fba
parentde4e3d7654bf97cdae844d16c6ff5408698539ea (diff)
downloadEpisodeBrowser-ab440290c6fd84ca1c9b7240ac9c90147d4660eb.tar.gz
Add Show In Explorer context menu item.data
-rw-r--r--c/episodelistview.cpp4
-rw-r--r--c/ext.cpp23
-rw-r--r--c/ext.h1
-rw-r--r--c/main.cpp1
-rw-r--r--c/res.h27
-rw-r--r--c/res.rc1
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 <ctype.h>
+#include <shlobj.h>
#include <string>
#include <string_view>
@@ -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"