File indexing completed on 2024-05-12 05:38:44
0001 /* This file is part of the KDE project 0002 * SPDX-FileCopyrightText: 2010 Lukas Tinkl <ltinkl@redhat.com> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.0-only 0005 * 0006 */ 0007 0008 #pragma once 0009 0010 #include <QObject> 0011 #include <QVariantAnimation> 0012 0013 #include <KAuth/ActionReply> 0014 #include <KAuth/HelperSupport> 0015 #include <kauth_version.h> 0016 0017 using namespace KAuth; 0018 0019 class BacklightHelper : public QObject 0020 { 0021 Q_OBJECT 0022 public: 0023 explicit BacklightHelper(QObject *parent = nullptr); 0024 0025 public Q_SLOTS: 0026 ActionReply brightness(const QVariantMap &args); 0027 ActionReply brightnessmax(const QVariantMap &args); 0028 ActionReply setbrightness(const QVariantMap &args); 0029 ActionReply syspath(const QVariantMap &args); 0030 0031 private: 0032 void init(); 0033 0034 int readBrightness() const; 0035 bool writeBrightness(int brightness) const; 0036 0037 int readFromDevice(const QString &device, const QString &property) const; 0038 bool writeToDevice(const QString &device, int brightness) const; 0039 0040 /** 0041 * The kernel offer from version 2.6.37 the type of the interface, and based on that 0042 * we can decide which interface is better for us, being the order 0043 * firmware-platform-raw 0044 */ 0045 void initUsingBacklightType(); 0046 QStringList getBacklightTypeDevices() const; 0047 0048 bool m_isSupported = false; 0049 QString m_sysctlDevice; 0050 QList<int> m_sysctlBrightnessLevels; 0051 QList<QPair<QString /*device path*/, int /*max brightness*/>> m_devices; 0052 0053 QVariantAnimation m_anim; 0054 };