Phosphor
Qt6 / Wayland library suite for window-management tools
Loading...
Searching...
No Matches
UPowerHost.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 fuddlesworth
2// SPDX-License-Identifier: LGPL-2.1-or-later
3
4#pragma once
5
6#include <PhosphorServiceUPower/phosphorserviceupower_export.h>
7
9
10#include <QDBusObjectPath>
11#include <QList>
12#include <QObject>
13
14class QDBusConnection;
15
16namespace PhosphorServiceUPower {
17
18class PHOSPHORSERVICEUPOWER_EXPORT UPowerHost : public QObject
19{
20 Q_OBJECT
21 Q_DISABLE_COPY_MOVE(UPowerHost)
22 Q_PROPERTY(bool available READ available NOTIFY availabilityChanged)
23 Q_PROPERTY(bool pending READ pending NOTIFY availabilityChanged)
24 Q_PROPERTY(QString error READ error NOTIFY availabilityChanged)
25 Q_PROPERTY(bool onBattery READ onBattery NOTIFY onBatteryChanged)
27 Q_PROPERTY(int deviceCount READ deviceCount NOTIFY deviceCountChanged)
28
29public:
30 explicit UPowerHost(QObject* parent = nullptr);
31 UPowerHost(const QDBusConnection& bus, const QString& service, QObject* parent = nullptr);
32 ~UPowerHost() override;
33 [[nodiscard]] bool available() const;
34 [[nodiscard]] bool pending() const;
35 [[nodiscard]] QString error() const;
36 Q_INVOKABLE void refresh();
37
38 [[nodiscard]] bool onBattery() const;
39 [[nodiscard]] UPowerDevice* displayDevice() const;
40 [[nodiscard]] int deviceCount() const;
41 [[nodiscard]] QList<UPowerDevice*> devices() const;
42 [[nodiscard]] Q_INVOKABLE PhosphorServiceUPower::UPowerDevice* deviceAt(int index) const;
43
44Q_SIGNALS:
51
52private Q_SLOTS:
53 void _q_onPropertiesChanged(const QString& iface, const QVariantMap& changed, const QStringList& invalidated);
54 void _q_onDeviceAdded(const QDBusObjectPath& path);
55 void _q_onDeviceRemoved(const QDBusObjectPath& path);
56
57private:
58 class Private;
59 std::unique_ptr<Private> d;
60};
61
62} // namespace PhosphorServiceUPower
Definition UPowerDevice.h:18
UPowerDevice * displayDevice() const
QList< UPowerDevice * > devices() const
void deviceAdded(PhosphorServiceUPower::UPowerDevice *device)
void deviceRemoved(PhosphorServiceUPower::UPowerDevice *device)
PhosphorServiceUPower::UPowerDevice * deviceAt(int index) const
UPowerHost(QObject *parent=nullptr)
UPowerHost(const QDBusConnection &bus, const QString &service, QObject *parent=nullptr)
Definition QmlRegistration.h:8