summaryrefslogtreecommitdiff
path: root/core/launcher/shutdownimpl.cpp
authorsandman <sandman>2002-06-27 01:44:44 (UTC)
committer sandman <sandman>2002-06-27 01:44:44 (UTC)
commit6d0df38a805c5560b0815df62b212d4be0913154 (patch) (unidiff)
tree3d6e276d877c4bfe2f1960ec62465cb5122bcade /core/launcher/shutdownimpl.cpp
parented8d1696ca8f0407cb7e6b91cc8d410dede5ccdc (diff)
downloadopie-6d0df38a805c5560b0815df62b212d4be0913154.zip
opie-6d0df38a805c5560b0815df62b212d4be0913154.tar.gz
opie-6d0df38a805c5560b0815df62b212d4be0913154.tar.bz2
Made the launcher dialog "liquid compatible":
remvoed the ui file and hand-coded the gui with smarter palette handling.
Diffstat (limited to 'core/launcher/shutdownimpl.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/shutdownimpl.cpp140
1 files changed, 106 insertions, 34 deletions
diff --git a/core/launcher/shutdownimpl.cpp b/core/launcher/shutdownimpl.cpp
index 06ed756..0c5b4f6 100644
--- a/core/launcher/shutdownimpl.cpp
+++ b/core/launcher/shutdownimpl.cpp
@@ -29,20 +29,91 @@
29#include <qlabel.h> 29#include <qlabel.h>
30#include <qlayout.h>
31#include <qpalette.h>
30 32
31 33
34static void changeButtonColor ( QPushButton *btn, const QColor &col )
35{
36 QPalette pal = btn-> palette ( );
37
38 pal. setColor ( QPalette::Active, QColorGroup::Button, col );
39 pal. setColor ( QPalette::Disabled, QColorGroup::Button, col );
40 pal. setColor ( QPalette::Inactive, QColorGroup::Button, col );
41
42 btn-> setPalette ( pal );
43}
44
32 45
33#include <stdio.h>
34ShutdownImpl::ShutdownImpl( QWidget* parent, const char *name, WFlags fl ) 46ShutdownImpl::ShutdownImpl( QWidget* parent, const char *name, WFlags fl )
35 : Shutdown( parent, name, fl ) 47 : QWidget ( parent, name, fl )
36{ 48{
37 timer = new QTimer( this ); 49 setCaption ( tr( "Shut down..." ));
38 connect( timer, SIGNAL(timeout()), this, SLOT(timeout()) ); 50
51 QVBoxLayout *vbox = new QVBoxLayout ( this );
52 vbox-> setSpacing ( 3 );
53 vbox-> setMargin ( 6 );
54
55 QButtonGroup *btngrp = new QButtonGroup ( this );
56
57 btngrp-> setTitle ( tr( "Terminate" ));
58 btngrp-> setColumnLayout ( 0, Qt::Vertical );
59 btngrp-> layout ( )-> setSpacing ( 0 );
60 btngrp-> layout ( )-> setMargin ( 0 );
61
62 QGridLayout *grid = new QGridLayout ( btngrp-> layout ( ));
63 grid-> setAlignment ( Qt::AlignTop );
64 grid-> setSpacing ( 3 );
65 grid-> setMargin ( 7 );
66
67 QPushButton *quit = new QPushButton ( tr( "Terminate Opie" ), btngrp, "quit" );
68 changeButtonColor ( quit, QColor ( 236, 236, 179 ));
69 btngrp-> insert ( quit, 4 );
70 grid-> addWidget ( quit, 1, 1 );
71
72 QPushButton *reboot = new QPushButton ( tr( "Reboot" ), btngrp, "reboot" );
73 changeButtonColor ( reboot, QColor( 236, 183, 181 ));
74 btngrp-> insert ( reboot, 2 );
75 grid-> addWidget( reboot, 1, 0 );
76
77 QPushButton *restart = new QPushButton ( tr( "Restart Opie" ), btngrp, "restart" );
78 changeButtonColor ( restart, QColor( 236, 236, 179 ));
79 btngrp-> insert ( restart, 3 );
80 grid-> addWidget ( restart, 0, 1 );
39 81
40 connect( ButtonGroup1, SIGNAL(clicked(int)), this, SLOT(buttonClicked(int)) ); 82 QPushButton *shutdown = new QPushButton( tr( "Shutdown" ), btngrp, "shutdown" );
41 connect( cancel, SIGNAL(clicked()), this, SLOT(cancelClicked()) ); 83 changeButtonColor ( shutdown, QColor( 236, 183, 181 ));
84 btngrp-> insert ( shutdown, 1 );
85 grid-> addWidget ( shutdown, 0, 0 );
86
87 vbox-> addWidget ( btngrp );
88
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 );
92
93 m_progress = new QProgressBar ( this, "progressBar" );
94 m_progress-> setFrameShape ( QProgressBar::Panel );
95 m_progress-> setFrameShadow ( QProgressBar::Sunken );
96 m_progress-> setTotalSteps ( 20 );
97 m_progress-> setIndicatorFollowsStyle ( false );
98 vbox-> addWidget ( m_progress );
99
100 vbox-> addItem ( new QSpacerItem ( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ));
101
102 QPushButton *cancel = new QPushButton ( tr( "Cancel" ), this, "cancel" );
103 changeButtonColor ( cancel, QColor( 181, 222, 178 ));
104 cancel-> setDefault ( true );
105 cancel-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding, cancel-> sizePolicy ( ). hasHeightForWidth ( )));
106 vbox-> addWidget ( cancel );
107
108 m_timer = new QTimer ( this );
109 connect ( m_timer, SIGNAL( timeout ( )), this, SLOT( timeout ( )));
110
111 connect ( btngrp, SIGNAL( clicked ( int )), this, SLOT( buttonClicked ( int )));
112 connect ( cancel, SIGNAL( clicked ( )), this, SLOT( cancelClicked ( )));
113
114 m_progress-> hide ( );
115 Global::hideInputMethod ( );
42 116
43 progressBar->hide();
44 Global::hideInputMethod();
45#ifdef QT_QWS_CUSTOM 117#ifdef QT_QWS_CUSTOM
46 QPushButton *sb = Shutdown::shutdown; 118 shutdown-> hide ( );
47 sb->hide();
48#endif 119#endif
@@ -50,44 +121,45 @@ ShutdownImpl::ShutdownImpl( QWidget* parent, const char *name, WFlags fl )
50 121
51void ShutdownImpl::buttonClicked( int b ) 122void ShutdownImpl::buttonClicked ( int b )
52{ 123{
53 progress = 0; 124 m_counter = 0;
125
54 switch ( b ) { 126 switch ( b ) {
55 case 1: 127 case 1:
56 operation = ShutdownSystem; 128 m_operation = ShutdownSystem;
57 break; 129 break;
58 case 2: 130 case 2:
59 operation = RebootSystem; 131 m_operation = RebootSystem;
60 break; 132 break;
61 case 3: 133 case 3:
62 operation = RestartDesktop; 134 m_operation = RestartDesktop;
63 break; 135 break;
64 case 4: 136 case 4:
65 operation = TerminateDesktop; 137 m_operation = TerminateDesktop;
66 break; 138 break;
67 } 139 }
68 info->hide(); 140 m_info-> hide ( );
69 progressBar->show(); 141 m_progress-> show ( );
70 timer->start( 300 ); 142 m_timer-> start ( 300 );
71 timeout(); 143 timeout ( );
72} 144}
73 145
74void ShutdownImpl::cancelClicked() 146void ShutdownImpl::cancelClicked ( )
75{ 147{
76 progressBar->hide(); 148 m_progress-> hide ( );
77 info->show(); 149 m_info-> show ( );
78 if ( timer->isActive() ) 150 if ( m_timer-> isActive ( ))
79 timer->stop(); 151 m_timer-> stop ( );
80 else 152 else
81 close(); 153 close ( );
82} 154}
83 155
84void ShutdownImpl::timeout() 156void ShutdownImpl::timeout ( )
85{ 157{
86 if ( (progress+=2) > progressBar->totalSteps() ) { 158 if (( m_counter += 2 ) > m_progress-> totalSteps ( )) {
87 progressBar->hide(); 159 m_progress-> hide ( );
88 timer->stop(); 160 m_timer-> stop ( );
89 emit shutdown( operation ); 161 emit shutdown ( m_operation );
90 } else { 162 }
91 progressBar->setProgress( progress ); 163 else
92 } 164 m_progress-> setProgress ( m_counter );
93} 165}