Commit 96673513 authored by Christoph Cullmann's avatar Christoph Cullmann 🐮
Browse files

group internal & external terminal open

both works for directories and files

utilities/kate!410
parent eb71fc2f
...@@ -71,11 +71,6 @@ void KateProjectTreeViewContextMenu::exec(const QString &filename, const QModelI ...@@ -71,11 +71,6 @@ void KateProjectTreeViewContextMenu::exec(const QString &filename, const QModelI
if (index.data(KateProjectItem::TypeRole).toInt() == KateProjectItem::Directory) { if (index.data(KateProjectItem::TypeRole).toInt() == KateProjectItem::Directory) {
addFile = menu.addAction(QIcon::fromTheme(QStringLiteral("document-new")), i18n("Add File")); addFile = menu.addAction(QIcon::fromTheme(QStringLiteral("document-new")), i18n("Add File"));
addFolder = menu.addAction(QIcon::fromTheme(QStringLiteral("folder-new")), i18n("Add Folder")); addFolder = menu.addAction(QIcon::fromTheme(QStringLiteral("folder-new")), i18n("Add Folder"));
if (KateProjectInfoViewTerminal::isLoadable()) {
menu.addAction(QIcon::fromTheme(QStringLiteral("terminal")), i18n("Open Terminal"), [parent, &filename]() {
parent->openTerminal(filename);
});
}
} }
// we can ATM only handle file renames // we can ATM only handle file renames
...@@ -111,14 +106,24 @@ void KateProjectTreeViewContextMenu::exec(const QString &filename, const QModelI ...@@ -111,14 +106,24 @@ void KateProjectTreeViewContextMenu::exec(const QString &filename, const QModelI
openWithMenu->setEnabled(!openWithMenu->isEmpty()); openWithMenu->setEnabled(!openWithMenu->isEmpty());
/** /**
* Open Containing folder * Open external terminal here
*/ */
auto openContaingFolderAction = menu.addAction(QIcon::fromTheme(QStringLiteral("document-open-folder")), i18n("&Open Containing Folder")); if (KateProjectInfoViewTerminal::isLoadable()) {
menu.addAction(QIcon::fromTheme(QStringLiteral("terminal")), i18n("Open Internal Terminal Here"), [parent, &filename]() {
QFileInfo checkFile(filename);
if (checkFile.isFile()) {
parent->openTerminal(checkFile.absolutePath());
} else {
parent->openTerminal(filename);
}
});
}
QAction *terminal = menu.addAction(QIcon::fromTheme(QStringLiteral("utilities-terminal")), i18n("Open External Terminal Here"));
/** /**
* Open external terminal here * Open Containing folder
*/ */
QAction *terminal = menu.addAction(QIcon::fromTheme(QStringLiteral("utilities-terminal")), i18n("Open External Terminal Here")); auto openContaingFolderAction = menu.addAction(QIcon::fromTheme(QStringLiteral("document-open-folder")), i18n("&Open Containing Folder"));
/** /**
* Git menu * Git menu
...@@ -175,9 +180,9 @@ void KateProjectTreeViewContextMenu::exec(const QString &filename, const QModelI ...@@ -175,9 +180,9 @@ void KateProjectTreeViewContextMenu::exec(const QString &filename, const QModelI
} else if (action == terminal) { } else if (action == terminal) {
// handle "open terminal here" // handle "open terminal here"
QFileInfo checkFile(filename); QFileInfo checkFile(filename);
if (QUrl::fromLocalFile(filename).isLocalFile() && checkFile.isFile()) { if (checkFile.isFile()) {
KToolInvocation::invokeTerminal(QString(), {}, QUrl::fromLocalFile(filename).toString(QUrl::RemoveFilename | QUrl::RemoveScheme)); KToolInvocation::invokeTerminal(QString(), {}, checkFile.absolutePath());
} if (QUrl::fromLocalFile(filename).isLocalFile() && checkFile.isDir()) { } else {
KToolInvocation::invokeTerminal(QString(), {}, filename); KToolInvocation::invokeTerminal(QString(), {}, filename);
} }
} else if (action->parentWidget() == openWithMenu) { } else if (action->parentWidget() == openWithMenu) {
......
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