Phosphor
Qt6 / Wayland library suite for window-management tools
Loading...
Searching...
No Matches
BrightnessDeviceModel.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 <PhosphorServiceBrightness/phosphorservicebrightness_export.h>
7
10
11#include <QAbstractListModel>
12
14
20class PHOSPHORSERVICEBRIGHTNESS_EXPORT BrightnessDeviceModel : public QAbstractListModel
21{
22 Q_OBJECT
23 Q_DISABLE_COPY_MOVE(BrightnessDeviceModel)
25 Q_PROPERTY(int count READ rowCount NOTIFY countChanged)
26
27public:
37 Q_ENUM(Roles)
38
39 explicit BrightnessDeviceModel(QObject* parent = nullptr);
41
42 [[nodiscard]] BrightnessHost* host() const;
44
45 [[nodiscard]] int rowCount(const QModelIndex& parent = {}) const override;
46 [[nodiscard]] QVariant data(const QModelIndex& index, int role) const override;
47 [[nodiscard]] QHash<int, QByteArray> roleNames() const override;
48
49Q_SIGNALS:
52
53private Q_SLOTS:
54 void onDeviceAdded(PhosphorServiceBrightness::BrightnessDevice* device);
55 void onDeviceRemoved(PhosphorServiceBrightness::BrightnessDevice* device);
56 void onDeviceBrightnessChanged(PhosphorServiceBrightness::BrightnessDevice* device);
57
58private:
59 void connectDevice(BrightnessDevice* device);
60
61 BrightnessHost* m_host = nullptr;
62 // Row mirror of host-owned BrightnessDevice pointers; the model does NOT
63 // own them. Dangling-safe because the host outlives its devices and clears
64 // the model on its own destruction (QObject::destroyed fires before the
65 // host's children are deleted).
66 QList<BrightnessDevice*> m_rows;
67};
68
69} // namespace PhosphorServiceBrightness
Roles
Definition BrightnessDeviceModel.h:28
@ PercentageRole
Definition BrightnessDeviceModel.h:35
@ NameRole
Definition BrightnessDeviceModel.h:31
@ MaxBrightnessRole
Definition BrightnessDeviceModel.h:34
@ BrightnessRole
Definition BrightnessDeviceModel.h:33
@ IdRole
Definition BrightnessDeviceModel.h:30
@ KindRole
Definition BrightnessDeviceModel.h:32
@ DeviceRole
Definition BrightnessDeviceModel.h:29
QVariant data(const QModelIndex &index, int role) const override
QHash< int, QByteArray > roleNames() const override
int rowCount(const QModelIndex &parent={}) const override
One brightness-controllable backlight: a display panel (under /sys/class/backlight) or a keyboard bac...
Definition BrightnessDevice.h:33
Enumerates the brightness-controllable backlights under a sysfs root.
Definition BrightnessHost.h:41
Definition BrightnessDevice.h:16