DtkSystemSettings
dtk library for systemsettings.
载入中...
搜索中...
未找到
dpowermanager.h
浏览该文件的文档.
1// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: LGPL-3.0-or-later
4
5#pragma once
6
7#include "dtkpower_global.h"
8
9#include <dexpected.h>
10#include <qobject.h>
11
12DPOWER_BEGIN_NAMESPACE
13using DCORE_NAMESPACE::DExpected;
14
15class DPowerManagerPrivate;
16class DPowerDevice;
17class DKbdBacklight;
18
19class DPowerManager : public QObject
20{
21 Q_OBJECT
22public:
23 explicit DPowerManager(QObject *parent = nullptr);
24 virtual ~DPowerManager();
25 // properties
26 Q_PROPERTY(bool lidIsClosed READ lidIsClosed NOTIFY lidIsClosedChanged);
27 Q_PROPERTY(bool lidIsPresent READ lidIsPresent NOTIFY lidIsPresentChanged);
28 Q_PROPERTY(bool hasBattery READ hasBattery);
29 Q_PROPERTY(bool onBattery READ onBattery);
30 Q_PROPERTY(bool supportKbdBacklight READ supportKbdBacklight);
31 Q_PROPERTY(QString daemonVersion READ daemonVersion);
32 bool lidIsClosed() const;
33 bool lidIsPresent() const;
34 bool hasBattery() const;
35 bool onBattery() const;
36 bool supportKbdBacklight() const;
37 QString daemonVersion() const;
38 QSharedPointer<DPowerDevice> displayDevice() const;
39 QSharedPointer<DPowerDevice> findDeviceByName(const QString &name) const;
40 QSharedPointer<DKbdBacklight> kbdBacklight() const;
41
42signals:
43 void deviceAdded(const QString &name);
44 void deviceRemoved(const QString &name);
45 void lidIsClosedChanged(const bool &value);
46 void lidIsPresentChanged(const bool &value);
47
48public slots:
49 DExpected<QStringList> devices() const;
50 DExpected<QString> criticalAction() const;
51 DExpected<void> refresh();
52
53private:
54 QScopedPointer<DPowerManagerPrivate> d_ptr;
55 Q_DECLARE_PRIVATE(DPowerManager)
56};
57
58DPOWER_END_NAMESPACE
电源设备管理类, 用于管理电源设备, 包括电源设备的创建, 电源设备的属性获取, 电源设备的状态获取等
Definition dpowermanager.h:20
QSharedPointer< DPowerDevice > displayDevice() const
当前显示的电源设备(这是一个表示要在桌面环境中显示的状态图标的复合设备, docker栏显示的电源图标指向的电源设备)
DExpected< QString > criticalAction() const
获取当电源严重不足的情况下, 电脑采取的操作
bool lidIsClosed() const
笔记本盖子关闭(或者二合一设备关上皮套)通过霍尔传感器读取相关数值
DExpected< void > refresh()
刷新设备列表
bool onBattery() const
系统是否使用电池电源运行
DExpected< QStringList > devices() const
枚举电源设备, 将此计算机上的电源设备以QStringList的方式列举
QString daemonVersion() const
守护程序版本
void deviceRemoved(const QString &name)
信号:设备被移除
bool hasBattery() const
系统是否具有电池
void deviceAdded(const QString &name)
信号:有新的设备被接入
bool lidIsPresent() const
笔记本盖子传感器是否有效
QSharedPointer< DKbdBacklight > kbdBacklight() const
创建键盘背光设备对象
void lidIsClosedChanged(const bool &value)
信号:笔记本盖子被关闭
QSharedPointer< DPowerDevice > findDeviceByName(const QString &name) const
通过设备名创建设备对象
void lidIsPresentChanged(const bool &value)
信号:笔记本盖子传感器启用状态发生改变
bool supportKbdBacklight() const
获取设备是否支持系统级调整键盘背光