File indexing completed on 2024-05-12 05:38:44
0001 /* This file is part of the KDE project 0002 SPDX-FileCopyrightText: 2006 Kevin Ottens <ervin@kde.org> 0003 SPDX-FileCopyrightText: 2008-2010 Dario Freddi <drf@kde.org> 0004 SPDX-FileCopyrightText: 2010 Alejandro Fiestas <alex@eyeos.org> 0005 SPDX-FileCopyrightText: 2015 Kai Uwe Broulik <kde@privat.broulik.de> 0006 0007 SPDX-License-Identifier: LGPL-2.0-only 0008 0009 */ 0010 0011 #pragma once 0012 0013 #include <QObject> 0014 0015 #include <powerdevilcore_export.h> 0016 0017 #include "powerdevilscreenbrightnesslogic.h" 0018 0019 class QPropertyAnimation; 0020 class BacklightBrightness; 0021 class DDCutilBrightness; 0022 0023 class POWERDEVILCORE_EXPORT ScreenBrightnessController : public QObject 0024 { 0025 Q_OBJECT 0026 public: 0027 ScreenBrightnessController(); 0028 0029 int screenBrightness() const; 0030 int screenBrightnessMax() const; 0031 void setScreenBrightness(int value); 0032 bool screenBrightnessAvailable() const; 0033 int screenBrightnessSteps(); 0034 0035 int screenBrightnessKeyPressed(PowerDevil::BrightnessLogic::BrightnessKeyType type); 0036 0037 Q_SIGNALS: 0038 void detectionFinished(); 0039 void screenBrightnessChanged(const PowerDevil::BrightnessLogic::BrightnessInfo &brightnessInfo); 0040 0041 private: 0042 void enumerateDevices(); 0043 void addDevice(const QString &); 0044 int calculateNextScreenBrightnessStep(int value, int valueMax, PowerDevil::BrightnessLogic::BrightnessKeyType keyType); 0045 0046 private Q_SLOTS: 0047 void onBacklightDetectionFinished(bool isSupported); 0048 void ddcScreenBrightnessChanged(); 0049 void onScreenBrightnessChanged(int value, int valueMax); 0050 0051 private: 0052 void animationValueChanged(const QVariant &value); 0053 0054 int m_cachedBrightness = 0; 0055 bool m_screenBrightnessAvailable = false; 0056 PowerDevil::ScreenBrightnessLogic m_screenBrightnessLogic; 0057 0058 BacklightBrightness *m_backlightBrightnessControl; 0059 DDCutilBrightness *m_ddcBrightnessControl; 0060 0061 QPropertyAnimation *m_brightnessAnimation = nullptr; 0062 const int m_brightnessAnimationDurationMsec = 250; 0063 const int m_brightnessAnimationThreshold = 100; 0064 };