summaryrefslogtreecommitdiffstats
path: root/ksmserver/shutdowndlg.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ksmserver/shutdowndlg.cpp')
-rw-r--r--ksmserver/shutdowndlg.cpp170
1 files changed, 125 insertions, 45 deletions
diff --git a/ksmserver/shutdowndlg.cpp b/ksmserver/shutdowndlg.cpp
index 6573f8bd2..66ba78ea0 100644
--- a/ksmserver/shutdowndlg.cpp
+++ b/ksmserver/shutdowndlg.cpp
@@ -379,7 +379,7 @@ void KSMShutdownFeedback::slotPaintEffect()
float doFancyLogoutFadeBackTime = 0;
if ( m_greyImageCreated == false ) {
m_greyImageCreated = true;
-
+
// eliminate nasty flicker on first show
m_root.resize( width(), height() );
TQImage blendedImage = m_grayImage;
@@ -388,31 +388,31 @@ void KSMShutdownFeedback::slotPaintEffect()
blendedImage.setAlphaBuffer(false);
p.drawImage( 0, 0, blendedImage );
p.end();
-
+
setBackgroundPixmap( m_root );
setGeometry( TQApplication::desktop()->geometry() );
setBackgroundMode( TQWidget::NoBackground );
-
+
m_unfadedImage = m_grayImage.copy();
-
+
register uchar * r = m_grayImage.bits();
uchar * end = m_grayImage.bits() + m_grayImage.numBytes();
-
+
while ( r != end ) {
*reinterpret_cast<TQRgb*>(r) = tqRgba(0, 0, 0, 107);
r += 4;
}
-
+
// start timer which is used for cpu-speed-independent fading
m_fadeTime.start();
m_rowsDone = 0;
}
-
+
// return if fading is completely done...
if ( ( m_grayOpacity >= 1.0f && m_fadeBackwards == FALSE ) || ( m_grayOpacity <= 0.0f && m_fadeBackwards == TRUE ) ) {
return;
}
-
+
if ( m_fadeBackwards == FALSE ) {
m_grayOpacity = m_fadeTime.elapsed() / doFancyLogoutFadeTime;
if ( m_grayOpacity > 1.0f )
@@ -423,23 +423,23 @@ void KSMShutdownFeedback::slotPaintEffect()
if ( m_grayOpacity < 0.0f )
m_grayOpacity = 0.0f;
}
-
+
const int imgWidth = m_unfadedImage.width();
int imgHeight = m_unfadedImage.height();
int heightUnit = imgHeight / 3;
if( heightUnit < 1 )
heightUnit = 1;
-
+
int y1 = static_cast<int>( imgHeight*m_grayOpacity - heightUnit + m_grayOpacity*heightUnit*2.0f );
if( y1 > imgHeight ) {
y1 = imgHeight;
}
-
+
int y2 = y1+heightUnit;
if( y2 > imgHeight ) {
y2 = imgHeight;
}
-
+
if( m_fadeBackwards == FALSE )
{
if( y1 > 0 && y1 < imgHeight && y1-m_rowsDone > 0 && m_rowsDone < imgHeight )
@@ -460,7 +460,7 @@ void KSMShutdownFeedback::slotPaintEffect()
m_rowsDone = y2;
}
}
-
+
int start_y1 = y1;
if( start_y1 < 0 ) {
start_y1 = 0;
@@ -481,7 +481,7 @@ void KSMShutdownFeedback::slotPaintEffect()
}
bitBlt( this, 0, start_y1, &img );
}
-
+
TQTimer::singleShot( 1, this, TQT_SLOT( slotPaintEffect() ) );
}
else {
@@ -492,18 +492,18 @@ void KSMShutdownFeedback::slotPaintEffect()
}
return;
}
-
+
if ( m_currentY == 0 ) {
setBackgroundMode( TQWidget::NoBackground );
setGeometry( TQApplication::desktop()->geometry() );
m_root.resize( width(), height() ); // for the default logout
-
+
KPixmap pixmap;
pixmap = TQPixmap(TQPixmap::grabWindow( tqt_xrootwin(), 0, 0, width(), height() ));
bitBlt( this, 0, 0, &pixmap );
bitBlt( &m_root, 0, 0, &pixmap );
}
-
+
KPixmap pixmap;
pixmap = TQPixmap(TQPixmap::grabWindow( tqt_xrootwin(), 0, m_currentY, width(), 10 ));
TQImage image = pixmap.convertToImage();
@@ -707,7 +707,7 @@ KSMShutdownDlg::KSMShutdownDlg( TQWidget* parent,
TQVBoxLayout* vbox = new TQVBoxLayout( this );
if (m_selection) {
- *m_selection = 0;
+ *m_selection = SuspendType::NotSpecified;
}
TQFrame* frame = new TQFrame( this );
@@ -758,15 +758,14 @@ KSMShutdownDlg::KSMShutdownDlg( TQWidget* parent,
FlatButton* btnLogout = new FlatButton( frame );
btnLogout->setTextLabel( TQString("&") + i18n("Log out"), false );
btnLogout->setPixmap( DesktopIcon( "back") );
+ TQToolTip::add( btnLogout, i18n( "<qt><p>Log out of the current session to login as a different user.</p></qt>" ) );
int i = btnLogout->textLabel().find( TQRegExp("\\&"), 0 ); // i == 1
btnLogout->setAccel( "ALT+" + btnLogout->textLabel().lower()[i+1] ) ;
hbuttonbox->addWidget ( btnLogout );
connect(btnLogout, TQT_SIGNAL(clicked()), TQT_SLOT(slotLogout()));
-
}
else
{
-
// konqy
lfrm = new TQFrame( frame );
lfrm->setFrameStyle( TQFrame::Panel | TQFrame::Sunken );
@@ -787,8 +786,8 @@ KSMShutdownDlg::KSMShutdownDlg( TQWidget* parent,
buttonlay->addStretch( 1 );
// End session
- KPushButton* btnLogout = new KPushButton( KGuiItem( i18n("&End Current Session"), "edit-undo"), frame );
- TQToolTip::add( btnLogout, i18n( "<qt><h3>End Current Session</h3><p>Log out of the current session to login with a different user</p></qt>" ) );
+ KPushButton* btnLogout = new KPushButton( KGuiItem( i18n("&Log out"), "edit-undo"), frame );
+ TQToolTip::add( btnLogout, i18n( "<qt><p>Log out of the current session to login as a different user.</p></qt>" ) );
btnFont = btnLogout->font();
buttonlay->addWidget( btnLogout );
connect(btnLogout, TQT_SIGNAL(clicked()), TQT_SLOT(slotLogout()));
@@ -810,6 +809,7 @@ KSMShutdownDlg::KSMShutdownDlg( TQWidget* parent,
bool canFreeze = false;
bool canSuspend = false;
bool canHibernate = false;
+ bool canHybridSuspend = false;
#if defined(COMPILE_HALBACKEND)
// Query HAL for suspend/resume support
@@ -865,6 +865,14 @@ KSMShutdownDlg::KSMShutdownDlg( TQWidget* parent,
{
canHibernate = true;
}
+
+ if (libhal_device_get_property_bool(m_halCtx,
+ "/org/freedesktop/Hal/devices/computer",
+ "power_management.can_suspend_hybrid",
+ NULL))
+ {
+ canHybridSuspend = true;
+ }
}
#elif defined(__TDE_HAVE_TDEHWLIB) // COMPILE_HALBACKEND
TDERootSystemDevice* rootDevice = TDEGlobal::hardwareDevices()->rootSystemDevice();
@@ -872,25 +880,30 @@ KSMShutdownDlg::KSMShutdownDlg( TQWidget* parent,
canFreeze = rootDevice->canFreeze();
canSuspend = rootDevice->canSuspend();
canHibernate = rootDevice->canHibernate();
+ canHybridSuspend = rootDevice->canHybridSuspend();
}
else {
canFreeze = false;
canSuspend = false;
canHibernate = false;
+ canHybridSuspend = false;
}
#endif // COMPILE_HALBACKEND
if(doUbuntuLogout) {
-
+ // Ubuntu style logout window
if (canFreeze && !disableSuspend)
{
// Freeze
FlatButton* btnFreeze = new FlatButton( frame );
btnFreeze->setTextLabel( i18n("&Freeze"), false );
btnFreeze->setPixmap( DesktopIcon( "suspend") );
+ TQToolTip::add(btnFreeze, i18n("<qt><p>Put the computer in software idle mode,"
+ " allowing for some powersaving. The system can be reactivated in a really short time,"
+ " almost instantly.</p><p>This correspond to ACPI S0 mode.</p></qt>"));
int i = btnFreeze->textLabel().find( TQRegExp("\\&"), 0 ); // i == 1
btnFreeze->setAccel( "ALT+" + btnFreeze->textLabel().lower()[i+1] ) ;
- hbuttonbox->addWidget ( btnFreeze);
+ hbuttonbox->addWidget ( btnFreeze );
connect(btnFreeze, TQT_SIGNAL(clicked()), TQT_SLOT(slotFreeze()));
}
@@ -898,11 +911,15 @@ KSMShutdownDlg::KSMShutdownDlg( TQWidget* parent,
{
// Suspend
FlatButton* btnSuspend = new FlatButton( frame );
- btnSuspend->setTextLabel( i18n("&Suspend"), false );
+ btnSuspend->setTextLabel( i18n("&Sleep"), 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'"
+ " 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
btnSuspend->setAccel( "ALT+" + btnSuspend->textLabel().lower()[i+1] ) ;
- hbuttonbox->addWidget ( btnSuspend);
+ hbuttonbox->addWidget ( btnSuspend );
connect(btnSuspend, TQT_SIGNAL(clicked()), TQT_SLOT(slotSuspend()));
}
@@ -912,12 +929,33 @@ KSMShutdownDlg::KSMShutdownDlg( TQWidget* parent,
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);
+ hbuttonbox->addWidget ( btnHibernate );
connect(btnHibernate, TQT_SIGNAL(clicked()), TQT_SLOT(slotHibernate()));
}
+ if (canHybridSuspend && !disableSuspend && !disableHibernate)
+ {
+ // Hybrid suspend
+ FlatButton* btnHybridSuspend = new FlatButton( frame );
+ btnHybridSuspend->setTextLabel( i18n("H&ybrid Suspend"), false );
+ btnHybridSuspend->setPixmap( DesktopIcon( "hibernate") );
+ TQToolTip::add(btnHybridSuspend, i18n("<qt><p>Put the computer in both suspend-to-memory and"
+ " suspend-to-disk mode. The system is stopped and its state saved to memory and to disk.</p>"
+ "<p>This offers the best of both 'Sleep' and 'Hibernate' modes combined together. The system is"
+ " de facto in 'Sleep' mode but if power is lost, work can still be resumed as if the system"
+ " had been hibernated, preventing any data loss.</p><p>This correspond to ACPI S3+S4 mode.</p>"
+ "<p>Also known as Suspend-to-RAM + Suspend-to-Disk mode.</p></qt>"));
+ int i = btnHybridSuspend->textLabel().find( TQRegExp("\\&"), 0 ); // i == 1
+ btnHybridSuspend->setAccel( "ALT+" + btnHybridSuspend->textLabel().lower()[i+1] ) ;
+ hbuttonbox->addWidget ( btnHybridSuspend );
+ connect(btnHybridSuspend, TQT_SIGNAL(clicked()), TQT_SLOT(slotHybridSuspend()));
+ }
+
// Separator (within buttonlay)
vbox->addWidget( new KSeparator( frame ) );
@@ -930,6 +968,7 @@ KSMShutdownDlg::KSMShutdownDlg( TQWidget* parent,
FlatButton* btnReboot = new FlatButton( frame );
btnReboot->setTextLabel( i18n("&Restart"), false );
btnReboot->setPixmap( DesktopIcon( "reload") );
+ TQToolTip::add( btnReboot, i18n( "<qt><p>Log out of the current session and restart the computer.</p></qt>" ) );
int i = btnReboot->textLabel().find( TQRegExp("\\&"), 0 ); // i == 1
btnReboot->setAccel( "ALT+" + btnReboot->textLabel().lower()[i+1] ) ;
hbuttonbox2->addWidget ( btnReboot);
@@ -968,8 +1007,9 @@ KSMShutdownDlg::KSMShutdownDlg( TQWidget* parent,
if (maysd) {
// Shutdown
FlatButton* btnHalt = new FlatButton( frame );
- btnHalt->setTextLabel( i18n("&Turn Off"), false );
+ btnHalt->setTextLabel( i18n("&Shutdown"), false );
btnHalt->setPixmap( DesktopIcon( "system-log-out") );
+ TQToolTip::add( btnHalt, i18n( "<qt><p>Log out of the current session and turn off the computer.</p></qt>" ) );
int i = btnHalt->textLabel().find( TQRegExp("\\&"), 0 ); // i == 1
btnHalt->setAccel( "ALT+" + btnHalt->textLabel().lower()[i+1] ) ;
hbuttonbox2->addWidget ( btnHalt );
@@ -991,10 +1031,11 @@ KSMShutdownDlg::KSMShutdownDlg( TQWidget* parent,
}
else
{
+ // Standard style logout window
if (maysd) {
// Shutdown
- KPushButton* btnHalt = new KPushButton( KGuiItem( i18n("&Turn Off Computer"), "system-log-out"), frame );
- TQToolTip::add( btnHalt, i18n( "<qt><h3>Turn Off Computer</h3><p>Log out of the current session and turn off the computer</p></qt>" ) );
+ KPushButton* btnHalt = new KPushButton( KGuiItem( i18n("&Shutdown"), "system-log-out"), frame );
+ TQToolTip::add( btnHalt, i18n( "<qt><p>Log out of the current session and turn off the computer.</p></qt>" ) );
btnHalt->setFont( btnFont );
buttonlay->addWidget( btnHalt );
connect(btnHalt, TQT_SIGNAL(clicked()), TQT_SLOT(slotHalt()));
@@ -1005,8 +1046,8 @@ KSMShutdownDlg::KSMShutdownDlg( TQWidget* parent,
if (mayrb) {
// Reboot
- KSMDelayedPushButton* btnReboot = new KSMDelayedPushButton( KGuiItem( i18n("&Restart Computer"), "reload"), frame );
- TQToolTip::add( btnReboot, i18n( "<qt><h3>Restart Computer</h3><p>Log out of the current session and restart the computer</p><p>Hold the mouse button or the space bar for a short while to get a list of options what to boot</p></qt>" ) );
+ KSMDelayedPushButton* btnReboot = new KSMDelayedPushButton( KGuiItem( i18n("&Restart"), "reload"), frame );
+ TQToolTip::add( btnReboot, i18n( "<qt><p>Log out of the current session and restart the computer.</p></qt>" ) );
btnReboot->setFont( btnFont );
buttonlay->addWidget( btnReboot );
@@ -1042,7 +1083,10 @@ KSMShutdownDlg::KSMShutdownDlg( TQWidget* parent,
if (canFreeze && !disableSuspend)
{
- KPushButton* btnFreeze = new KPushButton( KGuiItem( i18n("&Freeze Computer"), "suspend"), frame );
+ KPushButton* btnFreeze = new KPushButton( KGuiItem( i18n("&Freeze"), "suspend"), frame );
+ TQToolTip::add(btnFreeze, i18n("<qt><p>Put the computer in software idle mode,"
+ " allowing for some powersaving. The system can be reactivated in a really short time,"
+ " almost instantly.</p><p>This correspond to ACPI S0 mode.</p></qt>"));
btnFreeze->setFont( btnFont );
buttonlay->addWidget( btnFreeze );
connect(btnFreeze, TQT_SIGNAL(clicked()), TQT_SLOT(slotFreeze()));
@@ -1050,7 +1094,11 @@ KSMShutdownDlg::KSMShutdownDlg( TQWidget* parent,
if (canSuspend && !disableSuspend)
{
- KPushButton* btnSuspend = new KPushButton( KGuiItem( i18n("&Suspend Computer"), "suspend"), frame );
+ KPushButton* btnSuspend = new KPushButton( KGuiItem( i18n("&Sleep"), "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'"
+ " 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 );
buttonlay->addWidget( btnSuspend );
connect(btnSuspend, TQT_SIGNAL(clicked()), TQT_SLOT(slotSuspend()));
@@ -1058,12 +1106,29 @@ KSMShutdownDlg::KSMShutdownDlg( TQWidget* parent,
if (canHibernate && !disableHibernate)
{
- KPushButton* btnHibernate = new KPushButton( KGuiItem( i18n("&Hibernate Computer"), "hibernate"), frame );
+ 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 );
+ TQToolTip::add(btnHybridSuspend, i18n("<qt><p>Put the computer in both suspend-to-memory and"
+ " suspend-to-disk mode. The system is stopped and its state saved to memory and to disk.</p>"
+ "<p>This offers the best of both 'Sleep' and 'Hibernate' modes combined together. The system is"
+ " de facto in 'Sleep' mode but if power is lost, work can still be resumed as if the system"
+ " had been hibernated, preventing any data loss.</p><p>This correspond to ACPI S3+S4 mode.</p>"
+ "<p>Also known as Suspend-to-RAM + Suspend-to-Disk mode.</p></qt>"));
+ btnHybridSuspend->setFont( btnFont );
+ buttonlay->addWidget( btnHybridSuspend );
+ connect(btnHybridSuspend, TQT_SIGNAL(clicked()), TQT_SLOT(slotHybridSuspend()));
+ }
+
buttonlay->addStretch( 1 );
// Separator
@@ -1073,9 +1138,7 @@ KSMShutdownDlg::KSMShutdownDlg( TQWidget* parent,
KPushButton* btnBack = new KPushButton( KStdGuiItem::cancel(), frame );
buttonlay->addWidget( btnBack );
connect(btnBack, TQT_SIGNAL(clicked()), TQT_SLOT(reject()));
-
}
-
}
else {
// finish the dialog correctly
@@ -1102,11 +1165,7 @@ KSMShutdownDlg::KSMShutdownDlg( TQWidget* parent,
connect(btnBack, TQT_SIGNAL(clicked()), TQT_SLOT(reject()));
}
-
-
}
-
-
}
@@ -1158,7 +1217,7 @@ void KSMShutdownDlg::slotHalt()
void KSMShutdownDlg::slotSuspend()
{
#ifndef COMPILE_HALBACKEND
- *m_selection = 1; // Suspend
+ *m_selection = SuspendType::Suspend;
#else
if (m_dbusConn)
{
@@ -1182,7 +1241,7 @@ void KSMShutdownDlg::slotSuspend()
void KSMShutdownDlg::slotHibernate()
{
#ifndef COMPILE_HALBACKEND
- *m_selection = 2; // Hibernate
+ *m_selection = SuspendType::Hibernate;
#else
if (m_dbusConn)
{
@@ -1202,8 +1261,29 @@ void KSMShutdownDlg::slotHibernate()
void KSMShutdownDlg::slotFreeze()
{
- *m_selection = 3; // Freeze
- reject();
+ *m_selection = SuspendType::Freeze;
+ reject(); // continue on resume
+}
+
+void KSMShutdownDlg::slotHybridSuspend()
+{
+#ifndef COMPILE_HALBACKEND
+ *m_selection = SuspendType::HybridSuspend;
+#else
+ if (m_dbusConn)
+ {
+ DBusMessage *msg = dbus_message_new_method_call(
+ "org.freedesktop.Hal",
+ "/org/freedesktop/Hal/devices/computer",
+ "org.freedesktop.Hal.Device.SystemPowerManagement",
+ "SuspendHybrid");
+
+ dbus_connection_send(m_dbusConn, msg, NULL);
+
+ dbus_message_unref(msg);
+ }
+#endif
+ reject(); // continue on resume
}
bool KSMShutdownDlg::confirmShutdown( bool maysd, bool mayrb, TDEApplication::ShutdownType& sdtype, TQString& bootOption, int* selection )