File indexing completed on 2024-12-15 05:06:51
0001 /* 0002 * SPDX-FileCopyrightText: 2010 Dario Freddi <drf@kde.org> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include <powerdevilaction.h> 0010 #include <powerdevilbrightnesslogic.h> 0011 0012 namespace PowerDevil::BundledActions 0013 { 0014 class BrightnessControl : public PowerDevil::Action 0015 { 0016 Q_OBJECT 0017 Q_CLASSINFO("D-Bus Interface", "org.kde.Solid.PowerManagement.Actions.BrightnessControl") 0018 0019 public: 0020 explicit BrightnessControl(QObject *parent); 0021 0022 protected: 0023 void onProfileLoad(const QString &previousProfile, const QString &newProfile) override; 0024 void triggerImpl(const QVariantMap &args) override; 0025 bool isSupported() override; 0026 0027 public: 0028 bool loadAction(const PowerDevil::ProfileSettings &profileSettings) override; 0029 0030 int brightness() const; 0031 int brightnessMax() const; 0032 int brightnessSteps() const; 0033 0034 public Q_SLOTS: 0035 // DBus export 0036 void increaseBrightness(); 0037 void increaseBrightnessSmall(); 0038 void decreaseBrightness(); 0039 void decreaseBrightnessSmall(); 0040 void setBrightness(int percent); 0041 void setBrightnessSilent(int percent); 0042 0043 private Q_SLOTS: 0044 void onBrightnessChangedFromCore(const BrightnessLogic::BrightnessInfo &brightnessInfo); 0045 0046 Q_SIGNALS: 0047 void brightnessChanged(int value); 0048 void brightnessMaxChanged(int valueMax); 0049 0050 private: 0051 int brightnessPercent(float value) const; 0052 0053 int m_defaultValue = -1; 0054 }; 0055 0056 }