mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-26 14:23:09 +00:00
screenbrightnessplugin: Fix behaviour if dbus service is not initialized followup
Fix abfe419b3b
This commit is contained in:
parent
abfe419b3b
commit
fdf2ad87f6
2 changed files with 23 additions and 22 deletions
|
|
@ -20,7 +20,6 @@ target_link_libraries(screenbrightnessplugin PRIVATE
|
||||||
KF6::ConfigGui
|
KF6::ConfigGui
|
||||||
KF6::I18n
|
KF6::I18n
|
||||||
KF6::Screen
|
KF6::Screen
|
||||||
QCoro::DBus
|
|
||||||
)
|
)
|
||||||
|
|
||||||
ecm_finalize_qml_module(screenbrightnessplugin)
|
ecm_finalize_qml_module(screenbrightnessplugin)
|
||||||
|
|
|
||||||
|
|
@ -66,32 +66,34 @@ bool ScreenBrightnessUtil::brightnessAvailable() const
|
||||||
|
|
||||||
void ScreenBrightnessUtil::fetchBrightness()
|
void ScreenBrightnessUtil::fetchBrightness()
|
||||||
{
|
{
|
||||||
QDBusPendingReply<int> pendingReply = m_brightnessInterface->brightness();
|
QDBusPendingReply<int> reply = m_brightnessInterface->brightness();
|
||||||
const auto reply = co_await pendingReply;
|
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this);
|
||||||
|
|
||||||
if (reply.isError()) {
|
connect(watcher, &QDBusPendingCallWatcher::finished, this, [this](QDBusPendingCallWatcher *watcher) {
|
||||||
qWarning() << "Getting brightness failed:" << reply.error().name() << reply.error().message();
|
QDBusPendingReply<int> reply = *watcher;
|
||||||
return;
|
if (reply.isError()) {
|
||||||
}
|
qWarning() << "Getting brightness failed:" << reply.error().name() << reply.error().message();
|
||||||
|
} else if (m_brightness != reply.value()) {
|
||||||
if (m_brightness != reply.value()) {
|
m_brightness = reply.value();
|
||||||
m_brightness = reply.value();
|
Q_EMIT brightnessChanged();
|
||||||
Q_EMIT brightnessChanged();
|
}
|
||||||
}
|
watcher->deleteLater();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenBrightnessUtil::fetchMaxBrightness()
|
void ScreenBrightnessUtil::fetchMaxBrightness()
|
||||||
{
|
{
|
||||||
QDBusPendingReply<int> reply = m_brightnessInterface->brightnessMax();
|
QDBusPendingReply<int> reply = m_brightnessInterface->brightnessMax();
|
||||||
const auto reply = co_await pendingReply;
|
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this);
|
||||||
|
|
||||||
if (reply.isError()) {
|
connect(watcher, &QDBusPendingCallWatcher::finished, this, [this](QDBusPendingCallWatcher *watcher) {
|
||||||
qWarning() << "Getting max brightness failed:" << reply.error().name() << reply.error().message();
|
QDBusPendingReply<int> reply = *watcher;
|
||||||
return;
|
if (reply.isError()) {
|
||||||
}
|
qWarning() << "Getting max brightness failed:" << reply.error().name() << reply.error().message();
|
||||||
|
} else if (m_maxBrightness != reply.value()) {
|
||||||
if (m_maxBrightness != reply.value()) {
|
m_maxBrightness = reply.value();
|
||||||
m_maxBrightness = reply.value();
|
Q_EMIT maxBrightnessChanged();
|
||||||
Q_EMIT maxBrightnessChanged();
|
}
|
||||||
}
|
watcher->deleteLater();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue