diff --git a/plasma/runners/kill/CMakeLists.txt b/plasma/runners/kill/CMakeLists.txt index 744c73f3..8e202928 100644 --- a/plasma/runners/kill/CMakeLists.txt +++ b/plasma/runners/kill/CMakeLists.txt @@ -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} +) diff --git a/plasma/runners/kill/TODO b/plasma/runners/kill/TODO deleted file mode 100644 index e69de29b..00000000 diff --git a/plasma/runners/kill/killrunner.cpp b/plasma/runners/kill/killrunner.cpp index 81d7bdb8..c8faa5e6 100644 --- a/plasma/runners/kill/killrunner.cpp +++ b/plasma/runners/kill/killrunner.cpp @@ -26,8 +26,6 @@ #include #include -#include "killrunner_config.h" - #include 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(grp.readEntry(CONFIG_SORTING, static_cast(KillRunnerSort::NONE))); QList 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; } diff --git a/plasma/runners/kill/killrunner.h b/plasma/runners/kill/killrunner.h index 92e5dd37..c6f0333c 100644 --- a/plasma/runners/kill/killrunner.h +++ b/plasma/runners/kill/killrunner.h @@ -23,9 +23,9 @@ #include #include +#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 diff --git a/plasma/runners/kill/killrunner_config.cpp b/plasma/runners/kill/killrunner_config.cpp index bdb882b9..1c20960c 100644 --- a/plasma/runners/kill/killrunner_config.cpp +++ b/plasma/runners/kill/killrunner_config.cpp @@ -18,28 +18,30 @@ */ //Project-Includes +#include "killrunnerdefs.h" #include "killrunner_config.h" //KDE-Includes #include 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(CONFIG_SORTING, (int) NONE))); + m_ui->sorting->setCurrentIndex(m_ui->sorting->findData(grp.readEntry(CONFIG_SORTING, (int) KillRunnerSort::NONE))); emit changed(false); } diff --git a/plasma/runners/kill/killrunner_config.h b/plasma/runners/kill/killrunner_config.h index 3e015c2f..23c863bc 100644 --- a/plasma/runners/kill/killrunner_config.h +++ b/plasma/runners/kill/killrunner_config.h @@ -26,10 +26,6 @@ #include //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 diff --git a/plasma/runners/kill/killrunnerdefs.h b/plasma/runners/kill/killrunnerdefs.h new file mode 100644 index 00000000..cdefc8d2 --- /dev/null +++ b/plasma/runners/kill/killrunnerdefs.h @@ -0,0 +1,34 @@ +/* Copyright 2009 Jan Gerrit Marker + * + * 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 . + */ + +#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