Update KCM app to be aware of whether the effect is loaded, message appropriately

Improve device status checking state
This commit is contained in:
wheaney 2025-09-14 12:47:48 -07:00
parent c270ff653e
commit 5623fe1126
4 changed files with 32 additions and 7 deletions

View File

@ -14,7 +14,7 @@ There are two installations available. **Note: Don't manually install either of
## Breezy Desktop
Breezy Desktop is a virtual workspace solution for Linux desktops that use the KDE Plasma 6 or GNOME desktop environments (GNOME versions 42 through 48). It supports launching multiple virtual monitors alongside multiple physical monitors. For Linux users not running GNOME or KDE, you can play around with a [nested GNOME setup](#nested-gnome-setup).
Breezy Desktop is a virtual workspace solution for Linux desktops that use the KDE Plasma 6 or GNOME desktop environments (versions 42 through 48). It supports launching multiple virtual monitors alongside multiple physical monitors. For Linux users not running GNOME or KDE, you can play around with a [nested GNOME setup](#nested-gnome-setup).
For the best performance, ensure you have the latest graphics drivers installed for your distro.

View File

@ -34,6 +34,7 @@
#include <QHBoxLayout>
#include <QPushButton>
#include <QIcon>
#include <QTabWidget>
Q_LOGGING_CATEGORY(KWIN_XR, "kwin.xr")
@ -56,6 +57,9 @@ BreezyDesktopEffectConfig::BreezyDesktopEffectConfig(QObject *parent, const KPlu
ui.setupUi(widget());
addConfig(BreezyDesktopConfig::self(), widget());
// One-time check if the KWin effect backend is actually loaded. If not, disable UI early.
checkEffectLoaded();
// Show/enable Virtual Display controls only when we're on Wayland
const bool isWaylandSession = QGuiApplication::platformName().contains(QStringLiteral("wayland"), Qt::CaseInsensitive)
|| qEnvironmentVariable("XDG_SESSION_TYPE").compare(QStringLiteral("wayland"), Qt::CaseInsensitive) == 0;
@ -257,6 +261,23 @@ void BreezyDesktopEffectConfig::updateUnmanagedState()
{
}
void BreezyDesktopEffectConfig::checkEffectLoaded() {
OrgKdeKwinEffectsInterface iface(QStringLiteral("org.kde.KWin"), QStringLiteral("/Effects"), QDBusConnection::sessionBus());
QDBusReply<bool> reply = iface.call(QStringLiteral("isEffectLoaded"), QStringLiteral("breezy_desktop"));
if (!reply.isValid() || !reply.value()) {
if (auto tabWidget = widget()->findChild<QTabWidget*>()) {
tabWidget->setEnabled(false);
}
if (auto warn = widget()->findChild<QLabel*>(QStringLiteral("labelGlobalWarning"))) {
QPalette pal = warn->palette();
pal.setColor(QPalette::WindowText, QColor(Qt::red));
warn->setPalette(pal);
warn->setText(tr("The Breezy Desktop KWin effect is not loaded. Please log out and back in to enable it."));
warn->setVisible(true);
}
}
}
static QDBusInterface makeVDInterface() {
return QDBusInterface(
QStringLiteral("org.kde.KWin"),
@ -427,7 +448,7 @@ void BreezyDesktopEffectConfig::pollDriverState()
const bool wasDeviceConnected = m_deviceConnected;
m_deviceConnected = !m_connectedDeviceBrand.isEmpty() && !m_connectedDeviceModel.isEmpty();
if (ui.labelDeviceConnectionStatus->text().isEmpty() || m_deviceConnected != wasDeviceConnected) {
if (!m_driverStateInitialized || m_deviceConnected != wasDeviceConnected) {
ui.labelDeviceConnectionStatus->setText(m_deviceConnected ?
QStringLiteral("%1 %2 connected").arg(m_connectedDeviceBrand, m_connectedDeviceModel) :
QStringLiteral("No device connected"));
@ -439,6 +460,8 @@ void BreezyDesktopEffectConfig::pollDriverState()
if (ui.EnableMultitap->isChecked() != multitap) ui.EnableMultitap->setChecked(multitap);
refreshLicenseUi(stateJson);
m_driverStateInitialized = true;
}
bool BreezyDesktopEffectConfig::multitapEnabled(std::optional<QJsonObject> configJsonOpt)
@ -529,7 +552,7 @@ void BreezyDesktopEffectConfig::refreshLicenseUi(const QJsonObject &rootObj) {
auto labelSummary = tab->findChild<QLabel*>("labelLicenseSummary");
if (!labelSummary) return;
auto donate = tab->findChild<QLabel*>("labelDonateLink");
auto globalWarn = widget()->findChild<QLabel*>("labelGlobalLicenseWarning");
auto globalWarn = widget()->findChild<QLabel*>("labelGlobalWarning");
QString status = tr("disabled");
QString renewalDescriptor = QStringLiteral("");
@ -601,7 +624,7 @@ void BreezyDesktopEffectConfig::refreshLicenseUi(const QJsonObject &rootObj) {
if (donate) donate->setVisible(warningState || expired);
if (globalWarn) {
if (globalWarn && !globalWarn->isVisible()) {
if (warningState || expired) {
globalWarn->setText(message + (expired ? tr(" — effect disabled") : QString()));
globalWarn->setVisible(true);

View File

@ -38,6 +38,7 @@ private:
bool multitapEnabled(std::optional<QJsonObject> configJsonOpt);
void pollDriverState();
void refreshLicenseUi(const QJsonObject &rootObj);
void checkEffectLoaded();
void showStatus(QLabel *label, bool success, const QString &message);
void setRequestInProgress(std::initializer_list<QObject*> widgets, bool inProgress);
bool eventFilter(QObject *watched, QEvent *event) override;
@ -52,6 +53,7 @@ private:
KConfigWatcher::Ptr m_configWatcher;
bool m_updatingFromConfig = false;
bool m_driverStateInitialized = false;
bool m_deviceConnected = false;
QString m_connectedDeviceBrand;
QString m_connectedDeviceModel;

View File

@ -6,7 +6,7 @@
<item>
<widget class="QLabel" name="labelDeviceConnectionStatus">
<property name="text">
<string></string>
<string>Loading, please wait...</string>
</property>
<property name="alignment">
<set>Qt::AlignHCenter|Qt::AlignVCenter</set>
@ -21,7 +21,7 @@
</widget>
</item>
<item>
<widget class="QLabel" name="labelGlobalLicenseWarning">
<widget class="QLabel" name="labelGlobalWarning">
<property name="text">
<string/>
</property>
@ -58,7 +58,7 @@
<string>XR Effect enabled</string>
</property>
<property name="checked">
<bool>true</bool>
<bool>false</bool>
</property>
</widget>
</item>