Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Utilities
Kate
Commits
96673513
Commit
96673513
authored
May 24, 2021
by
Christoph Cullmann
🐮
Browse files
group internal & external terminal open
both works for directories and files
!410
parent
eb71fc2f
Changes
1
Hide whitespace changes
Inline
Side-by-side
addons/project/kateprojecttreeviewcontextmenu.cpp
View file @
96673513
...
...
@@ -71,11 +71,6 @@ void KateProjectTreeViewContextMenu::exec(const QString &filename, const QModelI
if
(
index
.
data
(
KateProjectItem
::
TypeRole
).
toInt
()
==
KateProjectItem
::
Directory
)
{
addFile
=
menu
.
addAction
(
QIcon
::
fromTheme
(
QStringLiteral
(
"document-new"
)),
i18n
(
"Add File"
));
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
...
...
@@ -111,14 +106,24 @@ void KateProjectTreeViewContextMenu::exec(const QString &filename, const QModelI
openWithMenu
->
setEnabled
(
!
openWithMenu
->
isEmpty
());
/**
* Open
Containing fold
er
* Open
external terminal h
er
e
*/
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 h
er
e
* Open
Containing fold
er
*/
QAction
*
terminal
=
menu
.
addAction
(
QIcon
::
fromTheme
(
QStringLiteral
(
"
utilities-terminal
"
)),
i18n
(
"Open
External Terminal H
er
e
"
));
auto
openContaingFolderAction
=
menu
.
addAction
(
QIcon
::
fromTheme
(
QStringLiteral
(
"
document-open-folder
"
)),
i18n
(
"
&
Open
Containing Fold
er"
));
/**
* Git menu
...
...
@@ -175,9 +180,9 @@ void KateProjectTreeViewContextMenu::exec(const QString &filename, const QModelI
}
else
if
(
action
==
terminal
)
{
// handle "open terminal here"
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
())
{
if
(
checkFile
.
isFile
())
{
KToolInvocation
::
invokeTerminal
(
QString
(),
{},
checkFile
.
absolutePath
(
));
}
else
{
KToolInvocation
::
invokeTerminal
(
QString
(),
{},
filename
);
}
}
else
if
(
action
->
parentWidget
()
==
openWithMenu
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment