diff --git a/runners/shell/CMakeLists.txt b/runners/shell/CMakeLists.txt --- a/runners/shell/CMakeLists.txt +++ b/runners/shell/CMakeLists.txt @@ -1,20 +1,15 @@ add_definitions(-DTRANSLATION_DOMAIN=\"plasma_runner_shell\") -set(krunner_shell_SRCS - shellrunner.cpp - shell_config.cpp -) +set(krunner_shell_SRCS shellrunner.cpp) -ki18n_wrap_ui(krunner_shell_SRCS shellOptions.ui) add_library(krunner_shell MODULE ${krunner_shell_SRCS}) target_link_libraries(krunner_shell KF5::KIOCore KF5::KIOWidgets KF5::I18n KF5::Plasma KF5::Runner KF5::Completion - Qt5::Widgets ) install(TARGETS krunner_shell DESTINATION ${KDE_INSTALL_PLUGINDIR}) diff --git a/runners/shell/shellOptions.ui b/runners/shell/shellOptions.ui deleted file mode 100644 --- a/runners/shell/shellOptions.ui +++ /dev/null @@ -1,264 +0,0 @@ - - - shellOptions - - - - 0 - 0 - 325 - 112 - - - - - 0 - 0 - - - - - 0 - - - 3 - - - - - 3 - - - 0 - - - - - QFrame::NoFrame - - - QFrame::Raised - - - - 0 - - - 3 - - - - - false - - - - 0 - 0 - - - - Enter the user you want to run the application as here. - - - User&name: - - - leUsername - - - - - - - false - - - - 5 - 0 - - - - Enter the password here for the user you specified above. - - - QLineEdit::Password - - - - - - - false - - - - 0 - 0 - - - - Enter the password here for the user you specified above. - - - Pass&word: - - - lePassword - - - - - - - Check this option if the application you want to run is a text mode application. The application will then be run in a terminal emulator window. - - - Run in &terminal window - - - - - - - false - - - - 5 - 0 - - - - Enter the user you want to run the application as here. - - - - - - - Check this option if you want to run the application with a different user id. Every process has a user id associated with it. This id code determines file access and other permissions. The password of the user is required to do this. - - - Run as a different &user - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 20 - 40 - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - - - KLineEdit - QLineEdit -
klineedit.h
-
-
- - cbRunInTerminal - cbRunAsOther - leUsername - lePassword - - - - - cbRunAsOther - toggled(bool) - lbUsername - setEnabled(bool) - - - 153 - 59 - - - 96 - 62 - - - - - cbRunAsOther - toggled(bool) - leUsername - setEnabled(bool) - - - 127 - 59 - - - 188 - 62 - - - - - cbRunAsOther - toggled(bool) - lbPassword - setEnabled(bool) - - - 81 - 45 - - - 146 - 101 - - - - - cbRunAsOther - toggled(bool) - lePassword - setEnabled(bool) - - - 114 - 41 - - - 323 - 101 - - - - -
diff --git a/runners/shell/shell_config.h b/runners/shell/shell_config.h deleted file mode 100644 --- a/runners/shell/shell_config.h +++ /dev/null @@ -1,45 +0,0 @@ -/*************************************************************************** - * Copyright 2008 by Montel Laurent * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * - ***************************************************************************/ - -#ifndef SHELLCONFIG_H -#define SHELLCONFIG_H - -#include - -#include - -#include "ui_shellOptions.h" - -class ShellConfig : public QWidget -{ - Q_OBJECT - public: - explicit ShellConfig(const KConfigGroup &config, QWidget* parent = nullptr); - ~ShellConfig() override; - - Ui::shellOptions m_ui; - - protected Q_SLOTS: - void slotUpdateUser(bool); - - private: - KConfigGroup m_config; -}; - -#endif diff --git a/runners/shell/shell_config.cpp b/runners/shell/shell_config.cpp deleted file mode 100644 --- a/runners/shell/shell_config.cpp +++ /dev/null @@ -1,60 +0,0 @@ - -/*************************************************************************** - * Copyright 2008 by Montel Laurent * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * - ***************************************************************************/ - -#include "shell_config.h" - - -#include -#include -#include -#include - -#include - -ShellConfig::ShellConfig(const KConfigGroup &config, QWidget* parent) - : QWidget(parent), - m_config(config) -{ - QHBoxLayout *hboxLayout = new QHBoxLayout(parent); - hboxLayout->addWidget(this); - m_ui.setupUi(this); - -#ifdef Q_OS_UNIX - connect(m_ui.cbRunAsOther, &QAbstractButton::clicked, this, &ShellConfig::slotUpdateUser); -#else - m_ui.cbRunAsOther->hide(); - m_ui.lbUsername->hide(); - m_ui.leUsername->hide(); - m_ui.lbPassword->hide(); - m_ui.lePassword->hide(); -#endif -} - -ShellConfig::~ShellConfig() -{ -} - -void ShellConfig::slotUpdateUser(bool b) -{ - if (b) { - m_ui.leUsername->setFocus(); - } -} - diff --git a/runners/shell/shellrunner.h b/runners/shell/shellrunner.h --- a/runners/shell/shellrunner.h +++ b/runners/shell/shellrunner.h @@ -19,7 +19,7 @@ #ifndef SHELLRUNNER_H #define SHELLRUNNER_H -#include +#include /** * This class runs programs using the literal name of the binary, much as one @@ -39,6 +39,8 @@ private: bool m_enabled; + QList m_actionList; + QIcon m_matchIcon; }; diff --git a/runners/shell/shellrunner.cpp b/runners/shell/shellrunner.cpp --- a/runners/shell/shellrunner.cpp +++ b/runners/shell/shellrunner.cpp @@ -20,77 +20,63 @@ #include "shellrunner.h" #include -#include #include #include -#include -#include #include -#include - -#include "shell_config.h" - K_EXPORT_PLASMA_RUNNER(shell, ShellRunner) -static QString s_runInTerminalId = QStringLiteral("runInTerminal"); - ShellRunner::ShellRunner(QObject *parent, const QVariantList &args) : Plasma::AbstractRunner(parent, args) { - setObjectName( QLatin1String("Command" )); + setObjectName(QStringLiteral("Command")); setPriority(AbstractRunner::HighestPriority); - setHasRunOptions(true); m_enabled = KAuthorized::authorize(QStringLiteral("run_command")) && KAuthorized::authorize(QStringLiteral("shell_access")); setIgnoredTypes(Plasma::RunnerContext::Directory | Plasma::RunnerContext::File | Plasma::RunnerContext::NetworkLocation | Plasma::RunnerContext::UnknownType | Plasma::RunnerContext::Help); addSyntax(Plasma::RunnerSyntax(QStringLiteral(":q:"), i18n("Finds commands that match :q:, using common shell syntax"))); - addAction(s_runInTerminalId, QIcon::fromTheme(QStringLiteral("utilities-terminal")), i18n("Run in Terminal Window")); + m_actionList = {addAction(QStringLiteral("runInTerminal"), + QIcon::fromTheme(QStringLiteral("utilities-terminal")), + i18n("Run in Terminal Window"))}; + m_matchIcon = QIcon::fromTheme(QStringLiteral("system-run")); } ShellRunner::~ShellRunner() { } void ShellRunner::match(Plasma::RunnerContext &context) { - if (!m_enabled) { + if (!context.isValid() || !m_enabled) { return; } - if (context.type() == Plasma::RunnerContext::Executable || - context.type() == Plasma::RunnerContext::ShellCommand) { - const QString term = context.query(); - Plasma::QueryMatch match(this); - match.setId(term); - match.setType(Plasma::QueryMatch::ExactMatch); - match.setIconName(QStringLiteral("system-run")); - match.setText(i18n("Run %1", term)); - match.setRelevance(0.7); - context.addMatch(match); - } + const QString term = context.query(); + Plasma::QueryMatch match(this); + match.setId(term); + match.setType(Plasma::QueryMatch::ExactMatch); + match.setIcon(m_matchIcon); + match.setText(i18n("Run %1", term)); + match.setRelevance(0.7); + context.addMatch(match); } void ShellRunner::run(const Plasma::RunnerContext &context, const Plasma::QueryMatch &match) { - Q_UNUSED(match); - - if (m_enabled) { - if (match.selectedAction() && match.selectedAction() == action(s_runInTerminalId)) { - KToolInvocation::invokeTerminal(context.query()); - } else { - KRun::runCommand(context.query(), nullptr); - } + if (match.selectedAction()) { + KToolInvocation::invokeTerminal(context.query()); + } else { + KRun::runCommand(context.query(), nullptr); } } QList ShellRunner::actionsForMatch(const Plasma::QueryMatch &match) { Q_UNUSED(match) - return {action(s_runInTerminalId)}; + return m_actionList; } #include "shellrunner.moc"