Commit e93a1d28 authored by Krzysztof Stokop's avatar Krzysztof Stokop
Browse files

Open terminal here

parent 3b73cba7
......@@ -27,6 +27,7 @@
#include <QMimeDatabase>
#include <QMimeType>
#include <QStandardPaths>
#include <KToolInvocation>
static QString getName()
{
......@@ -62,6 +63,8 @@ void KateProjectTreeViewContextMenu::exec(const QString &filename, const QModelI
*/
QAction *copyAction = menu.addAction(QIcon::fromTheme(QStringLiteral("edit-copy")), i18n("Copy File Path"));
QAction* terminal = menu.addAction(QIcon::fromTheme(QStringLiteral("utilities-terminal")), i18n("Open Terminal here"));
/**
* Handle "open with",
* find correct mimetype to query for possible applications
......@@ -116,6 +119,15 @@ void KateProjectTreeViewContextMenu::exec(const QString &filename, const QModelI
job->start();
};
auto terminalLambda = [](const QString &filename)
{
QFileInfo checkFile(filename);
if (QUrl::fromLocalFile(filename).isLocalFile() && checkFile.isFile())
KToolInvocation::invokeTerminal(QString(), {}, QUrl::fromLocalFile(filename).toString(QUrl::RemoveFilename | QUrl::RemoveScheme));
if (QUrl::fromLocalFile(filename).isLocalFile() && checkFile.isDir())
KToolInvocation::invokeTerminal(QString(), {}, filename);
};
// we can ATM only handle file renames
QAction *rename = nullptr;
if (index.data(KateProjectItem::TypeRole).toInt() == KateProjectItem::File) {
......@@ -131,7 +143,11 @@ void KateProjectTreeViewContextMenu::exec(const QString &filename, const QModelI
} else if (action->parentWidget() == openWithMenu) {
// handle "open with"
handleOpenWith(action, filename);
} else if (action == openContaingFolderAction) {
}
else if (action == terminal) {
// handle "open terminal here"
terminalLambda(filename);
}else if (action == openContaingFolderAction) {
KIO::highlightInFileManager({QUrl::fromLocalFile(filename)});
} else if (action == filePropertiesAction) {
// code copied and adapted from frameworks/kio/src/filewidgets/knewfilemenu.cpp
......
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