plasma: proper fix for the inter-depency of kcm_krunner_kill and krunner_kill targets

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2022-09-27 19:32:12 +03:00
parent 347b4042a3
commit 8798ee5053
7 changed files with 68 additions and 38 deletions

View file

@ -1,16 +1,10 @@
project(plasma-runner-kill)
# avoid putting the generated files in target specific
# directory which is the case when automated
set(CMAKE_AUTOUIC OFF)
set(krunner_kill_SRCS killrunner.cpp)
set(kcm_krunner_kill_SRCS
killrunner_config.cpp
)
qt4_wrap_ui(kcm_krunner_kill_SRCS killrunner_config.ui)
kde4_add_plugin(kcm_krunner_kill ${kcm_krunner_kill_SRCS})
target_link_libraries(kcm_krunner_kill
${KDE4_KDECORE_LIBS}
@ -18,15 +12,23 @@ target_link_libraries(kcm_krunner_kill
${KDE4_KCMUTILS_LIBS}
${QT_QTCORE_LIBRARY}
${QT_QTGUI_LIBRARY}
)
)
kde4_add_plugin(krunner_kill ${krunner_kill_SRCS})
target_link_libraries(krunner_kill
${KDE4_PLASMA_LIBS} ${KDE4_KIO_LIBS} processcore)
add_dependencies(krunner_kill kcm_krunner_kill)
${KDE4_PLASMA_LIBS}
${KDE4_KIO_LIBS}
processcore
)
install(TARGETS krunner_kill kcm_krunner_kill
DESTINATION ${KDE4_PLUGIN_INSTALL_DIR})
install(
TARGETS krunner_kill kcm_krunner_kill
DESTINATION ${KDE4_PLUGIN_INSTALL_DIR}
)
install(FILES plasma-runner-kill.desktop plasma-runner-kill_config.desktop
DESTINATION ${KDE4_SERVICES_INSTALL_DIR})
install(
FILES
plasma-runner-kill.desktop
plasma-runner-kill_config.desktop
DESTINATION ${KDE4_SERVICES_INSTALL_DIR}
)

View file

@ -26,8 +26,6 @@
#include <KUser>
#include <KMessageBox>
#include "killrunner_config.h"
#include <signal.h>
KillRunner::KillRunner(QObject *parent, const QVariantList& args)
@ -42,7 +40,6 @@ KillRunner::~KillRunner()
{
}
void KillRunner::reloadConfiguration()
{
KConfigGroup grp = config();
@ -51,7 +48,7 @@ void KillRunner::reloadConfiguration()
m_triggerWord = grp.readEntry(CONFIG_TRIGGERWORD, i18n("kill")) + ' ';
}
m_sorting = (KillRunnerConfig::Sort) grp.readEntry(CONFIG_SORTING, 0);
m_sorting = static_cast<KillRunnerSort>(grp.readEntry(CONFIG_SORTING, static_cast<int>(KillRunnerSort::NONE)));
QList<Plasma::RunnerSyntax> syntaxes;
syntaxes << Plasma::RunnerSyntax(m_triggerWord + ":q:",
i18n("Terminate running applications whose names match the query."));
@ -104,13 +101,13 @@ void KillRunner::match(Plasma::RunnerContext &context)
// Set the relevance
switch (m_sorting) {
case KillRunnerConfig::CPU:
case KillRunnerSort::CPU:
match.setRelevance((process->userUsage + process->sysUsage) / 100);
break;
case KillRunnerConfig::CPUI:
case KillRunnerSort::CPUI:
match.setRelevance(1 - (process->userUsage + process->sysUsage) / 100);
break;
case KillRunnerConfig::NONE:
case KillRunnerSort::NONE:
match.setRelevance(name.compare(term, Qt::CaseInsensitive) == 0 ? 1 : 9);
break;
}

View file

