-rw-r--r-- | core/launcher/shutdownimpl.cpp | 1 |
1 files changed, 0 insertions, 1 deletions
diff --git a/core/launcher/shutdownimpl.cpp b/core/launcher/shutdownimpl.cpp index 2731568..b66951f 100644 --- a/core/launcher/shutdownimpl.cpp +++ b/core/launcher/shutdownimpl.cpp | |||
@@ -26,129 +26,128 @@ | |||
26 | #include <qtimer.h> | 26 | #include <qtimer.h> |
27 | #include <qprogressbar.h> | 27 | #include <qprogressbar.h> |
28 | #include <qpushbutton.h> | 28 | #include <qpushbutton.h> |
29 | #include <qbuttongroup.h> | 29 | #include <qbuttongroup.h> |
30 | #include <qlabel.h> | 30 | #include <qlabel.h> |
31 | #include <qlayout.h> | 31 | #include <qlayout.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( "Shutdown..." ) ); | 49 | setCaption ( tr( "Shutdown..." ) ); |
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." ) ); | ||
91 | vbox-> addWidget ( m_info ); | 90 | vbox-> addWidget ( m_info ); |
92 | 91 | ||
93 | m_progress = new QProgressBar ( this, "progressBar" ); | 92 | m_progress = new QProgressBar ( this, "progressBar" ); |
94 | m_progress-> setFrameShape ( QProgressBar::Panel ); | 93 | m_progress-> setFrameShape ( QProgressBar::Panel ); |
95 | m_progress-> setFrameShadow ( QProgressBar::Sunken ); | 94 | m_progress-> setFrameShadow ( QProgressBar::Sunken ); |
96 | m_progress-> setTotalSteps ( 20 ); | 95 | m_progress-> setTotalSteps ( 20 ); |
97 | m_progress-> setIndicatorFollowsStyle ( false ); | 96 | m_progress-> setIndicatorFollowsStyle ( false ); |
98 | vbox-> addWidget ( m_progress ); | 97 | vbox-> addWidget ( m_progress ); |
99 | 98 | ||
100 | vbox-> addItem ( new QSpacerItem ( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ) ); | 99 | vbox-> addItem ( new QSpacerItem ( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ) ); |
101 | 100 | ||
102 | QPushButton *cancel = new QPushButton ( tr( "Cancel" ), this, "cancel" ); | 101 | QPushButton *cancel = new QPushButton ( tr( "Cancel" ), this, "cancel" ); |
103 | changeButtonColor ( cancel, QColor( 181, 222, 178 ) ); | 102 | changeButtonColor ( cancel, QColor( 181, 222, 178 ) ); |
104 | cancel-> setDefault ( true ); | 103 | cancel-> setDefault ( true ); |
105 | cancel-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding, cancel-> sizePolicy ( ). hasHeightForWidth ( ) ) ); | 104 | cancel-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding, cancel-> sizePolicy ( ). hasHeightForWidth ( ) ) ); |
106 | vbox-> addWidget ( cancel ); | 105 | vbox-> addWidget ( cancel ); |
107 | 106 | ||
108 | m_timer = new QTimer ( this ); | 107 | m_timer = new QTimer ( this ); |
109 | connect ( m_timer, SIGNAL( timeout() ), this, SLOT( timeout() ) ); | 108 | connect ( m_timer, SIGNAL( timeout() ), this, SLOT( timeout() ) ); |
110 | 109 | ||
111 | connect ( btngrp, SIGNAL( clicked(int) ), this, SLOT( buttonClicked(int) ) ); | 110 | connect ( btngrp, SIGNAL( clicked(int) ), this, SLOT( buttonClicked(int) ) ); |
112 | connect ( cancel, SIGNAL( clicked() ), this, SLOT( cancelClicked() ) ); | 111 | connect ( cancel, SIGNAL( clicked() ), this, SLOT( cancelClicked() ) ); |
113 | 112 | ||
114 | m_progress-> hide ( ); | 113 | m_progress-> hide ( ); |
115 | Global::hideInputMethod ( ); | 114 | Global::hideInputMethod ( ); |
116 | } | 115 | } |
117 | 116 | ||
118 | void ShutdownImpl::buttonClicked ( int b ) | 117 | void ShutdownImpl::buttonClicked ( int b ) |
119 | { | 118 | { |
120 | m_counter = 0; | 119 | m_counter = 0; |
121 | 120 | ||
122 | switch ( b ) { | 121 | switch ( b ) { |
123 | case 1: | 122 | case 1: |
124 | m_operation = ShutdownSystem; | 123 | m_operation = ShutdownSystem; |
125 | break; | 124 | break; |
126 | case 2: | 125 | case 2: |
127 | m_operation = RebootSystem; | 126 | m_operation = RebootSystem; |
128 | break; | 127 | break; |
129 | case 3: | 128 | case 3: |
130 | m_operation = RestartDesktop; | 129 | m_operation = RestartDesktop; |
131 | break; | 130 | break; |
132 | case 4: | 131 | case 4: |
133 | m_operation = TerminateDesktop; | 132 | m_operation = TerminateDesktop; |
134 | break; | 133 | break; |
135 | } | 134 | } |
136 | m_info-> hide ( ); | 135 | m_info-> hide ( ); |
137 | m_progress-> show ( ); | 136 | m_progress-> show ( ); |
138 | m_timer-> start ( 300 ); | 137 | m_timer-> start ( 300 ); |
139 | timeout ( ); | 138 | timeout ( ); |
140 | } | 139 | } |
141 | 140 | ||
142 | void ShutdownImpl::cancelClicked ( ) | 141 | void ShutdownImpl::cancelClicked ( ) |
143 | { | 142 | { |
144 | m_progress-> hide ( ); | 143 | m_progress-> hide ( ); |
145 | m_info-> show ( ); | 144 | m_info-> show ( ); |
146 | if ( m_timer-> isActive ( ) ) | 145 | if ( m_timer-> isActive ( ) ) |
147 | m_timer-> stop ( ); | 146 | m_timer-> stop ( ); |
148 | else | 147 | else |
149 | close ( ); | 148 | close ( ); |
150 | } | 149 | } |
151 | 150 | ||
152 | void ShutdownImpl::timeout ( ) | 151 | void ShutdownImpl::timeout ( ) |
153 | { | 152 | { |
154 | if ( ( m_counter += 2 ) > m_progress-> totalSteps ( ) ) { | 153 | if ( ( m_counter += 2 ) > m_progress-> totalSteps ( ) ) { |