summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRodrigo Pelorosso <[email protected]>2017-10-14 10:50:58 -0600
committerNathaniel Graham <[email protected]>2017-10-14 10:58:03 -0600
commit1db8e8953835cf2e445f9a7e52d935df9d402f3d (patch)
treed47d5a5e7a33ef26b770b053254bb19a5197a61f
parented945a4b4c6b3556e480086bb958d882e14f23d8 (diff)
Add option to show file in File Manager
Summary: This patch adds an option to show the selected file(s), or the file currently being viewed in the file browser. It opens the default file browser and highlights the files. {F5428928} {F5428927} Test Plan: - Select a file and right click on it, opening the contextual menu. Select the "Show in File Manager" option. The default file manager should open and highlight the file. - While viewing a file, right click on it, opening the contextual menu. Select the "Show in File Manager" option. The default file manager should open and highlight the file. It also shows the option under the File menu. Reviewers: ngraham, #kde_applications, rkflx Reviewed By: ngraham, rkflx Subscribers: rkflx, ngraham Differential Revision: https://phabricator.kde.org/D8282
-rw-r--r--app/fileopscontextmanageritem.cpp11
-rw-r--r--app/fileopscontextmanageritem.h2
-rw-r--r--app/thumbnailviewhelper.cpp1
-rw-r--r--app/viewmainpage.cpp2
4 files changed, 16 insertions, 0 deletions
diff --git a/app/fileopscontextmanageritem.cpp b/app/fileopscontextmanageritem.cpp
index 64b54a9..f89ad63 100644
--- a/app/fileopscontextmanageritem.cpp
+++ b/app/fileopscontextmanageritem.cpp
@@ -49,6 +49,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <KUrlMimeData>
#include <KFileItemActions>
#include <KFileItemListProperties>
+#include <KIO/OpenFileManagerWindowJob>
// Local
#include <lib/contextmanager.h>
@@ -187,6 +188,9 @@ FileOpsContextManagerItem::FileOpsContextManagerItem(ContextManager* manager, QL
connect(menu, &QMenu::aboutToShow, this, &FileOpsContextManagerItem::populateOpenMenu);
connect(menu, &QMenu::triggered, this, &FileOpsContextManagerItem::openWith);
+ mOpenContainingFolderAction = file->addAction("file_open_containing_folder", this, SLOT(openContainingFolder()));
+ mOpenContainingFolderAction->setText(i18n("Open Containing Folder"));
+
mRegularFileActionList
<< mRenameAction
<< mTrashAction
@@ -197,6 +201,7 @@ FileOpsContextManagerItem::FileOpsContextManagerItem(ContextManager* manager, QL
<< mLinkToAction
<< createSeparator(this)
<< mOpenWithAction
+ << mOpenContainingFolderAction
<< mShowPropertiesAction
<< createSeparator(this)
<< mCreateFolderAction
@@ -243,6 +248,7 @@ void FileOpsContextManagerItem::updateActions()
mDelAction->setEnabled(selectionNotEmpty);
mOpenWithAction->setEnabled(selectionNotEmpty);
mRenameAction->setEnabled(count == 1);
+ mOpenContainingFolderAction->setEnabled(selectionNotEmpty);
mCreateFolderAction->setEnabled(dirUrlIsValid);
mShowPropertiesAction->setEnabled(dirUrlIsValid || urlIsValid);
@@ -412,4 +418,9 @@ void FileOpsContextManagerItem::openWith(QAction* action)
KRun::runService(*service, list, mGroup);
}
+void FileOpsContextManagerItem::openContainingFolder()
+{
+ KIO::highlightInFileManager(urlList());
+}
+
} // namespace
diff --git a/app/fileopscontextmanageritem.h b/app/fileopscontextmanageritem.h
index d5234ae..fd3fb0f 100644
--- a/app/fileopscontextmanageritem.h
+++ b/app/fileopscontextmanageritem.h
@@ -66,6 +66,7 @@ private Q_SLOTS:
void createFolder();
void populateOpenMenu();
void openWith(QAction* action);
+ void openContainingFolder();
private:
QList<QUrl> urlList() const;
@@ -89,6 +90,7 @@ private:
QAction * mShowPropertiesAction;
QAction * mCreateFolderAction;
QAction * mOpenWithAction;
+ QAction * mOpenContainingFolderAction;
QList<QAction*> mRegularFileActionList;
QList<QAction*> mTrashFileActionList;
KService::List mServiceList;
diff --git a/app/thumbnailviewhelper.cpp b/app/thumbnailviewhelper.cpp
index 1e4771a..1026c73 100644
--- a/app/thumbnailviewhelper.cpp
+++ b/app/thumbnailviewhelper.cpp
@@ -94,6 +94,7 @@ void ThumbnailViewHelper::showContextMenu(QWidget* parent)
d->addActionToMenu(popup, "file_link_to");
popup.addSeparator();
d->addActionToMenu(popup, "file_open_with");
+ d->addActionToMenu(popup, "file_open_containing_folder");
#ifndef GWENVIEW_SEMANTICINFO_BACKEND_NONE
d->addActionToMenu(popup, "edit_tags");
#endif
diff --git a/app/viewmainpage.cpp b/app/viewmainpage.cpp
index 4c5cd18..a507f6f 100644
--- a/app/viewmainpage.cpp
+++ b/app/viewmainpage.cpp
@@ -567,6 +567,8 @@ void ViewMainPage::showContextMenu()
addActionToMenu(&menu, d->mActionCollection, "file_link_to");
menu.addSeparator();
addActionToMenu(&menu, d->mActionCollection, "file_open_with");
+ addActionToMenu(&menu, d->mActionCollection, "file_open_containing_folder");
+
menu.exec(QCursor::pos());
}