@ -23,9 +23,9 @@
#include <QAction>
#include <Plasma/AbstractRunner>
#include "killrunnerdefs.h"
#include "ksysguard/processcore/processes.h"
#include "ksysguard/processcore/process.h"
#include "killrunner_config.h"
class KillRunner : public Plasma::AbstractRunner
{
@ -50,8 +50,9 @@ private:
QString m_triggerWord;
/** How to sort */
KillRunnerConfig::Sort m_sorting;
KillRunnerSort m_sorting;
};
K_EXPORT_PLASMA_RUNNER(kill, KillRunner)
#endif
#endif // KILLRUNNER_H

View file

@ -18,28 +18,30 @@
*/
//Project-Includes
#include "killrunnerdefs.h"
#include "killrunner_config.h"
//KDE-Includes
#include <plasma/abstractrunner.h>
K_EXPORT_RUNNER_CONFIG(kill, KillRunnerConfig)
KillRunnerConfigForm::KillRunnerConfigForm(QWidget* parent) : QWidget(parent)
KillRunnerConfigForm::KillRunnerConfigForm(QWidget* parent)
: QWidget(parent)
{
setupUi(this);
}
KillRunnerConfig::KillRunnerConfig(QWidget* parent, const QVariantList& args) :
KCModule(KillRunnerConfigFactory::componentData(), parent, args)
KillRunnerConfig::KillRunnerConfig(QWidget* parent, const QVariantList& args)
: KCModule(KillRunnerConfigFactory::componentData(), parent, args)
{
m_ui = new KillRunnerConfigForm(this);
QGridLayout* layout = new QGridLayout(this);
layout->addWidget(m_ui, 0, 0);
m_ui->sorting->addItem(i18n("CPU usage"), CPU);
m_ui->sorting->addItem(i18n("inverted CPU usage"), CPUI);
m_ui->sorting->addItem(i18n("nothing"), NONE);
m_ui->sorting->addItem(i18n("CPU usage"), KillRunnerSort::CPU);
m_ui->sorting->addItem(i18n("inverted CPU usage"), KillRunnerSort::CPUI);
m_ui->sorting->addItem(i18n("nothing"), KillRunnerSort::NONE);
connect(m_ui->useTriggerWord,SIGNAL(stateChanged(int)),this,SLOT(changed()));
connect(m_ui->triggerWord,SIGNAL(textChanged(QString)),this,SLOT(changed()));
@ -58,7 +60,7 @@ void KillRunnerConfig::load()
m_ui->useTriggerWord->setChecked(grp.readEntry(CONFIG_USE_TRIGGERWORD,true));
m_ui->triggerWord->setText(grp.readEntry(CONFIG_TRIGGERWORD,i18n("kill")));
m_ui->sorting->setCurrentIndex(m_ui->sorting->findData(grp.readEntry<int>(CONFIG_SORTING, (int) NONE)));
m_ui->sorting->setCurrentIndex(m_ui->sorting->findData(grp.readEntry<int>(CONFIG_SORTING, (int) KillRunnerSort::NONE)));
emit changed(false);
}

View file

@ -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 = 0, const QVariantList& args = QVariantList());
/** Possibilities to sort */
enum Sort {NONE = 0, CPU, CPUI};
public slots:
void save();
@ -56,4 +49,5 @@ public slots:
private:
KillRunnerConfigForm* m_ui;
};
#endif
#endif // KILLRUNNERCONFIG_H

View file

@ -0,0 +1,34 @@
/* Copyright 2009 Jan Gerrit Marker <jangerrit@weiler-marker.com>
*
* 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 KILLRUNNERDEFS_H
#define KILLRUNNERDEFS_H
/** Possibilities to sort */
enum KillRunnerSort {
NONE = 0,
CPU = 1,
CPUI = 2
};
static const char CONFIG_USE_TRIGGERWORD[] = "useTriggerWord";
static const char CONFIG_TRIGGERWORD[] = "triggerWord";
static const char CONFIG_SORTING[] = "sorting";
#endif // KILLRUNNERDEFS_H