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>
feat/fix-suspend-code
Michele Calgaro 6 years ago
parent 98abb9e8ee
commit 359dc4faf4
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -146,8 +146,8 @@ enum SuspendType {
Freeze, Freeze,
Standby, Standby,
Suspend, Suspend,
Hibernate, HybridSuspend,
HybridSuspend Hibernate
}; };
}; };
@ -2745,12 +2745,12 @@ void KMenu::slotStartURL(const TQString& u)
else if ( u == "kicker:/suspend_ram" ) { else if ( u == "kicker:/suspend_ram" ) {
slotSuspend( SuspendType::Suspend ); slotSuspend( SuspendType::Suspend );
} }
else if ( u == "kicker:/suspend_disk" ) {
slotSuspend( SuspendType::Hibernate );
}
else if ( u == "kicker:/hybrid_suspend" ) { else if ( u == "kicker:/hybrid_suspend" ) {
slotSuspend( SuspendType::HybridSuspend ); slotSuspend( SuspendType::HybridSuspend );
} }
else if ( u == "kicker:/suspend_disk" ) {
slotSuspend( SuspendType::Hibernate );
}
else if ( u == "kicker:/savesession" ) { else if ( u == "kicker:/savesession" ) {
TQByteArray data; TQByteArray data;
kapp->dcopClient()->send( "ksmserver", "default", kapp->dcopClient()->send( "ksmserver", "default",
@ -3810,50 +3810,54 @@ int KMenu::max_items(int category) const
void KMenu::insertSuspendOption( int &nId, int &index ) void KMenu::insertSuspendOption( int &nId, int &index )
{ {
bool suspend_ram = false; bool canFreeze = false;
bool suspend_freeze = false; bool canStandby = false;
bool standby = false; bool canSuspend = false;
bool suspend_disk = false; bool canHybridSuspend = false;
bool hybrid_suspend = false; bool canHibernate = false;
#if defined(COMPILE_HALBACKEND) #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", "/org/freedesktop/Hal/devices/computer",
"power_management.can_suspend", "power_management.can_standby",
NULL); NULL);
standby = libhal_device_get_property_bool(m_halCtx, canSuspend = libhal_device_get_property_bool(m_halCtx,
"/org/freedesktop/Hal/devices/computer", "/org/freedesktop/Hal/devices/computer",
"power_management.can_standby", "power_management.can_suspend",
NULL); NULL);
suspend_disk = libhal_device_get_property_bool(m_halCtx, canHybridSuspend = libhal_device_get_property_bool(m_halCtx,
"/org/freedesktop/Hal/devices/computer", "/org/freedesktop/Hal/devices/computer",
"power_management.can_hibernate", "power_management.can_suspend_hybrid",
NULL); NULL);
hybrid_suspend = libhal_device_get_property_bool(m_halCtx, canHibernate = libhal_device_get_property_bool(m_halCtx,
"/org/freedesktop/Hal/devices/computer", "/org/freedesktop/Hal/devices/computer",
"power_management.can_suspend_hybrid", "power_management.can_hibernate",
NULL); NULL);
#elif defined(__TDE_HAVE_TDEHWLIB) // COMPILE_HALBACKEND #elif defined(__TDE_HAVE_TDEHWLIB) // COMPILE_HALBACKEND
TDERootSystemDevice* rootDevice = TDEGlobal::hardwareDevices()->rootSystemDevice(); TDERootSystemDevice* rootDevice = TDEGlobal::hardwareDevices()->rootSystemDevice();
if (rootDevice) { if (rootDevice) {
suspend_ram = rootDevice->canSuspend(); canFreeze = rootDevice->canFreeze();
suspend_freeze = rootDevice->canFreeze(); canStandby = rootDevice->canStandby();
standby = rootDevice->canStandby(); canSuspend = rootDevice->canSuspend();
suspend_disk = rootDevice->canHibernate(); canHybridSuspend = rootDevice->canHybridSuspend();
hybrid_suspend = rootDevice->canHybridSuspend(); canHibernate = rootDevice->canHibernate();
} }
#endif #endif
m_exitView->leftView()->insertSeparator( nId++, i18n("Suspend"), index++ ); 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"); TDEConfig config("power-managerrc");
bool disableFreeze = config.readBoolEntry("disableFreeze", false);
bool disableStandby = config.readBoolEntry("disableStandby", false);
bool disableSuspend = config.readBoolEntry("disableSuspend", false); bool disableSuspend = config.readBoolEntry("disableSuspend", false);
bool disableHybridSuspend = config.readBoolEntry("disableHybridSuspend", false);
bool disableHibernate = config.readBoolEntry("disableHibernate", false); bool disableHibernate = config.readBoolEntry("disableHibernate", false);
if ( suspend_freeze && !disableSuspend ) { if ( canFreeze && !disableFreeze ) {
m_exitView->leftView()->insertItem( m_exitView->leftView()->insertItem(
"suspend2ram", "suspend2ram",
i18n( "Freeze" ), i18n( "Freeze" ),
@ -3861,7 +3865,7 @@ void KMenu::insertSuspendOption( int &nId, int &index )
"kicker:/suspend_freeze", nId++, index++ ); "kicker:/suspend_freeze", nId++, index++ );
} }
if ( standby && !disableSuspend ) { if ( canStandby && !disableStandby ) {
m_exitView->leftView()->insertItem( m_exitView->leftView()->insertItem(
"media-playback-pause", "media-playback-pause",
i18n( "Standby" ), i18n( "Standby" ),
@ -3869,7 +3873,7 @@ void KMenu::insertSuspendOption( int &nId, int &index )
"kicker:/standby", nId++, index++ ); "kicker:/standby", nId++, index++ );
} }
if ( suspend_ram && !disableSuspend ) { if ( canSuspend && !disableSuspend ) {
m_exitView->leftView()->insertItem( m_exitView->leftView()->insertItem(
"suspend2ram", "suspend2ram",
i18n( "Suspend" ), i18n( "Suspend" ),
@ -3877,7 +3881,14 @@ void KMenu::insertSuspendOption( int &nId, int &index )
"kicker:/suspend_ram", nId++, 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( m_exitView->leftView()->insertItem(
"suspend2disk", "suspend2disk",
i18n( "Hibernate" ), i18n( "Hibernate" ),
@ -3885,13 +3896,6 @@ void KMenu::insertSuspendOption( int &nId, int &index )
"kicker:/suspend_disk", nId++, 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) void KMenu::slotSuspend(int id)
@ -3911,19 +3915,21 @@ void KMenu::slotSuspend(int id)
DBusMessage* msg = NULL; DBusMessage* msg = NULL;
if (m_dbusConn) { if (m_dbusConn) {
// No Freeze support in HAL // No Freeze nor Standby support in HAL
if (id == SuspendType::Standby) { if (id == SuspendType::Suspend) {
msg = dbus_message_new_method_call( msg = dbus_message_new_method_call(
"org.freedesktop.Hal", "org.freedesktop.Hal",
"/org/freedesktop/Hal/devices/computer", "/org/freedesktop/Hal/devices/computer",
"org.freedesktop.Hal.Device.SystemPowerManagement", "org.freedesktop.Hal.Device.SystemPowerManagement",
"Standby"); "Suspend");
} else if (id == SuspendType::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( msg = dbus_message_new_method_call(
"org.freedesktop.Hal", "org.freedesktop.Hal",
"/org/freedesktop/Hal/devices/computer", "/org/freedesktop/Hal/devices/computer",
"org.freedesktop.Hal.Device.SystemPowerManagement", "org.freedesktop.Hal.Device.SystemPowerManagement",
"Suspend"); "SuspendHybrid");
int wakeup=0; int wakeup=0;
dbus_message_append_args(msg, DBUS_TYPE_INT32, &wakeup, DBUS_TYPE_INVALID); dbus_message_append_args(msg, DBUS_TYPE_INT32, &wakeup, DBUS_TYPE_INVALID);
} else if (id == SuspendType::Hibernate) { } else if (id == SuspendType::Hibernate) {
@ -3932,14 +3938,6 @@ void KMenu::slotSuspend(int id)
"/org/freedesktop/Hal/devices/computer", "/org/freedesktop/Hal/devices/computer",
"org.freedesktop.Hal.Device.SystemPowerManagement", "org.freedesktop.Hal.Device.SystemPowerManagement",
"Hibernate"); "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 { } else {
return; return;
} }
@ -3958,10 +3956,10 @@ void KMenu::slotSuspend(int id)
error = !rootDevice->setPowerState(TDESystemPowerState::Standby); error = !rootDevice->setPowerState(TDESystemPowerState::Standby);
} else if (id == SuspendType::Suspend) { } else if (id == SuspendType::Suspend) {
error = !rootDevice->setPowerState(TDESystemPowerState::Suspend); error = !rootDevice->setPowerState(TDESystemPowerState::Suspend);
} else if (id == SuspendType::Hibernate) {
error = !rootDevice->setPowerState(TDESystemPowerState::Hibernate);
} else if (id == SuspendType::HybridSuspend) { } else if (id == SuspendType::HybridSuspend) {
error = !rootDevice->setPowerState(TDESystemPowerState::HybridSuspend); error = !rootDevice->setPowerState(TDESystemPowerState::HybridSuspend);
} else if (id == SuspendType::Hibernate) {
error = !rootDevice->setPowerState(TDESystemPowerState::Hibernate);
} else { } else {
return; return;
} }

@ -802,14 +802,18 @@ KSMShutdownDlg::KSMShutdownDlg( TQWidget* parent,
// respect lock on resume & disable suspend/hibernate settings // respect lock on resume & disable suspend/hibernate settings
// from power-manager // from power-manager
TDEConfig config("power-managerrc"); TDEConfig config("power-managerrc");
bool disableFreeze = config.readBoolEntry("disableFreeze", false);
bool disableStandby = config.readBoolEntry("disableStandby", false);
bool disableSuspend = config.readBoolEntry("disableSuspend", false); bool disableSuspend = config.readBoolEntry("disableSuspend", false);
bool disableHybridSuspend = config.readBoolEntry("disableHybridSuspend", false);
bool disableHibernate = config.readBoolEntry("disableHibernate", false); bool disableHibernate = config.readBoolEntry("disableHibernate", false);
m_lockOnResume = config.readBoolEntry("lockOnResume", true); m_lockOnResume = config.readBoolEntry("lockOnResume", true);
bool canFreeze = false; bool canFreeze = false;
bool canStandby = false;
bool canSuspend = false; bool canSuspend = false;
bool canHibernate = false;
bool canHybridSuspend = false; bool canHybridSuspend = false;
bool canHibernate = false;
#if defined(COMPILE_HALBACKEND) #if defined(COMPILE_HALBACKEND)
// Query HAL for suspend/resume support // Query HAL for suspend/resume support
@ -850,49 +854,40 @@ KSMShutdownDlg::KSMShutdownDlg( TQWidget* parent,
if (m_halCtx) if (m_halCtx)
{ {
if (libhal_device_get_property_bool(m_halCtx, canStandby = libhal_device_get_property_bool(m_halCtx,
"/org/freedesktop/Hal/devices/computer", "/org/freedesktop/Hal/devices/computer",
"power_management.can_suspend", "power_management.can_standby",
NULL)) NULL);
{
canSuspend = true;
}
if (libhal_device_get_property_bool(m_halCtx, canSuspend = libhal_device_get_property_bool(m_halCtx,
"/org/freedesktop/Hal/devices/computer", "/org/freedesktop/Hal/devices/computer",
"power_management.can_hibernate", "power_management.can_suspend",
NULL)) NULL);
{
canHibernate = true;
}
if (libhal_device_get_property_bool(m_halCtx, canHybridSuspend = libhal_device_get_property_bool(m_halCtx,
"/org/freedesktop/Hal/devices/computer", "/org/freedesktop/Hal/devices/computer",
"power_management.can_suspend_hybrid", "power_management.can_suspend_hybrid",
NULL)) NULL);
{
canHybridSuspend = true; 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 #elif defined(__TDE_HAVE_TDEHWLIB) // COMPILE_HALBACKEND
TDERootSystemDevice* rootDevice = TDEGlobal::hardwareDevices()->rootSystemDevice(); TDERootSystemDevice* rootDevice = TDEGlobal::hardwareDevices()->rootSystemDevice();
if (rootDevice) { if (rootDevice) {
canFreeze = rootDevice->canFreeze(); canFreeze = rootDevice->canFreeze();
canStandby = rootDevice->canStandby();
canSuspend = rootDevice->canSuspend(); canSuspend = rootDevice->canSuspend();
canHibernate = rootDevice->canHibernate();
canHybridSuspend = rootDevice->canHybridSuspend(); canHybridSuspend = rootDevice->canHybridSuspend();
} canHibernate = rootDevice->canHibernate();
else {
canFreeze = false;
canSuspend = false;
canHibernate = false;
canHybridSuspend = false;
} }
#endif // COMPILE_HALBACKEND #endif // COMPILE_HALBACKEND
if(doUbuntuLogout) { if(doUbuntuLogout) {
// Ubuntu style logout window // Ubuntu style logout window
if (canFreeze && !disableSuspend) if (canFreeze && !disableFreeze)
{ {
// Freeze // Freeze
FlatButton* btnFreeze = new FlatButton( frame ); FlatButton* btnFreeze = new FlatButton( frame );
@ -907,6 +902,21 @@ KSMShutdownDlg::KSMShutdownDlg( TQWidget* parent,
connect(btnFreeze, TQT_SIGNAL(clicked()), TQT_SLOT(slotFreeze())); 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) if (canSuspend && !disableSuspend)
{ {
// Suspend // Suspend
@ -914,7 +924,7 @@ KSMShutdownDlg::KSMShutdownDlg( TQWidget* parent,
btnSuspend->setTextLabel( i18n("&Suspend"), false ); btnSuspend->setTextLabel( i18n("&Suspend"), false );
btnSuspend->setPixmap( DesktopIcon( "suspend") ); btnSuspend->setPixmap( DesktopIcon( "suspend") );
TQToolTip::add(btnSuspend, i18n("<qt><p>Put the computer in suspend-to-memory mode." 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>" " 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>")); "<p>Also known as Suspend-to-RAM mode.</p></qt>"));
int i = btnSuspend->textLabel().find( TQRegExp("\\&"), 0 ); // i == 1 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())); connect(btnSuspend, TQT_SIGNAL(clicked()), TQT_SLOT(slotSuspend()));
} }
if (canHibernate && !disableHibernate) if (canHybridSuspend && !disableHybridSuspend)
{
// 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)
{ {
// Hybrid suspend // Hybrid suspend
FlatButton* btnHybridSuspend = new FlatButton( frame ); FlatButton* btnHybridSuspend = new FlatButton( frame );
@ -956,6 +951,21 @@ KSMShutdownDlg::KSMShutdownDlg( TQWidget* parent,
connect(btnHybridSuspend, TQT_SIGNAL(clicked()), TQT_SLOT(slotHybridSuspend())); 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) // Separator (within buttonlay)
vbox->addWidget( new KSeparator( frame ) ); 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 ); KPushButton* btnFreeze = new KPushButton( KGuiItem( i18n("&Freeze"), "suspend"), frame );
TQToolTip::add(btnFreeze, i18n("<qt><p>Put the computer in software idle mode," 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())); 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) if (canSuspend && !disableSuspend)
{ {
KPushButton* btnSuspend = new KPushButton( KGuiItem( i18n("&Suspend"), "suspend"), frame ); KPushButton* btnSuspend = new KPushButton( KGuiItem( i18n("&Suspend"), "suspend"), frame );
TQToolTip::add(btnSuspend, i18n("<qt><p>Put the computer in suspend-to-memory mode." 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>" " 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>")); "<p>Also known as Suspend-to-RAM mode.</p></qt>"));
btnSuspend->setFont( btnFont ); btnSuspend->setFont( btnFont );
@ -1104,18 +1125,7 @@ KSMShutdownDlg::KSMShutdownDlg( TQWidget* parent,
connect(btnSuspend, TQT_SIGNAL(clicked()), TQT_SLOT(slotSuspend())); connect(btnSuspend, TQT_SIGNAL(clicked()), TQT_SLOT(slotSuspend()));
} }
if (canHibernate && !disableHibernate) if (canHybridSuspend && !disableHybridSuspend)
{
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)
{ {
KPushButton* btnHybridSuspend = new KPushButton( KGuiItem( i18n("H&ybrid Suspend"), "hibernate"), frame ); 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" TQToolTip::add(btnHybridSuspend, i18n("<qt><p>Put the computer in both suspend-to-memory and"
@ -1129,6 +1139,17 @@ KSMShutdownDlg::KSMShutdownDlg( TQWidget* parent,
connect(btnHybridSuspend, TQT_SIGNAL(clicked()), TQT_SLOT(slotHybridSuspend())); 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 ); buttonlay->addStretch( 1 );
// Separator // Separator
@ -1214,6 +1235,18 @@ void KSMShutdownDlg::slotHalt()
accept(); 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() void KSMShutdownDlg::slotSuspend()
{ {
#ifndef COMPILE_HALBACKEND #ifndef COMPILE_HALBACKEND
@ -1238,10 +1271,10 @@ void KSMShutdownDlg::slotSuspend()
reject(); // continue on resume reject(); // continue on resume
} }
void KSMShutdownDlg::slotHibernate() void KSMShutdownDlg::slotHybridSuspend()
{ {
#ifndef COMPILE_HALBACKEND #ifndef COMPILE_HALBACKEND
*m_selection = SuspendType::Hibernate; *m_selection = SuspendType::HybridSuspend;
#else #else
if (m_dbusConn) if (m_dbusConn)
{ {
@ -1249,7 +1282,7 @@ void KSMShutdownDlg::slotHibernate()
"org.freedesktop.Hal", "org.freedesktop.Hal",
"/org/freedesktop/Hal/devices/computer", "/org/freedesktop/Hal/devices/computer",
"org.freedesktop.Hal.Device.SystemPowerManagement", "org.freedesktop.Hal.Device.SystemPowerManagement",
"Hibernate"); "SuspendHybrid");
dbus_connection_send(m_dbusConn, msg, NULL); dbus_connection_send(m_dbusConn, msg, NULL);
@ -1259,16 +1292,10 @@ void KSMShutdownDlg::slotHibernate()
reject(); // continue on resume reject(); // continue on resume
} }
void KSMShutdownDlg::slotFreeze() void KSMShutdownDlg::slotHibernate()
{
*m_selection = SuspendType::Freeze;
reject(); // continue on resume
}
void KSMShutdownDlg::slotHybridSuspend()
{ {
#ifndef COMPILE_HALBACKEND #ifndef COMPILE_HALBACKEND
*m_selection = SuspendType::HybridSuspend; *m_selection = SuspendType::Hibernate;
#else #else
if (m_dbusConn) if (m_dbusConn)
{ {
@ -1276,7 +1303,7 @@ void KSMShutdownDlg::slotHybridSuspend()
"org.freedesktop.Hal", "org.freedesktop.Hal",
"/org/freedesktop/Hal/devices/computer", "/org/freedesktop/Hal/devices/computer",
"org.freedesktop.Hal.Device.SystemPowerManagement", "org.freedesktop.Hal.Device.SystemPowerManagement",
"SuspendHybrid"); "Hibernate");
dbus_connection_send(m_dbusConn, msg, NULL); dbus_connection_send(m_dbusConn, msg, NULL);

@ -145,10 +145,11 @@ public slots:
void slotHalt(); void slotHalt();
void slotReboot(); void slotReboot();
void slotReboot(int); void slotReboot(int);
void slotSuspend();
void slotHibernate();
void slotFreeze(); void slotFreeze();
void slotStandby();
void slotSuspend();
void slotHybridSuspend(); void slotHybridSuspend();
void slotHibernate();
protected: protected:
~KSMShutdownDlg(); ~KSMShutdownDlg();

Loading…
Cancel
Save