Changeset View
Changeset View
Standalone View
Standalone View
daemon/actions/bundled/suspendsessionconfig.cpp
Show All 14 Lines | |||||
15 | * along with this program; if not, write to the * | 15 | * along with this program; if not, write to the * | ||
16 | * Free Software Foundation, Inc., * | 16 | * Free Software Foundation, Inc., * | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * | 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * | ||
18 | ***************************************************************************/ | 18 | ***************************************************************************/ | ||
19 | 19 | | |||
20 | 20 | | |||
21 | #include "suspendsessionconfig.h" | 21 | #include "suspendsessionconfig.h" | ||
22 | 22 | | |||
23 | #include "powerdevilpowermanagement.h" | ||||
24 | | ||||
23 | #include <QHBoxLayout> | 25 | #include <QHBoxLayout> | ||
24 | #include <QSpinBox> | 26 | #include <QSpinBox> | ||
25 | 27 | | |||
26 | #include <Solid/PowerManagement> | | |||
27 | | ||||
28 | #include <KComboBox> | 28 | #include <KComboBox> | ||
29 | #include <KLocalizedString> | 29 | #include <KLocalizedString> | ||
30 | #include <KPluginFactory> | 30 | #include <KPluginFactory> | ||
31 | #include <KSharedConfig> | 31 | #include <KSharedConfig> | ||
32 | #include <QIcon> | 32 | #include <QIcon> | ||
33 | #include <KConfig> | 33 | #include <KConfig> | ||
34 | #include "suspendsession.h" | 34 | #include "suspendsession.h" | ||
35 | 35 | | |||
Show All 37 Lines | 70 | { | |||
73 | m_comboBox = new KComboBox; | 73 | m_comboBox = new KComboBox; | ||
74 | m_idleTime = new QSpinBox; | 74 | m_idleTime = new QSpinBox; | ||
75 | m_idleTime->setMaximumWidth(150); | 75 | m_idleTime->setMaximumWidth(150); | ||
76 | m_idleTime->setMinimum(1); | 76 | m_idleTime->setMinimum(1); | ||
77 | m_idleTime->setMaximum(360); | 77 | m_idleTime->setMaximum(360); | ||
78 | m_idleTime->setValue(0); | 78 | m_idleTime->setValue(0); | ||
79 | m_idleTime->setSuffix(i18n(" min")); | 79 | m_idleTime->setSuffix(i18n(" min")); | ||
80 | 80 | | |||
81 | QSet< Solid::PowerManagement::SleepState > methods = Solid::PowerManagement::supportedSleepStates(); | 81 | if (PowerManagement::instance()->canSuspend()) { | ||
82 | | ||||
83 | if (methods.contains(Solid::PowerManagement::SuspendState)) { | | |||
84 | m_comboBox->addItem(QIcon::fromTheme("system-suspend"), i18n("Suspend"), (uint)SuspendSession::ToRamMode); | 82 | m_comboBox->addItem(QIcon::fromTheme("system-suspend"), i18n("Suspend"), (uint)SuspendSession::ToRamMode); | ||
85 | } | 83 | } | ||
86 | if (methods.contains(Solid::PowerManagement::HibernateState)) { | 84 | if (PowerManagement::instance()->canHibernate()) { | ||
87 | m_comboBox->addItem(QIcon::fromTheme("system-suspend-hibernate"), i18n("Hibernate"), (uint)SuspendSession::ToDiskMode); | 85 | m_comboBox->addItem(QIcon::fromTheme("system-suspend-hibernate"), i18n("Hibernate"), (uint)SuspendSession::ToDiskMode); | ||
88 | } | 86 | } | ||
89 | if (methods.contains(Solid::PowerManagement::HybridSuspendState)) { | 87 | if (PowerManagement::instance()->canHybridSuspend()) { | ||
90 | m_comboBox->addItem(QIcon::fromTheme("system-suspend-hybrid"), i18n("Hybrid suspend"), (uint)SuspendSession::SuspendHybridMode); | 88 | m_comboBox->addItem(QIcon::fromTheme("system-suspend-hybrid"), i18n("Hybrid suspend"), (uint)SuspendSession::SuspendHybridMode); | ||
91 | } | 89 | } | ||
92 | m_comboBox->addItem(QIcon::fromTheme("system-shutdown"), i18n("Shut down"), (uint)SuspendSession::ShutdownMode); | 90 | m_comboBox->addItem(QIcon::fromTheme("system-shutdown"), i18n("Shut down"), (uint)SuspendSession::ShutdownMode); | ||
93 | m_comboBox->addItem(QIcon::fromTheme("system-lock-screen"), i18n("Lock screen"), (uint)SuspendSession::LockScreenMode); | 91 | m_comboBox->addItem(QIcon::fromTheme("system-lock-screen"), i18n("Lock screen"), (uint)SuspendSession::LockScreenMode); | ||
94 | 92 | | |||
95 | hlay->addWidget(m_idleTime); | 93 | hlay->addWidget(m_idleTime); | ||
96 | hlay->addWidget(m_comboBox); | 94 | hlay->addWidget(m_comboBox); | ||
97 | hlay->addStretch(); | 95 | hlay->addStretch(); | ||
Show All 16 Lines |