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_iface(new QDBusInterface(s_service, s_path, s_iface, QDBusConnection::sessionBus(), this))
|
||||||
{
|
{
|
||||||
m_available = m_iface->isValid();
|
m_available = m_iface->isValid();
|
||||||
if (!m_available) {
|
|
||||||
qDebug() << "GameModeControl: Feral GameMode not available";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GameModeControl::available() const
|
bool GameModeControl::available() const
|
||||||
|
|
|
||||||
|
|
@ -25,8 +25,6 @@ PowerProfileControl::PowerProfileControl(QObject *parent)
|
||||||
// Subscribe to property changes
|
// Subscribe to property changes
|
||||||
QDBusConnection::systemBus()
|
QDBusConnection::systemBus()
|
||||||
.connect(s_service, s_path, s_propIface, QStringLiteral("PropertiesChanged"), this, SLOT(onPropertiesChanged(QString, QVariantMap, QStringList)));
|
.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
|
// Add event filter to listen for when wayland window appears, and try again
|
||||||
m_window->installEventFilter(this);
|
m_window->installEventFilter(this);
|
||||||
setInitialized(false);
|
setInitialized(false);
|
||||||
qCWarning(LOGGING_CATEGORY) << "Unable to set overlay: unable to get wayland window";
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -99,13 +98,11 @@ void RaiseLockscreen::setOverlay()
|
||||||
connect(waylandWindow, &QNativeInterface::Private::QWaylandWindow::surfaceRoleCreated, this, [this, waylandWindow]() {
|
connect(waylandWindow, &QNativeInterface::Private::QWaylandWindow::surfaceRoleCreated, this, [this, waylandWindow]() {
|
||||||
m_implementation->allow(waylandWindow->surface());
|
m_implementation->allow(waylandWindow->surface());
|
||||||
setInitialized(true);
|
setInitialized(true);
|
||||||
qCDebug(LOGGING_CATEGORY) << "Initialized overlay successfully";
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (waylandWindow->surface()) {
|
if (waylandWindow->surface()) {
|
||||||
m_implementation->allow(waylandWindow->surface());
|
m_implementation->allow(waylandWindow->surface());
|
||||||
setInitialized(true);
|
setInitialized(true);
|
||||||
qCDebug(LOGGING_CATEGORY) << "Initialized overlay successfully";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,16 @@
|
||||||
#include <QDBusPendingCallWatcher>
|
#include <QDBusPendingCallWatcher>
|
||||||
#include <QDBusPendingReply>
|
#include <QDBusPendingReply>
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
const QString SOLID_POWER_MANAGEMENT_SERVICE = QStringLiteral("org.kde.Solid.PowerManagement");
|
||||||
|
}
|
||||||
|
|
||||||
ScreenBrightnessUtil::ScreenBrightnessUtil(QObject *parent)
|
ScreenBrightnessUtil::ScreenBrightnessUtil(QObject *parent)
|
||||||
: QObject{parent}
|
: QObject{parent}
|
||||||
{
|
{
|
||||||
m_brightnessInterface =
|
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"),
|
QStringLiteral("/org/kde/Solid/PowerManagement/Actions/BrightnessControl"),
|
||||||
QDBusConnection::sessionBus(),
|
QDBusConnection::sessionBus(),
|
||||||
this);
|
this);
|
||||||
|
|
@ -24,14 +29,14 @@ ScreenBrightnessUtil::ScreenBrightnessUtil(QObject *parent)
|
||||||
this,
|
this,
|
||||||
&ScreenBrightnessUtil::fetchMaxBrightness);
|
&ScreenBrightnessUtil::fetchMaxBrightness);
|
||||||
|
|
||||||
fetchBrightness();
|
if (brightnessAvailable()) {
|
||||||
fetchMaxBrightness();
|
fetchBrightness();
|
||||||
|
fetchMaxBrightness();
|
||||||
|
}
|
||||||
|
|
||||||
// watch for brightness interface
|
// watch for brightness interface
|
||||||
m_brightnessInterfaceWatcher = new QDBusServiceWatcher(QStringLiteral("org.kde.Solid.PowerManagement.Actions.BrightnessControl"),
|
m_brightnessInterfaceWatcher =
|
||||||
QDBusConnection::sessionBus(),
|
new QDBusServiceWatcher(SOLID_POWER_MANAGEMENT_SERVICE, QDBusConnection::sessionBus(), QDBusServiceWatcher::WatchForOwnerChange, this);
|
||||||
QDBusServiceWatcher::WatchForOwnerChange,
|
|
||||||
this);
|
|
||||||
|
|
||||||
connect(m_brightnessInterfaceWatcher, &QDBusServiceWatcher::serviceRegistered, this, [this]() -> void {
|
connect(m_brightnessInterfaceWatcher, &QDBusServiceWatcher::serviceRegistered, this, [this]() -> void {
|
||||||
fetchBrightness();
|
fetchBrightness();
|
||||||
|
|
@ -51,6 +56,10 @@ int ScreenBrightnessUtil::brightness() const
|
||||||
|
|
||||||
void ScreenBrightnessUtil::setBrightness(int brightness)
|
void ScreenBrightnessUtil::setBrightness(int brightness)
|
||||||
{
|
{
|
||||||
|
if (!brightnessAvailable()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
m_brightnessInterface->setBrightness(brightness);
|
m_brightnessInterface->setBrightness(brightness);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -66,6 +75,10 @@ bool ScreenBrightnessUtil::brightnessAvailable() const
|
||||||
|
|
||||||
void ScreenBrightnessUtil::fetchBrightness()
|
void ScreenBrightnessUtil::fetchBrightness()
|
||||||
{
|
{
|
||||||
|
if (!brightnessAvailable()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QDBusPendingReply<int> reply = m_brightnessInterface->brightness();
|
QDBusPendingReply<int> reply = m_brightnessInterface->brightness();
|
||||||
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this);
|
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this);
|
||||||
|
|
||||||
|
|
@ -83,6 +96,10 @@ void ScreenBrightnessUtil::fetchBrightness()
|
||||||
|
|
||||||
void ScreenBrightnessUtil::fetchMaxBrightness()
|
void ScreenBrightnessUtil::fetchMaxBrightness()
|
||||||
{
|
{
|
||||||
|
if (!brightnessAvailable()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QDBusPendingReply<int> reply = m_brightnessInterface->brightnessMax();
|
QDBusPendingReply<int> reply = m_brightnessInterface->brightnessMax();
|
||||||
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this);
|
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -131,7 +131,6 @@ void FlashlightUtil::findTorchDevice()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (device == nullptr) {
|
if (device == nullptr) {
|
||||||
qWarning() << "No flashlight device found";
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue