diff options
author | Michele Calgaro <michele.calgaro@yahoo.it> | 2018-11-06 23:43:05 +0900 |
---|---|---|
committer | Michele Calgaro <michele.calgaro@yahoo.it> | 2019-02-13 18:05:37 +0900 |
commit | 359dc4faf49d8087260ac3a7110025491c9663c1 (patch) | |
tree | 95a10c33a7770007faacd073ec2e78557f45387f | |
parent | 98abb9e8ee924fb0b19cf8bfc40752f97ed8afb3 (diff) | |
download | tdebase-359dc4faf49d8087260ac3a7110025491c9663c1.tar.gz tdebase-359dc4faf49d8087260ac3a7110025491c9663c1.zip |
Fixed support for freeze/standby/suspend/hybrid suspend/hibernate in
main menus (both Classic and Kickoff).
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
-rw-r--r-- | kicker/kicker/ui/k_new_mnu.cpp | 98 | ||||
-rw-r--r-- | ksmserver/shutdowndlg.cpp | 183 | ||||
-rw-r--r-- | ksmserver/shutdowndlg.h | 5 |
3 files changed, 156 insertions, 130 deletions
diff --git a/kicker/kicker/ui/k_new_mnu.cpp b/kicker/kicker/ui/k_new_mnu.cpp index de97b592b..7541d5d94 100644 --- a/kicker/kicker/ui/k_new_mnu.cpp +++ b/kicker/kicker/ui/k_new_mnu.cpp @@ -146,8 +146,8 @@ enum SuspendType { Freeze, Standby, Suspend, - Hibernate, - HybridSuspend + HybridSuspend, + Hibernate }; }; @@ -2745,12 +2745,12 @@ void KMenu::slotStartURL(const TQString& u) else if ( u == "kicker:/suspend_ram" ) { slotSuspend( SuspendType::Suspend ); } - else if ( u == "kicker:/suspend_disk" ) { - slotSuspend( SuspendType::Hibernate ); - } else if ( u == "kicker:/hybrid_suspend" ) { slotSuspend( SuspendType::HybridSuspend ); } + else if ( u == "kicker:/suspend_disk" ) { + slotSuspend( SuspendType::Hibernate ); + } else if ( u == "kicker:/savesession" ) { TQByteArray data; kapp->dcopClient()->send( "ksmserver", "default", @@ -3810,50 +3810,54 @@ int KMenu::max_items(int category) const void KMenu::insertSuspendOption( int &nId, int &index ) { - bool suspend_ram = false; - bool suspend_freeze = false; - bool standby = false; - bool suspend_disk = false; - bool hybrid_suspend = false; + bool canFreeze = false; + bool canStandby = false; + bool canSuspend = false; + bool canHybridSuspend = false; + bool canHibernate = false; + #if defined(COMPILE_HALBACKEND) - suspend_ram = libhal_device_get_property_bool(m_halCtx, + canStandby = libhal_device_get_property_bool(m_halCtx, "/org/freedesktop/Hal/devices/computer", - "power_management.can_suspend", + "power_management.can_standby", NULL); - standby = libhal_device_get_property_bool(m_halCtx, + canSuspend = libhal_device_get_property_bool(m_halCtx, "/org/freedesktop/Hal/devices/computer", - "power_management.can_standby", + "power_management.can_suspend", NULL); - suspend_disk = libhal_device_get_property_bool(m_halCtx, + canHybridSuspend = libhal_device_get_property_bool(m_halCtx, "/org/freedesktop/Hal/devices/computer", - "power_management.can_hibernate", + "power_management.can_suspend_hybrid", NULL); - hybrid_suspend = libhal_device_get_property_bool(m_halCtx, + canHibernate = libhal_device_get_property_bool(m_halCtx, "/org/freedesktop/Hal/devices/computer", - "power_management.can_suspend_hybrid", + "power_management.can_hibernate", NULL); #elif defined(__TDE_HAVE_TDEHWLIB) // COMPILE_HALBACKEND TDERootSystemDevice* rootDevice = TDEGlobal::hardwareDevices()->rootSystemDevice(); if (rootDevice) { - suspend_ram = rootDevice->canSuspend(); - suspend_freeze = rootDevice->canFreeze(); - standby = rootDevice->canStandby(); - suspend_disk = rootDevice->canHibernate(); - hybrid_suspend = rootDevice->canHybridSuspend(); + canFreeze = rootDevice->canFreeze(); + canStandby = rootDevice->canStandby(); + canSuspend = rootDevice->canSuspend(); + canHybridSuspend = rootDevice->canHybridSuspend(); + canHibernate = rootDevice->canHibernate(); } #endif m_exitView->leftView()->insertSeparator( nId++, i18n("Suspend"), index++ ); - // respect disable suspend/hibernate settings from power-manager + // respect disable settings from power-manager TDEConfig config("power-managerrc"); + bool disableFreeze = config.readBoolEntry("disableFreeze", false); + bool disableStandby = config.readBoolEntry("disableStandby", false); bool disableSuspend = config.readBoolEntry("disableSuspend", false); + bool disableHybridSuspend = config.readBoolEntry("disableHybridSuspend", false); bool disableHibernate = config.readBoolEntry("disableHibernate", false); - if ( suspend_freeze && !disableSuspend ) { + if ( canFreeze && !disableFreeze ) { m_exitView->leftView()->insertItem( "suspend2ram", i18n( "Freeze" ), @@ -3861,7 +3865,7 @@ void KMenu::insertSuspendOption( int &nId, int &index ) "kicker:/suspend_freeze", nId++, index++ ); } - if ( standby && !disableSuspend ) { + if ( canStandby && !disableStandby ) { m_exitView->leftView()->insertItem( "media-playback-pause", i18n( "Standby" ), @@ -3869,7 +3873,7 @@ void KMenu::insertSuspendOption( int &nId, int &index ) "kicker:/standby", nId++, index++ ); } - if ( suspend_ram && !disableSuspend ) { + if ( canSuspend && !disableSuspend ) { m_exitView->leftView()->insertItem( "suspend2ram", i18n( "Suspend" ), @@ -3877,7 +3881,14 @@ void KMenu::insertSuspendOption( int &nId, int &index ) "kicker:/suspend_ram", nId++, index++ ); } - if ( suspend_disk && !disableHibernate ) { + if ( canHybridSuspend && !disableHybridSuspend ) { + m_exitView->leftView()->insertItem( + "suspend2disk", + i18n( "Hybrid Suspend" ), + i18n( "Suspend to RAM + Disk" ), + "kicker:/hybrid_suspend", nId++, index++ ); + } + if ( canHibernate && !disableHibernate ) { m_exitView->leftView()->insertItem( "suspend2disk", i18n( "Hibernate" ), @@ -3885,13 +3896,6 @@ void KMenu::insertSuspendOption( int &nId, int &index ) "kicker:/suspend_disk", nId++, index++ ); } - if ( hybrid_suspend && !disableSuspend && !disableHibernate ) { - m_exitView->leftView()->insertItem( - "suspend2disk", - i18n( "Hybrid Suspend" ), - i18n( "Suspend to RAM + Disk" ), - "kicker:/hybrid_suspend", nId++, index++ ); - } } void KMenu::slotSuspend(int id) @@ -3911,19 +3915,21 @@ void KMenu::slotSuspend(int id) DBusMessage* msg = NULL; if (m_dbusConn) { - // No Freeze support in HAL - if (id == SuspendType::Standby) { + // No Freeze nor Standby support in HAL + if (id == SuspendType::Suspend) { msg = dbus_message_new_method_call( "org.freedesktop.Hal", "/org/freedesktop/Hal/devices/computer", "org.freedesktop.Hal.Device.SystemPowerManagement", - "Standby"); - } else if (id == SuspendType::Suspend) { + "Suspend"); + int wakeup=0; + dbus_message_append_args(msg, DBUS_TYPE_INT32, &wakeup, DBUS_TYPE_INVALID); + } else if (id == SuspendType::HybridSuspend) { msg = dbus_message_new_method_call( "org.freedesktop.Hal", "/org/freedesktop/Hal/devices/computer", "org.freedesktop.Hal.Device.SystemPowerManagement", - "Suspend"); + "SuspendHybrid"); int wakeup=0; dbus_message_append_args(msg, DBUS_TYPE_INT32, &wakeup, DBUS_TYPE_INVALID); } else if (id == SuspendType::Hibernate) { @@ -3932,14 +3938,6 @@ void KMenu::slotSuspend(int id) "/org/freedesktop/Hal/devices/computer", "org.freedesktop.Hal.Device.SystemPowerManagement", "Hibernate"); - } else if (id == SuspendType::HybridSuspend) { - msg = dbus_message_new_method_call( - "org.freedesktop.Hal", - "/org/freedesktop/Hal/devices/computer", - "org.freedesktop.Hal.Device.SystemPowerManagement", - "SuspendHybrid"); - int wakeup=0; - dbus_message_append_args(msg, DBUS_TYPE_INT32, &wakeup, DBUS_TYPE_INVALID); } else { return; } @@ -3958,10 +3956,10 @@ void KMenu::slotSuspend(int id) error = !rootDevice->setPowerState(TDESystemPowerState::Standby); } else if (id == SuspendType::Suspend) { error = !rootDevice->setPowerState(TDESystemPowerState::Suspend); - } else if (id == SuspendType::Hibernate) { - error = !rootDevice->setPowerState(TDESystemPowerState::Hibernate); } else if (id == SuspendType::HybridSuspend) { error = !rootDevice->setPowerState(TDESystemPowerState::HybridSuspend); + } else if (id == SuspendType::Hibernate) { + error = !rootDevice->setPowerState(TDESystemPowerState::Hibernate); } else { return; } diff --git a/ksmserver/shutdowndlg.cpp b/ksmserver/shutdowndlg.cpp index 052ba59f0..8d73ed505 100644 --- a/ksmserver/shutdowndlg.cpp +++ b/ksmserver/shutdowndlg.cpp @@ -802,14 +802,18 @@ KSMShutdownDlg::KSMShutdownDlg( TQWidget* parent, // respect lock on resume & disable suspend/hibernate settings // from power-manager TDEConfig config("power-managerrc"); + bool disableFreeze = config.readBoolEntry("disableFreeze", false); + bool disableStandby = config.readBoolEntry("disableStandby", false); bool disableSuspend = config.readBoolEntry("disableSuspend", false); + bool disableHybridSuspend = config.readBoolEntry("disableHybridSuspend", false); bool disableHibernate = config.readBoolEntry("disableHibernate", false); m_lockOnResume = config.readBoolEntry("lockOnResume", true); bool canFreeze = false; + bool canStandby = false; bool canSuspend = false; - bool canHibernate = false; bool canHybridSuspend = false; + bool canHibernate = false; #if defined(COMPILE_HALBACKEND) // Query HAL for suspend/resume support @@ -850,49 +854,40 @@ KSMShutdownDlg::KSMShutdownDlg( TQWidget* parent, if (m_halCtx) { - if (libhal_device_get_property_bool(m_halCtx, - "/org/freedesktop/Hal/devices/computer", - "power_management.can_suspend", - NULL)) - { - canSuspend = true; - } - - if (libhal_device_get_property_bool(m_halCtx, - "/org/freedesktop/Hal/devices/computer", - "power_management.can_hibernate", - NULL)) - { - canHibernate = true; - } - - if (libhal_device_get_property_bool(m_halCtx, - "/org/freedesktop/Hal/devices/computer", - "power_management.can_suspend_hybrid", - NULL)) - { - canHybridSuspend = true; - } + canStandby = libhal_device_get_property_bool(m_halCtx, + "/org/freedesktop/Hal/devices/computer", + "power_management.can_standby", + NULL); + + canSuspend = libhal_device_get_property_bool(m_halCtx, + "/org/freedesktop/Hal/devices/computer", + "power_management.can_suspend", + NULL); + + canHybridSuspend = libhal_device_get_property_bool(m_halCtx, + "/org/freedesktop/Hal/devices/computer", + "power_management.can_suspend_hybrid", + NULL); + + canHibernate = libhal_device_get_property_bool(m_halCtx, + "/org/freedesktop/Hal/devices/computer", + "power_management.can_hibernate", + NULL); } #elif defined(__TDE_HAVE_TDEHWLIB) // COMPILE_HALBACKEND TDERootSystemDevice* rootDevice = TDEGlobal::hardwareDevices()->rootSystemDevice(); if (rootDevice) { - canFreeze = rootDevice->canFreeze(); - canSuspend = rootDevice->canSuspend(); - canHibernate = rootDevice->canHibernate(); - canHybridSuspend = rootDevice->canHybridSuspend(); - } - else { - canFreeze = false; - canSuspend = false; - canHibernate = false; - canHybridSuspend = false; + canFreeze = rootDevice->canFreeze(); + canStandby = rootDevice->canStandby(); + canSuspend = rootDevice->canSuspend(); + canHybridSuspend = rootDevice->canHybridSuspend(); + canHibernate = rootDevice->canHibernate(); } #endif // COMPILE_HALBACKEND if(doUbuntuLogout) { // Ubuntu style logout window - if (canFreeze && !disableSuspend) + if (canFreeze && !disableFreeze) { // Freeze FlatButton* btnFreeze = new FlatButton( frame ); @@ -907,6 +902,21 @@ KSMShutdownDlg::KSMShutdownDlg( TQWidget* parent, connect(btnFreeze, TQT_SIGNAL(clicked()), TQT_SLOT(slotFreeze())); } + if (canStandby && !disableStandby) + { + // Standby + FlatButton* btnStandby = new FlatButton( frame ); + btnStandby->setTextLabel( i18n("&Standby"), false ); + btnStandby->setPixmap( DesktopIcon( "suspend") ); + TQToolTip::add(btnStandby, i18n("<qt><p>Put the computer in real idle mode," + " allowing for more powersaving than 'Freeze'. The system can be reactivated in a really short time," + " almost instantly.</p><p>This correspond to ACPI S1 mode.</p></qt>")); + int i = btnStandby->textLabel().find( TQRegExp("\\&"), 0 ); // i == 1 + btnStandby->setAccel( "ALT+" + btnStandby->textLabel().lower()[i+1] ) ; + hbuttonbox->addWidget ( btnStandby ); + connect(btnStandby, TQT_SIGNAL(clicked()), TQT_SLOT(slotStandby())); + } + if (canSuspend && !disableSuspend) { // Suspend @@ -914,7 +924,7 @@ KSMShutdownDlg::KSMShutdownDlg( TQWidget* parent, btnSuspend->setTextLabel( i18n("&Suspend"), false ); btnSuspend->setPixmap( DesktopIcon( "suspend") ); TQToolTip::add(btnSuspend, i18n("<qt><p>Put the computer in suspend-to-memory mode." - " The system is stopped and its state saved to memory.</p><p> This allows more powersaving than 'Freeze'" + " The system is stopped and its state saved to memory.</p><p> This allows more powersaving than 'Standby'" " but requires longer time to reactivate the system.</p><p>This correspond to ACPI S3 mode.</p>" "<p>Also known as Suspend-to-RAM mode.</p></qt>")); int i = btnSuspend->textLabel().find( TQRegExp("\\&"), 0 ); // i == 1 @@ -923,22 +933,7 @@ KSMShutdownDlg::KSMShutdownDlg( TQWidget* parent, connect(btnSuspend, TQT_SIGNAL(clicked()), TQT_SLOT(slotSuspend())); } - if (canHibernate && !disableHibernate) - { - // Hibernate - FlatButton* btnHibernate = new FlatButton( frame ); - btnHibernate->setTextLabel( i18n("&Hibernate"), false ); - btnHibernate->setPixmap( DesktopIcon( "hibernate") ); - TQToolTip::add(btnHibernate, i18n("<qt><p>Put the computer in suspend-to-disk mode." - " The system is stopped and its state saved to disk.</p><p>This offers the greatest powersaving but" - " considerable time is required to reactivate the system again.</p><p>This correspond to ACPI S4 mode.</p><p>Also known as Suspend-to-Disk mode.</p></qt>")); - int i = btnHibernate->textLabel().find( TQRegExp("\\&"), 0 ); // i == 1 - btnHibernate->setAccel( "ALT+" + btnHibernate->textLabel().lower()[i+1] ) ; - hbuttonbox->addWidget ( btnHibernate ); - connect(btnHibernate, TQT_SIGNAL(clicked()), TQT_SLOT(slotHibernate())); - } - - if (canHybridSuspend && !disableSuspend && !disableHibernate) + if (canHybridSuspend && !disableHybridSuspend) { // Hybrid suspend FlatButton* btnHybridSuspend = new FlatButton( frame ); @@ -956,6 +951,21 @@ KSMShutdownDlg::KSMShutdownDlg( TQWidget* parent, connect(btnHybridSuspend, TQT_SIGNAL(clicked()), TQT_SLOT(slotHybridSuspend())); } + if (canHibernate && !disableHibernate) + { + // Hibernate + FlatButton* btnHibernate = new FlatButton( frame ); + btnHibernate->setTextLabel( i18n("&Hibernate"), false ); + btnHibernate->setPixmap( DesktopIcon( "hibernate") ); + TQToolTip::add(btnHibernate, i18n("<qt><p>Put the computer in suspend-to-disk mode." + " The system is stopped and its state saved to disk.</p><p>This offers the greatest powersaving but" + " considerable time is required to reactivate the system again.</p><p>This correspond to ACPI S4 mode.</p><p>Also known as Suspend-to-Disk mode.</p></qt>")); + int i = btnHibernate->textLabel().find( TQRegExp("\\&"), 0 ); // i == 1 + btnHibernate->setAccel( "ALT+" + btnHibernate->textLabel().lower()[i+1] ) ; + hbuttonbox->addWidget ( btnHibernate ); + connect(btnHibernate, TQT_SIGNAL(clicked()), TQT_SLOT(slotHibernate())); + } + // Separator (within buttonlay) vbox->addWidget( new KSeparator( frame ) ); @@ -1081,7 +1091,7 @@ KSMShutdownDlg::KSMShutdownDlg( TQWidget* parent, } } - if (canFreeze && !disableSuspend) + if (canFreeze && !disableFreeze) { KPushButton* btnFreeze = new KPushButton( KGuiItem( i18n("&Freeze"), "suspend"), frame ); TQToolTip::add(btnFreeze, i18n("<qt><p>Put the computer in software idle mode," @@ -1092,11 +1102,22 @@ KSMShutdownDlg::KSMShutdownDlg( TQWidget* parent, connect(btnFreeze, TQT_SIGNAL(clicked()), TQT_SLOT(slotFreeze())); } + if (canStandby && !disableStandby) + { + KPushButton* btnStandby = new KPushButton( KGuiItem( i18n("&Standby"), "suspend"), frame ); + TQToolTip::add(btnStandby, i18n("<qt><p>Put the computer in real idle mode," + " allowing for more powersaving than 'Freeze'. The system can be reactivated in a really short time," + " almost instantly.</p><p>This correspond to ACPI S1 mode.</p></qt>")); + btnStandby->setFont( btnFont ); + buttonlay->addWidget( btnStandby ); + connect(btnStandby, TQT_SIGNAL(clicked()), TQT_SLOT(slotStandby())); + } + if (canSuspend && !disableSuspend) { KPushButton* btnSuspend = new KPushButton( KGuiItem( i18n("&Suspend"), "suspend"), frame ); TQToolTip::add(btnSuspend, i18n("<qt><p>Put the computer in suspend-to-memory mode." - " The system is stopped and its state saved to memory.</p><p> This allows more powersaving than 'Freeze'" + " The system is stopped and its state saved to memory.</p><p> This allows more powersaving than 'Standby'" " but requires longer time to reactivate the system.</p><p>This correspond to ACPI S3 mode.</p>" "<p>Also known as Suspend-to-RAM mode.</p></qt>")); btnSuspend->setFont( btnFont ); @@ -1104,18 +1125,7 @@ KSMShutdownDlg::KSMShutdownDlg( TQWidget* parent, connect(btnSuspend, TQT_SIGNAL(clicked()), TQT_SLOT(slotSuspend())); } - if (canHibernate && !disableHibernate) - { - KPushButton* btnHibernate = new KPushButton( KGuiItem( i18n("&Hibernate"), "hibernate"), frame ); - TQToolTip::add(btnHibernate, i18n("<qt><p>Put the computer in suspend-to-disk mode." - " The system is stopped and its state saved to disk.</p><p>This offers the greatest powersaving but" - " considerable time is required to reactivate the system again.</p><p>This correspond to ACPI S4 mode.</p><p>Also known as Suspend-to-Disk mode.</p></qt>")); - btnHibernate->setFont( btnFont ); - buttonlay->addWidget( btnHibernate ); - connect(btnHibernate, TQT_SIGNAL(clicked()), TQT_SLOT(slotHibernate())); - } - - if (canHybridSuspend && !disableSuspend && !disableHibernate) + if (canHybridSuspend && !disableHybridSuspend) { KPushButton* btnHybridSuspend = new KPushButton( KGuiItem( i18n("H&ybrid Suspend"), "hibernate"), frame ); TQToolTip::add(btnHybridSuspend, i18n("<qt><p>Put the computer in both suspend-to-memory and" @@ -1128,6 +1138,17 @@ KSMShutdownDlg::KSMShutdownDlg( TQWidget* parent, buttonlay->addWidget( btnHybridSuspend ); connect(btnHybridSuspend, TQT_SIGNAL(clicked()), TQT_SLOT(slotHybridSuspend())); } + + if (canHibernate && !disableHibernate) + { + KPushButton* btnHibernate = new KPushButton( KGuiItem( i18n("&Hibernate"), "hibernate"), frame ); + TQToolTip::add(btnHibernate, i18n("<qt><p>Put the computer in suspend-to-disk mode." + " The system is stopped and its state saved to disk.</p><p>This offers the greatest powersaving but" + " considerable time is required to reactivate the system again.</p><p>This correspond to ACPI S4 mode.</p><p>Also known as Suspend-to-Disk mode.</p></qt>")); + btnHibernate->setFont( btnFont ); + buttonlay->addWidget( btnHibernate ); + connect(btnHibernate, TQT_SIGNAL(clicked()), TQT_SLOT(slotHibernate())); + } buttonlay->addStretch( 1 ); @@ -1214,6 +1235,18 @@ void KSMShutdownDlg::slotHalt() accept(); } +void KSMShutdownDlg::slotFreeze() +{ + *m_selection = SuspendType::Freeze; + reject(); // continue on resume +} + +void KSMShutdownDlg::slotStandby() +{ + *m_selection = SuspendType::Standby; + reject(); // continue on resume +} + void KSMShutdownDlg::slotSuspend() { #ifndef COMPILE_HALBACKEND @@ -1238,10 +1271,10 @@ void KSMShutdownDlg::slotSuspend() reject(); // continue on resume } -void KSMShutdownDlg::slotHibernate() +void KSMShutdownDlg::slotHybridSuspend() { #ifndef COMPILE_HALBACKEND - *m_selection = SuspendType::Hibernate; + *m_selection = SuspendType::HybridSuspend; #else if (m_dbusConn) { @@ -1249,7 +1282,7 @@ void KSMShutdownDlg::slotHibernate() "org.freedesktop.Hal", "/org/freedesktop/Hal/devices/computer", "org.freedesktop.Hal.Device.SystemPowerManagement", - "Hibernate"); + "SuspendHybrid"); dbus_connection_send(m_dbusConn, msg, NULL); @@ -1259,16 +1292,10 @@ void KSMShutdownDlg::slotHibernate() reject(); // continue on resume } -void KSMShutdownDlg::slotFreeze() -{ - *m_selection = SuspendType::Freeze; - reject(); // continue on resume -} - -void KSMShutdownDlg::slotHybridSuspend() +void KSMShutdownDlg::slotHibernate() { #ifndef COMPILE_HALBACKEND - *m_selection = SuspendType::HybridSuspend; + *m_selection = SuspendType::Hibernate; #else if (m_dbusConn) { @@ -1276,7 +1303,7 @@ void KSMShutdownDlg::slotHybridSuspend() "org.freedesktop.Hal", "/org/freedesktop/Hal/devices/computer", "org.freedesktop.Hal.Device.SystemPowerManagement", - "SuspendHybrid"); + "Hibernate"); dbus_connection_send(m_dbusConn, msg, NULL); diff --git a/ksmserver/shutdowndlg.h b/ksmserver/shutdowndlg.h index 25ee60f77..f69c91677 100644 --- a/ksmserver/shutdowndlg.h +++ b/ksmserver/shutdowndlg.h @@ -145,10 +145,11 @@ public slots: void slotHalt(); void slotReboot(); void slotReboot(int); - void slotSuspend(); - void slotHibernate(); void slotFreeze(); + void slotStandby(); + void slotSuspend(); void slotHybridSuspend(); + void slotHibernate(); protected: ~KSMShutdownDlg(); |