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 | |
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')
-rw-r--r-- | ksmserver/KSMServerInterface.h | 2 | ||||
-rw-r--r-- | ksmserver/Makefile.am | 4 | ||||
-rw-r--r-- | ksmserver/server.h | 12 | ||||
-rw-r--r-- | ksmserver/shutdown.cpp | 78 | ||||
-rw-r--r-- | ksmserver/shutdowndlg.cpp | 70 | ||||
-rw-r--r-- | ksmserver/shutdowndlg.h | 19 | ||||
-rw-r--r-- | ksmserver/test.cpp | 7 | ||||
-rw-r--r-- | ksmserver/timed.ui | 352 |
8 files changed, 529 insertions, 15 deletions
diff --git a/ksmserver/KSMServerInterface.h b/ksmserver/KSMServerInterface.h index 52fdf0942..a628b92ba 100644 --- a/ksmserver/KSMServerInterface.h +++ b/ksmserver/KSMServerInterface.h @@ -22,6 +22,8 @@ k_dcop: virtual void suspendStartup( TQCString ) = 0; virtual void resumeStartup( TQCString ) = 0; + + virtual void logoutTimed( int, int, TQString ) = 0; }; #endif diff --git a/ksmserver/Makefile.am b/ksmserver/Makefile.am index 62f9d8976..19b328bc5 100644 --- a/ksmserver/Makefile.am +++ b/ksmserver/Makefile.am @@ -28,7 +28,7 @@ ksmserver_la_METASOURCES = AUTO # Order is important for --enable-final! ksmserver_la_SOURCES = main.cpp server.cpp shutdowndlg.cpp \ legacy.cpp startup.cpp shutdown.cpp client.cpp \ - KSMServerInterface.skel server.skel + KSMServerInterface.skel server.skel timed.ui ksmserver_la_LDFLAGS = $(all_libraries) -avoid-version -module ksmserver_la_LIBADD = ../kdmlib/libdmctl.la $(LIB_KDEUI) $(HAL_LIBS) $(DBUS_LIBS) @@ -42,7 +42,7 @@ updatedir = $(kde_datadir)/kconf_update EXTRA_PROGRAMS = testsh -testsh_SOURCES = test.cpp +testsh_SOURCES = test.cpp timed.ui testsh_LDFLAGS = $(all_libraries) $(KDE_RPATH) testsh_LDADD = $(LIB_KDEUI) shutdowndlg.lo ../kdmlib/libdmctl.la $(HAL_LIBS) $(DBUS_LIBS) diff --git a/ksmserver/server.h b/ksmserver/server.h index 3d5904e53..0fc900042 100644 --- a/ksmserver/server.h +++ b/ksmserver/server.h @@ -85,6 +85,7 @@ public: // public API void restoreSession( TQString sessionName ); void startDefaultSession(); + void shutdown( KApplication::ShutdownConfirm confirm, KApplication::ShutdownType sdtype, KApplication::ShutdownMode sdmode ); @@ -92,6 +93,11 @@ public: virtual void suspendStartup( TQCString app ); virtual void resumeStartup( TQCString app ); + bool checkStatus( bool &logoutConfirmed, bool &maysd, + KApplication::ShutdownConfirm confirm, + KApplication::ShutdownType sdtype, + KApplication::ShutdownMode sdmode ); + public slots: void cleanUp(); @@ -142,6 +148,11 @@ private: bool defaultSession() const; // empty session void setupXIOErrorHandler(); + void shutdownInternal( KApplication::ShutdownConfirm confirm, + KApplication::ShutdownType sdtype, + KApplication::ShutdownMode sdmode, + TQString bootOption = TQString::null ); + void performLegacySessionSave(); void storeLegacySession( KConfig* config ); void restoreLegacySession( KConfig* config ); @@ -157,6 +168,7 @@ private: // public dcop interface void logout( int, int, int ); + virtual void logoutTimed( int, int, TQString ); TQStringList sessionList(); TQString currentSession(); void saveCurrentSession(); 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 ); diff --git a/ksmserver/shutdowndlg.cpp b/ksmserver/shutdowndlg.cpp index 7b0493559..f6295a158 100644 --- a/ksmserver/shutdowndlg.cpp +++ b/ksmserver/shutdowndlg.cpp @@ -29,6 +29,7 @@ Copyright (C) 2000 Matthias Ettrich <ettrich@kde.org> #include <tqregexp.h> #include <klocale.h> +#include <kconfig.h> #include <kapplication.h> #include <kdebug.h> #include <kpushbutton.h> @@ -340,6 +341,7 @@ KSMShutdownDlg::KSMShutdownDlg( TQWidget* parent, buttonlay->addStretch( 1 ); // End session KPushButton* btnLogout = new KPushButton( KGuiItem( i18n("&End Current Session"), "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>" ) ); btnFont = btnLogout->font(); buttonlay->addWidget( btnLogout ); connect(btnLogout, TQT_SIGNAL(clicked()), TQT_SLOT(slotLogout())); @@ -510,14 +512,16 @@ KSMShutdownDlg::KSMShutdownDlg( TQWidget* parent, { // Shutdown KPushButton* btnHalt = new KPushButton( KGuiItem( i18n("&Turn Off Computer"), "exit"), 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>" ) ); btnHalt->setFont( btnFont ); buttonlay->addWidget( btnHalt ); connect(btnHalt, TQT_SIGNAL(clicked()), TQT_SLOT(slotHalt())); - if ( sdtype == KApplication::ShutdownTypeHalt ) + if ( sdtype == KApplication::ShutdownTypeHalt || getenv("KDM_AUTOLOGIN") ) btnHalt->setFocus(); // 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>" ) ); btnReboot->setFont( btnFont ); buttonlay->addWidget( btnReboot ); @@ -761,6 +765,70 @@ void KSMDelayedPushButton::slotTimeout() setDown(false); } +KSMDelayedMessageBox::KSMDelayedMessageBox( KApplication::ShutdownType sdtype, const TQString &bootOption, int confirmDelay ) + : TimedLogoutDlg( 0, 0, true, WType_Popup ), m_remaining(confirmDelay) +{ + if ( sdtype == KApplication::ShutdownTypeHalt ) + { + m_title->setText( i18n( "Would you like to turn off your computer?" ) ); + m_template = i18n( "This computer will turn off automatically\n" + "after %1 seconds." ); + m_logo->setPixmap( BarIcon( "exit", 48 ) ); + } else if ( sdtype == KApplication::ShutdownTypeReboot ) + { + if (bootOption.isEmpty()) + m_title->setText( i18n( "Would you like to reboot your computer?" ) ); + else + m_title->setText( i18n( "Would you like to reboot to \"%1\"?" ).arg(bootOption) ); + m_template = i18n( "This computer will reboot automatically\n" + "after %1 seconds." ); + m_logo->setPixmap( BarIcon( "reload", 48 ) ); + } else { + m_title->setText( i18n( "Would you like to end your current session?" ) ); + m_template = i18n( "This session will end\n" + "after %1 seconds automatically." ); + m_logo->setPixmap( BarIcon( "previous", 48 ) ); + } + + updateText(); + adjustSize(); + if ( double( height() ) / width() < 0.25 ) + { + setFixedHeight( qRound( width() * 0.3 ) ); + adjustSize(); + } + TQTimer *timer = new TQTimer( this ); + timer->start( 1000 ); + connect( timer, TQT_SIGNAL( timeout() ), TQT_SLOT( updateText() ) ); + KDialog::centerOnScreen(this); +} + +void KSMDelayedMessageBox::updateText() +{ + m_remaining--; + if ( m_remaining == 0 ) + { + accept(); + return; + } + m_text->setText( m_template.arg( m_remaining ) ); +} + +bool KSMDelayedMessageBox::showTicker( KApplication::ShutdownType sdtype, const TQString &bootOption, int confirmDelay ) +{ + kapp->enableStyles(); + KSMDelayedMessageBox msg( sdtype, bootOption, confirmDelay ); + TQSize sh = msg.sizeHint(); + TQRect rect = KGlobalSettings::desktopGeometry(TQCursor::pos()); + + msg.move(rect.x() + (rect.width() - sh.width())/2, + rect.y() + (rect.height() - sh.height())/2); + bool result = msg.exec(); + + kapp->disableStyles(); + return result; +} + KSMPushButton::KSMPushButton( const KGuiItem &item, TQWidget *parent, const char *name) diff --git a/ksmserver/shutdowndlg.h b/ksmserver/shutdowndlg.h index a1d720669..79ee8ca37 100644 --- a/ksmserver/shutdowndlg.h +++ b/ksmserver/shutdowndlg.h @@ -26,6 +26,7 @@ class TQString; class KAction; +#include "timed.h" #include <kapplication.h> #include <kpixmapio.h> @@ -165,4 +166,22 @@ class FlatButton : public QToolButton +class TQLabel; + +class KSMDelayedMessageBox : public TimedLogoutDlg +{ + Q_OBJECT + +public: + KSMDelayedMessageBox( KApplication::ShutdownType sdtype, const TQString &bootOption, int confirmDelay ); + static bool showTicker( KApplication::ShutdownType sdtype, const TQString &bootOption, int confirmDelay ); + +protected slots: + void updateText(); + +private: + TQString m_template; + int m_remaining; +}; + #endif diff --git a/ksmserver/test.cpp b/ksmserver/test.cpp index 846c449db..8f248725f 100644 --- a/ksmserver/test.cpp +++ b/ksmserver/test.cpp @@ -14,11 +14,16 @@ main(int argc, char *argv[]) a.iconLoader()->addAppDir("ksmserver"); KSMShutdownFeedback::start(); + // ShutdownTypeNone == Logout == 0 + // ShutdownTypeReboot == 1 + // ShutdownTypeHalt == 2 KApplication::ShutdownType sdtype = KApplication::ShutdownTypeNone; TQString bopt; + KSMDelayedMessageBox::showTicker( sdtype ); + /* (void)KSMShutdownDlg::confirmShutdown( true, sdtype, - bopt ); + bopt );*/ /* (void)KSMShutdownDlg::confirmShutdown( false, sdtype, bopt ); */ diff --git a/ksmserver/timed.ui b/ksmserver/timed.ui new file mode 100644 index 000000000..23d7aa2a0 --- /dev/null +++ b/ksmserver/timed.ui @@ -0,0 +1,352 @@ +<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> +<class>TimedLogoutDlg</class> +<widget class="QDialog"> + <property name="name"> + <cstring>TimedLogoutDlg</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>381</width> + <height>131</height> + </rect> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="caption"> + <string>Confirmation</string> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <property name="spacing"> + <number>0</number> + </property> + <widget class="QFrame"> + <property name="name"> + <cstring>frame3</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="frameShape"> + <enum>StyledPanel</enum> + </property> + <property name="frameShadow"> + <enum>Raised</enum> + </property> + <property name="lineWidth"> + <number>2</number> + </property> + <property name="margin"> + <number>0</number> + </property> + <property name="midLineWidth"> + <number>0</number> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout10</cstring> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <property name="spacing"> + <number>0</number> + </property> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout8</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout6</cstring> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <property name="spacing"> + <number>0</number> + </property> + <spacer> + <property name="name"> + <cstring>spacer3_2</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>MinimumExpanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>2</height> + </size> + </property> + </spacer> + <widget class="QLabel"> + <property name="name"> + <cstring>m_logo</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>1</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>48</width> + <height>48</height> + </size> + </property> + <property name="scaledContents"> + <bool>true</bool> + </property> + </widget> + <spacer> + <property name="name"> + <cstring>spacer3</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>MinimumExpanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>2</height> + </size> + </property> + </spacer> + </vbox> + </widget> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout7</cstring> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>7</number> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>m_title</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="font"> + <font> + <bold>1</bold> + </font> + </property> + <property name="text"> + <string>Would you like to shutdown your computer?</string> + </property> + <property name="textFormat"> + <enum>PlainText</enum> + </property> + <property name="alignment"> + <set>AlignVCenter|AlignLeft</set> + </property> + </widget> + <widget class="QLabel"> + <property name="name"> + <cstring>m_text</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>If you do not act, your computer will shutdown +after X automatically.</string> + </property> + <property name="textFormat"> + <enum>RichText</enum> + </property> + <property name="alignment"> + <set>WordBreak|AlignVCenter</set> + </property> + </widget> + <spacer> + <property name="name"> + <cstring>spacer4</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Preferred</enum> + </property> + <property name="sizeHint"> + <size> + <width>30</width> + <height>0</height> + </size> + </property> + </spacer> + </vbox> + </widget> + </hbox> + </widget> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout9</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <spacer> + <property name="name"> + <cstring>spacer2</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>90</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="QPushButton"> + <property name="name"> + <cstring>pushButton1</cstring> + </property> + <property name="text"> + <string>Confirm</string> + </property> + <property name="on"> + <bool>false</bool> + </property> + </widget> + <spacer> + <property name="name"> + <cstring>spacer2_2</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>90</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="QPushButton"> + <property name="name"> + <cstring>pushButton2</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Cancel</string> + </property> + </widget> + <spacer> + <property name="name"> + <cstring>spacer2_2_2</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>90</width> + <height>20</height> + </size> + </property> + </spacer> + </hbox> + </widget> + </vbox> + </widget> + </hbox> + </widget> + </vbox> +</widget> +<connections> + <connection> + <sender>pushButton1</sender> + <signal>clicked()</signal> + <receiver>TimedLogoutDlg</receiver> + <slot>accept()</slot> + </connection> + <connection> + <sender>pushButton2</sender> + <signal>clicked()</signal> + <receiver>TimedLogoutDlg</receiver> + <slot>reject()</slot> + </connection> +</connections> +<layoutdefaults spacing="6" margin="11"/> +</UI> |