You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
78 lines
3.2 KiB
78 lines
3.2 KiB
diff --git a/containmentactions/contextmenu/menu.cpp b/containmentactions/contextmenu/menu.cpp
|
|
index 8f5a827..6271a7d 100644
|
|
--- a/containmentactions/contextmenu/menu.cpp
|
|
+++ b/containmentactions/contextmenu/menu.cpp
|
|
@@ -30,6 +30,7 @@
|
|
#include <QIcon>
|
|
#include <KGlobalAccel>
|
|
#include <KLocalizedString>
|
|
+#include <KToolInvocation>
|
|
|
|
#include <Plasma/Containment>
|
|
#include <Plasma/Corona>
|
|
@@ -40,6 +41,7 @@
|
|
|
|
ContextMenu::ContextMenu(QObject *parent, const QVariantList &args)
|
|
: Plasma::ContainmentActions(parent, args),
|
|
+ m_runKonsoleAction(nullptr),
|
|
m_runCommandAction(nullptr),
|
|
m_lockScreenAction(nullptr),
|
|
m_logoutAction(nullptr),
|
|
@@ -79,6 +81,7 @@ void ContextMenu::restore(const KConfigGroup &config)
|
|
<< QStringLiteral("configure shortcuts")
|
|
<< QStringLiteral("_sep1")
|
|
<< QStringLiteral("_context")
|
|
+ << QStringLiteral("_run_konsole")
|
|
<< QStringLiteral("_run_command")
|
|
<< QStringLiteral("add widgets")
|
|
<< QStringLiteral("_add panel")
|
|
@@ -105,6 +108,10 @@ void ContextMenu::restore(const KConfigGroup &config)
|
|
|
|
// everything below should only happen once, so check for it
|
|
if (!m_runCommandAction) {
|
|
+ m_runKonsoleAction = new QAction(i18n("Konsole"), this);
|
|
+ m_runKonsoleAction->setIcon(QIcon::fromTheme("utilities-terminal"));
|
|
+ connect(m_runKonsoleAction, &QAction::triggered, this, &ContextMenu::runKonsole);
|
|
+
|
|
m_runCommandAction = new QAction(i18nc("plasma_containmentactions_contextmenu", "Show KRunner"), this);
|
|
m_runCommandAction->setIcon(QIcon::fromTheme(QStringLiteral("plasma-search")));
|
|
m_runCommandAction->setShortcut(KGlobalAccel::self()->globalShortcut(QStringLiteral("krunner.desktop"), QStringLiteral("_launch")).value(0));
|
|
@@ -185,6 +192,8 @@ QAction *ContextMenu::action(const QString &name)
|
|
if (c->corona() && c->corona()->immutability() == Plasma::Types::Mutable) {
|
|
return c->corona()->actions()->action(QStringLiteral("add panel"));
|
|
}
|
|
+ } else if (name == QLatin1String("_run_konsole")) {
|
|
+ return m_runKonsoleAction;
|
|
} else if (name == QLatin1String("_run_command")) {
|
|
if (KAuthorized::authorizeAction(QStringLiteral("run_command")) && KAuthorized::authorize(QStringLiteral("run_command"))) {
|
|
return m_runCommandAction;
|
|
@@ -212,6 +221,11 @@ QAction *ContextMenu::action(const QString &name)
|
|
return nullptr;
|
|
}
|
|
|
|
+void ContextMenu::runKonsole()
|
|
+{
|
|
+ KToolInvocation::invokeTerminal(QString(), QDir::homePath());
|
|
+}
|
|
+
|
|
void ContextMenu::runCommand()
|
|
{
|
|
if (!KAuthorized::authorizeAction(QStringLiteral("run_command"))) {
|
|
diff --git a/containmentactions/contextmenu/menu.h b/containmentactions/contextmenu/menu.h
|
|
index 813ff38..a157a48 100644
|
|
--- a/containmentactions/contextmenu/menu.h
|
|
+++ b/containmentactions/contextmenu/menu.h
|
|
@@ -42,10 +42,12 @@ public:
|
|
void save(KConfigGroup &config) override;
|
|
|
|
public Q_SLOTS:
|
|
+ void runKonsole();
|
|
void runCommand();
|
|
void startLogout();
|
|
|
|
private:
|
|
+ QAction *m_runKonsoleAction;
|
|
QAction *m_runCommandAction;
|
|
QAction *m_lockScreenAction;
|
|
QAction *m_logoutAction;
|