Commit b44a6578 authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇 Committed by Christoph Cullmann

[File Tree] Add "Open Containing Folder" menu entry

Summary: It was present in the Projects view but not the Documents tree.

Test Plan: {F6627981}

Reviewers: #kate, #vdg, dhaumann

Reviewed By: #kate, #vdg, dhaumann

Subscribers: dhaumann, abetts, ngraham, kwrite-devel

Tags: #kate

Differential Revision: https://phabricator.kde.org/D19197
parent caa72429
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include <KStandardAction> #include <KStandardAction>
#include <KIO/DeleteJob> #include <KIO/DeleteJob>
#include <KIO/CopyJob> #include <KIO/CopyJob>
#include <KIO/OpenFileManagerWindowJob>
#include <QMimeDatabase> #include <QMimeDatabase>
#include <QClipboard> #include <QClipboard>
...@@ -83,6 +84,10 @@ KateFileTree::KateFileTree(QWidget *parent): QTreeView(parent) ...@@ -83,6 +84,10 @@ KateFileTree::KateFileTree(QWidget *parent): QTreeView(parent)
connect(m_filelistCloseOtherDocument, &QAction::triggered, this, &KateFileTree::slotDocumentCloseOther); connect(m_filelistCloseOtherDocument, &QAction::triggered, this, &KateFileTree::slotDocumentCloseOther);
m_filelistCloseOtherDocument->setWhatsThis(i18n("Close other documents in this folder.")); m_filelistCloseOtherDocument->setWhatsThis(i18n("Close other documents in this folder."));
m_filelistOpenContainingFolder = new QAction(QIcon::fromTheme(QStringLiteral("document-open-folder")), i18nc("@action:inmenu", "Open Containing Folder"), this);
connect(m_filelistOpenContainingFolder, &QAction::triggered, this, &KateFileTree::slotOpenContainingFolder);
m_filelistOpenContainingFolder->setWhatsThis(i18n("Open the folder this file is located in."));
m_filelistCopyFilename = new QAction(QIcon::fromTheme(QStringLiteral("edit-copy")), i18nc("@action:inmenu", "Copy File Path"), this); m_filelistCopyFilename = new QAction(QIcon::fromTheme(QStringLiteral("edit-copy")), i18nc("@action:inmenu", "Copy File Path"), this);
connect(m_filelistCopyFilename, &QAction::triggered, this, &KateFileTree::slotCopyFilename); connect(m_filelistCopyFilename, &QAction::triggered, this, &KateFileTree::slotCopyFilename);
m_filelistCopyFilename->setWhatsThis(i18n("Copy path and filename to the clipboard.")); m_filelistCopyFilename->setWhatsThis(i18n("Copy path and filename to the clipboard."));
...@@ -237,6 +242,7 @@ void KateFileTree::contextMenuEvent(QContextMenuEvent *event) ...@@ -237,6 +242,7 @@ void KateFileTree::contextMenuEvent(QContextMenuEvent *event)
if (isFile) { if (isFile) {
menu.addAction(m_filelistCloseOtherDocument); menu.addAction(m_filelistCloseOtherDocument);
menu.addSeparator(); menu.addSeparator();
menu.addAction(m_filelistOpenContainingFolder);
menu.addAction(m_filelistCopyFilename); menu.addAction(m_filelistCopyFilename);
menu.addAction(m_filelistRenameFile); menu.addAction(m_filelistRenameFile);
menu.addAction(m_filelistPrintDocument); menu.addAction(m_filelistPrintDocument);
...@@ -246,6 +252,7 @@ void KateFileTree::contextMenuEvent(QContextMenuEvent *event) ...@@ -246,6 +252,7 @@ void KateFileTree::contextMenuEvent(QContextMenuEvent *event)
connect(openWithMenu, &QMenu::triggered, this, &KateFileTree::slotOpenWithMenuAction); connect(openWithMenu, &QMenu::triggered, this, &KateFileTree::slotOpenWithMenuAction);
const bool hasFileName = doc->url().isValid(); const bool hasFileName = doc->url().isValid();
m_filelistOpenContainingFolder->setEnabled(hasFileName);
m_filelistCopyFilename->setEnabled(hasFileName); m_filelistCopyFilename->setEnabled(hasFileName);
m_filelistRenameFile->setEnabled(hasFileName); m_filelistRenameFile->setEnabled(hasFileName);
m_filelistDeleteDocument->setEnabled(hasFileName); m_filelistDeleteDocument->setEnabled(hasFileName);
...@@ -417,6 +424,14 @@ void KateFileTree::slotDocumentReload() ...@@ -417,6 +424,14 @@ void KateFileTree::slotDocumentReload()
} }
} }
void KateFileTree::slotOpenContainingFolder()
{
KTextEditor::Document *doc = model()->data(m_indexContextMenu, KateFileTreeModel::DocumentRole).value<KTextEditor::Document *>();
if (doc) {
KIO::highlightInFileManager({doc->url()});
}
}
void KateFileTree::slotCopyFilename() void KateFileTree::slotCopyFilename()
{ {
KTextEditor::Document *doc = model()->data(m_indexContextMenu, KateFileTreeModel::DocumentRole).value<KTextEditor::Document *>(); KTextEditor::Document *doc = model()->data(m_indexContextMenu, KateFileTreeModel::DocumentRole).value<KTextEditor::Document *>();
......
...@@ -48,6 +48,7 @@ public Q_SLOTS: ...@@ -48,6 +48,7 @@ public Q_SLOTS:
void slotCollapseRecursive(); void slotCollapseRecursive();
void slotDocumentCloseOther(); void slotDocumentCloseOther();
void slotDocumentReload(); void slotDocumentReload();
void slotOpenContainingFolder();
void slotCopyFilename(); void slotCopyFilename();
void slotCurrentChanged(const QModelIndex &current, const QModelIndex &previous); void slotCurrentChanged(const QModelIndex &current, const QModelIndex &previous);
void slotDocumentFirst(); void slotDocumentFirst();
...@@ -94,6 +95,7 @@ private: ...@@ -94,6 +95,7 @@ private:
QAction *m_filelistCollapseRecursive; QAction *m_filelistCollapseRecursive;
QAction *m_filelistCloseOtherDocument; QAction *m_filelistCloseOtherDocument;
QAction *m_filelistReloadDocument; QAction *m_filelistReloadDocument;
QAction *m_filelistOpenContainingFolder;
QAction *m_filelistCopyFilename; QAction *m_filelistCopyFilename;
QAction *m_filelistRenameFile; QAction *m_filelistRenameFile;
QAction *m_filelistPrintDocument; QAction *m_filelistPrintDocument;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment