2023-02-16 13:51:55 +08:00
|
|
|
// Copyright (C) 2011 ~ 2022 Deepin Technology Co., Ltd.
|
|
|
|
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
2022-11-28 14:37:54 +08:00
|
|
|
|
|
|
|
#ifndef BRIGHTNESSMODEL_H
|
|
|
|
#define BRIGHTNESSMODEL_H
|
|
|
|
|
2022-11-28 19:24:43 +08:00
|
|
|
#include <QDBusObjectPath>
|
2022-11-28 14:37:54 +08:00
|
|
|
#include <QObject>
|
|
|
|
|
|
|
|
class BrightMonitor;
|
|
|
|
class QDBusMessage;
|
|
|
|
class QScreen;
|
|
|
|
|
|
|
|
class BrightnessModel : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit BrightnessModel(QObject *parent = nullptr);
|
|
|
|
~BrightnessModel();
|
|
|
|
|
|
|
|
QList<BrightMonitor *> monitors();
|
|
|
|
BrightMonitor *primaryMonitor() const;
|
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
void primaryChanged(BrightMonitor *);
|
2023-09-13 18:05:20 +08:00
|
|
|
void monitorChanged();
|
2023-09-04 14:59:26 +08:00
|
|
|
void monitorLightChanged();
|
2022-11-28 14:37:54 +08:00
|
|
|
|
|
|
|
protected Q_SLOTS:
|
|
|
|
void primaryScreenChanged(QScreen *screen);
|
2022-11-28 19:24:43 +08:00
|
|
|
void onPropertyChanged(const QDBusMessage &msg);
|
|
|
|
|
|
|
|
private:
|
|
|
|
QList<BrightMonitor *> readMonitors(const QList<QDBusObjectPath> &paths);
|
2022-11-28 14:37:54 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
QList<BrightMonitor *> m_monitor;
|
2022-11-28 19:24:43 +08:00
|
|
|
QString m_primaryScreenName;
|
2022-11-28 14:37:54 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
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<QVariant> &argument);
|
|
|
|
|
|
|
|
private:
|
|
|
|
QString m_path;
|
|
|
|
QString m_name;
|
|
|
|
int m_brightness;
|
|
|
|
bool m_enabled;
|
|
|
|
bool m_isPrimary;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // DISPLAYMODEL_H
|