mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-26 14:23:09 +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"
|
||||
"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: 2018 Kai Uwe Broulik <kde@privat.broulik.de>
|
||||
- SPDX-FileCopyrightText: 2013-2014 Daniel Vrátil <dvratil@kde.org>
|
||||
|
|
@ -18,6 +18,9 @@
|
|||
<method name="setAutoRotate">
|
||||
<arg type="b" name="value" direction="in" />
|
||||
</method>
|
||||
<method name="isAutoRotateAvailable">
|
||||
<arg type="b" direction="out" />
|
||||
</method>
|
||||
<signal name="outputConnected">
|
||||
<arg type="s" name="outputName" direction="out" />
|
||||
</signal>
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ MobileShell.QuickSetting {
|
|||
icon: "rotation-allowed"
|
||||
settingsCommand: "plasma-open-settings kcm_kscreen"
|
||||
enabled: ScreenRotationUtil.screenRotationEnabled
|
||||
available: ScreenRotationUtil.available
|
||||
function toggle() {
|
||||
ScreenRotationUtil.screenRotationEnabled = !enabled
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,3 +39,15 @@ void ScreenRotationUtil::setScreenRotation(bool 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_PROPERTY(bool screenRotationEnabled READ screenRotation WRITE setScreenRotation NOTIFY screenRotationChanged);
|
||||
Q_PROPERTY(bool available READ isAvailable);
|
||||
|
||||
public:
|
||||
ScreenRotationUtil(QObject *parent = nullptr);
|
||||
|
|
@ -21,6 +22,8 @@ public:
|
|||
bool screenRotation();
|
||||
void setScreenRotation(bool value);
|
||||
|
||||
bool isAvailable();
|
||||
|
||||
Q_SIGNALS:
|
||||
void screenRotationChanged(bool value);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue