diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-09-03 09:14:57 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-09-03 09:14:57 +0000 |
commit | 27856879bf962f178d88e79144e37a47e731b122 (patch) | |
tree | a3bd3f489b755cd2941e7c53b90d12d6bfd4fbe3 /ksmserver/shutdown.cpp | |
parent | c5228d52f504d6d2c0fefdd625ec08ebb8e91f85 (diff) | |
download | tdebase-27856879bf962f178d88e79144e37a47e731b122.tar.gz tdebase-27856879bf962f178d88e79144e37a47e731b122.zip |
* Massive import of OpenSUSE patches, primarily for bugfixes
* Added some infrastructure created by OpenSUSE to allow for future addition of the Kickoff menu as an option
* Minor Slackware compilation fixes
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1171255 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'ksmserver/shutdown.cpp')
-rw-r--r-- | ksmserver/shutdown.cpp | 78 |
1 files changed, 67 insertions, 11 deletions
diff --git a/ksmserver/shutdown.cpp b/ksmserver/shutdown.cpp index 16fab8b4d..a850d40be 100644 --- a/ksmserver/shutdown.cpp +++ b/ksmserver/shutdown.cpp @@ -93,14 +93,16 @@ void KSMServer::logout( int confirm, int sdtype, int sdmode ) (KApplication::ShutdownMode)sdmode ); } -void KSMServer::shutdown( KApplication::ShutdownConfirm confirm, - KApplication::ShutdownType sdtype, KApplication::ShutdownMode sdmode ) +bool KSMServer::checkStatus( bool &logoutConfirmed, bool &maysd, + KApplication::ShutdownConfirm confirm, + KApplication::ShutdownType sdtype, + KApplication::ShutdownMode sdmode ) { pendingShutdown.stop(); if( dialogActive ) - return; + return false; if( state >= Shutdown ) // already performing shutdown - return; + return false; if( state != Idle ) // performing startup { // perform shutdown as soon as startup is finished, in order to avoid saving partial session @@ -111,25 +113,44 @@ void KSMServer::shutdown( KApplication::ShutdownConfirm confirm, pendingShutdown_sdtype = sdtype; pendingShutdown_sdmode = sdmode; } - return; + return false; } KConfig *config = KGlobal::config(); config->reparseConfiguration(); // config may have changed in the KControl module config->setGroup("General" ); - bool logoutConfirmed = + logoutConfirmed = (confirm == KApplication::ShutdownConfirmYes) ? false : - (confirm == KApplication::ShutdownConfirmNo) ? true : - !config->readBoolEntry( "confirmLogout", true ); - bool maysd = false; + (confirm == KApplication::ShutdownConfirmNo) ? true : + !config->readBoolEntry( "confirmLogout", true ); + maysd = false; if (config->readBoolEntry( "offerShutdown", true ) && DM().canShutdown()) maysd = true; if (!maysd) { if (sdtype != KApplication::ShutdownTypeNone && sdtype != KApplication::ShutdownTypeDefault && logoutConfirmed) - return; /* unsupported fast shutdown */ + return false; /* unsupported fast shutdown */ + } + + return true; +} + +void KSMServer::shutdownInternal( KApplication::ShutdownConfirm confirm, + KApplication::ShutdownType sdtype, + KApplication::ShutdownMode sdmode, + TQString bopt ) +{ + bool maysd = false; + bool logoutConfirmed = false; + if ( !checkStatus( logoutConfirmed, maysd, confirm, sdtype, sdmode ) ) + return; + + KConfig *config = KGlobal::config(); + + config->setGroup("General" ); + if (!maysd) { sdtype = KApplication::ShutdownTypeNone; } else if (sdtype == KApplication::ShutdownTypeDefault) sdtype = (KApplication::ShutdownType) @@ -138,7 +159,6 @@ void KSMServer::shutdown( KApplication::ShutdownConfirm confirm, sdmode = KApplication::ShutdownModeInteractive; dialogActive = true; - TQString bopt; if ( !logoutConfirmed ) { KSMShutdownFeedback::start(); // make the screen gray logoutConfirmed = @@ -204,6 +224,42 @@ void KSMServer::shutdown( KApplication::ShutdownConfirm confirm, dialogActive = false; } +void KSMServer::shutdown( KApplication::ShutdownConfirm confirm, + KApplication::ShutdownType sdtype, KApplication::ShutdownMode sdmode ) +{ + shutdownInternal( confirm, sdtype, sdmode ); +} + +#include <kmessagebox.h> + +void KSMServer::logoutTimed( int sdtype, int sdmode, TQString bootOption ) +{ + int confirmDelay; + + KConfig* config = KGlobal::config(); + config->setGroup( "General" ); + + if ( sdtype == KApplication::ShutdownTypeHalt ) + confirmDelay = config->readNumEntry( "confirmShutdownDelay", 31 ); + else if ( sdtype == KApplication::ShutdownTypeReboot ) + confirmDelay = config->readNumEntry( "confirmRebootDelay", 31 ); + else + confirmDelay = config->readNumEntry( "confirmLogoutDelay", 31 ); + + bool result = true; + if (confirmDelay) { + KSMShutdownFeedback::start(); // make the screen gray + result = KSMDelayedMessageBox::showTicker( (KApplication::ShutdownType)sdtype, bootOption, confirmDelay ); + KSMShutdownFeedback::stop(); // make the screen become normal again + } + + if ( result ) + shutdownInternal( KApplication::ShutdownConfirmNo, + (KApplication::ShutdownType)sdtype, + (KApplication::ShutdownMode)sdmode, + bootOption ); +} + void KSMServer::pendingShutdownTimeout() { shutdown( pendingShutdown_confirm, pendingShutdown_sdtype, pendingShutdown_sdmode ); |