summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2018-07-18 23:09:31 +0200
committerGravatar Robert C. Helling <helling@atdotde.de>2018-07-20 08:29:27 +0200
commit4f42e4fd509ce69f1ea80111e72e11895fd956df (patch)
tree3901a2236c973537c0850de6a912da002c5611f2
parent325b8bba35c339d626071b3feedbc6140774a725 (diff)
downloadsubsurface-4f42e4fd509ce69f1ea80111e72e11895fd956df.tar.gz
Dive media: implement "Open folder of selected media files"
Add a context-menu entry to TabDivePhotos which opens the folder(s) of all selected files. Fixes #1514. Suggested-by: Stefan Fuchs <sfuchs@gmx.de> Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
-rw-r--r--desktop-widgets/tab-widgets/TabDivePhotos.cpp18
-rw-r--r--desktop-widgets/tab-widgets/TabDivePhotos.h1
2 files changed, 19 insertions, 0 deletions
diff --git a/desktop-widgets/tab-widgets/TabDivePhotos.cpp b/desktop-widgets/tab-widgets/TabDivePhotos.cpp
index adac7bf29..5148926ec 100644
--- a/desktop-widgets/tab-widgets/TabDivePhotos.cpp
+++ b/desktop-widgets/tab-widgets/TabDivePhotos.cpp
@@ -10,6 +10,7 @@
#include <QMenu>
#include <QUrl>
#include <QMessageBox>
+#include <QFileInfo>
//TODO: Remove those in the future.
#include "../mainwindow.h"
@@ -54,6 +55,7 @@ void TabDivePhotos::contextMenuEvent(QContextMenuEvent *event)
popup.addSeparator();
popup.addAction(tr("Delete selected media files"), this, SLOT(removeSelectedPhotos()));
popup.addAction(tr("Delete all media files"), this, SLOT(removeAllPhotos()));
+ popup.addAction(tr("Open folder of selected media files"), this, SLOT(openFolderOfSelectedFiles()));
popup.addAction(tr("Recalculate selected thumbnails"), this, SLOT(recalculateSelectedThumbnails()));
popup.exec(event->globalPos());
event->accept();
@@ -83,6 +85,22 @@ void TabDivePhotos::removeSelectedPhotos()
DivePictureModel::instance()->removePictures(getSelectedFilenames());
}
+void TabDivePhotos::openFolderOfSelectedFiles()
+{
+ QVector<QString> directories;
+ for (const QString &filename: getSelectedFilenames()) {
+ QFileInfo info(filename);
+ if (!info.exists())
+ continue;
+ QString path = info.absolutePath();
+ if (path.isEmpty() || directories.contains(path))
+ continue;
+ directories.append(path);
+ }
+ for (const QString &dir: directories)
+ QDesktopServices::openUrl(QUrl::fromLocalFile(dir));
+}
+
void TabDivePhotos::recalculateSelectedThumbnails()
{
Thumbnailer::instance()->calculateThumbnails(getSelectedFilenames());
diff --git a/desktop-widgets/tab-widgets/TabDivePhotos.h b/desktop-widgets/tab-widgets/TabDivePhotos.h
index a752fef19..f172df180 100644
--- a/desktop-widgets/tab-widgets/TabDivePhotos.h
+++ b/desktop-widgets/tab-widgets/TabDivePhotos.h
@@ -27,6 +27,7 @@ private slots:
void removeAllPhotos();
void removeSelectedPhotos();
void recalculateSelectedThumbnails();
+ void openFolderOfSelectedFiles();
void changeZoomLevel(int delta);
private: