diff --git a/containmentactions/contextmenu/menu.h b/containmentactions/contextmenu/menu.h --- a/containmentactions/contextmenu/menu.h +++ b/containmentactions/contextmenu/menu.h @@ -1,5 +1,8 @@ /* * Copyright 2009 by Chani Armitage + * Copyright (c) 2018 Kai Uwe Broulik + * Work sponsored by the LiMux project of + * the city of Munich. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as @@ -44,11 +47,13 @@ void lockScreen(); void startLogout(); void logout(); + void openDisplaySettings(); private: QAction *m_runCommandAction; QAction *m_lockScreenAction; QAction *m_logoutAction; + QAction *m_displaySettingsAction; QAction *m_separator1; QAction *m_separator2; QAction *m_separator3; diff --git a/containmentactions/contextmenu/menu.cpp b/containmentactions/contextmenu/menu.cpp --- a/containmentactions/contextmenu/menu.cpp +++ b/containmentactions/contextmenu/menu.cpp @@ -1,5 +1,8 @@ /* * Copyright 2009 by Chani Armitage + * Copyright (c) 2018 Kai Uwe Broulik + * Work sponsored by the LiMux project of + * the city of Munich. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as @@ -49,6 +52,7 @@ m_runCommandAction(nullptr), m_lockScreenAction(nullptr), m_logoutAction(nullptr), + m_displaySettingsAction(nullptr), m_separator1(nullptr), m_separator2(nullptr), m_separator3(nullptr), @@ -77,9 +81,10 @@ actions.insert(QStringLiteral("configure shortcuts"), false); m_actionOrder << QStringLiteral("_context") << QStringLiteral("_run_command") << QStringLiteral("add widgets") << QStringLiteral("_add panel") << QStringLiteral("manage activities") << QStringLiteral("remove") << QStringLiteral("lock widgets") << QStringLiteral("_sep1") - <setShortcut(KGlobalAccel::self()->globalShortcut(QStringLiteral("ksmserver"), QStringLiteral("Log Out")).value(0)); connect(m_logoutAction, &QAction::triggered, this, &ContextMenu::startLogout); + m_displaySettingsAction = new QAction(i18nc("plasma_containmentactions_contextmenu", "Configure Displays..."), this); + m_displaySettingsAction->setIcon(QIcon::fromTheme(QStringLiteral("preferences-desktop-display-randr"))); + connect(m_displaySettingsAction, &QAction::triggered, this, &ContextMenu::openDisplaySettings); + m_separator1 = new QAction(this); m_separator1->setSeparator(true); m_separator2 = new QAction(this); @@ -185,6 +194,11 @@ if (c->corona()) { return c->corona()->actions()->action(QStringLiteral("manage activities")); } + } else if (name == QLatin1String("kscreen")) { + if (KAuthorized::authorizeControlModule(QStringLiteral("kcm_kscreen.desktop")) + && KService::serviceByStorageId(QStringLiteral("kcm_kscreen"))) { + return m_displaySettingsAction; + } } else { //FIXME: remove action: make removal of current activity possible return c->actions()->action(name); @@ -246,6 +260,11 @@ KWorkSpace::requestShutDown(); } +void ContextMenu::openDisplaySettings() +{ + QProcess::startDetached(QStringLiteral("kcmshell5"), {QStringLiteral("kcm_kscreen")}); +} + QWidget* ContextMenu::createConfigurationInterface(QWidget* parent) { QWidget *widget = new QWidget(parent);