Changeset View
Changeset View
Standalone View
Standalone View
logout-greeter/shutdowndlg.cpp
Show All 24 Lines | |||||
25 | 25 | | |||
26 | #include <QApplication> | 26 | #include <QApplication> | ||
27 | #include <QQuickItem> | 27 | #include <QQuickItem> | ||
28 | #include <QTimer> | 28 | #include <QTimer> | ||
29 | #include <QFile> | 29 | #include <QFile> | ||
30 | #include <QDBusConnection> | 30 | #include <QDBusConnection> | ||
31 | #include <QDBusMessage> | 31 | #include <QDBusMessage> | ||
32 | #include <QDBusPendingCall> | 32 | #include <QDBusPendingCall> | ||
33 | #include <QDBusPendingCallWatcher> | ||||
34 | #include <QDBusPendingReply> | ||||
35 | #include <QDBusVariant> | ||||
33 | #include <QQuickView> | 36 | #include <QQuickView> | ||
34 | #include <QQmlContext> | 37 | #include <QQmlContext> | ||
35 | #include <QQmlEngine> | 38 | #include <QQmlEngine> | ||
36 | #include <QQmlPropertyMap> | 39 | #include <QQmlPropertyMap> | ||
37 | #include <QPainter> | 40 | #include <QPainter> | ||
38 | #include <QStandardPaths> | 41 | #include <QStandardPaths> | ||
39 | #include <QX11Info> | 42 | #include <QX11Info> | ||
40 | #include <QScreen> | 43 | #include <QScreen> | ||
Show All 20 Lines | |||||
61 | #include <fixx11h.h> | 64 | #include <fixx11h.h> | ||
62 | 65 | | |||
63 | #include <config-workspace.h> | 66 | #include <config-workspace.h> | ||
64 | #include <debug.h> | 67 | #include <debug.h> | ||
65 | 68 | | |||
66 | #include <KWayland/Client/surface.h> | 69 | #include <KWayland/Client/surface.h> | ||
67 | #include <KWayland/Client/plasmashell.h> | 70 | #include <KWayland/Client/plasmashell.h> | ||
68 | 71 | | |||
72 | static const QString s_login1Service = QStringLiteral("org.freedesktop.login1"); | ||||
73 | static const QString s_login1Path = QStringLiteral("/org/freedesktop/login1"); | ||||
74 | static const QString s_dbusPropertiesInterface = QStringLiteral("org.freedesktop.DBus.Properties"); | ||||
75 | static const QString s_login1ManagerInterface = QStringLiteral("org.freedesktop.login1.Manager"); | ||||
76 | static const QString s_login1RebootToFirmwareSetup = QStringLiteral("RebootToFirmwareSetup"); | ||||
77 | | ||||
69 | Q_DECLARE_METATYPE(Solid::PowerManagement::SleepState) | 78 | Q_DECLARE_METATYPE(Solid::PowerManagement::SleepState) | ||
70 | 79 | | |||
71 | KSMShutdownDlg::KSMShutdownDlg(QWindow* parent, | 80 | KSMShutdownDlg::KSMShutdownDlg(QWindow* parent, | ||
72 | bool maysd, KWorkSpace::ShutdownType sdtype, | 81 | bool maysd, KWorkSpace::ShutdownType sdtype, | ||
73 | KWayland::Client::PlasmaShell *plasmaShell) | 82 | KWayland::Client::PlasmaShell *plasmaShell) | ||
74 | : QuickViewSharedEngine(parent), | 83 | : QuickViewSharedEngine(parent), | ||
75 | m_result(false), | 84 | m_result(false), | ||
76 | m_waylandPlasmaShell(plasmaShell) | 85 | m_waylandPlasmaShell(plasmaShell) | ||
Show All 36 Lines | 88 | { | |||
113 | QQmlPropertyMap *mapSpdMethods = new QQmlPropertyMap(this); | 122 | QQmlPropertyMap *mapSpdMethods = new QQmlPropertyMap(this); | ||
114 | QSet<Solid::PowerManagement::SleepState> spdMethods = Solid::PowerManagement::supportedSleepStates(); | 123 | QSet<Solid::PowerManagement::SleepState> spdMethods = Solid::PowerManagement::supportedSleepStates(); | ||
115 | mapSpdMethods->insert(QStringLiteral("StandbyState"), QVariant::fromValue(spdMethods.contains(Solid::PowerManagement::StandbyState))); | 124 | mapSpdMethods->insert(QStringLiteral("StandbyState"), QVariant::fromValue(spdMethods.contains(Solid::PowerManagement::StandbyState))); | ||
116 | mapSpdMethods->insert(QStringLiteral("SuspendState"), QVariant::fromValue(spdMethods.contains(Solid::PowerManagement::SuspendState))); | 125 | mapSpdMethods->insert(QStringLiteral("SuspendState"), QVariant::fromValue(spdMethods.contains(Solid::PowerManagement::SuspendState))); | ||
117 | mapSpdMethods->insert(QStringLiteral("HibernateState"), QVariant::fromValue(spdMethods.contains(Solid::PowerManagement::HibernateState))); | 126 | mapSpdMethods->insert(QStringLiteral("HibernateState"), QVariant::fromValue(spdMethods.contains(Solid::PowerManagement::HibernateState))); | ||
118 | context->setContextProperty(QStringLiteral("spdMethods"), mapSpdMethods); | 127 | context->setContextProperty(QStringLiteral("spdMethods"), mapSpdMethods); | ||
119 | context->setContextProperty(QStringLiteral("canLogout"), KAuthorized::authorize(QStringLiteral("logout"))); | 128 | context->setContextProperty(QStringLiteral("canLogout"), KAuthorized::authorize(QStringLiteral("logout"))); | ||
120 | 129 | | |||
130 | // Trying to access a non-existant context property throws an error, always create the property and then update it later | ||||
131 | context->setContextProperty("rebootToFirmwareSetup", false); | ||||
132 | | ||||
133 | QDBusMessage message = QDBusMessage::createMethodCall(s_login1Service, s_login1Path, s_dbusPropertiesInterface, QStringLiteral("Get")); | ||||
134 | message.setArguments({s_login1ManagerInterface, s_login1RebootToFirmwareSetup}); | ||||
135 | QDBusPendingReply<QVariant> call = QDBusConnection::systemBus().asyncCall(message); | ||||
136 | QDBusPendingCallWatcher *callWatcher = new QDBusPendingCallWatcher(call, this); | ||||
137 | connect(callWatcher, &QDBusPendingCallWatcher::finished, context, [context](QDBusPendingCallWatcher *watcher) { | ||||
138 | QDBusPendingReply<QVariant> reply = *watcher; | ||||
139 | watcher->deleteLater(); | ||||
140 | | ||||
141 | if (reply.value().toBool()) { | ||||
142 | context->setContextProperty("rebootToFirmwareSetup", true); | ||||
143 | } | ||||
144 | }); | ||||
145 | | ||||
121 | // TODO KF6 remove, used to read "BootManager" from kdmrc | 146 | // TODO KF6 remove, used to read "BootManager" from kdmrc | ||
122 | context->setContextProperty(QStringLiteral("bootManager"), QStringLiteral("None")); | 147 | context->setContextProperty(QStringLiteral("bootManager"), QStringLiteral("None")); | ||
123 | 148 | | |||
124 | //TODO KF6 remove. Unused | 149 | //TODO KF6 remove. Unused | ||
125 | context->setContextProperty(QStringLiteral("choose"), false); | 150 | context->setContextProperty(QStringLiteral("choose"), false); | ||
126 | 151 | | |||
127 | 152 | | |||
128 | // TODO KF6 remove, used to call KDisplayManager::bootOptions | 153 | // TODO KF6 remove, used to call KDisplayManager::bootOptions | ||
▲ Show 20 Lines • Show All 182 Lines • Show Last 20 Lines |