MCPcopy Create free account
hub / github.com/KDE/kwin / LightSensorSubscription

Method LightSensorSubscription

src/utils/lightsensor.cpp:65–92  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

63};
64
65LightSensorSubscription::LightSensorSubscription()
66 : m_sensorProperties(std::make_unique<OrgFreedesktopDBusPropertiesInterface>(serviceName(), objectPath(), QDBusConnection::systemBus()))
67 , m_sensorInterface(std::make_unique<NetHadessSensorProxyInterface>(serviceName(), objectPath(), QDBusConnection::systemBus()))
68{
69 connect(m_sensorProperties.get(), &OrgFreedesktopDBusPropertiesInterface::PropertiesChanged, this, &LightSensorSubscription::onPropertiesChanged);
70
71 intoFuture<void>(m_sensorInterface->ClaimLight()).then([](const std::expected<void, QDBusError> &result) {
72 if (!result) {
73 qCWarning(KWIN_CORE) << "net.hadess.SensorProxy.ClaimLight() failed:" << result.error();
74 }
75 });
76
77 intoFuture<QVariant>(m_sensorProperties->Get(m_sensorInterface->interface(), QStringLiteral("LightLevelUnit"))).then(this, [this](const std::expected<QVariant, QDBusError> &result) {
78 if (result.has_value()) {
79 setUnit(result->toString());
80 } else {
81 qCWarning(KWIN_CORE) << "Failed to fetch net.hadess.SensorProxy.LightLevelUnit property:" << result.error();
82 }
83 });
84
85 intoFuture<QVariant>(m_sensorProperties->Get(m_sensorInterface->interface(), QStringLiteral("LightLevel"))).then(this, [this](const std::expected<QVariant, QDBusError> &result) {
86 if (result.has_value()) {
87 setReading(result->toDouble());
88 } else {
89 qCWarning(KWIN_CORE) << "Failed to fetch net.hadess.SensorProxy.LightLevel property:" << result.error();
90 }
91 });
92}
93
94LightSensorSubscription::~LightSensorSubscription()
95{

Callers

nothing calls this directly

Calls 5

errorMethod · 0.80
serviceNameFunction · 0.70
objectPathFunction · 0.70
getMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected