File indexing completed on 2024-05-05 17:45:02
0001 /* 0002 SPDX-FileCopyrightText: 2008 Dario Freddi <drf@kdemod.ath.cx> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include <KRunner/AbstractRunner> 0010 #include <QDBusConnection> 0011 0012 class SessionManagement; 0013 0014 struct RunnerKeyword { 0015 QString triggerWord; 0016 QString translatedTriggerWord; 0017 bool supportPartialMatch = true; 0018 }; 0019 0020 class PowerDevilRunner : public Plasma::AbstractRunner 0021 { 0022 Q_OBJECT 0023 public: 0024 PowerDevilRunner(QObject *parent, const KPluginMetaData &metaData, const QVariantList &args); 0025 ~PowerDevilRunner() override; 0026 0027 void match(Plasma::RunnerContext &context) override; 0028 void run(const Plasma::RunnerContext &context, const Plasma::QueryMatch &action) override; 0029 0030 private Q_SLOTS: 0031 void updateStatus(); 0032 0033 private: 0034 void updateSyntaxes(); 0035 void addSuspendMatch(int value, QList<Plasma::QueryMatch> &matches, Plasma::QueryMatch::Type type); 0036 // Returns -1 if there is no match, otherwise the percentage that the user has entered 0037 int matchesScreenBrightnessKeywords(const QString &query) const; 0038 bool matchesRunnerKeywords(const QList<RunnerKeyword> &keywords, Plasma::QueryMatch::Type &type, const QString &query) const; 0039 void addSyntaxForKeyword(const QList<RunnerKeyword> &keywords, const QString &description); 0040 0041 SessionManagement *m_session; 0042 RunnerKeyword m_suspend, m_toRam; 0043 RunnerKeyword m_sleep; 0044 RunnerKeyword m_hibernate, m_toDisk; 0045 RunnerKeyword m_dimScreen; 0046 RunnerKeyword m_screenBrightness; 0047 };