mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-08-02 17:54:45 +00:00
quicksettings/screenrotation: hide when not available
On devices where auto-rotate is not (yet) available, make sure not to show an auto-rotate toggle with no functionality.
This commit is contained in:
parent
ca68be8521
commit
f8aeffa56d
4 changed files with 21 additions and 2 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
|
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
|
||||||
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
|
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
|
||||||
<!--
|
<!--
|
||||||
- SPDX-FileCopyrightText: 2020 Luca Weiss
|
- SPDX-FileCopyrightText: 2020-2022 Luca Weiss <luca@z3ntu.xyz>
|
||||||
- SPDX-FileCopyrightText: 2020 Bhushan Shah <bshah@kde.org>
|
- SPDX-FileCopyrightText: 2020 Bhushan Shah <bshah@kde.org>
|
||||||
- SPDX-FileCopyrightText: 2018 Kai Uwe Broulik <kde@privat.broulik.de>
|
- SPDX-FileCopyrightText: 2018 Kai Uwe Broulik <kde@privat.broulik.de>
|
||||||
- SPDX-FileCopyrightText: 2013-2014 Daniel Vrátil <dvratil@kde.org>
|
- SPDX-FileCopyrightText: 2013-2014 Daniel Vrátil <dvratil@kde.org>
|
||||||
|
|
@ -18,6 +18,9 @@
|
||||||
<method name="setAutoRotate">
|
<method name="setAutoRotate">
|
||||||
<arg type="b" name="value" direction="in" />
|
<arg type="b" name="value" direction="in" />
|
||||||
</method>
|
</method>
|
||||||
|
<method name="isAutoRotateAvailable">
|
||||||
|
<arg type="b" direction="out" />
|
||||||
|
</method>
|
||||||
<signal name="outputConnected">
|
<signal name="outputConnected">
|
||||||
<arg type="s" name="outputName" direction="out" />
|
<arg type="s" name="outputName" direction="out" />
|
||||||
</signal>
|
</signal>
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ MobileShell.QuickSetting {
|
||||||
icon: "rotation-allowed"
|
icon: "rotation-allowed"
|
||||||
settingsCommand: "plasma-open-settings kcm_kscreen"
|
settingsCommand: "plasma-open-settings kcm_kscreen"
|
||||||
enabled: ScreenRotationUtil.screenRotationEnabled
|
enabled: ScreenRotationUtil.screenRotationEnabled
|
||||||
|
available: ScreenRotationUtil.available
|
||||||
function toggle() {
|
function toggle() {
|
||||||
ScreenRotationUtil.screenRotationEnabled = !enabled
|
ScreenRotationUtil.screenRotationEnabled = !enabled
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,3 +39,15 @@ void ScreenRotationUtil::setScreenRotation(bool value)
|
||||||
Q_EMIT screenRotationChanged(value);
|
Q_EMIT screenRotationChanged(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ScreenRotationUtil::isAvailable()
|
||||||
|
{
|
||||||
|
QDBusPendingReply<bool> reply = m_kscreenInterface->isAutoRotateAvailable();
|
||||||
|
reply.waitForFinished();
|
||||||
|
if (reply.isError()) {
|
||||||
|
qWarning() << "Getting available failed:" << reply.error().name() << reply.error().message();
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return reply.value();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ class ScreenRotationUtil : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(bool screenRotationEnabled READ screenRotation WRITE setScreenRotation NOTIFY screenRotationChanged);
|
Q_PROPERTY(bool screenRotationEnabled READ screenRotation WRITE setScreenRotation NOTIFY screenRotationChanged);
|
||||||
|
Q_PROPERTY(bool available READ isAvailable);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ScreenRotationUtil(QObject *parent = nullptr);
|
ScreenRotationUtil(QObject *parent = nullptr);
|
||||||
|
|
@ -21,6 +22,8 @@ public:
|
||||||
bool screenRotation();
|
bool screenRotation();
|
||||||
void setScreenRotation(bool value);
|
void setScreenRotation(bool value);
|
||||||
|
|
||||||
|
bool isAvailable();
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void screenRotationChanged(bool value);
|
void screenRotationChanged(bool value);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue