/* * Copyright (C) 2011 ~ 2022 Deepin Technology Co., Ltd. * * Author: donghualin * * Maintainer: donghualin * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef BRIGHTNESSMODEL_H #define BRIGHTNESSMODEL_H #include #include class BrightMonitor; class QDBusMessage; class QScreen; class BrightnessModel : public QObject { Q_OBJECT public: explicit BrightnessModel(QObject *parent = nullptr); ~BrightnessModel(); QList monitors(); BrightMonitor *primaryMonitor() const; Q_SIGNALS: void primaryChanged(BrightMonitor *); void screenVisibleChanged(bool); protected Q_SLOTS: void primaryScreenChanged(QScreen *screen); void onPropertyChanged(const QDBusMessage &msg); private: QList readMonitors(const QList &paths); private: QList m_monitor; QString m_primaryScreenName; }; class BrightMonitor : public QObject { Q_OBJECT public: explicit BrightMonitor(QString path, QObject *parent); ~BrightMonitor(); Q_SIGNALS: void brightnessChanged(int); void nameChanged(QString); void enabledChanged(bool); public: void setPrimary(bool primary); int brightness(); bool enabled(); QString name(); bool isPrimary(); public slots: void setBrightness(int value); void onPropertyChanged(const QDBusMessage &msg); private: QDBusMessage callMethod(const QString &methodName, const QList &argument); private: QString m_path; QString m_name; int m_brightness; bool m_enabled; bool m_isPrimary; }; #endif // DISPLAYMODEL_H