diff --git a/components/screenbrightnessplugin/CMakeLists.txt b/components/screenbrightnessplugin/CMakeLists.txt index 13f3c9f1..1f2096ed 100644 --- a/components/screenbrightnessplugin/CMakeLists.txt +++ b/components/screenbrightnessplugin/CMakeLists.txt @@ -20,7 +20,6 @@ target_link_libraries(screenbrightnessplugin PRIVATE KF6::ConfigGui KF6::I18n KF6::Screen - QCoro::DBus ) ecm_finalize_qml_module(screenbrightnessplugin) diff --git a/components/screenbrightnessplugin/screenbrightnessutil.cpp b/components/screenbrightnessplugin/screenbrightnessutil.cpp index dd6db7f7..2f79a7b7 100644 --- a/components/screenbrightnessplugin/screenbrightnessutil.cpp +++ b/components/screenbrightnessplugin/screenbrightnessutil.cpp @@ -66,32 +66,34 @@ bool ScreenBrightnessUtil::brightnessAvailable() const void ScreenBrightnessUtil::fetchBrightness() { - QDBusPendingReply pendingReply = m_brightnessInterface->brightness(); - const auto reply = co_await pendingReply; + QDBusPendingReply reply = m_brightnessInterface->brightness(); + QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this); - if (reply.isError()) { - qWarning() << "Getting brightness failed:" << reply.error().name() << reply.error().message(); - return; - } - - if (m_brightness != reply.value()) { - m_brightness = reply.value(); - Q_EMIT brightnessChanged(); - } + connect(watcher, &QDBusPendingCallWatcher::finished, this, [this](QDBusPendingCallWatcher *watcher) { + QDBusPendingReply reply = *watcher; + if (reply.isError()) { + qWarning() << "Getting brightness failed:" << reply.error().name() << reply.error().message(); + } else if (m_brightness != reply.value()) { + m_brightness = reply.value(); + Q_EMIT brightnessChanged(); + } + watcher->deleteLater(); + }); } void ScreenBrightnessUtil::fetchMaxBrightness() { QDBusPendingReply reply = m_brightnessInterface->brightnessMax(); - const auto reply = co_await pendingReply; + QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this); - if (reply.isError()) { - qWarning() << "Getting max brightness failed:" << reply.error().name() << reply.error().message(); - return; - } - - if (m_maxBrightness != reply.value()) { - m_maxBrightness = reply.value(); - Q_EMIT maxBrightnessChanged(); - } + connect(watcher, &QDBusPendingCallWatcher::finished, this, [this](QDBusPendingCallWatcher *watcher) { + QDBusPendingReply reply = *watcher; + if (reply.isError()) { + qWarning() << "Getting max brightness failed:" << reply.error().name() << reply.error().message(); + } else if (m_maxBrightness != reply.value()) { + m_maxBrightness = reply.value(); + Q_EMIT maxBrightnessChanged(); + } + watcher->deleteLater(); + }); }