summaryrefslogtreecommitdiff
path: root/core/applets/logoutapplet/logout.cpp
Unidiff
Diffstat (limited to 'core/applets/logoutapplet/logout.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/logoutapplet/logout.cpp29
1 files changed, 19 insertions, 10 deletions
diff --git a/core/applets/logoutapplet/logout.cpp b/core/applets/logoutapplet/logout.cpp
index 9470401..1769ae6 100644
--- a/core/applets/logoutapplet/logout.cpp
+++ b/core/applets/logoutapplet/logout.cpp
@@ -32,17 +32,27 @@ QString LogoutApplet::name ( ) const
32 32
33QString LogoutApplet::text ( ) const 33QString LogoutApplet::text ( ) const
34{ 34{
35 return tr( "Logout" ); 35 return tr( "Logout" );
36} 36}
37 37
38QString LogoutApplet::tr( const char* s ) const
39{
40 return qApp->translate( "LogoutApplet", s, 0 );
41}
42
43QString LogoutApplet::tr( const char* s, const char* p ) const
44{
45 return qApp->translate( "LogoutApplet", s, p );
46}
47
38QIconSet LogoutApplet::icon ( ) const 48QIconSet LogoutApplet::icon ( ) const
39{ 49{
40 QPixmap pix; 50 QPixmap pix;
41 QImage img = Resource::loadImage ( "logout" ); 51 QImage img = Resource::loadImage ( "logout" );
42 52
43 if ( !img. isNull ( )) 53 if ( !img. isNull ( ))
44 pix. convertFromImage ( img. smoothScale ( 14, 14 )); 54 pix. convertFromImage ( img. smoothScale ( 14, 14 ));
45 return pix; 55 return pix;
46} 56}
47 57
48QPopupMenu *LogoutApplet::popup ( QWidget * ) const 58QPopupMenu *LogoutApplet::popup ( QWidget * ) const
@@ -53,30 +63,30 @@ QPopupMenu *LogoutApplet::popup ( QWidget * ) const
53// This is a workaround for a Qt bug 63// This is a workaround for a Qt bug
54// clipboard applet has to stop its poll timer, or Qt/E 64// clipboard applet has to stop its poll timer, or Qt/E
55// will hang on quit() right before it emits aboutToQuit() 65// will hang on quit() right before it emits aboutToQuit()
56 66
57class HackApplication : public QApplication { 67class HackApplication : public QApplication {
58public: 68public:
59 HackApplication ( ) : QApplication ( dummy, 0 ) 69 HackApplication ( ) : QApplication ( dummy, 0 )
60 { 70 {
61 } 71 }
62 72
63 void emit_about_to_quit ( ) 73 void emit_about_to_quit ( )
64 { 74 {
65 emit aboutToQuit ( ); 75 emit aboutToQuit ( );
66 } 76 }
67 77
68 int dummy; 78 int dummy;
69}; 79};
70 80
71 81
72void LogoutApplet::activated ( ) 82void LogoutApplet::activated ( )
73{ 83{
74 QMessageBox mb ( tr( "Logout" ), 84 QMessageBox mb ( tr( "Logout" ),
75 tr( "Do you really want to\nend this session ?" ), 85 tr( "Do you really want to\nend this session ?" ),
76 QMessageBox::NoIcon, 86 QMessageBox::NoIcon,
77 QMessageBox::Yes | QMessageBox::Default, 87 QMessageBox::Yes | QMessageBox::Default,
78 QMessageBox::No | QMessageBox::Escape, 88 QMessageBox::No | QMessageBox::Escape,
79 QMessageBox::NoButton ); 89 QMessageBox::NoButton );
80 90
81 mb. setButtonText ( QMessageBox::Yes, "Yes" ); 91 mb. setButtonText ( QMessageBox::Yes, "Yes" );
82 mb. setButtonText ( QMessageBox::No, "No" ); 92 mb. setButtonText ( QMessageBox::No, "No" );
@@ -84,13 +94,13 @@ void LogoutApplet::activated ( )
84 94
85 if ( mb. exec ( ) == QMessageBox::Yes ) { 95 if ( mb. exec ( ) == QMessageBox::Yes ) {
86 { QCopEnvelope envelope( "QPE/System", "forceQuit()" ); } 96 { QCopEnvelope envelope( "QPE/System", "forceQuit()" ); }
87 97
88 qApp-> processEvents ( ); // ensure the message goes out. 98 qApp-> processEvents ( ); // ensure the message goes out.
89 sleep ( 1 ); // You have 1 second to comply. 99 sleep ( 1 ); // You have 1 second to comply.
90 100
91 ((HackApplication *) qApp )-> emit_about_to_quit ( ); 101 ((HackApplication *) qApp )-> emit_about_to_quit ( );
92 qApp-> quit(); 102 qApp-> quit();
93 } 103 }
94} 104}
95 105
96 106
@@ -109,7 +119,6 @@ QRESULT LogoutApplet::queryInterface ( const QUuid &uuid, QUnknownInterface **if
109 119
110Q_EXPORT_INTERFACE( ) 120Q_EXPORT_INTERFACE( )
111{ 121{
112 Q_CREATE_INSTANCE( LogoutApplet ) 122 Q_CREATE_INSTANCE( LogoutApplet )
113} 123}
114 124
115