Changeset View
Changeset View
Standalone View
Standalone View
daemon/actions/bundled/handlebuttoneventsconfig.cpp
Show All 17 Lines | |||||
18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * | 18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * | ||
19 | ***************************************************************************/ | 19 | ***************************************************************************/ | ||
20 | 20 | | |||
21 | #include "handlebuttoneventsconfig.h" | 21 | #include "handlebuttoneventsconfig.h" | ||
22 | 22 | | |||
23 | #include "suspendsession.h" | 23 | #include "suspendsession.h" | ||
24 | #include "upower_interface.h" | 24 | #include "upower_interface.h" | ||
25 | 25 | | |||
26 | #include <Solid/Device> | 26 | #include "powerdevilpowermanagement.h" | ||
27 | #include <Solid/PowerManagement> | | |||
28 | 27 | | |||
29 | #include <KLocalizedString> | 28 | #include <KLocalizedString> | ||
30 | #include <KPluginFactory> | 29 | #include <KPluginFactory> | ||
31 | #include <KSharedConfig> | 30 | #include <KSharedConfig> | ||
32 | #include <QComboBox> | 31 | #include <QComboBox> | ||
33 | #include <QCheckBox> | 32 | #include <QCheckBox> | ||
34 | #include <QIcon> | 33 | #include <QIcon> | ||
35 | 34 | | |||
▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Line(s) | 83 | { | |||
89 | ); | 88 | ); | ||
90 | m_powerButtonCombo = new QComboBox; | 89 | m_powerButtonCombo = new QComboBox; | ||
91 | 90 | | |||
92 | // Fill the boxes with options! | 91 | // Fill the boxes with options! | ||
93 | { | 92 | { | ||
94 | QList<QComboBox *> boxes; | 93 | QList<QComboBox *> boxes; | ||
95 | boxes << m_lidCloseCombo << m_powerButtonCombo; | 94 | boxes << m_lidCloseCombo << m_powerButtonCombo; | ||
96 | 95 | | |||
97 | QSet< Solid::PowerManagement::SleepState > methods = Solid::PowerManagement::supportedSleepStates(); | | |||
98 | | ||||
99 | Q_FOREACH (QComboBox *box, boxes) { | 96 | Q_FOREACH (QComboBox *box, boxes) { | ||
100 | box->addItem(QIcon::fromTheme("dialog-cancel"), i18n("Do nothing"), (uint)SuspendSession::None); | 97 | box->addItem(QIcon::fromTheme("dialog-cancel"), i18n("Do nothing"), (uint)SuspendSession::None); | ||
101 | if (methods.contains(Solid::PowerManagement::SuspendState)) { | 98 | if (PowerManagement::instance()->canSuspend()) { | ||
102 | box->addItem(QIcon::fromTheme("system-suspend"), i18n("Suspend"), (uint)SuspendSession::ToRamMode); | 99 | box->addItem(QIcon::fromTheme("system-suspend"), i18n("Suspend"), (uint)SuspendSession::ToRamMode); | ||
103 | } | 100 | } | ||
104 | if (methods.contains(Solid::PowerManagement::HibernateState)) { | 101 | if (PowerManagement::instance()->canHibernate()) { | ||
105 | box->addItem(QIcon::fromTheme("system-suspend-hibernate"), i18n("Hibernate"), (uint)SuspendSession::ToDiskMode); | 102 | box->addItem(QIcon::fromTheme("system-suspend-hibernate"), i18n("Hibernate"), (uint)SuspendSession::ToDiskMode); | ||
106 | } | 103 | } | ||
107 | if (methods.contains(Solid::PowerManagement::HybridSuspendState)) { | 104 | if (PowerManagement::instance()->canHybridSuspend()) { | ||
108 | box->addItem(QIcon::fromTheme("system-suspend-hybrid"), i18n("Hybrid suspend"), (uint)SuspendSession::SuspendHybridMode); | 105 | box->addItem(QIcon::fromTheme("system-suspend-hybrid"), i18n("Hybrid suspend"), (uint)SuspendSession::SuspendHybridMode); | ||
109 | } | 106 | } | ||
110 | box->addItem(QIcon::fromTheme("system-shutdown"), i18n("Shut down"), (uint)SuspendSession::ShutdownMode); | 107 | box->addItem(QIcon::fromTheme("system-shutdown"), i18n("Shut down"), (uint)SuspendSession::ShutdownMode); | ||
111 | box->addItem(QIcon::fromTheme("system-lock-screen"), i18n("Lock screen"), (uint)SuspendSession::LockScreenMode); | 108 | box->addItem(QIcon::fromTheme("system-lock-screen"), i18n("Lock screen"), (uint)SuspendSession::LockScreenMode); | ||
112 | if (box != m_lidCloseCombo) { | 109 | if (box != m_lidCloseCombo) { | ||
113 | box->addItem(QIcon::fromTheme("system-log-out"), i18n("Prompt log out dialog"), (uint)SuspendSession::LogoutDialogMode); | 110 | box->addItem(QIcon::fromTheme("system-log-out"), i18n("Prompt log out dialog"), (uint)SuspendSession::LogoutDialogMode); | ||
114 | } | 111 | } | ||
115 | box->addItem(QIcon::fromTheme("preferences-desktop-screensaver"), i18n("Turn off screen"), (uint)SuspendSession::TurnOffScreenMode); | 112 | box->addItem(QIcon::fromTheme("preferences-desktop-screensaver"), i18n("Turn off screen"), (uint)SuspendSession::TurnOffScreenMode); | ||
▲ Show 20 Lines • Show All 66 Lines • Show Last 20 Lines |