Diffstat (limited to 'core/launcher/shutdownimpl.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/launcher/shutdownimpl.cpp | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/core/launcher/shutdownimpl.cpp b/core/launcher/shutdownimpl.cpp new file mode 100644 index 0000000..06ed756 --- a/dev/null +++ b/core/launcher/shutdownimpl.cpp | |||
@@ -0,0 +1,95 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Qtopia Environment. | ||
5 | ** | ||
6 | ** This file may be distributed and/or modified under the terms of the | ||
7 | ** GNU General Public License version 2 as published by the Free Software | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | |||
21 | #include "shutdownimpl.h" | ||
22 | |||
23 | #include <qpe/global.h> | ||
24 | |||
25 | #include <qtimer.h> | ||
26 | #include <qprogressbar.h> | ||
27 | #include <qpushbutton.h> | ||
28 | #include <qbuttongroup.h> | ||
29 | #include <qlabel.h> | ||
30 | |||
31 | |||
32 | |||
33 | #include <stdio.h> | ||
34 | ShutdownImpl::ShutdownImpl( QWidget* parent, const char *name, WFlags fl ) | ||
35 | : Shutdown( parent, name, fl ) | ||
36 | { | ||
37 | timer = new QTimer( this ); | ||
38 | connect( timer, SIGNAL(timeout()), this, SLOT(timeout()) ); | ||
39 | |||
40 | connect( ButtonGroup1, SIGNAL(clicked(int)), this, SLOT(buttonClicked(int)) ); | ||
41 | connect( cancel, SIGNAL(clicked()), this, SLOT(cancelClicked()) ); | ||
42 | |||
43 | progressBar->hide(); | ||
44 | Global::hideInputMethod(); | ||
45 | #ifdef QT_QWS_CUSTOM | ||
46 | QPushButton *sb = Shutdown::shutdown; | ||
47 | sb->hide(); | ||
48 | #endif | ||
49 | } | ||
50 | |||
51 | void ShutdownImpl::buttonClicked( int b ) | ||
52 | { | ||
53 | progress = 0; | ||
54 | switch ( b ) { | ||
55 | case 1: | ||
56 | operation = ShutdownSystem; | ||
57 | break; | ||
58 | case 2: | ||
59 | operation = RebootSystem; | ||
60 | break; | ||
61 | case 3: | ||
62 | operation = RestartDesktop; | ||
63 | break; | ||
64 | case 4: | ||
65 | operation = TerminateDesktop; | ||
66 | break; | ||
67 | } | ||
68 | info->hide(); | ||
69 | progressBar->show(); | ||
70 | timer->start( 300 ); | ||
71 | timeout(); | ||
72 | } | ||
73 | |||
74 | void ShutdownImpl::cancelClicked() | ||
75 | { | ||
76 | progressBar->hide(); | ||
77 | info->show(); | ||
78 | if ( timer->isActive() ) | ||
79 | timer->stop(); | ||
80 | else | ||
81 | close(); | ||
82 | } | ||
83 | |||
84 | void ShutdownImpl::timeout() | ||
85 | { | ||
86 | if ( (progress+=2) > progressBar->totalSteps() ) { | ||
87 | progressBar->hide(); | ||
88 | timer->stop(); | ||
89 | emit shutdown( operation ); | ||
90 | } else { | ||
91 | progressBar->setProgress( progress ); | ||
92 | } | ||
93 | } | ||
94 | |||
95 | |||