From 4c28cc3346d7671cfeaba7a18c565f3c3e230338 Mon Sep 17 00:00:00 2001 From: Kai Uwe Broulik Date: Wed, 13 Mar 2019 10:08:17 +0100 Subject: [PATCH] [Logout Screen] Show info that rebooting will enter firmware setup When the flag to reboot into BIOS/UEFI setup is set, show a hint on the logout screen. For simplicity and to avoid the layout from shifting, and since the user had to explicitly enable the flag and probably know what they're doing, it is shown regardless of what action is highlighted. Differential Revision: https://phabricator.kde.org/D19562 --- logout-greeter/shutdowndlg.cpp | 25 +++++++++++++++++++++++++ lookandfeel/contents/logout/Logout.qml | 12 ++++++++++++ 2 files changed, 37 insertions(+) diff --git a/logout-greeter/shutdowndlg.cpp b/logout-greeter/shutdowndlg.cpp index dcbc67e12..9e3ba1715 100644 --- a/logout-greeter/shutdowndlg.cpp +++ b/logout-greeter/shutdowndlg.cpp @@ -30,6 +30,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include #include #include +#include +#include +#include #include #include #include @@ -66,6 +69,12 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include #include +static const QString s_login1Service = QStringLiteral("org.freedesktop.login1"); +static const QString s_login1Path = QStringLiteral("/org/freedesktop/login1"); +static const QString s_dbusPropertiesInterface = QStringLiteral("org.freedesktop.DBus.Properties"); +static const QString s_login1ManagerInterface = QStringLiteral("org.freedesktop.login1.Manager"); +static const QString s_login1RebootToFirmwareSetup = QStringLiteral("RebootToFirmwareSetup"); + Q_DECLARE_METATYPE(Solid::PowerManagement::SleepState) KSMShutdownDlg::KSMShutdownDlg(QWindow* parent, @@ -118,6 +127,22 @@ KSMShutdownDlg::KSMShutdownDlg(QWindow* parent, context->setContextProperty(QStringLiteral("spdMethods"), mapSpdMethods); context->setContextProperty(QStringLiteral("canLogout"), KAuthorized::authorize(QStringLiteral("logout"))); + // Trying to access a non-existant context property throws an error, always create the property and then update it later + context->setContextProperty("rebootToFirmwareSetup", false); + + QDBusMessage message = QDBusMessage::createMethodCall(s_login1Service, s_login1Path, s_dbusPropertiesInterface, QStringLiteral("Get")); + message.setArguments({s_login1ManagerInterface, s_login1RebootToFirmwareSetup}); + QDBusPendingReply call = QDBusConnection::systemBus().asyncCall(message); + QDBusPendingCallWatcher *callWatcher = new QDBusPendingCallWatcher(call, this); + connect(callWatcher, &QDBusPendingCallWatcher::finished, context, [context](QDBusPendingCallWatcher *watcher) { + QDBusPendingReply reply = *watcher; + watcher->deleteLater(); + + if (reply.value().toBool()) { + context->setContextProperty("rebootToFirmwareSetup", true); + } + }); + // TODO KF6 remove, used to read "BootManager" from kdmrc context->setContextProperty(QStringLiteral("bootManager"), QStringLiteral("None")); diff --git a/lookandfeel/contents/logout/Logout.qml b/lookandfeel/contents/logout/Logout.qml index 2cec81a05..fd3a8584e 100644 --- a/lookandfeel/contents/logout/Logout.qml +++ b/lookandfeel/contents/logout/Logout.qml @@ -155,6 +155,18 @@ PlasmaCore.ColorScope { visible: sessionsModel.count > 1 } + PlasmaComponents.Label { + font.pointSize: theme.defaultFont.pointSize + 1 + Layout.maximumWidth: units.gridUnit * 16 + Layout.alignment: Qt.AlignHCenter + Layout.fillWidth: true + horizontalAlignment: Text.AlignHCenter + wrapMode: Text.WordWrap + font.italic: true + text: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "When restarted, the computer will enter the firmware setup screen.") + visible: rebootToFirmwareSetup + } + RowLayout { spacing: units.largeSpacing * 2 Layout.alignment: Qt.AlignHCenter