Improve license messaging, effect toggling, and add button for rearranging displays
This commit is contained in:
parent
713b9c7fc1
commit
343205f598
|
|
@ -226,11 +226,11 @@ int BreezyDesktopEffect::requestedEffectChainPosition() const
|
||||||
void BreezyDesktopEffect::toggle()
|
void BreezyDesktopEffect::toggle()
|
||||||
{
|
{
|
||||||
if (isRunning()) {
|
if (isRunning()) {
|
||||||
qCCritical(KWIN_XR) << "\t\t\tBreezy - toggle - deactivating";
|
qCCritical(KWIN_XR) << "\t\t\tBreezy - toggle - disabling";
|
||||||
deactivate();
|
disableDriver();
|
||||||
} else {
|
} else {
|
||||||
qCCritical(KWIN_XR) << "\t\t\tBreezy - toggle - activating";
|
qCCritical(KWIN_XR) << "\t\t\tBreezy - toggle - enabling";
|
||||||
activate();
|
enableDriver();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -277,11 +277,17 @@ void BreezyDesktopEffect::enableDriver()
|
||||||
XRDriverIPC::instance().writeConfig(obj);
|
XRDriverIPC::instance().writeConfig(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BreezyDesktopEffect::disableDriver()
|
||||||
|
{
|
||||||
|
qCCritical(KWIN_XR) << "\t\t\tBreezy - disableDriver";
|
||||||
|
QJsonObject obj;
|
||||||
|
obj.insert(QStringLiteral("disabled"), true);
|
||||||
|
obj.insert(QStringLiteral("external_mode"), QStringLiteral("none"));
|
||||||
|
XRDriverIPC::instance().writeConfig(obj);
|
||||||
|
}
|
||||||
|
|
||||||
void BreezyDesktopEffect::addVirtualDisplay(QSize size)
|
void BreezyDesktopEffect::addVirtualDisplay(QSize size)
|
||||||
{
|
{
|
||||||
// QSize size(2560, 1440);
|
|
||||||
// addVirtualDisplay(size);
|
|
||||||
|
|
||||||
static int virtualDisplayCount = 0;
|
static int virtualDisplayCount = 0;
|
||||||
++virtualDisplayCount;
|
++virtualDisplayCount;
|
||||||
QString name = QStringLiteral("BreezyDesktop_VirtualDisplay_%1x%2_%3").arg(size.width()).arg(size.height()).arg(virtualDisplayCount);
|
QString name = QStringLiteral("BreezyDesktop_VirtualDisplay_%1x%2_%3").arg(size.width()).arg(size.height()).arg(virtualDisplayCount);
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,7 @@ namespace KWin
|
||||||
void activate();
|
void activate();
|
||||||
void deactivate();
|
void deactivate();
|
||||||
void enableDriver();
|
void enableDriver();
|
||||||
|
void disableDriver();
|
||||||
void toggle();
|
void toggle();
|
||||||
void addVirtualDisplay(QSize size);
|
void addVirtualDisplay(QSize size);
|
||||||
void updateImuRotation();
|
void updateImuRotation();
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,9 @@
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QJsonValue>
|
#include <QJsonValue>
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
#include <QPushButton>
|
#include <QDesktopServices>
|
||||||
|
#include <QUrl>
|
||||||
|
#include <QProcess>
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
#include <QDBusInterface>
|
#include <QDBusInterface>
|
||||||
#include <QDBusConnection>
|
#include <QDBusConnection>
|
||||||
|
|
@ -157,6 +159,16 @@ BreezyDesktopEffectConfig::BreezyDesktopEffectConfig(QObject *parent, const KPlu
|
||||||
callAddVirtualDisplay(2560, 1440);
|
callAddVirtualDisplay(2560, 1440);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// General tab: Open KDE Displays Settings
|
||||||
|
if (auto btnDisplays = widget()->findChild<QPushButton*>(QStringLiteral("buttonOpenDisplaysSettings"))) {
|
||||||
|
connect(btnDisplays, &QPushButton::clicked, this, [this]() {
|
||||||
|
// Try launching the KScreen KCM
|
||||||
|
if (!QProcess::startDetached(QStringLiteral("kcmshell6"), {QStringLiteral("kcm_kscreen")})) {
|
||||||
|
QDesktopServices::openUrl(QUrl(QStringLiteral("systemsettings://kcm_kscreen")));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BreezyDesktopEffectConfig::~BreezyDesktopEffectConfig()
|
BreezyDesktopEffectConfig::~BreezyDesktopEffectConfig()
|
||||||
|
|
@ -218,6 +230,25 @@ void BreezyDesktopEffectConfig::updateUnmanagedState()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BreezyDesktopEffectConfig::enableDriver()
|
||||||
|
{
|
||||||
|
qCCritical(KWIN_XR) << "\t\t\tBreezy config - enableDriver";
|
||||||
|
QJsonObject obj;
|
||||||
|
obj.insert(QStringLiteral("disabled"), false);
|
||||||
|
obj.insert(QStringLiteral("output_mode"), QStringLiteral("external_only"));
|
||||||
|
obj.insert(QStringLiteral("external_mode"), QStringLiteral("breezy_desktop"));
|
||||||
|
XRDriverIPC::instance().writeConfig(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BreezyDesktopEffectConfig::disableDriver()
|
||||||
|
{
|
||||||
|
qCCritical(KWIN_XR) << "\t\t\tBreezy config - disableDriver";
|
||||||
|
QJsonObject obj;
|
||||||
|
obj.insert(QStringLiteral("disabled"), true);
|
||||||
|
obj.insert(QStringLiteral("external_mode"), QStringLiteral("none"));
|
||||||
|
XRDriverIPC::instance().writeConfig(obj);
|
||||||
|
}
|
||||||
|
|
||||||
void BreezyDesktopEffectConfig::pollDriverState()
|
void BreezyDesktopEffectConfig::pollDriverState()
|
||||||
{
|
{
|
||||||
auto &bridge = XRDriverIPC::instance();
|
auto &bridge = XRDriverIPC::instance();
|
||||||
|
|
@ -304,12 +335,15 @@ void BreezyDesktopEffectConfig::refreshLicenseUi(const QJsonObject &rootObj) {
|
||||||
if (!tab) return;
|
if (!tab) return;
|
||||||
auto labelSummary = tab->findChild<QLabel*>("labelLicenseSummary");
|
auto labelSummary = tab->findChild<QLabel*>("labelLicenseSummary");
|
||||||
if (!labelSummary) return;
|
if (!labelSummary) return;
|
||||||
|
auto donate = tab->findChild<QLabel*>("labelDonateLink");
|
||||||
|
auto globalWarn = widget()->findChild<QLabel*>("labelGlobalLicenseWarning");
|
||||||
|
|
||||||
QString status = tr("disabled");
|
QString status = tr("disabled");
|
||||||
QString renewalDescriptor = QStringLiteral("");
|
QString renewalDescriptor = QStringLiteral("");
|
||||||
auto uiView = rootObj.value(QStringLiteral("ui_view")).toObject();
|
auto uiView = rootObj.value(QStringLiteral("ui_view")).toObject();
|
||||||
auto license = uiView.value(QStringLiteral("license")).toObject();
|
auto license = uiView.value(QStringLiteral("license")).toObject();
|
||||||
bool warningState = true;
|
bool warningState = false;
|
||||||
|
bool expired = false;
|
||||||
if (!license.isEmpty()) {
|
if (!license.isEmpty()) {
|
||||||
auto tiers = license.value(QStringLiteral("tiers")).toObject();
|
auto tiers = license.value(QStringLiteral("tiers")).toObject();
|
||||||
QJsonValue prodTier = tiers.value(QStringLiteral("subscriber"));
|
QJsonValue prodTier = tiers.value(QStringLiteral("subscriber"));
|
||||||
|
|
@ -349,23 +383,48 @@ void BreezyDesktopEffectConfig::refreshLicenseUi(const QJsonObject &rootObj) {
|
||||||
} else {
|
} else {
|
||||||
QJsonValue isEnabled = prodFeatureObj.value(QStringLiteral("is_enabled"));
|
QJsonValue isEnabled = prodFeatureObj.value(QStringLiteral("is_enabled"));
|
||||||
QJsonValue isTrial = prodFeatureObj.value(QStringLiteral("is_trial"));
|
QJsonValue isTrial = prodFeatureObj.value(QStringLiteral("is_trial"));
|
||||||
if (isEnabled.toBool() && isTrial.toBool()) {
|
if (isEnabled.toBool()) {
|
||||||
status = tr("in trial");
|
if (isTrial.toBool()) {
|
||||||
auto secsVal = prodFeatureObj.value(QStringLiteral("funds_needed_in_seconds"));
|
status = tr("in trial");
|
||||||
if (secsVal.isDouble()) {
|
auto secsVal = prodFeatureObj.value(QStringLiteral("funds_needed_in_seconds"));
|
||||||
qint64 secs = static_cast<qint64>(secsVal.toDouble());
|
if (secsVal.isDouble()) {
|
||||||
QString remaining = secondsToRemainingString(secs);
|
qint64 secs = static_cast<qint64>(secsVal.toDouble());
|
||||||
warningState = !remaining.isEmpty();
|
QString remaining = secondsToRemainingString(secs);
|
||||||
if (warningState) {
|
warningState = !remaining.isEmpty();
|
||||||
QString timeDescriptor = tr("%1 remaining").arg(remaining);
|
if (warningState) {
|
||||||
renewalDescriptor = tr(" (%1)").arg(timeDescriptor);
|
QString timeDescriptor = tr("%1 remaining").arg(remaining);
|
||||||
|
renewalDescriptor = tr(" (%1)").arg(timeDescriptor);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
expired = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
labelSummary->setText(tr("Productivity Tier features are %1%2").arg(status, renewalDescriptor));
|
const QString message = tr("Productivity Tier features are %1%2").arg(status, renewalDescriptor);
|
||||||
|
labelSummary->setText(message);
|
||||||
|
|
||||||
|
if (donate) donate->setVisible(warningState || expired);
|
||||||
|
|
||||||
|
if (globalWarn) {
|
||||||
|
if (warningState || expired) {
|
||||||
|
globalWarn->setText(message + (expired ? tr(" — effect disabled") : QString()));
|
||||||
|
globalWarn->setVisible(true);
|
||||||
|
} else {
|
||||||
|
globalWarn->clear();
|
||||||
|
globalWarn->setVisible(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (expired) {
|
||||||
|
if (ui.tabWidget) ui.tabWidget->setEnabled(false);
|
||||||
|
OrgKdeKwinEffectsInterface interface(QStringLiteral("org.kde.KWin"), QStringLiteral("/Effects"), QDBusConnection::sessionBus());
|
||||||
|
interface.unloadEffect(QStringLiteral("breezy_desktop"));
|
||||||
|
} else {
|
||||||
|
if (ui.tabWidget) ui.tabWidget->setEnabled(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "breezydesktopeffectkcm.moc"
|
#include "breezydesktopeffectkcm.moc"
|
||||||
|
|
@ -25,6 +25,8 @@ public Q_SLOTS:
|
||||||
void defaults() override;
|
void defaults() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void enableDriver();
|
||||||
|
void disableDriver();
|
||||||
void updateUiFromConfig();
|
void updateUiFromConfig();
|
||||||
void updateUiFromDefaultConfig();
|
void updateUiFromDefaultConfig();
|
||||||
void updateConfigFromUi();
|
void updateConfigFromUi();
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,25 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="labelGlobalLicenseWarning">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="visible">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="wordWrap">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignHCenter|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">color: rgb(200,0,0); font-weight: bold;</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTabWidget" name="tabWidget">
|
<widget class="QTabWidget" name="tabWidget">
|
||||||
<property name="tabPosition">
|
<property name="tabPosition">
|
||||||
|
|
@ -148,10 +167,17 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="buttonOpenDisplaysSettings">
|
||||||
|
<property name="text">
|
||||||
|
<string>Rearrange displays</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="0" colspan="2">
|
<item row="5" column="0" colspan="2">
|
||||||
<widget class="KShortcutsEditor" name="shortcutsEditor" native="true">
|
<widget class="KShortcutsEditor" name="shortcutsEditor" native="true">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||||
|
|
@ -271,6 +297,22 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="labelDonateLink">
|
||||||
|
<property name="text">
|
||||||
|
<string><a href="https://ko-fi.com/wheaney">Renew or support on Ko‑fi</a></string>
|
||||||
|
</property>
|
||||||
|
<property name="openExternalLinks">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignHCenter|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
<property name="visible">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="groupBoxEmail">
|
<widget class="QGroupBox" name="groupBoxEmail">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue