diff --git a/daemon/actions/bundled/handlebuttonevents.h b/daemon/actions/bundled/handlebuttonevents.h --- a/daemon/actions/bundled/handlebuttonevents.h +++ b/daemon/actions/bundled/handlebuttonevents.h @@ -73,6 +73,7 @@ uint m_lidAction = 0; bool m_triggerLidActionWhenExternalMonitorPresent = false; bool m_externalMonitorPresent = false; + bool m_suspendThenHibernateEnabled = false; uint m_powerButtonAction = 0; uint m_sleepButtonAction = 1; diff --git a/daemon/actions/bundled/handlebuttonevents.cpp b/daemon/actions/bundled/handlebuttonevents.cpp --- a/daemon/actions/bundled/handlebuttonevents.cpp +++ b/daemon/actions/bundled/handlebuttonevents.cpp @@ -186,6 +186,7 @@ bool HandleButtonEvents::loadAction(const KConfigGroup& config) { // Read configs + m_suspendThenHibernateEnabled = config.readEntry("suspendThenHibernate", false); m_lidAction = config.readEntry("lidAction", 0); m_triggerLidActionWhenExternalMonitorPresent = config.readEntry("triggerLidActionWhenExternalMonitorPresent", false); m_powerButtonAction = config.readEntry("powerButtonAction", 0); diff --git a/daemon/actions/bundled/handlebuttoneventsconfig.h b/daemon/actions/bundled/handlebuttoneventsconfig.h --- a/daemon/actions/bundled/handlebuttoneventsconfig.h +++ b/daemon/actions/bundled/handlebuttoneventsconfig.h @@ -42,7 +42,6 @@ QList< QPair< QString, QWidget* > > buildUi() override; private: - QCheckBox *m_enableSuspendThenHibernate; QComboBox *m_lidCloseCombo; QCheckBox *m_triggerLidActionWhenExternalMonitorPresent; QComboBox *m_powerButtonCombo; diff --git a/daemon/actions/bundled/handlebuttoneventsconfig.cpp b/daemon/actions/bundled/handlebuttoneventsconfig.cpp --- a/daemon/actions/bundled/handlebuttoneventsconfig.cpp +++ b/daemon/actions/bundled/handlebuttoneventsconfig.cpp @@ -60,13 +60,6 @@ if (m_powerButtonCombo) { configGroup().writeEntry("powerButtonAction", m_powerButtonCombo->itemData(m_powerButtonCombo->currentIndex()).toUInt()); } - if(m_enableSuspendThenHibernate) { - // save true only if the system can suspend and hibernate - configGroup().writeEntry( - "suspendThenHibernate", m_enableSuspendThenHibernate->isChecked()); - } else { - configGroup().writeEntry("suspendThenHibernate", false); - } configGroup().sync(); } @@ -84,16 +77,11 @@ if (m_powerButtonCombo) { m_powerButtonCombo->setCurrentIndex(m_powerButtonCombo->findData(QVariant::fromValue(configGroup().readEntry("powerButtonAction", 0)))); } - if (m_enableSuspendThenHibernate) { - // check if the system can suspend and hibernate before setting the value. - m_enableSuspendThenHibernate->setChecked(configGroup().readEntry("suspendThenHibernate", false)); - } } QList< QPair< QString, QWidget* > > HandleButtonEventsConfig::buildUi() { // Create the boxes - m_enableSuspendThenHibernate = new QCheckBox(i18nc("Hibernate after a delay when suspended", "Hibernate after a delay when suspended")); m_lidCloseCombo = new QComboBox; m_triggerLidActionWhenExternalMonitorPresent = new QCheckBox( i18nc("Execute action on lid close even when external monitor is connected", "Even when an external monitor is connected") @@ -128,7 +116,6 @@ connect(m_lidCloseCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(setChanged())); connect(m_triggerLidActionWhenExternalMonitorPresent, SIGNAL(stateChanged(int)), this, SLOT(setChanged())); connect(m_powerButtonCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(setChanged())); - connect(m_enableSuspendThenHibernate, SIGNAL(stateChanged(int)), this, SLOT(setChanged())); bool lidFound = false; bool powerFound = true; // HACK This needs proper API!! @@ -164,12 +151,6 @@ m_powerButtonCombo->deleteLater(); m_powerButtonCombo = nullptr; } - if (PowerManagement::instance()->canSuspendThenHibernate()) { - retlist.append(qMakePair< QString, QWidget* >(QLatin1Literal("NONE"), m_enableSuspendThenHibernate)); - } else { - m_enableSuspendThenHibernate->deleteLater(); - m_enableSuspendThenHibernate = nullptr; - } // unified width for the comboboxes @@ -180,9 +161,6 @@ if (m_powerButtonCombo) { comboBoxMaxWidth = qMax(comboBoxMaxWidth, m_powerButtonCombo->sizeHint().width()); } - if (m_enableSuspendThenHibernate) { - comboBoxMaxWidth = qMax(comboBoxMaxWidth, m_enableSuspendThenHibernate->sizeHint().width()); - } if (m_lidCloseCombo) { m_lidCloseCombo->setMinimumWidth(300); m_lidCloseCombo->setMaximumWidth(comboBoxMaxWidth); @@ -191,10 +169,6 @@ m_powerButtonCombo->setMinimumWidth(300); m_powerButtonCombo->setMaximumWidth(comboBoxMaxWidth); } - if(m_enableSuspendThenHibernate) { - m_enableSuspendThenHibernate->setMinimumWidth(300); - m_enableSuspendThenHibernate->setMaximumWidth(comboBoxMaxWidth); - } return retlist; } diff --git a/daemon/actions/bundled/suspendsession.h b/daemon/actions/bundled/suspendsession.h --- a/daemon/actions/bundled/suspendsession.h +++ b/daemon/actions/bundled/suspendsession.h @@ -49,8 +49,7 @@ LogoutDialogMode = 16, LockScreenMode = 32, TurnOffScreenMode = 64, - ToggleScreenOnOffMode = 128, - SuspendThenHibernateMode = 256 + ToggleScreenOnOffMode = 128 }; explicit SuspendSession(QObject *parent); @@ -69,7 +68,6 @@ void suspendToRam(); void suspendToDisk(); void suspendHybrid(); - void suspendThenHibernate(); Q_SIGNALS: void aboutToSuspend(); @@ -79,6 +77,7 @@ void triggerSuspendSession(uint action); private: + bool m_suspendThenHibernateEnabled = false; int m_idleTime = 0; uint m_autoType; QVariantMap m_savedArgs; diff --git a/daemon/actions/bundled/suspendsession.cpp b/daemon/actions/bundled/suspendsession.cpp --- a/daemon/actions/bundled/suspendsession.cpp +++ b/daemon/actions/bundled/suspendsession.cpp @@ -111,7 +111,7 @@ const auto mode = static_cast(args["Type"].toUInt()); - if (mode == ToRamMode || mode == ToDiskMode || mode == SuspendHybridMode || mode == SuspendThenHibernateMode) { + if (mode == ToRamMode || mode == ToDiskMode || mode == SuspendHybridMode) { // don't suspend if shutting down if (KWorkSpace::isShuttingDown()) { qCDebug(POWERDEVIL) << "Not suspending because a shutdown is in progress"; @@ -134,7 +134,11 @@ switch ((Mode) (args["Type"].toUInt())) { case ToRamMode: Q_EMIT aboutToSuspend(); - suspendJob = backend()->suspend(PowerDevil::BackendInterface::ToRam); + if (m_suspendThenHibernateEnabled) { + suspendJob = backend()->suspend(PowerDevil::BackendInterface::SuspendThenHibernate); + } else { + suspendJob = backend()->suspend(PowerDevil::BackendInterface::ToRam); + } break; case ToDiskMode: Q_EMIT aboutToSuspend(); @@ -144,10 +148,6 @@ Q_EMIT aboutToSuspend(); suspendJob = backend()->suspend(PowerDevil::BackendInterface::HybridSuspend); break; - case SuspendThenHibernateMode: - Q_EMIT aboutToSuspend(); - suspendJob = backend()->suspend(PowerDevil::BackendInterface::SuspendThenHibernate); - break; case ShutdownMode: KWorkSpace::requestShutDown(KWorkSpace::ShutdownConfirmNo, KWorkSpace::ShutdownTypeHalt); break; @@ -183,6 +183,9 @@ } m_autoType = config.readEntry("suspendType", 0); } + if (config.isValid() && config.hasKey("suspendThenHibernate")) { + m_suspendThenHibernateEnabled = config.readEntry("suspendThenHibernate", false); + } return true; } @@ -202,11 +205,6 @@ triggerSuspendSession(ToRamMode); } -void SuspendSession::suspendThenHibernate() -{ - triggerSuspendSession(SuspendThenHibernateMode); -} - void SuspendSession::triggerSuspendSession(uint action) { trigger({ diff --git a/daemon/actions/bundled/suspendsessionconfig.h b/daemon/actions/bundled/suspendsessionconfig.h --- a/daemon/actions/bundled/suspendsessionconfig.h +++ b/daemon/actions/bundled/suspendsessionconfig.h @@ -44,7 +44,7 @@ private: QSpinBox *m_idleTime; - QCheckBox *m_suspendThenHibernateEnabled; + QCheckBox *m_suspendThenHibernateCheck; KComboBox *m_comboBox; }; diff --git a/daemon/actions/bundled/suspendsessionconfig.cpp b/daemon/actions/bundled/suspendsessionconfig.cpp --- a/daemon/actions/bundled/suspendsessionconfig.cpp +++ b/daemon/actions/bundled/suspendsessionconfig.cpp @@ -54,9 +54,9 @@ { configGroup().writeEntry< uint >("suspendType", m_comboBox->itemData(m_comboBox->currentIndex()).toUInt()); configGroup().writeEntry("idleTime", m_idleTime->value() * 60 * 1000); - if (m_suspendThenHibernateEnabled) { + if (m_suspendThenHibernateCheck) { configGroup().writeEntry( - "suspendThenHibernate", m_suspendThenHibernateEnabled->isChecked()); + "suspendThenHibernate", m_suspendThenHibernateCheck->isChecked()); } else { configGroup().writeEntry("suspendThenHibernate", false); } @@ -71,15 +71,15 @@ uint suspendType = configGroup().readEntry< uint >("suspendType", 0); m_comboBox->setCurrentIndex(m_comboBox->findData(suspendType)); m_idleTime->setValue((configGroup().readEntry("idleTime", 600000) / 60) / 1000); - if (m_suspendThenHibernateEnabled) { - m_suspendThenHibernateEnabled->setChecked(configGroup().readEntry("suspendThenHibernate", false)); + if (m_suspendThenHibernateCheck) { + m_suspendThenHibernateCheck->setChecked(configGroup().readEntry("suspendThenHibernate", false)); } } QList< QPair< QString, QWidget* > > SuspendSessionConfig::buildUi() { - m_suspendThenHibernateEnabled = new QCheckBox( - i18nc("Hibernate after a delay when suspended", "Hibernate after a delay when suspended")); + m_suspendThenHibernateCheck = new QCheckBox( + i18nc("Hibernate after 3 hours when suspended", "Hibernate after 3 hours when suspended")); QWidget *tempWidget = new QWidget; QHBoxLayout *hlay = new QHBoxLayout; m_comboBox = new KComboBox; @@ -114,20 +114,19 @@ connect(m_comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(setChanged())); connect(m_idleTime, SIGNAL(valueChanged(int)), this, SLOT(setChanged())); - connect(m_suspendThenHibernateEnabled, SIGNAL(stateChanged(int)), this, SLOT(setChanged())); + connect(m_suspendThenHibernateCheck, SIGNAL(stateChanged(int)), this, SLOT(setChanged())); if (PowerManagement::instance()->canSuspendThenHibernate()) { - retlist.append(qMakePair< QString, QWidget* >(QLatin1Literal("NONE"), m_suspendThenHibernateEnabled)); + retlist.append(qMakePair< QString, QWidget* >(QLatin1Literal("NONE"), m_suspendThenHibernateCheck)); } else { - m_suspendThenHibernateEnabled->deleteLater(); - m_suspendThenHibernateEnabled = nullptr; + m_suspendThenHibernateCheck->deleteLater(); + m_suspendThenHibernateCheck = nullptr; } - int comboBoxMaxWidth = 300; - if (m_suspendThenHibernateEnabled) { - comboBoxMaxWidth = qMax(comboBoxMaxWidth, m_suspendThenHibernateEnabled->sizeHint().width()); - m_suspendThenHibernateEnabled->setMinimumWidth(300); - m_suspendThenHibernateEnabled->setMaximumWidth(comboBoxMaxWidth); + if (m_suspendThenHibernateCheck) { + int comboBoxMinWidth = 300; + m_suspendThenHibernateCheck->setMinimumWidth(comboBoxMinWidth); + m_suspendThenHibernateCheck->setMaximumWidth(qMax(comboBoxMinWidth, m_suspendThenHibernateCheck->sizeHint().width())); } return retlist; @@ -135,5 +134,5 @@ } } -r + #include "suspendsessionconfig.moc" diff --git a/daemon/org.freedesktop.PowerManagement.xml b/daemon/org.freedesktop.PowerManagement.xml --- a/daemon/org.freedesktop.PowerManagement.xml +++ b/daemon/org.freedesktop.PowerManagement.xml @@ -11,7 +11,7 @@ - + @@ -30,7 +30,7 @@ - + diff --git a/daemon/powerdevilfdoconnector.cpp b/daemon/powerdevilfdoconnector.cpp --- a/daemon/powerdevilfdoconnector.cpp +++ b/daemon/powerdevilfdoconnector.cpp @@ -93,11 +93,6 @@ triggerSuspendSession(BundledActions::SuspendSession::SuspendHybridMode); } -void FdoConnector::SuspendThenHibernate() -{ - triggerSuspendSession(BundledActions::SuspendSession::SuspendThenHibernateMode); -} - bool FdoConnector::HasInhibit() { return PolicyAgent::instance()->requirePolicyCheck(PolicyAgent::InterruptSession) != PolicyAgent::None; diff --git a/kcmodule/activities/activitywidget.cpp b/kcmodule/activities/activitywidget.cpp --- a/kcmodule/activities/activitywidget.cpp +++ b/kcmodule/activities/activitywidget.cpp @@ -100,10 +100,6 @@ m_ui->alwaysActionBox->addItem(QIcon::fromTheme("system-suspend-hibernate"), i18n("Hibernate"), (uint)SuspendSession::ToDiskMode); } - if (PowerDevil::PowerManagement::instance()->canSuspendThenHibernate()) { - m_ui->alwaysActionBox->addItem(QIcon::fromTheme("system-suspend-hibernate"), - i18n("Suspend then Hibernate"), (uint)SuspendSession::SuspendThenHibernateMode); - } m_ui->alwaysActionBox->addItem(QIcon::fromTheme("system-shutdown"), i18n("Shut down"), (uint)SuspendSession::ShutdownMode); m_ui->actLikeComboBox->clear();