diff --git a/logout-greeter/shutdowndlg.cpp b/logout-greeter/shutdowndlg.cpp --- a/logout-greeter/shutdowndlg.cpp +++ b/logout-greeter/shutdowndlg.cpp @@ -30,6 +30,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -66,6 +69,12 @@ #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 @@ 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 --- a/lookandfeel/contents/logout/Logout.qml +++ b/lookandfeel/contents/logout/Logout.qml @@ -155,6 +155,18 @@ 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