Commit 63deb6a0 authored by Alexander Lohnau's avatar Alexander Lohnau 💬

Kill Runner: Move config keys to new file

Summary:
The config keys/sorting enum have been moved to a new file, before this the runner included the header of the config class.
This patch originated from https://phabricator.kde.org/D27513, but it was requested to split it up into separate patches.

Test Plan: Should compile.

Reviewers: davidedmundson, ngraham, broulik, meven, apol

Reviewed By: meven

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D27576
parent 25babca1
/* Copyright 2009 <Jan Gerrit Marker> <jangerrit@weiler-marker.com>
* Copyright 2020 <Alexander Lohnau> <alexander.lohnau@gmx.de>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) version 3, or any
* later version accepted by the membership of KDE e.V. (or its
* successor approved by the membership of KDE e.V.), which shall
* act as a proxy defined in Section 6 of version 3 of the license.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef KILLRUNNER_CONFIG_KEYS_H
#define KILLRUNNER_CONFIG_KEYS_H
static const char CONFIG_USE_TRIGGERWORD[] = "useTriggerWord";
static const char CONFIG_TRIGGERWORD[] = "triggerWord";
static const char CONFIG_SORTING[] = "sorting";
/** Possibilities to sort */
enum Sort {NONE = 0, CPU, CPUI};
#endif
......@@ -26,12 +26,11 @@
#include <KProcess>
#include <KUser>
#include <kauth.h>
#include <KLocalizedString>
#include "processcore/processes.h"
#include "processcore/process.h"
#include "killrunner_config.h"
K_EXPORT_PLASMA_RUNNER(kill, KillRunner)
KillRunner::KillRunner(QObject *parent, const QVariantList& args)
......@@ -63,7 +62,7 @@ void KillRunner::reloadConfiguration()
m_triggerWord = grp.readEntry(CONFIG_TRIGGERWORD, i18n("kill")) + QLatin1Char(' ');
}
m_sorting = (KillRunnerConfig::Sort) grp.readEntry(CONFIG_SORTING, 0);
m_sorting = (Sort) grp.readEntry(CONFIG_SORTING, static_cast<int>(Sort::NONE));
QList<Plasma::RunnerSyntax> syntaxes;
syntaxes << Plasma::RunnerSyntax(m_triggerWord + QStringLiteral(":q:"),
i18n("Terminate running applications whose names match the query."));
......@@ -147,13 +146,13 @@ void KillRunner::match(Plasma::RunnerContext &context)
// Set the relevance
switch (m_sorting) {
case KillRunnerConfig::CPU:
case Sort::CPU:
match.setRelevance((process->userUsage() + process->sysUsage()) / 100);
break;
case KillRunnerConfig::CPUI:
case Sort::CPUI:
match.setRelevance(1 - (process->userUsage() + process->sysUsage()) / 100);
break;
case KillRunnerConfig::NONE:
case Sort::NONE:
match.setRelevance(name.compare(term, Qt::CaseInsensitive) == 0 ? 1 : 9);
break;
}
......
......@@ -25,7 +25,7 @@
#include <KRunner/AbstractRunner>
#include "killrunner_config.h"
#include "config_keys.h"
class QAction;
namespace KSysGuard
......@@ -61,7 +61,7 @@ private:
QString m_triggerWord;
/** How to sort */
KillRunnerConfig::Sort m_sorting;
Sort m_sorting;
/** process lister */
KSysGuard::Processes *m_processes;
......
......@@ -24,6 +24,7 @@
#include <KSharedConfig>
#include <KPluginFactory>
#include <krunner/abstractrunner.h>
#include "config_keys.h"
K_PLUGIN_FACTORY(KillRunnerConfigFactory, registerPlugin<KillRunnerConfig>(QStringLiteral("kcm_krunner_kill"));)
......
......@@ -26,10 +26,6 @@
#include <KCModule>
//Qt
static const char CONFIG_USE_TRIGGERWORD[] = "useTriggerWord";
static const char CONFIG_TRIGGERWORD[] = "triggerWord";
static const char CONFIG_SORTING[] = "sorting";
class KillRunnerConfigForm : public QWidget, public Ui::KillRunnerConfigUi
{
Q_OBJECT
......@@ -44,9 +40,6 @@ class KillRunnerConfig : public KCModule
public:
explicit KillRunnerConfig(QWidget* parent = nullptr, const QVariantList& args = QVariantList());
/** Possibilities to sort */
enum Sort {NONE = 0, CPU, CPUI};
public Q_SLOTS:
void save() override;
......
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