Changeset View
Changeset View
Standalone View
Standalone View
runners/sessions/sessionrunner.cpp
Show All 12 Lines | |||||
13 | * You should have received a copy of the GNU Library General Public | 13 | * You should have received a copy of the GNU Library General Public | ||
14 | * License along with this program; if not, write to the | 14 | * License along with this program; if not, write to the | ||
15 | * Free Software Foundation, Inc., | 15 | * Free Software Foundation, Inc., | ||
16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
17 | */ | 17 | */ | ||
18 | 18 | | |||
19 | #include "sessionrunner.h" | 19 | #include "sessionrunner.h" | ||
20 | 20 | | |||
21 | | ||||
22 | #include <KAuthorized> | 21 | #include <KAuthorized> | ||
23 | #include <QDebug> | 22 | #include <QDebug> | ||
24 | #include <KLocalizedString> | 23 | #include <KLocalizedString> | ||
25 | #include <QMessageBox> | 24 | #include <QMessageBox> | ||
26 | 25 | | |||
27 | #include "kworkspace.h" | 26 | #include "kworkspace.h" | ||
28 | 27 | | |||
29 | #include "screensaver_interface.h" | 28 | #include "screensaver_interface.h" | ||
▲ Show 20 Lines • Show All 178 Lines • ▼ Show 20 Line(s) | 123 | { | |||
208 | 207 | | |||
209 | context.addMatches(matches); | 208 | context.addMatches(matches); | ||
210 | } | 209 | } | ||
211 | 210 | | |||
212 | void SessionRunner::run(const Plasma::RunnerContext &context, const Plasma::QueryMatch &match) | 211 | void SessionRunner::run(const Plasma::RunnerContext &context, const Plasma::QueryMatch &match) | ||
213 | { | 212 | { | ||
214 | Q_UNUSED(context); | 213 | Q_UNUSED(context); | ||
215 | if (match.data().type() == QVariant::Int) { | 214 | if (match.data().type() == QVariant::Int) { | ||
216 | KWorkSpace::ShutdownType type = KWorkSpace::ShutdownTypeDefault; | | |||
217 | | ||||
218 | switch (match.data().toInt()) { | 215 | switch (match.data().toInt()) { | ||
219 | case LogoutAction: | 216 | case LogoutAction: | ||
220 | type = KWorkSpace::ShutdownTypeNone; | 217 | m_session.requestLogout(); | ||
221 | break; | 218 | break; | ||
222 | case RestartAction: | 219 | case RestartAction: | ||
223 | type = KWorkSpace::ShutdownTypeReboot; | 220 | m_session.requestReboot(); | ||
224 | break; | 221 | break; | ||
225 | case ShutdownAction: | 222 | case ShutdownAction: | ||
226 | type = KWorkSpace::ShutdownTypeHalt; | 223 | m_session.requestShutdown(); | ||
227 | break; | 224 | break; | ||
228 | case LockAction: | 225 | case LockAction: | ||
229 | lock(); | 226 | m_session.lock(); | ||
230 | return; | | |||
231 | break; | 227 | break; | ||
232 | } | 228 | } | ||
233 | | ||||
234 | if (type != KWorkSpace::ShutdownTypeDefault) { | | |||
235 | KWorkSpace::ShutdownConfirm confirm = KWorkSpace::ShutdownConfirmDefault; | | |||
236 | KWorkSpace::requestShutDown(confirm, type); | | |||
237 | return; | 229 | return; | ||
238 | } | 230 | } | ||
239 | } | | |||
240 | 231 | | |||
241 | if (!match.data().toString().isEmpty()) { | 232 | if (!match.data().toString().isEmpty()) { | ||
242 | dm.lockSwitchVT(match.data().toString().toInt()); | 233 | dm.lockSwitchVT(match.data().toString().toInt()); | ||
243 | return; | 234 | return; | ||
244 | } | 235 | } | ||
245 | 236 | | |||
246 | //TODO: this message is too verbose and too technical. | 237 | //TODO: this message is too verbose and too technical. | ||
247 | int result = QMessageBox::warning( | 238 | int result = QMessageBox::warning( | ||
Show All 9 Lines | 241 | i18n("<p>You have chosen to open another desktop session.<br />" | |||
257 | "Ctrl, Alt and the appropriate F-key at the same time. " | 248 | "Ctrl, Alt and the appropriate F-key at the same time. " | ||
258 | "Additionally, the KDE Panel and Desktop menus have " | 249 | "Additionally, the KDE Panel and Desktop menus have " | ||
259 | "actions for switching between sessions.</p>", | 250 | "actions for switching between sessions.</p>", | ||
260 | 7, 8)); | 251 | 7, 8)); | ||
261 | 252 | | |||
262 | if (result == QMessageBox::Cancel) { | 253 | if (result == QMessageBox::Cancel) { | ||
263 | return; | 254 | return; | ||
264 | } | 255 | } | ||
256 | m_session.lock(); | ||||
265 | 257 | | |||
266 | lock(); | | |||
broulik: This got lost. Ideally that also followed the "automatically lock" setting like everywhere else… | |||||
267 | dm.startReserve(); | 258 | dm.startReserve(); | ||
268 | } | 259 | } | ||
269 | 260 | | |||
270 | void SessionRunner::lock() | | |||
271 | { | | |||
272 | QString interface(QStringLiteral("org.freedesktop.ScreenSaver")); | | |||
273 | org::freedesktop::ScreenSaver screensaver(interface, QStringLiteral("/ScreenSaver"), | | |||
274 | QDBusConnection::sessionBus()); | | |||
275 | if (screensaver.isValid()) { | | |||
276 | screensaver.Lock(); | | |||
277 | } | | |||
278 | } | | |||
279 | | ||||
280 | #include "sessionrunner.moc" | 261 | #include "sessionrunner.moc" |
This got lost. Ideally that also followed the "automatically lock" setting like everywhere else, cf. SessionsModel