summaryrefslogtreecommitdiff
authorsandman <sandman>2002-11-17 02:03:01 (UTC)
committer sandman <sandman>2002-11-17 02:03:01 (UTC)
commit5a1f5ba99dfb754f1be4500dd55dca42b36413b8 (patch) (unidiff)
tree18b10582e1a4b1d28f5091494a2939fcad5f9de9
parentd28c78c564f3c6ecad91506c50e2c80e66c1a718 (diff)
downloadopie-5a1f5ba99dfb754f1be4500dd55dca42b36413b8.zip
opie-5a1f5ba99dfb754f1be4500dd55dca42b36413b8.tar.gz
opie-5a1f5ba99dfb754f1be4500dd55dca42b36413b8.tar.bz2
- enabled the Shutdown button in Shutdown-Settings on OZ
- enabled the LockKeyState indicator for iPAQs (to the right of the clock applet, since also iPAQs can have keyboards) - kergoth forgot a QT_QWS_EBX -> QT_QWS_SHARP - the launcher binary is now exactly the same on iPAQ and Zaurus
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/shutdownimpl.cpp5
-rw-r--r--core/launcher/taskbar.cpp8
2 files changed, 2 insertions, 11 deletions
diff --git a/core/launcher/shutdownimpl.cpp b/core/launcher/shutdownimpl.cpp
index a202b7b..cf4f926 100644
--- a/core/launcher/shutdownimpl.cpp
+++ b/core/launcher/shutdownimpl.cpp
@@ -1,179 +1,174 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 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 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 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 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. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "shutdownimpl.h" 21#include "shutdownimpl.h"
22 22
23#include <qpe/global.h> 23#include <qpe/global.h>
24#include <qpe/qcopenvelope_qws.h> 24#include <qpe/qcopenvelope_qws.h>
25 25
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#include <qpalette.h> 32#include <qpalette.h>
33 33
34 34
35static void changeButtonColor ( QPushButton *btn, const QColor &col ) 35static void changeButtonColor ( QPushButton *btn, const QColor &col )
36{ 36{
37 QPalette pal = btn-> palette ( ); 37 QPalette pal = btn-> palette ( );
38 38
39 pal. setColor ( QPalette::Active, QColorGroup::Button, col ); 39 pal. setColor ( QPalette::Active, QColorGroup::Button, col );
40 pal. setColor ( QPalette::Disabled, QColorGroup::Button, col ); 40 pal. setColor ( QPalette::Disabled, QColorGroup::Button, col );
41 pal. setColor ( QPalette::Inactive, QColorGroup::Button, col ); 41 pal. setColor ( QPalette::Inactive, QColorGroup::Button, col );
42 42
43 btn-> setPalette ( pal ); 43 btn-> setPalette ( pal );
44} 44}
45 45
46 46
47ShutdownImpl::ShutdownImpl( QWidget* parent, const char *name, WFlags fl ) 47ShutdownImpl::ShutdownImpl( QWidget* parent, const char *name, WFlags fl )
48 : QWidget ( parent, name, fl ) 48 : QWidget ( parent, name, fl )
49{ 49{
50 setCaption ( tr( "Shut down..." ) ); 50 setCaption ( tr( "Shut down..." ) );
51 51
52 QVBoxLayout *vbox = new QVBoxLayout ( this ); 52 QVBoxLayout *vbox = new QVBoxLayout ( this );
53 vbox-> setSpacing ( 3 ); 53 vbox-> setSpacing ( 3 );
54 vbox-> setMargin ( 6 ); 54 vbox-> setMargin ( 6 );
55 55
56 QButtonGroup *btngrp = new QButtonGroup ( this ); 56 QButtonGroup *btngrp = new QButtonGroup ( this );
57 57
58 btngrp-> setTitle ( tr( "Terminate" ) ); 58 btngrp-> setTitle ( tr( "Terminate" ) );
59 btngrp-> setColumnLayout ( 0, Qt::Vertical ); 59 btngrp-> setColumnLayout ( 0, Qt::Vertical );
60 btngrp-> layout ( ) -> setSpacing ( 0 ); 60 btngrp-> layout ( ) -> setSpacing ( 0 );
61 btngrp-> layout ( ) -> setMargin ( 0 ); 61 btngrp-> layout ( ) -> setMargin ( 0 );
62 62
63 QGridLayout *grid = new QGridLayout ( btngrp-> layout ( ) ); 63 QGridLayout *grid = new QGridLayout ( btngrp-> layout ( ) );
64 grid-> setAlignment ( Qt::AlignTop ); 64 grid-> setAlignment ( Qt::AlignTop );
65 grid-> setSpacing ( 3 ); 65 grid-> setSpacing ( 3 );
66 grid-> setMargin ( 7 ); 66 grid-> setMargin ( 7 );
67 67
68 QPushButton *quit = new QPushButton ( tr( "Terminate Opie" ), btngrp, "quit" ); 68 QPushButton *quit = new QPushButton ( tr( "Terminate Opie" ), btngrp, "quit" );
69 changeButtonColor ( quit, QColor ( 236, 236, 179 ) ); 69 changeButtonColor ( quit, QColor ( 236, 236, 179 ) );
70 btngrp-> insert ( quit, 4 ); 70 btngrp-> insert ( quit, 4 );
71 grid-> addWidget ( quit, 1, 1 ); 71 grid-> addWidget ( quit, 1, 1 );
72 72
73 QPushButton *reboot = new QPushButton ( tr( "Reboot" ), btngrp, "reboot" ); 73 QPushButton *reboot = new QPushButton ( tr( "Reboot" ), btngrp, "reboot" );
74 changeButtonColor ( reboot, QColor( 236, 183, 181 ) ); 74 changeButtonColor ( reboot, QColor( 236, 183, 181 ) );
75 btngrp-> insert ( reboot, 2 ); 75 btngrp-> insert ( reboot, 2 );
76 grid-> addWidget( reboot, 1, 0 ); 76 grid-> addWidget( reboot, 1, 0 );
77 77
78 QPushButton *restart = new QPushButton ( tr( "Restart Opie" ), btngrp, "restart" ); 78 QPushButton *restart = new QPushButton ( tr( "Restart Opie" ), btngrp, "restart" );
79 changeButtonColor ( restart, QColor( 236, 236, 179 ) ); 79 changeButtonColor ( restart, QColor( 236, 236, 179 ) );
80 btngrp-> insert ( restart, 3 ); 80 btngrp-> insert ( restart, 3 );
81 grid-> addWidget ( restart, 0, 1 ); 81 grid-> addWidget ( restart, 0, 1 );
82 82
83 QPushButton *shutdown = new QPushButton( tr( "Shutdown" ), btngrp, "shutdown" ); 83 QPushButton *shutdown = new QPushButton( tr( "Shutdown" ), btngrp, "shutdown" );
84 changeButtonColor ( shutdown, QColor( 236, 183, 181 ) ); 84 changeButtonColor ( shutdown, QColor( 236, 183, 181 ) );
85 btngrp-> insert ( shutdown, 1 ); 85 btngrp-> insert ( shutdown, 1 );
86 grid-> addWidget ( shutdown, 0, 0 ); 86 grid-> addWidget ( shutdown, 0, 0 );
87 87
88 vbox-> addWidget ( btngrp ); 88 vbox-> addWidget ( btngrp );
89 89
90 m_info = new QLabel ( this, "info" ); 90 m_info = new QLabel ( this, "info" );
91 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 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." ) );
92 vbox-> addWidget ( m_info ); 92 vbox-> addWidget ( m_info );
93 93
94 m_progress = new QProgressBar ( this, "progressBar" ); 94 m_progress = new QProgressBar ( this, "progressBar" );
95 m_progress-> setFrameShape ( QProgressBar::Panel ); 95 m_progress-> setFrameShape ( QProgressBar::Panel );
96 m_progress-> setFrameShadow ( QProgressBar::Sunken ); 96 m_progress-> setFrameShadow ( QProgressBar::Sunken );
97 m_progress-> setTotalSteps ( 20 ); 97 m_progress-> setTotalSteps ( 20 );
98 m_progress-> setIndicatorFollowsStyle ( false ); 98 m_progress-> setIndicatorFollowsStyle ( false );
99 vbox-> addWidget ( m_progress ); 99 vbox-> addWidget ( m_progress );
100 100
101 vbox-> addItem ( new QSpacerItem ( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ) ); 101 vbox-> addItem ( new QSpacerItem ( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ) );
102 102
103 QPushButton *cancel = new QPushButton ( tr( "Cancel" ), this, "cancel" ); 103 QPushButton *cancel = new QPushButton ( tr( "Cancel" ), this, "cancel" );
104 changeButtonColor ( cancel, QColor( 181, 222, 178 ) ); 104 changeButtonColor ( cancel, QColor( 181, 222, 178 ) );
105 cancel-> setDefault ( true ); 105 cancel-> setDefault ( true );
106 cancel-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding, cancel-> sizePolicy ( ). hasHeightForWidth ( ) ) ); 106 cancel-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding, cancel-> sizePolicy ( ). hasHeightForWidth ( ) ) );
107 vbox-> addWidget ( cancel ); 107 vbox-> addWidget ( cancel );
108 108
109 m_timer = new QTimer ( this ); 109 m_timer = new QTimer ( this );
110 connect ( m_timer, SIGNAL( timeout ( ) ), this, SLOT( timeout ( ) ) ); 110 connect ( m_timer, SIGNAL( timeout ( ) ), this, SLOT( timeout ( ) ) );
111 111
112 connect ( btngrp, SIGNAL( clicked ( int ) ), this, SLOT( buttonClicked ( int ) ) ); 112 connect ( btngrp, SIGNAL( clicked ( int ) ), this, SLOT( buttonClicked ( int ) ) );
113 connect ( cancel, SIGNAL( clicked ( ) ), this, SLOT( cancelClicked ( ) ) ); 113 connect ( cancel, SIGNAL( clicked ( ) ), this, SLOT( cancelClicked ( ) ) );
114 114
115 m_progress-> hide ( ); 115 m_progress-> hide ( );
116 Global::hideInputMethod ( ); 116 Global::hideInputMethod ( );
117
118#ifdef QT_QWS_SHARP
119
120 shutdown-> hide ( );
121#endif
122} 117}
123 118
124void ShutdownImpl::buttonClicked ( int b ) 119void ShutdownImpl::buttonClicked ( int b )
125{ 120{
126 m_counter = 0; 121 m_counter = 0;
127 122
128 switch ( b ) { 123 switch ( b ) {
129 case 1: 124 case 1:
130 m_operation = ShutdownSystem; 125 m_operation = ShutdownSystem;
131 break; 126 break;
132 case 2: 127 case 2:
133 m_operation = RebootSystem; 128 m_operation = RebootSystem;
134 break; 129 break;
135 case 3: 130 case 3:
136 m_operation = RestartDesktop; 131 m_operation = RestartDesktop;
137 break; 132 break;
138 case 4: 133 case 4:
139 m_operation = TerminateDesktop; 134 m_operation = TerminateDesktop;
140 break; 135 break;
141 } 136 }
142 m_info-> hide ( ); 137 m_info-> hide ( );
143 m_progress-> show ( ); 138 m_progress-> show ( );
144 m_timer-> start ( 300 ); 139 m_timer-> start ( 300 );
145 timeout ( ); 140 timeout ( );
146} 141}
147 142
148void ShutdownImpl::cancelClicked ( ) 143void ShutdownImpl::cancelClicked ( )
149{ 144{
150 m_progress-> hide ( ); 145 m_progress-> hide ( );
151 m_info-> show ( ); 146 m_info-> show ( );
152 if ( m_timer-> isActive ( ) ) 147 if ( m_timer-> isActive ( ) )
153 m_timer-> stop ( ); 148 m_timer-> stop ( );
154 else 149 else
155 close ( ); 150 close ( );
156} 151}
157 152
158void ShutdownImpl::timeout ( ) 153void ShutdownImpl::timeout ( )
159{ 154{
160 if ( ( m_counter += 2 ) > m_progress-> totalSteps ( ) ) { 155 if ( ( m_counter += 2 ) > m_progress-> totalSteps ( ) ) {
161 m_progress-> hide ( ); 156 m_progress-> hide ( );
162 m_timer-> stop ( ); 157 m_timer-> stop ( );
163 emit shutdown ( m_operation ); 158 emit shutdown ( m_operation );
164 } 159 }
165 else 160 else
166 m_progress-> setProgress ( m_counter ); 161 m_progress-> setProgress ( m_counter );
167} 162}
168 163
169void ShutdownImpl::hide ( ) 164void ShutdownImpl::hide ( )
170{ 165{
171 if ( isVisible ( )) { 166 if ( isVisible ( )) {
172 // hack - shutdown is a launcher dialog, but treated like a standalone app 167 // hack - shutdown is a launcher dialog, but treated like a standalone app
173 QCopEnvelope e( "QPE/System", "closing(QString)" ); 168 QCopEnvelope e( "QPE/System", "closing(QString)" );
174 e << QString ( "shutdown" ); 169 e << QString ( "shutdown" );
175 170
176 } 171 }
177 QWidget::hide ( ); 172 QWidget::hide ( );
178} 173}
179 174
diff --git a/core/launcher/taskbar.cpp b/core/launcher/taskbar.cpp
index 1e6b74e..b4b7df6 100644
--- a/core/launcher/taskbar.cpp
+++ b/core/launcher/taskbar.cpp
@@ -1,338 +1,334 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 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 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 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 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. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19*********************************************************************/ 19*********************************************************************/
20 20
21#include "startmenu.h" 21#include "startmenu.h"
22#include "inputmethods.h" 22#include "inputmethods.h"
23#include "runningappbar.h" 23#include "runningappbar.h"
24#include "systray.h" 24#include "systray.h"
25#include "calibrate.h" 25#include "calibrate.h"
26#include "wait.h" 26#include "wait.h"
27#include "appicons.h" 27#include "appicons.h"
28 28
29#include "taskbar.h" 29#include "taskbar.h"
30#include "desktop.h" 30#include "desktop.h"
31 31
32#include <qpe/qpeapplication.h> 32#include <qpe/qpeapplication.h>
33#include <qpe/qcopenvelope_qws.h> 33#include <qpe/qcopenvelope_qws.h>
34#include <qpe/global.h> 34#include <qpe/global.h>
35 35
36#if defined( QT_QWS_SHARP ) || defined( QT_QWS_IPAQ ) 36#if defined( QT_QWS_SHARP ) || defined( QT_QWS_IPAQ )
37#include <qpe/custom.h> 37#include <qpe/custom.h>
38#endif 38#endif
39 39
40#include <opie/odevice.h> 40#include <opie/odevice.h>
41 41
42#include <qlabel.h> 42#include <qlabel.h>
43#include <qlayout.h> 43#include <qlayout.h>
44#include <qtimer.h> 44#include <qtimer.h>
45#include <qwindowsystem_qws.h> 45#include <qwindowsystem_qws.h>
46#include <qwidgetstack.h> 46#include <qwidgetstack.h>
47 47
48#if defined( Q_WS_QWS ) 48#if defined( Q_WS_QWS )
49#include <qwsdisplay_qws.h> 49#include <qwsdisplay_qws.h>
50#include <qgfx_qws.h> 50#include <qgfx_qws.h>
51#endif 51#endif
52 52
53 53
54using namespace Opie; 54using namespace Opie;
55 55
56#define FACTORY(T) \ 56#define FACTORY(T) \
57 static QWidget *new##T( bool maximized ) { \ 57 static QWidget *new##T( bool maximized ) { \
58 QWidget *w = new T( 0, "test", QWidget::WDestructiveClose | QWidget::WGroupLeader ); \ 58 QWidget *w = new T( 0, "test", QWidget::WDestructiveClose | QWidget::WGroupLeader ); \
59 if ( maximized ) { \ 59 if ( maximized ) { \
60 if ( qApp->desktop()->width() <= 350 ) { \ 60 if ( qApp->desktop()->width() <= 350 ) { \
61 w->showMaximized(); \ 61 w->showMaximized(); \
62 } else { \ 62 } else { \
63 w->resize( QSize( 300, 300 ) ); \ 63 w->resize( QSize( 300, 300 ) ); \
64 } \ 64 } \
65 } \ 65 } \
66 w->show(); \ 66 w->show(); \
67 return w; \ 67 return w; \
68 } 68 }
69 69
70 70
71#ifdef SINGLE_APP 71#ifdef SINGLE_APP
72#define APP(a,b,c,d) FACTORY(b) 72#define APP(a,b,c,d) FACTORY(b)
73#include "../launcher/apps.h" 73#include "../launcher/apps.h"
74#undef APP 74#undef APP
75#endif // SINGLE_APP 75#endif // SINGLE_APP
76 76
77static Global::Command builtins[] = { 77static Global::Command builtins[] = {
78 78
79#ifdef SINGLE_APP 79#ifdef SINGLE_APP
80#define APP(a,b,c,d) { a, new##b, c }, 80#define APP(a,b,c,d) { a, new##b, c },
81#include "../launcher/apps.h" 81#include "../launcher/apps.h"
82#undef APP 82#undef APP
83#endif 83#endif
84 84
85#if defined(QT_QWS_IPAQ) || defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_EBX) 85#if defined(QT_QWS_IPAQ) || defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_SHARP)
86 { "calibrate", TaskBar::calibrate, 1, 0 }, 86 { "calibrate", TaskBar::calibrate, 1, 0 },
87#endif 87#endif
88#if !defined(QT_QWS_CASSIOPEIA) 88#if !defined(QT_QWS_CASSIOPEIA)
89 { "shutdown", Global::shutdown, 1, 0 }, 89 { "shutdown", Global::shutdown, 1, 0 },
90// { "run", run, 1, 0 }, 90// { "run", run, 1, 0 },
91#endif 91#endif
92 92
93 { 0, TaskBar::calibrate, 0, 0 }, 93 { 0, TaskBar::calibrate, 0, 0 },
94}; 94};
95 95
96static bool initNumLock() 96static bool initNumLock()
97{ 97{
98#ifdef QPE_INITIAL_NUMLOCK_STATE 98#ifdef QPE_INITIAL_NUMLOCK_STATE
99 QPE_INITIAL_NUMLOCK_STATE 99 QPE_INITIAL_NUMLOCK_STATE
100#endif 100#endif
101 return FALSE; 101 return FALSE;
102} 102}
103 103
104class LockKeyState : public QWidget 104class LockKeyState : public QWidget
105{ 105{
106public: 106public:
107 LockKeyState( QWidget *parent ) : 107 LockKeyState( QWidget *parent ) :
108 QWidget(parent), 108 QWidget(parent),
109 nl(initNumLock()), cl(FALSE) 109 nl(initNumLock()), cl(FALSE)
110 { 110 {
111 nl_pm = Resource::loadPixmap("numlock"); 111 nl_pm = Resource::loadPixmap("numlock");
112 cl_pm = Resource::loadPixmap("capslock"); 112 cl_pm = Resource::loadPixmap("capslock");
113 } 113 }
114 QSize sizeHint() const 114 QSize sizeHint() const
115 { 115 {
116 return QSize(nl_pm.width()+2,nl_pm.width()+nl_pm.height()+1); 116 return QSize(nl_pm.width()+2,nl_pm.width()+nl_pm.height()+1);
117 } 117 }
118 void toggleNumLockState() 118 void toggleNumLockState()
119 { 119 {
120 nl = !nl; repaint(); 120 nl = !nl; repaint();
121 } 121 }
122 void toggleCapsLockState() 122 void toggleCapsLockState()
123 { 123 {
124 cl = !cl; repaint(); 124 cl = !cl; repaint();
125 } 125 }
126 void paintEvent( QPaintEvent * ) 126 void paintEvent( QPaintEvent * )
127 { 127 {
128 int y = (height()-sizeHint().height())/2; 128 int y = (height()-sizeHint().height())/2;
129 QPainter p(this); 129 QPainter p(this);
130 if ( nl ) 130 if ( nl )
131 p.drawPixmap(1,y,nl_pm); 131 p.drawPixmap(1,y,nl_pm);
132 if ( cl ) 132 if ( cl )
133 p.drawPixmap(1,y+nl_pm.height()+1,cl_pm); 133 p.drawPixmap(1,y+nl_pm.height()+1,cl_pm);
134 } 134 }
135private: 135private:
136 QPixmap nl_pm, cl_pm; 136 QPixmap nl_pm, cl_pm;
137 bool nl, cl; 137 bool nl, cl;
138}; 138};
139 139
140TaskBar::~TaskBar() 140TaskBar::~TaskBar()
141{ 141{
142} 142}
143 143
144 144
145TaskBar::TaskBar() : QHBox(0, 0, WStyle_Customize | WStyle_Tool | WStyle_StaysOnTop | WGroupLeader) 145TaskBar::TaskBar() : QHBox(0, 0, WStyle_Customize | WStyle_Tool | WStyle_StaysOnTop | WGroupLeader)
146{ 146{
147 Global::setBuiltinCommands(builtins); 147 Global::setBuiltinCommands(builtins);
148 148
149 sm = new StartMenu( this ); 149 sm = new StartMenu( this );
150 150
151 inputMethods = new InputMethods( this ); 151 inputMethods = new InputMethods( this );
152 connect( inputMethods, SIGNAL(inputToggled(bool)), 152 connect( inputMethods, SIGNAL(inputToggled(bool)),
153 this, SLOT(calcMaxWindowRect()) ); 153 this, SLOT(calcMaxWindowRect()) );
154 //new QuickLauncher( this ); 154 //new QuickLauncher( this );
155 155
156 stack = new QWidgetStack( this ); 156 stack = new QWidgetStack( this );
157 stack->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) ); 157 stack->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) );
158 label = new QLabel(stack); 158 label = new QLabel(stack);
159 159
160 //mru = new MRUList( stack ); 160 //mru = new MRUList( stack );
161 //stack->raiseWidget( mru ); 161 //stack->raiseWidget( mru );
162 162
163 runningAppBar = new RunningAppBar(stack); 163 runningAppBar = new RunningAppBar(stack);
164 stack->raiseWidget(runningAppBar); 164 stack->raiseWidget(runningAppBar);
165 165
166 waitIcon = new Wait( this ); 166 waitIcon = new Wait( this );
167 (void) new AppIcons( this ); 167 (void) new AppIcons( this );
168 168
169 sysTray = new SysTray( this ); 169 sysTray = new SysTray( this );
170 170
171 // ## make customizable in some way? 171 // ## make customizable in some way?
172#ifdef QT_QWS_SHARP
173 lockState = new LockKeyState( this ); 172 lockState = new LockKeyState( this );
174#else
175 lockState = 0;
176#endif
177 173
178#if defined(Q_WS_QWS) 174#if defined(Q_WS_QWS)
179#if !defined(QT_NO_COP) 175#if !defined(QT_NO_COP)
180 QCopChannel *channel = new QCopChannel( "QPE/TaskBar", this ); 176 QCopChannel *channel = new QCopChannel( "QPE/TaskBar", this );
181 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 177 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
182 this, SLOT(receive(const QCString&, const QByteArray&)) ); 178 this, SLOT(receive(const QCString&, const QByteArray&)) );
183#endif 179#endif
184#endif 180#endif
185 waitTimer = new QTimer( this ); 181 waitTimer = new QTimer( this );
186 connect( waitTimer, SIGNAL( timeout() ), this, SLOT( stopWait() ) ); 182 connect( waitTimer, SIGNAL( timeout() ), this, SLOT( stopWait() ) );
187 clearer = new QTimer( this ); 183 clearer = new QTimer( this );
188 QObject::connect(clearer, SIGNAL(timeout()), SLOT(clearStatusBar())); 184 QObject::connect(clearer, SIGNAL(timeout()), SLOT(clearStatusBar()));
189 QObject::connect(clearer, SIGNAL(timeout()), sysTray, SLOT(show())); 185 QObject::connect(clearer, SIGNAL(timeout()), sysTray, SLOT(show()));
190} 186}
191 187
192void TaskBar::setStatusMessage( const QString &text ) 188void TaskBar::setStatusMessage( const QString &text )
193{ 189{
194 if ( !text.isEmpty() ) { 190 if ( !text.isEmpty() ) {
195 label->setText( text ); 191 label->setText( text );
196 stack->raiseWidget( label ); 192 stack->raiseWidget( label );
197 if ( sysTray && ( label->fontMetrics().width( text ) > label->width() ) ) 193 if ( sysTray && ( label->fontMetrics().width( text ) > label->width() ) )
198 sysTray->hide(); 194 sysTray->hide();
199 clearer->start( 3000, TRUE ); 195 clearer->start( 3000, TRUE );
200 } else { 196 } else {
201 clearStatusBar(); 197 clearStatusBar();
202 } 198 }
203} 199}
204 200
205void TaskBar::clearStatusBar() 201void TaskBar::clearStatusBar()
206{ 202{
207 label->clear(); 203 label->clear();
208 stack->raiseWidget(runningAppBar); 204 stack->raiseWidget(runningAppBar);
209 // stack->raiseWidget( mru ); 205 // stack->raiseWidget( mru );
210} 206}
211 207
212void TaskBar::startWait() 208void TaskBar::startWait()
213{ 209{
214 waitIcon->setWaiting( true ); 210 waitIcon->setWaiting( true );
215 // a catchall stop after 10 seconds... 211 // a catchall stop after 10 seconds...
216 waitTimer->start( 10 * 1000, true ); 212 waitTimer->start( 10 * 1000, true );
217} 213}
218 214
219void TaskBar::stopWait(const QString& /*app*/) 215void TaskBar::stopWait(const QString& /*app*/)
220{ 216{
221 waitTimer->stop(); 217 waitTimer->stop();
222 //mru->addTask(sm->execToLink(app)); 218 //mru->addTask(sm->execToLink(app));
223 waitIcon->setWaiting( false ); 219 waitIcon->setWaiting( false );
224} 220}
225 221
226void TaskBar::stopWait() 222void TaskBar::stopWait()
227{ 223{
228 waitTimer->stop(); 224 waitTimer->stop();
229 225
230 waitIcon->setWaiting( false ); 226 waitIcon->setWaiting( false );
231} 227}
232 228
233void TaskBar::resizeEvent( QResizeEvent *e ) 229void TaskBar::resizeEvent( QResizeEvent *e )
234{ 230{
235 QHBox::resizeEvent( e ); 231 QHBox::resizeEvent( e );
236 calcMaxWindowRect(); 232 calcMaxWindowRect();
237} 233}
238 234
239void TaskBar::styleChange( QStyle &s ) 235void TaskBar::styleChange( QStyle &s )
240{ 236{
241 QHBox::styleChange( s ); 237 QHBox::styleChange( s );
242 calcMaxWindowRect(); 238 calcMaxWindowRect();
243} 239}
244 240
245void TaskBar::calcMaxWindowRect() 241void TaskBar::calcMaxWindowRect()
246{ 242{
247#ifdef Q_WS_QWS 243#ifdef Q_WS_QWS
248 QRect wr; 244 QRect wr;
249 int displayWidth = qApp->desktop()->width(); 245 int displayWidth = qApp->desktop()->width();
250 QRect ir = inputMethods->inputRect(); 246 QRect ir = inputMethods->inputRect();
251 if ( ir.isValid() ) { 247 if ( ir.isValid() ) {
252 wr.setCoords( 0, 0, displayWidth-1, ir.top()-1 ); 248 wr.setCoords( 0, 0, displayWidth-1, ir.top()-1 );
253 } else { 249 } else {
254 wr.setCoords( 0, 0, displayWidth-1, y()-1 ); 250 wr.setCoords( 0, 0, displayWidth-1, y()-1 );
255 } 251 }
256 252
257#if QT_VERSION < 300 253#if QT_VERSION < 300
258 QWSServer::setMaxWindowRect( qt_screen->mapToDevice(wr, 254 QWSServer::setMaxWindowRect( qt_screen->mapToDevice(wr,
259 QSize(qt_screen->width(),qt_screen->height())) 255 QSize(qt_screen->width(),qt_screen->height()))
260 ); 256 );
261#else 257#else
262 QWSServer::setMaxWindowRect( wr ); 258 QWSServer::setMaxWindowRect( wr );
263#endif 259#endif
264#endif 260#endif
265} 261}
266 262
267void TaskBar::receive( const QCString &msg, const QByteArray &data ) 263void TaskBar::receive( const QCString &msg, const QByteArray &data )
268{ 264{
269 QDataStream stream( data, IO_ReadOnly ); 265 QDataStream stream( data, IO_ReadOnly );
270 if ( msg == "message(QString)" ) { 266 if ( msg == "message(QString)" ) {
271 QString text; 267 QString text;
272 stream >> text; 268 stream >> text;
273 setStatusMessage( text ); 269 setStatusMessage( text );
274 } else if ( msg == "hideInputMethod()" ) { 270 } else if ( msg == "hideInputMethod()" ) {
275 inputMethods->hideInputMethod(); 271 inputMethods->hideInputMethod();
276 } else if ( msg == "showInputMethod()" ) { 272 } else if ( msg == "showInputMethod()" ) {
277 inputMethods->showInputMethod(); 273 inputMethods->showInputMethod();
278 } else if ( msg == "reloadInputMethods()" ) { 274 } else if ( msg == "reloadInputMethods()" ) {
279 inputMethods->loadInputMethods(); 275 inputMethods->loadInputMethods();
280 } else if ( msg == "reloadApps()" ) { 276 } else if ( msg == "reloadApps()" ) {
281 sm->reloadApps(); 277 sm->reloadApps();
282 } else if ( msg == "reloadApplets()" ) { 278 } else if ( msg == "reloadApplets()" ) {
283 sysTray->clearApplets(); 279 sysTray->clearApplets();
284 sysTray->addApplets(); 280 sysTray->addApplets();
285 sm->reloadApplets(); 281 sm->reloadApplets();
286 } else if ( msg == "soundAlarm()" ) { 282 } else if ( msg == "soundAlarm()" ) {
287 Desktop::soundAlarm(); 283 Desktop::soundAlarm();
288 } 284 }
289 else if ( msg == "setLed(int,bool)" ) { 285 else if ( msg == "setLed(int,bool)" ) {
290 int led, status; 286 int led, status;
291 stream >> led >> status; 287 stream >> led >> status;
292 288
293 QValueList <OLed> ll = ODevice::inst ( )-> ledList ( ); 289 QValueList <OLed> ll = ODevice::inst ( )-> ledList ( );
294 if ( ll. count ( )){ 290 if ( ll. count ( )){
295 OLed l = ll. contains ( Led_Mail ) ? Led_Mail : ll [0]; 291 OLed l = ll. contains ( Led_Mail ) ? Led_Mail : ll [0];
296 bool canblink = ODevice::inst ( )-> ledStateList ( l ). contains ( Led_BlinkSlow ); 292 bool canblink = ODevice::inst ( )-> ledStateList ( l ). contains ( Led_BlinkSlow );
297 293
298 ODevice::inst ( )-> setLedState ( l, status ? ( canblink ? Led_BlinkSlow : Led_On ) : Led_Off ); 294 ODevice::inst ( )-> setLedState ( l, status ? ( canblink ? Led_BlinkSlow : Led_On ) : Led_Off );
299 } 295 }
300 } 296 }
301} 297}
302 298
303QWidget *TaskBar::calibrate(bool) 299QWidget *TaskBar::calibrate(bool)
304{ 300{
305#ifdef Q_WS_QWS 301#ifdef Q_WS_QWS
306 Calibrate *c = new Calibrate; 302 Calibrate *c = new Calibrate;
307 c->show(); 303 c->show();
308 return c; 304 return c;
309#else 305#else
310 return 0; 306 return 0;
311#endif 307#endif
312} 308}
313 309
314void TaskBar::toggleNumLockState() 310void TaskBar::toggleNumLockState()
315{ 311{
316 if ( lockState ) lockState->toggleNumLockState(); 312 if ( lockState ) lockState->toggleNumLockState();
317} 313}
318 314
319void TaskBar::toggleCapsLockState() 315void TaskBar::toggleCapsLockState()
320{ 316{
321 if ( lockState ) lockState->toggleCapsLockState(); 317 if ( lockState ) lockState->toggleCapsLockState();
322} 318}
323 319
324void TaskBar::toggleSymbolInput() 320void TaskBar::toggleSymbolInput()
325{ 321{
326 if ( inputMethods->currentShown() == "Unicode" ) { 322 if ( inputMethods->currentShown() == "Unicode" ) {
327 inputMethods->hideInputMethod(); 323 inputMethods->hideInputMethod();
328 } else { 324 } else {
329 inputMethods->showInputMethod("Unicode"); 325 inputMethods->showInputMethod("Unicode");
330 } 326 }
331} 327}
332 328
333bool TaskBar::recoverMemory() 329bool TaskBar::recoverMemory()
334{ 330{
335 //eturn mru->quitOldApps(); 331 //eturn mru->quitOldApps();
336 return true; 332 return true;
337} 333}
338 334