mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-06-11 00:47:22 +00:00
Guard optional services and trim noisy logs
Skip brightness DBus calls when the service is unavailable and stop\nemitting expected-missing-service debug warnings in optional plugin\npaths.
This commit is contained in:
parent
dd3e366e17
commit
43e1477a14
5 changed files with 24 additions and 16 deletions
|
|
@ -18,9 +18,6 @@ GameModeControl::GameModeControl(QObject *parent)
|
|||
, m_iface(new QDBusInterface(s_service, s_path, s_iface, QDBusConnection::sessionBus(), this))
|
||||
{
|
||||
m_available = m_iface->isValid();
|
||||
if (!m_available) {
|
||||
qDebug() << "GameModeControl: Feral GameMode not available";
|
||||
}
|
||||
}
|
||||
|
||||
bool GameModeControl::available() const
|
||||
|
|
|
|||
|
|
@ -25,8 +25,6 @@ PowerProfileControl::PowerProfileControl(QObject *parent)
|
|||
// Subscribe to property changes
|
||||
QDBusConnection::systemBus()
|
||||
.connect(s_service, s_path, s_propIface, QStringLiteral("PropertiesChanged"), this, SLOT(onPropertiesChanged(QString, QVariantMap, QStringList)));
|
||||
} else {
|
||||
qDebug() << "PowerProfileControl: power-profiles-daemon not available";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -90,7 +90,6 @@ void RaiseLockscreen::setOverlay()
|
|||
// Add event filter to listen for when wayland window appears, and try again
|
||||
m_window->installEventFilter(this);
|
||||
setInitialized(false);
|
||||
qCWarning(LOGGING_CATEGORY) << "Unable to set overlay: unable to get wayland window";
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -99,13 +98,11 @@ void RaiseLockscreen::setOverlay()
|
|||
connect(waylandWindow, &QNativeInterface::Private::QWaylandWindow::surfaceRoleCreated, this, [this, waylandWindow]() {
|
||||
m_implementation->allow(waylandWindow->surface());
|
||||
setInitialized(true);
|
||||
qCDebug(LOGGING_CATEGORY) << "Initialized overlay successfully";
|
||||
});
|
||||
|
||||
if (waylandWindow->surface()) {
|
||||
m_implementation->allow(waylandWindow->surface());
|
||||
setInitialized(true);
|
||||
qCDebug(LOGGING_CATEGORY) << "Initialized overlay successfully";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,11 +6,16 @@
|
|||
#include <QDBusPendingCallWatcher>
|
||||
#include <QDBusPendingReply>
|
||||
|
||||
namespace
|
||||
{
|
||||
const QString SOLID_POWER_MANAGEMENT_SERVICE = QStringLiteral("org.kde.Solid.PowerManagement");
|
||||
}
|
||||
|
||||
ScreenBrightnessUtil::ScreenBrightnessUtil(QObject *parent)
|
||||
: QObject{parent}
|
||||
{
|
||||
m_brightnessInterface =
|
||||
new org::kde::Solid::PowerManagement::Actions::BrightnessControl(QStringLiteral("org.kde.Solid.PowerManagement"),
|
||||
new org::kde::Solid::PowerManagement::Actions::BrightnessControl(SOLID_POWER_MANAGEMENT_SERVICE,
|
||||
QStringLiteral("/org/kde/Solid/PowerManagement/Actions/BrightnessControl"),
|
||||
QDBusConnection::sessionBus(),
|
||||
this);
|
||||
|
|
@ -24,14 +29,14 @@ ScreenBrightnessUtil::ScreenBrightnessUtil(QObject *parent)
|
|||
this,
|
||||
&ScreenBrightnessUtil::fetchMaxBrightness);
|
||||
|
||||
if (brightnessAvailable()) {
|
||||
fetchBrightness();
|
||||
fetchMaxBrightness();
|
||||
}
|
||||
|
||||
// watch for brightness interface
|
||||
m_brightnessInterfaceWatcher = new QDBusServiceWatcher(QStringLiteral("org.kde.Solid.PowerManagement.Actions.BrightnessControl"),
|
||||
QDBusConnection::sessionBus(),
|
||||
QDBusServiceWatcher::WatchForOwnerChange,
|
||||
this);
|
||||
m_brightnessInterfaceWatcher =
|
||||
new QDBusServiceWatcher(SOLID_POWER_MANAGEMENT_SERVICE, QDBusConnection::sessionBus(), QDBusServiceWatcher::WatchForOwnerChange, this);
|
||||
|
||||
connect(m_brightnessInterfaceWatcher, &QDBusServiceWatcher::serviceRegistered, this, [this]() -> void {
|
||||
fetchBrightness();
|
||||
|
|
@ -51,6 +56,10 @@ int ScreenBrightnessUtil::brightness() const
|
|||
|
||||
void ScreenBrightnessUtil::setBrightness(int brightness)
|
||||
{
|
||||
if (!brightnessAvailable()) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_brightnessInterface->setBrightness(brightness);
|
||||
}
|
||||
|
||||
|
|
@ -66,6 +75,10 @@ bool ScreenBrightnessUtil::brightnessAvailable() const
|
|||
|
||||
void ScreenBrightnessUtil::fetchBrightness()
|
||||
{
|
||||
if (!brightnessAvailable()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QDBusPendingReply<int> reply = m_brightnessInterface->brightness();
|
||||
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this);
|
||||
|
||||
|
|
@ -83,6 +96,10 @@ void ScreenBrightnessUtil::fetchBrightness()
|
|||
|
||||
void ScreenBrightnessUtil::fetchMaxBrightness()
|
||||
{
|
||||
if (!brightnessAvailable()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QDBusPendingReply<int> reply = m_brightnessInterface->brightnessMax();
|
||||
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this);
|
||||
|
||||
|
|
|
|||
|
|
@ -131,7 +131,6 @@ void FlashlightUtil::findTorchDevice()
|
|||
}
|
||||
|
||||
if (device == nullptr) {
|
||||
qWarning() << "No flashlight device found";
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue