Skip to content

Commit

Permalink
Add "Open Folder" context menu option
Browse files Browse the repository at this point in the history
Added an option to open the zim's location in the OS's file manager
  • Loading branch information
juuz0 committed Aug 2, 2023
1 parent 08b2f25 commit 3788616
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion resources/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,5 +148,6 @@
"open-book": "Open book",
"download-book": "Download book",
"pause-download": "Pause download",
"resume-download": "Resume download"
"resume-download": "Resume download",
"open-folder": "Open folder"
}
8 changes: 8 additions & 0 deletions src/contentmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "kiwixconfirmbox.h"
#include <QtConcurrent/QtConcurrentRun>
#include "contentmanagerheader.h"
#include <QDesktopServices>

ContentManager::ContentManager(Library* library, kiwix::Downloader* downloader, QObject *parent)
: QObject(parent),
Expand Down Expand Up @@ -99,6 +100,7 @@ void ContentManager::onCustomContextMenu(const QPoint &point)
QAction menuPauseBook(gt("pause-download"), this);
QAction menuResumeBook(gt("resume-download"), this);
QAction menuCancelBook(gt("cancel-download"), this);
QAction menuOpenFolder(gt("open-folder"), this);

if (bookNode->isDownloading()) {
if (bookNode->getDownloadInfo().paused) {
Expand All @@ -110,8 +112,14 @@ void ContentManager::onCustomContextMenu(const QPoint &point)
} else {
try {
const auto book = KiwixApp::instance()->getLibrary()->getBookById(id);
auto bookPath = QString::fromStdString(book.getPath());
contextMenu.addAction(&menuOpenBook);
contextMenu.addAction(&menuDeleteBook);
contextMenu.addAction(&menuOpenFolder);
connect(&menuOpenFolder, &QAction::triggered, [=]() {
QFileInfo fileInfo(bookPath);
QDesktopServices::openUrl(fileInfo.absoluteDir().absolutePath());
});
} catch (...) {
contextMenu.addAction(&menuDownloadBook);
}
Expand Down

0 comments on commit 3788616

Please sign in to comment.