-rw-r--r-- | core/launcher/shutdownimpl.cpp | 191 | ||||
-rw-r--r-- | core/launcher/shutdownimpl.h | 26 |
2 files changed, 109 insertions, 108 deletions
diff --git a/core/launcher/shutdownimpl.cpp b/core/launcher/shutdownimpl.cpp index 0c5b4f6..b1925d9 100644 --- a/core/launcher/shutdownimpl.cpp +++ b/core/launcher/shutdownimpl.cpp | |||
@@ -29,139 +29,140 @@ | |||
29 | #include <qlabel.h> | 29 | #include <qlabel.h> |
30 | #include <qlayout.h> | 30 | #include <qlayout.h> |
31 | #include <qpalette.h> | 31 | #include <qpalette.h> |
32 | 32 | ||
33 | 33 | ||
34 | static void changeButtonColor ( QPushButton *btn, const QColor &col ) | 34 | static void changeButtonColor ( QPushButton *btn, const QColor &col ) |
35 | { | 35 | { |
36 | QPalette pal = btn-> palette ( ); | 36 | QPalette pal = btn-> palette ( ); |
37 | 37 | ||
38 | pal. setColor ( QPalette::Active, QColorGroup::Button, col ); | 38 | pal. setColor ( QPalette::Active, QColorGroup::Button, col ); |
39 | pal. setColor ( QPalette::Disabled, QColorGroup::Button, col ); | 39 | pal. setColor ( QPalette::Disabled, QColorGroup::Button, col ); |
40 | pal. setColor ( QPalette::Inactive, QColorGroup::Button, col ); | 40 | pal. setColor ( QPalette::Inactive, QColorGroup::Button, col ); |
41 | 41 | ||
42 | btn-> setPalette ( pal ); | 42 | btn-> setPalette ( pal ); |
43 | } | 43 | } |
44 | 44 | ||
45 | 45 | ||
46 | ShutdownImpl::ShutdownImpl( QWidget* parent, const char *name, WFlags fl ) | 46 | ShutdownImpl::ShutdownImpl( QWidget* parent, const char *name, WFlags fl ) |
47 | : QWidget ( parent, name, fl ) | 47 | : QWidget ( parent, name, fl ) |
48 | { | 48 | { |
49 | setCaption ( tr( "Shut down..." )); | 49 | setCaption ( tr( "Shut down..." ) ); |
50 | 50 | ||
51 | QVBoxLayout *vbox = new QVBoxLayout ( this ); | 51 | QVBoxLayout *vbox = new QVBoxLayout ( this ); |
52 | vbox-> setSpacing ( 3 ); | 52 | vbox-> setSpacing ( 3 ); |
53 | vbox-> setMargin ( 6 ); | 53 | vbox-> setMargin ( 6 ); |
54 | 54 | ||
55 | QButtonGroup *btngrp = new QButtonGroup ( this ); | 55 | QButtonGroup *btngrp = new QButtonGroup ( this ); |
56 | 56 | ||
57 | btngrp-> setTitle ( tr( "Terminate" )); | 57 | btngrp-> setTitle ( tr( "Terminate" ) ); |
58 | btngrp-> setColumnLayout ( 0, Qt::Vertical ); | 58 | btngrp-> setColumnLayout ( 0, Qt::Vertical ); |
59 | btngrp-> layout ( )-> setSpacing ( 0 ); | 59 | btngrp-> layout ( ) -> setSpacing ( 0 ); |
60 | btngrp-> layout ( )-> setMargin ( 0 ); | 60 | btngrp-> layout ( ) -> setMargin ( 0 ); |
61 | 61 | ||
62 | QGridLayout *grid = new QGridLayout ( btngrp-> layout ( )); | 62 | QGridLayout *grid = new QGridLayout ( btngrp-> layout ( ) ); |
63 | grid-> setAlignment ( Qt::AlignTop ); | 63 | grid-> setAlignment ( Qt::AlignTop ); |
64 | grid-> setSpacing ( 3 ); | 64 | grid-> setSpacing ( 3 ); |
65 | grid-> setMargin ( 7 ); | 65 | grid-> setMargin ( 7 ); |
66 | 66 | ||
67 | QPushButton *quit = new QPushButton ( tr( "Terminate Opie" ), btngrp, "quit" ); | 67 | QPushButton *quit = new QPushButton ( tr( "Terminate Opie" ), btngrp, "quit" ); |
68 | changeButtonColor ( quit, QColor ( 236, 236, 179 )); | 68 | changeButtonColor ( quit, QColor ( 236, 236, 179 ) ); |
69 | btngrp-> insert ( quit, 4 ); | 69 | btngrp-> insert ( quit, 4 ); |
70 | grid-> addWidget ( quit, 1, 1 ); | 70 | grid-> addWidget ( quit, 1, 1 ); |
71 | 71 | ||
72 | QPushButton *reboot = new QPushButton ( tr( "Reboot" ), btngrp, "reboot" ); | 72 | QPushButton *reboot = new QPushButton ( tr( "Reboot" ), btngrp, "reboot" ); |
73 | changeButtonColor ( reboot, QColor( 236, 183, 181 )); | 73 | changeButtonColor ( reboot, QColor( 236, 183, 181 ) ); |
74 | btngrp-> insert ( reboot, 2 ); | 74 | btngrp-> insert ( reboot, 2 ); |
75 | grid-> addWidget( reboot, 1, 0 ); | 75 | grid-> addWidget( reboot, 1, 0 ); |
76 | 76 | ||
77 | QPushButton *restart = new QPushButton ( tr( "Restart Opie" ), btngrp, "restart" ); | 77 | QPushButton *restart = new QPushButton ( tr( "Restart Opie" ), btngrp, "restart" ); |
78 | changeButtonColor ( restart, QColor( 236, 236, 179 )); | 78 | changeButtonColor ( restart, QColor( 236, 236, 179 ) ); |
79 | btngrp-> insert ( restart, 3 ); | 79 | btngrp-> insert ( restart, 3 ); |
80 | grid-> addWidget ( restart, 0, 1 ); | 80 | grid-> addWidget ( restart, 0, 1 ); |
81 | 81 | ||
82 | QPushButton *shutdown = new QPushButton( tr( "Shutdown" ), btngrp, "shutdown" ); | 82 | QPushButton *shutdown = new QPushButton( tr( "Shutdown" ), btngrp, "shutdown" ); |
83 | changeButtonColor ( shutdown, QColor( 236, 183, 181 )); | 83 | changeButtonColor ( shutdown, QColor( 236, 183, 181 ) ); |
84 | btngrp-> insert ( shutdown, 1 ); | 84 | btngrp-> insert ( shutdown, 1 ); |
85 | grid-> addWidget ( shutdown, 0, 0 ); | 85 | grid-> addWidget ( shutdown, 0, 0 ); |
86 | 86 | ||
87 | vbox-> addWidget ( btngrp ); | 87 | vbox-> addWidget ( btngrp ); |
88 | 88 | ||
89 | m_info = new QLabel ( this, "info" ); | 89 | m_info = new QLabel ( this, "info" ); |
90 | m_info-> setText( tr( "<p>\n" "These termination options are provided primarily for use while developing and testing the Opie system. In a normal environment, these concepts are unnecessary." ) ); | 90 | m_info-> setText( tr( "<p>\n" "These termination options are provided primarily for use while developing and testing the Opie system. In a normal environment, these concepts are unnecessary." ) ); |
91 | vbox-> addWidget ( m_info ); | 91 | vbox-> addWidget ( m_info ); |
92 | 92 | ||
93 | m_progress = new QProgressBar ( this, "progressBar" ); | 93 | m_progress = new QProgressBar ( this, "progressBar" ); |
94 | m_progress-> setFrameShape ( QProgressBar::Panel ); | 94 | m_progress-> setFrameShape ( QProgressBar::Panel ); |
95 | m_progress-> setFrameShadow ( QProgressBar::Sunken ); | 95 | m_progress-> setFrameShadow ( QProgressBar::Sunken ); |
96 | m_progress-> setTotalSteps ( 20 ); | 96 | m_progress-> setTotalSteps ( 20 ); |
97 | m_progress-> setIndicatorFollowsStyle ( false ); | 97 | m_progress-> setIndicatorFollowsStyle ( false ); |
98 | vbox-> addWidget ( m_progress ); | 98 | vbox-> addWidget ( m_progress ); |
99 | 99 | ||
100 | vbox-> addItem ( new QSpacerItem ( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding )); | 100 | vbox-> addItem ( new QSpacerItem ( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ) ); |
101 | 101 | ||
102 | QPushButton *cancel = new QPushButton ( tr( "Cancel" ), this, "cancel" ); | 102 | QPushButton *cancel = new QPushButton ( tr( "Cancel" ), this, "cancel" ); |
103 | changeButtonColor ( cancel, QColor( 181, 222, 178 )); | 103 | changeButtonColor ( cancel, QColor( 181, 222, 178 ) ); |
104 | cancel-> setDefault ( true ); | 104 | cancel-> setDefault ( true ); |
105 | cancel-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding, cancel-> sizePolicy ( ). hasHeightForWidth ( ))); | 105 | cancel-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding, cancel-> sizePolicy ( ). hasHeightForWidth ( ) ) ); |
106 | vbox-> addWidget ( cancel ); | 106 | vbox-> addWidget ( cancel ); |
107 | 107 | ||
108 | m_timer = new QTimer ( this ); | 108 | m_timer = new QTimer ( this ); |
109 | connect ( m_timer, SIGNAL( timeout ( )), this, SLOT( timeout ( ))); | 109 | connect ( m_timer, SIGNAL( timeout ( ) ), this, SLOT( timeout ( ) ) ); |
110 | 110 | ||
111 | connect ( btngrp, SIGNAL( clicked ( int )), this, SLOT( buttonClicked ( int ))); | 111 | connect ( btngrp, SIGNAL( clicked ( int ) ), this, SLOT( buttonClicked ( int ) ) ); |
112 | connect ( cancel, SIGNAL( clicked ( )), this, SLOT( cancelClicked ( ))); | 112 | connect ( cancel, SIGNAL( clicked ( ) ), this, SLOT( cancelClicked ( ) ) ); |
113 | 113 | ||
114 | m_progress-> hide ( ); | 114 | m_progress-> hide ( ); |
115 | Global::hideInputMethod ( ); | 115 | Global::hideInputMethod ( ); |
116 | 116 | ||
117 | #ifdef QT_QWS_CUSTOM | 117 | #ifdef QT_QWS_CUSTOM |
118 | shutdown-> hide ( ); | 118 | |
119 | #endif | 119 | shutdown-> hide ( ); |
120 | #endif | ||
120 | } | 121 | } |
121 | 122 | ||
122 | void ShutdownImpl::buttonClicked ( int b ) | 123 | void ShutdownImpl::buttonClicked ( int b ) |
123 | { | 124 | { |
124 | m_counter = 0; | 125 | m_counter = 0; |
125 | 126 | ||
126 | switch ( b ) { | 127 | switch ( b ) { |
127 | case 1: | 128 | case 1: |
128 | m_operation = ShutdownSystem; | 129 | m_operation = ShutdownSystem; |
129 | break; | 130 | break; |
130 | case 2: | 131 | case 2: |
131 | m_operation = RebootSystem; | 132 | m_operation = RebootSystem; |
132 | break; | 133 | break; |
133 | case 3: | 134 | case 3: |
134 | m_operation = RestartDesktop; | 135 | m_operation = RestartDesktop; |
135 | break; | 136 | break; |
136 | case 4: | 137 | case 4: |
137 | m_operation = TerminateDesktop; | 138 | m_operation = TerminateDesktop; |
138 | break; | 139 | break; |
139 | } | 140 | } |
140 | m_info-> hide ( ); | 141 | m_info-> hide ( ); |
141 | m_progress-> show ( ); | 142 | m_progress-> show ( ); |
142 | m_timer-> start ( 300 ); | 143 | m_timer-> start ( 300 ); |
143 | timeout ( ); | 144 | timeout ( ); |
144 | } | 145 | } |
145 | 146 | ||
146 | void ShutdownImpl::cancelClicked ( ) | 147 | void ShutdownImpl::cancelClicked ( ) |
147 | { | 148 | { |
148 | m_progress-> hide ( ); | 149 | m_progress-> hide ( ); |
149 | m_info-> show ( ); | 150 | m_info-> show ( ); |
150 | if ( m_timer-> isActive ( )) | 151 | if ( m_timer-> isActive ( ) ) |
151 | m_timer-> stop ( ); | 152 | m_timer-> stop ( ); |
152 | else | 153 | else |
153 | close ( ); | 154 | close ( ); |
154 | } | 155 | } |
155 | 156 | ||
156 | void ShutdownImpl::timeout ( ) | 157 | void ShutdownImpl::timeout ( ) |
157 | { | 158 | { |
158 | if (( m_counter += 2 ) > m_progress-> totalSteps ( )) { | 159 | if ( ( m_counter += 2 ) > m_progress-> totalSteps ( ) ) { |
159 | m_progress-> hide ( ); | 160 | m_progress-> hide ( ); |
160 | m_timer-> stop ( ); | 161 | m_timer-> stop ( ); |
161 | emit shutdown ( m_operation ); | 162 | emit shutdown ( m_operation ); |
162 | } | 163 | } |
163 | else | 164 | else |
164 | m_progress-> setProgress ( m_counter ); | 165 | m_progress-> setProgress ( m_counter ); |
165 | } | 166 | } |
166 | 167 | ||
167 | 168 | ||
diff --git a/core/launcher/shutdownimpl.h b/core/launcher/shutdownimpl.h index 462f347..c2ebcc7 100644 --- a/core/launcher/shutdownimpl.h +++ b/core/launcher/shutdownimpl.h | |||
@@ -23,33 +23,33 @@ | |||
23 | #include <qwidget.h> | 23 | #include <qwidget.h> |
24 | 24 | ||
25 | class QTimer; | 25 | class QTimer; |
26 | class QLabel; | 26 | class QLabel; |
27 | class QProgressBar; | 27 | class QProgressBar; |
28 | 28 | ||
29 | class ShutdownImpl : public QWidget | 29 | class ShutdownImpl : public QWidget |
30 | { | 30 | { |
31 | Q_OBJECT | 31 | Q_OBJECT |
32 | public: | 32 | public: |
33 | ShutdownImpl( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 33 | ShutdownImpl( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
34 | 34 | ||
35 | enum Type { ShutdownSystem, RebootSystem, RestartDesktop, TerminateDesktop }; | 35 | enum Type { ShutdownSystem, RebootSystem, RestartDesktop, TerminateDesktop }; |
36 | 36 | ||
37 | signals: | 37 | signals: |
38 | void shutdown( ShutdownImpl::Type ); | 38 | void shutdown( ShutdownImpl::Type ); |
39 | 39 | ||
40 | private slots: | 40 | private slots: |
41 | void buttonClicked( int ); | 41 | void buttonClicked( int ); |
42 | void cancelClicked(); | 42 | void cancelClicked(); |
43 | void timeout(); | 43 | void timeout(); |
44 | 44 | ||
45 | private: | 45 | private: |
46 | QTimer *m_timer; | 46 | QTimer *m_timer; |
47 | int m_counter; | 47 | int m_counter; |
48 | Type m_operation; | 48 | Type m_operation; |
49 | 49 | ||
50 | QLabel * m_info; | 50 | QLabel * m_info; |
51 | QProgressBar *m_progress; | 51 | QProgressBar *m_progress; |
52 | }; | 52 | }; |
53 | 53 | ||
54 | #endif | 54 | #endif |
55 | 55 | ||