summaryrefslogtreecommitdiff
authorkergoth <kergoth>2003-03-19 05:38:25 (UTC)
committer kergoth <kergoth>2003-03-19 05:38:25 (UTC)
commit234f974bea8f93213fa43bb8b501dee5db43cbdc (patch) (unidiff)
treefc9c441bbbb1d12d1fc929cecfd323c03fafb48c
parentf35989ef21fb5a27ebe6f6924ee2cc601318c1b8 (diff)
downloadopie-234f974bea8f93213fa43bb8b501dee5db43cbdc.zip
opie-234f974bea8f93213fa43bb8b501dee5db43cbdc.tar.gz
opie-234f974bea8f93213fa43bb8b501dee5db43cbdc.tar.bz2
Goodbye QT_QWS_EBX and QT_QWS_SHARP.. hello QT_QWS_SL5XXX!
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/calibrate/main.cpp2
-rw-r--r--core/apps/embeddedkonsole/TEWidget.cpp2
-rw-r--r--core/launcher/desktop.cpp2
-rw-r--r--core/launcher/main.cpp8
-rw-r--r--core/launcher/taskbar.cpp4
-rw-r--r--core/multimedia/opieplayer/loopcontrol_threaded.cpp2
-rw-r--r--core/opie-login/main.cpp2
-rw-r--r--library/power.cpp2
-rw-r--r--library/qpeapplication.cpp2
-rw-r--r--library/storage.cpp2
-rw-r--r--mkspecs/qws/linux-sharp-g++/qmake.conf2
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayer.cpp6
-rw-r--r--noncore/settings/sound/soundsettings.cpp2
-rw-r--r--noncore/tools/formatter/formatter.cpp4
-rw-r--r--qt/qconfig-qpe.h2
-rw-r--r--x11/libqpe-x11/qpe/qpeapplication.cpp2
16 files changed, 23 insertions, 23 deletions
diff --git a/core/apps/calibrate/main.cpp b/core/apps/calibrate/main.cpp
index cb041c9..d1ad083 100644
--- a/core/apps/calibrate/main.cpp
+++ b/core/apps/calibrate/main.cpp
@@ -1,42 +1,42 @@
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 "calibrate.h" 21#include "calibrate.h"
22 22
23#include <qfile.h> 23#include <qfile.h>
24#include <qpe/qpeapplication.h> 24#include <qpe/qpeapplication.h>
25 25
26int main( int argc, char ** argv ) 26int main( int argc, char ** argv )
27{ 27{
28 QPEApplication a( argc, argv ); 28 QPEApplication a( argc, argv );
29 int retval = 0; 29 int retval = 0;
30 30
31#if defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) 31#if defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_IPAQ) || defined(QT_QWS_SL5XXX)
32 if ( !QFile::exists( "/etc/pointercal" ) ) { 32 if ( !QFile::exists( "/etc/pointercal" ) ) {
33 // Make sure calibration widget starts on top. 33 // Make sure calibration widget starts on top.
34 Calibrate *cal = new Calibrate; 34 Calibrate *cal = new Calibrate;
35 a.setMainWidget(cal); 35 a.setMainWidget(cal);
36 a.showMainWidget(cal); 36 a.showMainWidget(cal);
37 retval = a.exec(); 37 retval = a.exec();
38 delete cal; 38 delete cal;
39 } 39 }
40#endif 40#endif
41 return retval; 41 return retval;
42} 42}
diff --git a/core/apps/embeddedkonsole/TEWidget.cpp b/core/apps/embeddedkonsole/TEWidget.cpp
index 8214e7d..d0850e3 100644
--- a/core/apps/embeddedkonsole/TEWidget.cpp
+++ b/core/apps/embeddedkonsole/TEWidget.cpp
@@ -1,1358 +1,1358 @@
1/* ------------------------------------------------------------------------ */ 1/* ------------------------------------------------------------------------ */
2/* */ 2/* */
3/* [TEWidget.C] Terminal Emulation Widget */ 3/* [TEWidget.C] Terminal Emulation Widget */
4/* */ 4/* */
5/* ------------------------------------------------------------------------ */ 5/* ------------------------------------------------------------------------ */
6/* */ 6/* */
7/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ 7/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */
8/* */ 8/* */
9/* This file is part of Konsole - an X terminal for KDE */ 9/* This file is part of Konsole - an X terminal for KDE */
10/* */ 10/* */
11/* ------------------------------------------------------------------------ */ 11/* ------------------------------------------------------------------------ */
12/* */ 12/* */
13/* Ported Konsole to Qt/Embedded */ 13/* Ported Konsole to Qt/Embedded */
14/* */ 14/* */
15/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ 15/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */
16/* */ 16/* */
17/* -------------------------------------------------------------------------- */ 17/* -------------------------------------------------------------------------- */
18/*! \class TEWidget 18/*! \class TEWidget
19 19
20 \brief Visible screen contents 20 \brief Visible screen contents
21 21
22 This class is responsible to map the `image' of a terminal emulation to the 22 This class is responsible to map the `image' of a terminal emulation to the
23 display. All the dependency of the emulation to a specific GUI or toolkit is 23 display. All the dependency of the emulation to a specific GUI or toolkit is
24 localized here. Further, this widget has no knowledge about being part of an 24 localized here. Further, this widget has no knowledge about being part of an
25 emulation, it simply work within the terminal emulation framework by exposing 25 emulation, it simply work within the terminal emulation framework by exposing
26 size and key events and by being ordered to show a new image. 26 size and key events and by being ordered to show a new image.
27 27
28 <ul> 28 <ul>
29 <li> The internal image has the size of the widget (evtl. rounded up) 29 <li> The internal image has the size of the widget (evtl. rounded up)
30 <li> The external image used in setImage can have any size. 30 <li> The external image used in setImage can have any size.
31 <li> (internally) the external image is simply copied to the internal 31 <li> (internally) the external image is simply copied to the internal
32 when a setImage happens. During a resizeEvent no painting is done 32 when a setImage happens. During a resizeEvent no painting is done
33 a paintEvent is expected to follow anyway. 33 a paintEvent is expected to follow anyway.
34 </ul> 34 </ul>
35 35
36 \sa TEScreen \sa Emulation 36 \sa TEScreen \sa Emulation
37*/ 37*/
38 38
39/* FIXME: 39/* FIXME:
40 - 'image' may also be used uninitialized (it isn't in fact) in resizeEvent 40 - 'image' may also be used uninitialized (it isn't in fact) in resizeEvent
41 - 'font_a' not used in mouse events 41 - 'font_a' not used in mouse events
42 - add destructor 42 - add destructor
43*/ 43*/
44 44
45/* TODO 45/* TODO
46 - evtl. be sensitive to `paletteChange' while using default colors. 46 - evtl. be sensitive to `paletteChange' while using default colors.
47 - set different 'rounding' styles? I.e. have a mode to show clipped chars? 47 - set different 'rounding' styles? I.e. have a mode to show clipped chars?
48*/ 48*/
49 49
50// #include "config.h" 50// #include "config.h"
51#include "TEWidget.h" 51#include "TEWidget.h"
52#include "session.h" 52#include "session.h"
53#include <qpe/config.h> 53#include <qpe/config.h>
54 54
55#include <qpe/resource.h> 55#include <qpe/resource.h>
56#include <qpe/sound.h> 56#include <qpe/sound.h>
57 57
58#if !(QT_NO_COP) 58#if !(QT_NO_COP)
59#include <qpe/qcopenvelope_qws.h> 59#include <qpe/qcopenvelope_qws.h>
60#endif 60#endif
61 61
62#include <qcursor.h> 62#include <qcursor.h>
63#include <qregexp.h> 63#include <qregexp.h>
64#include <qpainter.h> 64#include <qpainter.h>
65#include <qclipboard.h> 65#include <qclipboard.h>
66#include <qstyle.h> 66#include <qstyle.h>
67#include <qfile.h> 67#include <qfile.h>
68#include <qdragobject.h> 68#include <qdragobject.h>
69 69
70#include <stdio.h> 70#include <stdio.h>
71#include <stdlib.h> 71#include <stdlib.h>
72#include <unistd.h> 72#include <unistd.h>
73#include <ctype.h> 73#include <ctype.h>
74#include <sys/stat.h> 74#include <sys/stat.h>
75#include <sys/types.h> 75#include <sys/types.h>
76#include <signal.h> 76#include <signal.h>
77 77
78#include <assert.h> 78#include <assert.h>
79 79
80// #include "TEWidget.moc" 80// #include "TEWidget.moc"
81//#include <kapp.h> 81//#include <kapp.h>
82//#include <kcursor.h> 82//#include <kcursor.h>
83//#include <kurl.h> 83//#include <kurl.h>
84//#include <kdebug.h> 84//#include <kdebug.h>
85//#include <klocale.h> 85//#include <klocale.h>
86 86
87#define HERE printf("%s(%d): %s\n",__FILE__,__LINE__,__FUNCTION__) 87#define HERE printf("%s(%d): %s\n",__FILE__,__LINE__,__FUNCTION__)
88#define HCNT(Name) // { static int cnt = 1; printf("%s(%d): %s %d\n",__FILE__,__LINE__,Name,cnt++); } 88#define HCNT(Name) // { static int cnt = 1; printf("%s(%d): %s %d\n",__FILE__,__LINE__,Name,cnt++); }
89 89
90#define loc(X,Y) ((Y)*columns+(X)) 90#define loc(X,Y) ((Y)*columns+(X))
91 91
92//FIXME: the rim should normally be 1, 0 only when running in full screen mode. 92//FIXME: the rim should normally be 1, 0 only when running in full screen mode.
93#define rimX 0 // left/right rim width 93#define rimX 0 // left/right rim width
94#define rimY 0 // top/bottom rim high 94#define rimY 0 // top/bottom rim high
95 95
96#define SCRWIDTH 16 // width of the scrollbar 96#define SCRWIDTH 16 // width of the scrollbar
97 97
98#define yMouseScroll 1 98#define yMouseScroll 1
99// scroll increment used when dragging selection at top/bottom of window. 99// scroll increment used when dragging selection at top/bottom of window.
100 100
101/* ------------------------------------------------------------------------- */ 101/* ------------------------------------------------------------------------- */
102/* */ 102/* */
103/* Colors */ 103/* Colors */
104/* */ 104/* */
105/* ------------------------------------------------------------------------- */ 105/* ------------------------------------------------------------------------- */
106 106
107//FIXME: the default color table is in session.C now. 107//FIXME: the default color table is in session.C now.
108// We need a way to get rid of this one, here. 108// We need a way to get rid of this one, here.
109static const ColorEntry base_color_table[TABLE_COLORS] = 109static const ColorEntry base_color_table[TABLE_COLORS] =
110// The following are almost IBM standard color codes, with some slight 110// The following are almost IBM standard color codes, with some slight
111// gamma correction for the dim colors to compensate for bright X screens. 111// gamma correction for the dim colors to compensate for bright X screens.
112// It contains the 8 ansiterm/xterm colors in 2 intensities. 112// It contains the 8 ansiterm/xterm colors in 2 intensities.
113{ 113{
114 // Fixme: could add faint colors here, also. 114 // Fixme: could add faint colors here, also.
115 // normal 115 // normal
116 ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 1, 0 ), // Dfore, Dback 116 ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 1, 0 ), // Dfore, Dback
117 ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0x18), 0, 0 ), // Black, Red 117 ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0x18), 0, 0 ), // Black, Red
118 ColorEntry(QColor(0x18,0xB2,0x18), 0, 0 ), ColorEntry( QColor(0xB2,0x68,0x18), 0, 0 ), // Green, Yellow 118 ColorEntry(QColor(0x18,0xB2,0x18), 0, 0 ), ColorEntry( QColor(0xB2,0x68,0x18), 0, 0 ), // Green, Yellow
119 ColorEntry(QColor(0x18,0x18,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), // Blue, Magenta 119 ColorEntry(QColor(0x18,0x18,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), // Blue, Magenta
120 ColorEntry(QColor(0x18,0xB2,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 0, 0 ), // Cyan, White 120 ColorEntry(QColor(0x18,0xB2,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 0, 0 ), // Cyan, White
121 // intensiv 121 // intensiv
122 ColorEntry(QColor(0x00,0x00,0x00), 0, 1 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 1, 0 ), 122 ColorEntry(QColor(0x00,0x00,0x00), 0, 1 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 1, 0 ),
123 ColorEntry(QColor(0x68,0x68,0x68), 0, 0 ), ColorEntry( QColor(0xFF,0x54,0x54), 0, 0 ), 123 ColorEntry(QColor(0x68,0x68,0x68), 0, 0 ), ColorEntry( QColor(0xFF,0x54,0x54), 0, 0 ),
124 ColorEntry(QColor(0x54,0xFF,0x54), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0x54), 0, 0 ), 124 ColorEntry(QColor(0x54,0xFF,0x54), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0x54), 0, 0 ),
125 ColorEntry(QColor(0x54,0x54,0xFF), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), 125 ColorEntry(QColor(0x54,0x54,0xFF), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ),
126 ColorEntry(QColor(0x54,0xFF,0xFF), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 0, 0 ) 126 ColorEntry(QColor(0x54,0xFF,0xFF), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 0, 0 )
127}; 127};
128 128
129/* Note that we use ANSI color order (bgr), while IBMPC color order is (rgb) 129/* Note that we use ANSI color order (bgr), while IBMPC color order is (rgb)
130 130
131 Code 0 1 2 3 4 5 6 7 131 Code 0 1 2 3 4 5 6 7
132 ----------- ------- ------- ------- ------- ------- ------- ------- ------- 132 ----------- ------- ------- ------- ------- ------- ------- ------- -------
133 ANSI (bgr) Black Red Green Yellow Blue Magenta Cyan White 133 ANSI (bgr) Black Red Green Yellow Blue Magenta Cyan White
134 IBMPC (rgb) Black Blue Green Cyan Red Magenta Yellow White 134 IBMPC (rgb) Black Blue Green Cyan Red Magenta Yellow White
135*/ 135*/
136 136
137QColor TEWidget::getDefaultBackColor() 137QColor TEWidget::getDefaultBackColor()
138{ 138{
139 return color_table[DEFAULT_BACK_COLOR].color; 139 return color_table[DEFAULT_BACK_COLOR].color;
140} 140}
141 141
142const ColorEntry* TEWidget::getColorTable() const 142const ColorEntry* TEWidget::getColorTable() const
143{ 143{
144 return color_table; 144 return color_table;
145} 145}
146 146
147const ColorEntry* TEWidget::getdefaultColorTable() const 147const ColorEntry* TEWidget::getdefaultColorTable() const
148{ 148{
149 return base_color_table; 149 return base_color_table;
150} 150}
151 151
152 152
153const QPixmap *TEWidget::backgroundPixmap() 153const QPixmap *TEWidget::backgroundPixmap()
154{ 154{
155 static QPixmap *bg = new QPixmap("~/qpim/main/pics/faded_bg.xpm"); 155 static QPixmap *bg = new QPixmap("~/qpim/main/pics/faded_bg.xpm");
156 const QPixmap *pm = bg; 156 const QPixmap *pm = bg;
157 return pm; 157 return pm;
158} 158}
159 159
160void TEWidget::setColorTable(const ColorEntry table[]) 160void TEWidget::setColorTable(const ColorEntry table[])
161{ 161{
162 for (int i = 0; i < TABLE_COLORS; i++) color_table[i] = table[i]; 162 for (int i = 0; i < TABLE_COLORS; i++) color_table[i] = table[i];
163 163
164 const QPixmap* pm = backgroundPixmap(); 164 const QPixmap* pm = backgroundPixmap();
165 if (!pm) setBackgroundColor(color_table[DEFAULT_BACK_COLOR].color); 165 if (!pm) setBackgroundColor(color_table[DEFAULT_BACK_COLOR].color);
166 update(); 166 update();
167} 167}
168 168
169//FIXME: add backgroundPixmapChanged. 169//FIXME: add backgroundPixmapChanged.
170 170
171/* ------------------------------------------------------------------------- */ 171/* ------------------------------------------------------------------------- */
172/* */ 172/* */
173/* Font */ 173/* Font */
174/* */ 174/* */
175/* ------------------------------------------------------------------------- */ 175/* ------------------------------------------------------------------------- */
176 176
177/* 177/*
178 The VT100 has 32 special graphical characters. The usual vt100 extended 178 The VT100 has 32 special graphical characters. The usual vt100 extended
179 xterm fonts have these at 0x00..0x1f. 179 xterm fonts have these at 0x00..0x1f.
180 180
181 QT's iso mapping leaves 0x00..0x7f without any changes. But the graphicals 181 QT's iso mapping leaves 0x00..0x7f without any changes. But the graphicals
182 come in here as proper unicode characters. 182 come in here as proper unicode characters.
183 183
184 We treat non-iso10646 fonts as VT100 extended and do the requiered mapping 184 We treat non-iso10646 fonts as VT100 extended and do the requiered mapping
185 from unicode to 0x00..0x1f. The remaining translation is then left to the 185 from unicode to 0x00..0x1f. The remaining translation is then left to the
186 QCodec. 186 QCodec.
187*/ 187*/
188 188
189// assert for i in [0..31] : vt100extended(vt100_graphics[i]) == i. 189// assert for i in [0..31] : vt100extended(vt100_graphics[i]) == i.
190 190
191unsigned short vt100_graphics[32] = 191unsigned short vt100_graphics[32] =
192{ // 0/8 1/9 2/10 3/11 4/12 5/13 6/14 7/15 192{ // 0/8 1/9 2/10 3/11 4/12 5/13 6/14 7/15
193 0x0020, 0x25C6, 0x2592, 0x2409, 0x240c, 0x240d, 0x240a, 0x00b0, 193 0x0020, 0x25C6, 0x2592, 0x2409, 0x240c, 0x240d, 0x240a, 0x00b0,
194 0x00b1, 0x2424, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c, 194 0x00b1, 0x2424, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c,
195 0xF800, 0xF801, 0x2500, 0xF803, 0xF804, 0x251c, 0x2524, 0x2534, 195 0xF800, 0xF801, 0x2500, 0xF803, 0xF804, 0x251c, 0x2524, 0x2534,
196 0x252c, 0x2502, 0x2264, 0x2265, 0x03C0, 0x2260, 0x00A3, 0x00b7 196 0x252c, 0x2502, 0x2264, 0x2265, 0x03C0, 0x2260, 0x00A3, 0x00b7
197}; 197};
198 198
199static QChar vt100extended(QChar c) 199static QChar vt100extended(QChar c)
200{ 200{
201 switch (c.unicode()) 201 switch (c.unicode())
202 { 202 {
203 case 0x25c6 : return 1; 203 case 0x25c6 : return 1;
204 case 0x2592 : return 2; 204 case 0x2592 : return 2;
205 case 0x2409 : return 3; 205 case 0x2409 : return 3;
206 case 0x240c : return 4; 206 case 0x240c : return 4;
207 case 0x240d : return 5; 207 case 0x240d : return 5;
208 case 0x240a : return 6; 208 case 0x240a : return 6;
209 case 0x00b0 : return 7; 209 case 0x00b0 : return 7;
210 case 0x00b1 : return 8; 210 case 0x00b1 : return 8;
211 case 0x2424 : return 9; 211 case 0x2424 : return 9;
212 case 0x240b : return 10; 212 case 0x240b : return 10;
213 case 0x2518 : return 11; 213 case 0x2518 : return 11;
214 case 0x2510 : return 12; 214 case 0x2510 : return 12;
215 case 0x250c : return 13; 215 case 0x250c : return 13;
216 case 0x2514 : return 14; 216 case 0x2514 : return 14;
217 case 0x253c : return 15; 217 case 0x253c : return 15;
218 case 0xf800 : return 16; 218 case 0xf800 : return 16;
219 case 0xf801 : return 17; 219 case 0xf801 : return 17;
220 case 0x2500 : return 18; 220 case 0x2500 : return 18;
221 case 0xf803 : return 19; 221 case 0xf803 : return 19;
222 case 0xf804 : return 20; 222 case 0xf804 : return 20;
223 case 0x251c : return 21; 223 case 0x251c : return 21;
224 case 0x2524 : return 22; 224 case 0x2524 : return 22;
225 case 0x2534 : return 23; 225 case 0x2534 : return 23;
226 case 0x252c : return 24; 226 case 0x252c : return 24;
227 case 0x2502 : return 25; 227 case 0x2502 : return 25;
228 case 0x2264 : return 26; 228 case 0x2264 : return 26;
229 case 0x2265 : return 27; 229 case 0x2265 : return 27;
230 case 0x03c0 : return 28; 230 case 0x03c0 : return 28;
231 case 0x2260 : return 29; 231 case 0x2260 : return 29;
232 case 0x00a3 : return 30; 232 case 0x00a3 : return 30;
233 case 0x00b7 : return 31; 233 case 0x00b7 : return 31;
234 } 234 }
235 return c; 235 return c;
236} 236}
237 237
238static QChar identicalMap(QChar c) 238static QChar identicalMap(QChar c)
239{ 239{
240 return c; 240 return c;
241} 241}
242 242
243void TEWidget::fontChange(const QFont &) 243void TEWidget::fontChange(const QFont &)
244{ 244{
245 QFontMetrics fm(font()); 245 QFontMetrics fm(font());
246 font_h = fm.height(); 246 font_h = fm.height();
247 font_w = fm.maxWidth(); 247 font_w = fm.maxWidth();
248 font_a = fm.ascent(); 248 font_a = fm.ascent();
249//printf("font_h: %d\n",font_h); 249//printf("font_h: %d\n",font_h);
250//printf("font_w: %d\n",font_w); 250//printf("font_w: %d\n",font_w);
251//printf("font_a: %d\n",font_a); 251//printf("font_a: %d\n",font_a);
252//printf("charset: %s\n",QFont::encodingName(font().charSet()).ascii()); 252//printf("charset: %s\n",QFont::encodingName(font().charSet()).ascii());
253//printf("rawname: %s\n",font().rawName().ascii()); 253//printf("rawname: %s\n",font().rawName().ascii());
254 fontMap = 254 fontMap =
255#if QT_VERSION < 300 255#if QT_VERSION < 300
256 strcmp(QFont::encodingName(font().charSet()).ascii(),"iso10646") 256 strcmp(QFont::encodingName(font().charSet()).ascii(),"iso10646")
257 ? vt100extended 257 ? vt100extended
258 : 258 :
259#endif 259#endif
260 identicalMap; 260 identicalMap;
261 propagateSize(); 261 propagateSize();
262 update(); 262 update();
263} 263}
264 264
265void TEWidget::setVTFont(const QFont& f) 265void TEWidget::setVTFont(const QFont& f)
266{ 266{
267 QFrame::setFont(f); 267 QFrame::setFont(f);
268} 268}
269 269
270QFont TEWidget::getVTFont() { 270QFont TEWidget::getVTFont() {
271 return font(); 271 return font();
272} 272}
273 273
274void TEWidget::setFont(const QFont &) 274void TEWidget::setFont(const QFont &)
275{ 275{
276 // ignore font change request if not coming from konsole itself 276 // ignore font change request if not coming from konsole itself
277} 277}
278 278
279/* ------------------------------------------------------------------------- */ 279/* ------------------------------------------------------------------------- */
280/* */ 280/* */
281/* Constructor / Destructor */ 281/* Constructor / Destructor */
282/* */ 282/* */
283/* ------------------------------------------------------------------------- */ 283/* ------------------------------------------------------------------------- */
284 284
285TEWidget::TEWidget(QWidget *parent, const char *name) : QFrame(parent,name) 285TEWidget::TEWidget(QWidget *parent, const char *name) : QFrame(parent,name)
286{ 286{
287#ifndef QT_NO_CLIPBOARD 287#ifndef QT_NO_CLIPBOARD
288 cb = QApplication::clipboard(); 288 cb = QApplication::clipboard();
289 QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), 289 QObject::connect( (QObject*)cb, SIGNAL(dataChanged()),
290 this, SLOT(onClearSelection()) ); 290 this, SLOT(onClearSelection()) );
291#endif 291#endif
292 292
293 scrollbar = new QScrollBar(this); 293 scrollbar = new QScrollBar(this);
294 scrollbar->setCursor( arrowCursor ); 294 scrollbar->setCursor( arrowCursor );
295 connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); 295 connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int)));
296 296
297 hScrollbar = new QScrollBar(this); 297 hScrollbar = new QScrollBar(this);
298 hScrollbar->setCursor( arrowCursor ); 298 hScrollbar->setCursor( arrowCursor );
299 hScrollbar->setOrientation(QScrollBar::Horizontal); 299 hScrollbar->setOrientation(QScrollBar::Horizontal);
300 hScrollbar->setMaximumHeight(16); 300 hScrollbar->setMaximumHeight(16);
301 301
302 connect( hScrollbar, SIGNAL(valueChanged(int)), this, SLOT( hScrollChanged(int))); 302 connect( hScrollbar, SIGNAL(valueChanged(int)), this, SLOT( hScrollChanged(int)));
303 303
304 Config cfg("Konsole"); 304 Config cfg("Konsole");
305 cfg.setGroup("ScrollBar"); 305 cfg.setGroup("ScrollBar");
306 switch( cfg.readNumEntry("Position",2)){ 306 switch( cfg.readNumEntry("Position",2)){
307 case 0: 307 case 0:
308 scrollLoc = SCRNONE; 308 scrollLoc = SCRNONE;
309 break; 309 break;
310 case 1: 310 case 1:
311 scrollLoc = SCRLEFT; 311 scrollLoc = SCRLEFT;
312 break; 312 break;
313 case 2: 313 case 2:
314 scrollLoc = SCRRIGHT; 314 scrollLoc = SCRRIGHT;
315 break; 315 break;
316 }; 316 };
317 317
318 useHorzScroll=cfg.readBoolEntry("HorzScroll",0); 318 useHorzScroll=cfg.readBoolEntry("HorzScroll",0);
319 319
320 blinkT = new QTimer(this); 320 blinkT = new QTimer(this);
321 connect(blinkT, SIGNAL(timeout()), this, SLOT(blinkEvent())); 321 connect(blinkT, SIGNAL(timeout()), this, SLOT(blinkEvent()));
322 // blinking = FALSE; 322 // blinking = FALSE;
323 blinking = TRUE; 323 blinking = TRUE;
324 324
325 resizing = FALSE; 325 resizing = FALSE;
326 actSel = 0; 326 actSel = 0;
327 image = 0; 327 image = 0;
328 lines = 1; 328 lines = 1;
329 columns = 1; 329 columns = 1;
330 font_w = 1; 330 font_w = 1;
331 font_h = 1; 331 font_h = 1;
332 font_a = 1; 332 font_a = 1;
333 word_selection_mode = FALSE; 333 word_selection_mode = FALSE;
334 hposition = 0; 334 hposition = 0;
335 vcolumns = 0; 335 vcolumns = 0;
336 useBeep = true; 336 useBeep = true;
337 337
338 setMouseMarks(TRUE); 338 setMouseMarks(TRUE);
339 setVTFont( QFont("fixed") ); 339 setVTFont( QFont("fixed") );
340 setColorTable(base_color_table); // init color table 340 setColorTable(base_color_table); // init color table
341 341
342 qApp->installEventFilter( this ); //FIXME: see below 342 qApp->installEventFilter( this ); //FIXME: see below
343// KCursor::setAutoHideCursor( this, true ); 343// KCursor::setAutoHideCursor( this, true );
344 344
345 // Init DnD //////////////////////////////////////////////////////////////// 345 // Init DnD ////////////////////////////////////////////////////////////////
346 currentSession = NULL; 346 currentSession = NULL;
347// setAcceptDrops(true); // attempt 347// setAcceptDrops(true); // attempt
348// m_drop = new QPopupMenu(this); 348// m_drop = new QPopupMenu(this);
349// m_drop->insertItem( QString("Paste"), 0); 349// m_drop->insertItem( QString("Paste"), 0);
350// m_drop->insertItem( QString("cd"), 1); 350// m_drop->insertItem( QString("cd"), 1);
351// connect(m_drop, SIGNAL(activated(int)), SLOT(drop_menu_activated(int))); 351// connect(m_drop, SIGNAL(activated(int)), SLOT(drop_menu_activated(int)));
352 352
353 // we need focus so that the auto-hide cursor feature works 353 // we need focus so that the auto-hide cursor feature works
354 setFocus(); 354 setFocus();
355 setFocusPolicy( WheelFocus ); 355 setFocusPolicy( WheelFocus );
356} 356}
357 357
358//FIXME: make proper destructor 358//FIXME: make proper destructor
359// Here's a start (David) 359// Here's a start (David)
360TEWidget::~TEWidget() 360TEWidget::~TEWidget()
361{ 361{
362 qApp->removeEventFilter( this ); 362 qApp->removeEventFilter( this );
363 if (image) free(image); 363 if (image) free(image);
364} 364}
365 365
366/* ------------------------------------------------------------------------- */ 366/* ------------------------------------------------------------------------- */
367/* */ 367/* */
368/* Display Operations */ 368/* Display Operations */
369/* */ 369/* */
370/* ------------------------------------------------------------------------- */ 370/* ------------------------------------------------------------------------- */
371 371
372/*! 372/*!
373 attributed string draw primitive 373 attributed string draw primitive
374*/ 374*/
375 375
376void TEWidget::drawAttrStr(QPainter &paint, QRect rect, 376void TEWidget::drawAttrStr(QPainter &paint, QRect rect,
377 QString& str, ca attr, BOOL pm, BOOL clear) 377 QString& str, ca attr, BOOL pm, BOOL clear)
378{ 378{
379 if (pm && color_table[attr.b].transparent) 379 if (pm && color_table[attr.b].transparent)
380 { 380 {
381 paint.setBackgroundMode( TransparentMode ); 381 paint.setBackgroundMode( TransparentMode );
382 if (clear) erase(rect); 382 if (clear) erase(rect);
383 } 383 }
384 else 384 else
385 { 385 {
386 if (blinking) 386 if (blinking)
387 paint.fillRect(rect, color_table[attr.b].color); 387 paint.fillRect(rect, color_table[attr.b].color);
388 else 388 else
389 { 389 {
390 paint.setBackgroundMode( OpaqueMode ); 390 paint.setBackgroundMode( OpaqueMode );
391 paint.setBackgroundColor( color_table[attr.b].color ); 391 paint.setBackgroundColor( color_table[attr.b].color );
392 } 392 }
393 } 393 }
394 394
395 if (color_table[attr.f].bold) 395 if (color_table[attr.f].bold)
396 paint.setPen(QColor( 0x8F, 0x00, 0x00 )); 396 paint.setPen(QColor( 0x8F, 0x00, 0x00 ));
397 else 397 else
398 paint.setPen(color_table[attr.f].color); 398 paint.setPen(color_table[attr.f].color);
399 399
400 paint.drawText(rect.x(),rect.y()+font_a, str); 400 paint.drawText(rect.x(),rect.y()+font_a, str);
401 401
402 if (attr.r & RE_UNDERLINE) 402 if (attr.r & RE_UNDERLINE)
403 paint.drawLine(rect.left(), rect.y()+font_a+1, rect.right(),rect.y()+font_a+1 ); 403 paint.drawLine(rect.left(), rect.y()+font_a+1, rect.right(),rect.y()+font_a+1 );
404} 404}
405 405
406/*! 406/*!
407 The image can only be set completely. 407 The image can only be set completely.
408 408
409 The size of the new image may or may not match the size of the widget. 409 The size of the new image may or may not match the size of the widget.
410*/ 410*/
411 411
412void TEWidget::setImage(const ca* const newimg, int lines, int columns) 412void TEWidget::setImage(const ca* const newimg, int lines, int columns)
413{ int y,x,len; 413{ int y,x,len;
414 const QPixmap* pm = backgroundPixmap(); 414 const QPixmap* pm = backgroundPixmap();
415 QPainter paint; 415 QPainter paint;
416 setUpdatesEnabled(FALSE); 416 setUpdatesEnabled(FALSE);
417 paint.begin( this ); 417 paint.begin( this );
418HCNT("setImage"); 418HCNT("setImage");
419 419
420 QPoint tL = contentsRect().topLeft(); 420 QPoint tL = contentsRect().topLeft();
421 int tLx = tL.x(); 421 int tLx = tL.x();
422 int tLy = tL.y(); 422 int tLy = tL.y();
423 hasBlinker = FALSE; 423 hasBlinker = FALSE;
424 424
425 int cf = -1; // undefined 425 int cf = -1; // undefined
426 int cb = -1; // undefined 426 int cb = -1; // undefined
427 int cr = -1; // undefined 427 int cr = -1; // undefined
428 428
429 int lins = QMIN(this->lines, QMAX(0,lines )); 429 int lins = QMIN(this->lines, QMAX(0,lines ));
430 int cols = QMIN(this->columns,QMAX(0,columns)); 430 int cols = QMIN(this->columns,QMAX(0,columns));
431 QChar *disstrU = new QChar[cols]; 431 QChar *disstrU = new QChar[cols];
432 for (y = 0; y < lins; y++) { 432 for (y = 0; y < lins; y++) {
433 const ca* lcl = &image[y*this->columns]; 433 const ca* lcl = &image[y*this->columns];
434 const ca* const ext = &newimg[y*columns]; 434 const ca* const ext = &newimg[y*columns];
435 if (!resizing) // not while resizing, we're expecting a paintEvent 435 if (!resizing) // not while resizing, we're expecting a paintEvent
436 for (x = 0; x < cols; x++) 436 for (x = 0; x < cols; x++)
437 { 437 {
438 hasBlinker |= (ext[x].r & RE_BLINK); 438 hasBlinker |= (ext[x].r & RE_BLINK);
439 if (ext[x] != lcl[x]) 439 if (ext[x] != lcl[x])
440 { 440 {
441 cr = ext[x].r; 441 cr = ext[x].r;
442 cb = ext[x].b; 442 cb = ext[x].b;
443 if (ext[x].f != cf) cf = ext[x].f; 443 if (ext[x].f != cf) cf = ext[x].f;
444 int lln = cols - x; 444 int lln = cols - x;
445 disstrU[0] = fontMap(ext[x+0].c); 445 disstrU[0] = fontMap(ext[x+0].c);
446 for (len = 1; len < lln; len++) 446 for (len = 1; len < lln; len++)
447 { 447 {
448 if (ext[x+len].f != cf || ext[x+len].b != cb || ext[x+len].r != cr || 448 if (ext[x+len].f != cf || ext[x+len].b != cb || ext[x+len].r != cr ||
449 ext[x+len] == lcl[x+len] ) 449 ext[x+len] == lcl[x+len] )
450 break; 450 break;
451 disstrU[len] = fontMap(ext[x+len].c); 451 disstrU[len] = fontMap(ext[x+len].c);
452 } 452 }
453 QString unistr(disstrU,len); 453 QString unistr(disstrU,len);
454 drawAttrStr(paint, 454 drawAttrStr(paint,
455 QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h), 455 QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h),
456 unistr, ext[x], pm != NULL, true); 456 unistr, ext[x], pm != NULL, true);
457 x += len - 1; 457 x += len - 1;
458 } 458 }
459 } 459 }
460 // finally, make `image' become `newimg'. 460 // finally, make `image' become `newimg'.
461 memcpy((void*)lcl,(const void*)ext,cols*sizeof(ca)); 461 memcpy((void*)lcl,(const void*)ext,cols*sizeof(ca));
462 } 462 }
463 drawFrame( &paint ); 463 drawFrame( &paint );
464 paint.end(); 464 paint.end();
465 setUpdatesEnabled(TRUE); 465 setUpdatesEnabled(TRUE);
466 if ( hasBlinker && !blinkT->isActive()) blinkT->start(1000); // 1000 ms 466 if ( hasBlinker && !blinkT->isActive()) blinkT->start(1000); // 1000 ms
467 if (!hasBlinker && blinkT->isActive()) { blinkT->stop(); blinking = FALSE; } 467 if (!hasBlinker && blinkT->isActive()) { blinkT->stop(); blinking = FALSE; }
468 delete [] disstrU; 468 delete [] disstrU;
469} 469}
470 470
471// paint Event //////////////////////////////////////////////////// 471// paint Event ////////////////////////////////////////////////////
472 472
473/*! 473/*!
474 The difference of this routine vs. the `setImage' is, 474 The difference of this routine vs. the `setImage' is,
475 that the drawing does not include a difference analysis 475 that the drawing does not include a difference analysis
476 between the old and the new image. Instead, the internal 476 between the old and the new image. Instead, the internal
477 image is used and the painting bound by the PaintEvent box. 477 image is used and the painting bound by the PaintEvent box.
478*/ 478*/
479 479
480void TEWidget::paintEvent( QPaintEvent* pe ) 480void TEWidget::paintEvent( QPaintEvent* pe )
481{ 481{
482 482
483//{ static int cnt = 0; printf("paint %d\n",cnt++); } 483//{ static int cnt = 0; printf("paint %d\n",cnt++); }
484 const QPixmap* pm = backgroundPixmap(); 484 const QPixmap* pm = backgroundPixmap();
485 QPainter paint; 485 QPainter paint;
486 setUpdatesEnabled(FALSE); 486 setUpdatesEnabled(FALSE);
487 paint.begin( this ); 487 paint.begin( this );
488 paint.setBackgroundMode( TransparentMode ); 488 paint.setBackgroundMode( TransparentMode );
489HCNT("paintEvent"); 489HCNT("paintEvent");
490 490
491 // Note that the actual widget size can be slightly larger 491 // Note that the actual widget size can be slightly larger
492 // that the image (the size is truncated towards the smaller 492 // that the image (the size is truncated towards the smaller
493 // number of characters in `resizeEvent'. The paint rectangle 493 // number of characters in `resizeEvent'. The paint rectangle
494 // can thus be larger than the image, but less then the size 494 // can thus be larger than the image, but less then the size
495 // of one character. 495 // of one character.
496 496
497 QRect rect = pe->rect().intersect(contentsRect()); 497 QRect rect = pe->rect().intersect(contentsRect());
498 498
499 QPoint tL = contentsRect().topLeft(); 499 QPoint tL = contentsRect().topLeft();
500 int tLx = tL.x(); 500 int tLx = tL.x();
501 int tLy = tL.y(); 501 int tLy = tL.y();
502 502
503 int lux = QMIN(columns-1, QMAX(0,(rect.left() - tLx - blX ) / font_w)); 503 int lux = QMIN(columns-1, QMAX(0,(rect.left() - tLx - blX ) / font_w));
504 int luy = QMIN(lines-1, QMAX(0,(rect.top() - tLy - bY ) / font_h)); 504 int luy = QMIN(lines-1, QMAX(0,(rect.top() - tLy - bY ) / font_h));
505 int rlx = QMIN(columns-1, QMAX(0,(rect.right() - tLx - blX ) / font_w)); 505 int rlx = QMIN(columns-1, QMAX(0,(rect.right() - tLx - blX ) / font_w));
506 int rly = QMIN(lines-1, QMAX(0,(rect.bottom() - tLy - bY ) / font_h)); 506 int rly = QMIN(lines-1, QMAX(0,(rect.bottom() - tLy - bY ) / font_h));
507 507
508 /* 508 /*
509 printf("paintEvent: %d..%d, %d..%d (%d..%d, %d..%d)\n",lux,rlx,luy,rly, 509 printf("paintEvent: %d..%d, %d..%d (%d..%d, %d..%d)\n",lux,rlx,luy,rly,
510 rect.left(), rect.right(), rect.top(), rect.bottom()); 510 rect.left(), rect.right(), rect.top(), rect.bottom());
511 */ 511 */
512 512
513 // if (pm != NULL && color_table[image->b].transparent) 513 // if (pm != NULL && color_table[image->b].transparent)
514 // erase(rect); 514 // erase(rect);
515 // BL: I have no idea why we need this, and it breaks the refresh. 515 // BL: I have no idea why we need this, and it breaks the refresh.
516 516
517 QChar *disstrU = new QChar[columns]; 517 QChar *disstrU = new QChar[columns];
518 for (int y = luy; y <= rly; y++) 518 for (int y = luy; y <= rly; y++)
519 for (int x = lux; x <= rlx; x++) 519 for (int x = lux; x <= rlx; x++)
520 { 520 {
521 int len = 1; 521 int len = 1;
522 disstrU[0] = fontMap(image[loc(x,y)].c); 522 disstrU[0] = fontMap(image[loc(x,y)].c);
523 int cf = image[loc(x,y)].f; 523 int cf = image[loc(x,y)].f;
524 int cb = image[loc(x,y)].b; 524 int cb = image[loc(x,y)].b;
525 int cr = image[loc(x,y)].r; 525 int cr = image[loc(x,y)].r;
526 while (x+len <= rlx && 526 while (x+len <= rlx &&
527 image[loc(x+len,y)].f == cf && 527 image[loc(x+len,y)].f == cf &&
528 image[loc(x+len,y)].b == cb && 528 image[loc(x+len,y)].b == cb &&
529 image[loc(x+len,y)].r == cr ) 529 image[loc(x+len,y)].r == cr )
530 { 530 {
531 disstrU[len] = fontMap(image[loc(x+len,y)].c); 531 disstrU[len] = fontMap(image[loc(x+len,y)].c);
532 len += 1; 532 len += 1;
533 } 533 }
534 QString unistr(disstrU,len); 534 QString unistr(disstrU,len);
535 drawAttrStr(paint, 535 drawAttrStr(paint,
536 QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h), 536 QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h),
537 unistr, image[loc(x,y)], pm != NULL, false); 537 unistr, image[loc(x,y)], pm != NULL, false);
538 x += len - 1; 538 x += len - 1;
539 } 539 }
540 delete [] disstrU; 540 delete [] disstrU;
541 drawFrame( &paint ); 541 drawFrame( &paint );
542 paint.end(); 542 paint.end();
543 setUpdatesEnabled(TRUE); 543 setUpdatesEnabled(TRUE);
544} 544}
545 545
546void TEWidget::blinkEvent() 546void TEWidget::blinkEvent()
547{ 547{
548 blinking = !blinking; 548 blinking = !blinking;
549 repaint(FALSE); 549 repaint(FALSE);
550} 550}
551 551
552/* ------------------------------------------------------------------------- */ 552/* ------------------------------------------------------------------------- */
553/* */ 553/* */
554/* Resizing */ 554/* Resizing */
555/* */ 555/* */
556/* ------------------------------------------------------------------------- */ 556/* ------------------------------------------------------------------------- */
557 557
558void TEWidget::resizeEvent(QResizeEvent* ev) 558void TEWidget::resizeEvent(QResizeEvent* ev)
559{ 559{
560// printf("resize: %d,%d\n",ev->size().width(),ev->size().height()); 560// printf("resize: %d,%d\n",ev->size().width(),ev->size().height());
561 //printf("approx: %d,%d\n",ev->size().width()/font_w,ev->size().height()/font_h); 561 //printf("approx: %d,%d\n",ev->size().width()/font_w,ev->size().height()/font_h);
562 //printf("leaves: %d,%d\n",ev->size().width()%font_w,ev->size().height()%font_h); 562 //printf("leaves: %d,%d\n",ev->size().width()%font_w,ev->size().height()%font_h);
563 //printf("curren: %d,%d\n",width(),height()); 563 //printf("curren: %d,%d\n",width(),height());
564HCNT("resizeEvent"); 564HCNT("resizeEvent");
565 565
566 // see comment in `paintEvent' concerning the rounding. 566 // see comment in `paintEvent' concerning the rounding.
567 //FIXME: could make a routine here; check width(),height() 567 //FIXME: could make a routine here; check width(),height()
568 assert(ev->size().width() == width()); 568 assert(ev->size().width() == width());
569 assert(ev->size().height() == height()); 569 assert(ev->size().height() == height());
570 570
571 propagateSize(); 571 propagateSize();
572} 572}
573 573
574void TEWidget::propagateSize() 574void TEWidget::propagateSize()
575{ 575{
576 ca* oldimg = image; 576 ca* oldimg = image;
577 int oldlin = lines; 577 int oldlin = lines;
578 int oldcol = columns; 578 int oldcol = columns;
579 makeImage(); 579 makeImage();
580 // we copy the old image to reduce flicker 580 // we copy the old image to reduce flicker
581 int lins = QMIN(oldlin,lines); 581 int lins = QMIN(oldlin,lines);
582 int cols = QMIN(oldcol,columns); 582 int cols = QMIN(oldcol,columns);
583 if (oldimg) 583 if (oldimg)
584 { 584 {
585 for (int lin = 0; lin < lins; lin++) 585 for (int lin = 0; lin < lins; lin++)
586 memcpy((void*)&image[columns*lin], 586 memcpy((void*)&image[columns*lin],
587 (void*)&oldimg[oldcol*lin],cols*sizeof(ca)); 587 (void*)&oldimg[oldcol*lin],cols*sizeof(ca));
588 free(oldimg); //FIXME: try new,delete 588 free(oldimg); //FIXME: try new,delete
589 } 589 }
590 else 590 else
591 clearImage(); 591 clearImage();
592 592
593 //NOTE: control flows from the back through the chest right into the eye. 593 //NOTE: control flows from the back through the chest right into the eye.
594 // `emu' will call back via `setImage'. 594 // `emu' will call back via `setImage'.
595 595
596 resizing = TRUE; 596 resizing = TRUE;
597 emit changedImageSizeSignal(lines, columns); // expose resizeEvent 597 emit changedImageSizeSignal(lines, columns); // expose resizeEvent
598 resizing = FALSE; 598 resizing = FALSE;
599} 599}
600 600
601/* ------------------------------------------------------------------------- */ 601/* ------------------------------------------------------------------------- */
602/* */ 602/* */
603/* Scrollbar */ 603/* Scrollbar */
604/* */ 604/* */
605/* ------------------------------------------------------------------------- */ 605/* ------------------------------------------------------------------------- */
606 606
607void TEWidget::scrollChanged(int) { 607void TEWidget::scrollChanged(int) {
608 emit changedHistoryCursor(scrollbar->value()); //expose 608 emit changedHistoryCursor(scrollbar->value()); //expose
609} 609}
610 610
611void TEWidget::hScrollChanged(int loc) { 611void TEWidget::hScrollChanged(int loc) {
612 hposition = loc; 612 hposition = loc;
613 propagateSize(); 613 propagateSize();
614 update(); 614 update();
615 615
616// emit changedHorzCursor( hScrollbar->value()); //expose 616// emit changedHorzCursor( hScrollbar->value()); //expose
617} 617}
618 618
619void TEWidget::setScroll(int cursor, int slines) 619void TEWidget::setScroll(int cursor, int slines)
620{ 620{
621 disconnect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); 621 disconnect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int)));
622 scrollbar->setRange(0,slines); 622 scrollbar->setRange(0,slines);
623 scrollbar->setSteps(1,lines); 623 scrollbar->setSteps(1,lines);
624 scrollbar->setValue(cursor); 624 scrollbar->setValue(cursor);
625 connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); 625 connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int)));
626} 626}
627 627
628void TEWidget::setScrollbarLocation(int loc) 628void TEWidget::setScrollbarLocation(int loc)
629{ 629{
630 if (scrollLoc == loc) return; // quickly 630 if (scrollLoc == loc) return; // quickly
631 scrollLoc = loc; 631 scrollLoc = loc;
632 propagateSize(); 632 propagateSize();
633 update(); 633 update();
634} 634}
635 635
636/* ------------------------------------------------------------------------- */ 636/* ------------------------------------------------------------------------- */
637/* */ 637/* */
638/* Mouse */ 638/* Mouse */
639/* */ 639/* */
640/* ------------------------------------------------------------------------- */ 640/* ------------------------------------------------------------------------- */
641 641
642/*! 642/*!
643 Three different operations can be performed using the mouse, and the 643 Three different operations can be performed using the mouse, and the
644 routines in this section serve all of them: 644 routines in this section serve all of them:
645 645
646 1) The press/release events are exposed to the application 646 1) The press/release events are exposed to the application
647 2) Marking (press and move left button) and Pasting (press middle button) 647 2) Marking (press and move left button) and Pasting (press middle button)
648 3) The right mouse button is used from the configuration menu 648 3) The right mouse button is used from the configuration menu
649 649
650 NOTE: During the marking process we attempt to keep the cursor within 650 NOTE: During the marking process we attempt to keep the cursor within
651 the bounds of the text as being displayed by setting the mouse position 651 the bounds of the text as being displayed by setting the mouse position
652 whenever the mouse has left the text area. 652 whenever the mouse has left the text area.
653 653
654 Two reasons to do so: 654 Two reasons to do so:
655 1) QT does not allow the `grabMouse' to confine-to the TEWidget. 655 1) QT does not allow the `grabMouse' to confine-to the TEWidget.
656 Thus a `XGrapPointer' would have to be used instead. 656 Thus a `XGrapPointer' would have to be used instead.
657 2) Even if so, this would not help too much, since the text area 657 2) Even if so, this would not help too much, since the text area
658 of the TEWidget is normally not identical with it's bounds. 658 of the TEWidget is normally not identical with it's bounds.
659 659
660 The disadvantage of the current handling is, that the mouse can visibly 660 The disadvantage of the current handling is, that the mouse can visibly
661 leave the bounds of the widget and is then moved back. Because of the 661 leave the bounds of the widget and is then moved back. Because of the
662 current construction, and the reasons mentioned above, we cannot do better 662 current construction, and the reasons mentioned above, we cannot do better
663 without changing the overall construction. 663 without changing the overall construction.
664*/ 664*/
665 665
666/*! 666/*!
667*/ 667*/
668 668
669void TEWidget::mousePressEvent(QMouseEvent* ev) 669void TEWidget::mousePressEvent(QMouseEvent* ev)
670{ 670{
671//printf("press [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button()); 671//printf("press [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button());
672 if ( !contentsRect().contains(ev->pos()) ) return; 672 if ( !contentsRect().contains(ev->pos()) ) return;
673 QPoint tL = contentsRect().topLeft(); 673 QPoint tL = contentsRect().topLeft();
674 int tLx = tL.x(); 674 int tLx = tL.x();
675 int tLy = tL.y(); 675 int tLy = tL.y();
676 676
677 word_selection_mode = FALSE; 677 word_selection_mode = FALSE;
678 678
679//printf("press top left [%d,%d] by=%d\n",tLx,tLy, bY); 679//printf("press top left [%d,%d] by=%d\n",tLx,tLy, bY);
680 if ( ev->button() == LeftButton) 680 if ( ev->button() == LeftButton)
681 { 681 {
682 QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); 682 QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h);
683 683
684 if ( ev->state() & ControlButton ) preserve_line_breaks = FALSE ; 684 if ( ev->state() & ControlButton ) preserve_line_breaks = FALSE ;
685 685
686 if (mouse_marks || (ev->state() & ShiftButton)) 686 if (mouse_marks || (ev->state() & ShiftButton))
687 { 687 {
688 emit clearSelectionSignal(); 688 emit clearSelectionSignal();
689 iPntSel = pntSel = pos; 689 iPntSel = pntSel = pos;
690 actSel = 1; // left mouse button pressed but nothing selected yet. 690 actSel = 1; // left mouse button pressed but nothing selected yet.
691 grabMouse( /*crossCursor*/ ); // handle with care! 691 grabMouse( /*crossCursor*/ ); // handle with care!
692 } 692 }
693 else 693 else
694 { 694 {
695 emit mouseSignal( 0, pos.x() + 1, pos.y() + 1 ); // left button 695 emit mouseSignal( 0, pos.x() + 1, pos.y() + 1 ); // left button
696 } 696 }
697 } 697 }
698 if ( ev->button() == MidButton ) 698 if ( ev->button() == MidButton )
699 { 699 {
700 emitSelection(); 700 emitSelection();
701 } 701 }
702 if ( ev->button() == RightButton ) // Configure 702 if ( ev->button() == RightButton ) // Configure
703 { 703 {
704 emit configureRequest( this, ev->state()&(ShiftButton|ControlButton), ev->x(), ev->y() ); 704 emit configureRequest( this, ev->state()&(ShiftButton|ControlButton), ev->x(), ev->y() );
705 } 705 }
706} 706}
707 707
708void TEWidget::mouseMoveEvent(QMouseEvent* ev) 708void TEWidget::mouseMoveEvent(QMouseEvent* ev)
709{ 709{
710 // for auto-hiding the cursor, we need mouseTracking 710 // for auto-hiding the cursor, we need mouseTracking
711 if (ev->state() == NoButton ) return; 711 if (ev->state() == NoButton ) return;
712 712
713 if (actSel == 0) return; 713 if (actSel == 0) return;
714 714
715 // don't extend selection while pasting 715 // don't extend selection while pasting
716 if (ev->state() & MidButton) return; 716 if (ev->state() & MidButton) return;
717 717
718 //if ( !contentsRect().contains(ev->pos()) ) return; 718 //if ( !contentsRect().contains(ev->pos()) ) return;
719 QPoint tL = contentsRect().topLeft(); 719 QPoint tL = contentsRect().topLeft();
720 int tLx = tL.x(); 720 int tLx = tL.x();
721 int tLy = tL.y(); 721 int tLy = tL.y();
722 int scroll = scrollbar->value(); 722 int scroll = scrollbar->value();
723// int hScroll = hScrollbar->value(); 723// int hScroll = hScrollbar->value();
724 724
725 // we're in the process of moving the mouse with the left button pressed 725 // we're in the process of moving the mouse with the left button pressed
726 // the mouse cursor will kept catched within the bounds of the text in 726 // the mouse cursor will kept catched within the bounds of the text in
727 // this widget. 727 // this widget.
728 728
729 // Adjust position within text area bounds. See FIXME above. 729 // Adjust position within text area bounds. See FIXME above.
730 QPoint pos = ev->pos(); 730 QPoint pos = ev->pos();
731 if ( pos.x() < tLx+blX ) pos.setX( tLx+blX ); 731 if ( pos.x() < tLx+blX ) pos.setX( tLx+blX );
732 if ( pos.x() > tLx+blX+columns*font_w-1 ) pos.setX( tLx+blX+columns*font_w ); 732 if ( pos.x() > tLx+blX+columns*font_w-1 ) pos.setX( tLx+blX+columns*font_w );
733 if ( pos.y() < tLy+bY ) pos.setY( tLy+bY ); 733 if ( pos.y() < tLy+bY ) pos.setY( tLy+bY );
734 if ( pos.y() > tLy+bY+lines*font_h-1 ) pos.setY( tLy+bY+lines*font_h-1 ); 734 if ( pos.y() > tLy+bY+lines*font_h-1 ) pos.setY( tLy+bY+lines*font_h-1 );
735 // check if we produce a mouse move event by this 735 // check if we produce a mouse move event by this
736 if ( pos != ev->pos() ) cursor().setPos(mapToGlobal(pos)); 736 if ( pos != ev->pos() ) cursor().setPos(mapToGlobal(pos));
737 737
738 if ( pos.y() == tLy+bY+lines*font_h-1 ) 738 if ( pos.y() == tLy+bY+lines*font_h-1 )
739 { 739 {
740 scrollbar->setValue(scrollbar->value()+yMouseScroll); // scrollforward 740 scrollbar->setValue(scrollbar->value()+yMouseScroll); // scrollforward
741 } 741 }
742 if ( pos.y() == tLy+bY ) 742 if ( pos.y() == tLy+bY )
743 { 743 {
744 scrollbar->setValue(scrollbar->value()-yMouseScroll); // scrollback 744 scrollbar->setValue(scrollbar->value()-yMouseScroll); // scrollback
745 } 745 }
746 746
747 QPoint here = QPoint((pos.x()-tLx-blX)/font_w,(pos.y()-tLy-bY)/font_h); 747 QPoint here = QPoint((pos.x()-tLx-blX)/font_w,(pos.y()-tLy-bY)/font_h);
748 QPoint ohere; 748 QPoint ohere;
749 bool swapping = FALSE; 749 bool swapping = FALSE;
750 750
751 if ( word_selection_mode ) 751 if ( word_selection_mode )
752 { 752 {
753 // Extend to word boundaries 753 // Extend to word boundaries
754 int i; 754 int i;
755 int selClass; 755 int selClass;
756 756
757 bool left_not_right = ( here.y() < iPntSel.y() || 757 bool left_not_right = ( here.y() < iPntSel.y() ||
758 here.y() == iPntSel.y() && here.x() < iPntSel.x() ); 758 here.y() == iPntSel.y() && here.x() < iPntSel.x() );
759 bool old_left_not_right = ( pntSel.y() < iPntSel.y() || 759 bool old_left_not_right = ( pntSel.y() < iPntSel.y() ||
760 pntSel.y() == iPntSel.y() && pntSel.x() < iPntSel.x() ); 760 pntSel.y() == iPntSel.y() && pntSel.x() < iPntSel.x() );
761 swapping = left_not_right != old_left_not_right; 761 swapping = left_not_right != old_left_not_right;
762 762
763 // Find left (left_not_right ? from here : from start) 763 // Find left (left_not_right ? from here : from start)
764 QPoint left = left_not_right ? here : iPntSel; 764 QPoint left = left_not_right ? here : iPntSel;
765 i = loc(left.x(),left.y()); 765 i = loc(left.x(),left.y());
766 selClass = charClass(image[i].c); 766 selClass = charClass(image[i].c);
767 while ( left.x() > 0 && charClass(image[i-1].c) == selClass ) 767 while ( left.x() > 0 && charClass(image[i-1].c) == selClass )
768 { i--; left.rx()--; } 768 { i--; left.rx()--; }
769 769
770 // Find left (left_not_right ? from start : from here) 770 // Find left (left_not_right ? from start : from here)
771 QPoint right = left_not_right ? iPntSel : here; 771 QPoint right = left_not_right ? iPntSel : here;
772 i = loc(right.x(),right.y()); 772 i = loc(right.x(),right.y());
773 selClass = charClass(image[i].c); 773 selClass = charClass(image[i].c);
774 while ( right.x() < columns-1 && charClass(image[i+1].c) == selClass ) 774 while ( right.x() < columns-1 && charClass(image[i+1].c) == selClass )
775 { i++; right.rx()++; } 775 { i++; right.rx()++; }
776 776
777 // Pick which is start (ohere) and which is extension (here) 777 // Pick which is start (ohere) and which is extension (here)
778 if ( left_not_right ) 778 if ( left_not_right )
779 { 779 {
780 here = left; ohere = right; 780 here = left; ohere = right;
781 } 781 }
782 else 782 else
783 { 783 {
784 here = right; ohere = left; 784 here = right; ohere = left;
785 } 785 }
786 } 786 }
787 787
788 if (here == pntSel && scroll == scrollbar->value()) return; // not moved 788 if (here == pntSel && scroll == scrollbar->value()) return; // not moved
789 789
790 if ( word_selection_mode ) { 790 if ( word_selection_mode ) {
791 if ( actSel < 2 || swapping ) { 791 if ( actSel < 2 || swapping ) {
792 emit beginSelectionSignal( ohere.x(), ohere.y() ); 792 emit beginSelectionSignal( ohere.x(), ohere.y() );
793 } 793 }
794 } else if ( actSel < 2 ) { 794 } else if ( actSel < 2 ) {
795 emit beginSelectionSignal( pntSel.x(), pntSel.y() ); 795 emit beginSelectionSignal( pntSel.x(), pntSel.y() );
796 } 796 }
797 797
798 actSel = 2; // within selection 798 actSel = 2; // within selection
799 pntSel = here; 799 pntSel = here;
800 emit extendSelectionSignal( here.x(), here.y() ); 800 emit extendSelectionSignal( here.x(), here.y() );
801} 801}
802 802
803void TEWidget::mouseReleaseEvent(QMouseEvent* ev) 803void TEWidget::mouseReleaseEvent(QMouseEvent* ev)
804{ 804{
805//printf("release [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button()); 805//printf("release [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button());
806 if ( ev->button() == LeftButton) 806 if ( ev->button() == LeftButton)
807 { 807 {
808 if ( actSel > 1 ) emit endSelectionSignal(preserve_line_breaks); 808 if ( actSel > 1 ) emit endSelectionSignal(preserve_line_breaks);
809 preserve_line_breaks = TRUE; 809 preserve_line_breaks = TRUE;
810 actSel = 0; 810 actSel = 0;
811 811
812 //FIXME: emits a release event even if the mouse is 812 //FIXME: emits a release event even if the mouse is
813 // outside the range. The procedure used in `mouseMoveEvent' 813 // outside the range. The procedure used in `mouseMoveEvent'
814 // applies here, too. 814 // applies here, too.
815 815
816 QPoint tL = contentsRect().topLeft(); 816 QPoint tL = contentsRect().topLeft();
817 int tLx = tL.x(); 817 int tLx = tL.x();
818 int tLy = tL.y(); 818 int tLy = tL.y();
819 819
820 if (!mouse_marks && !(ev->state() & ShiftButton)) 820 if (!mouse_marks && !(ev->state() & ShiftButton))
821 emit mouseSignal( 3, // release 821 emit mouseSignal( 3, // release
822 (ev->x()-tLx-blX)/font_w + 1, 822 (ev->x()-tLx-blX)/font_w + 1,
823 (ev->y()-tLy-bY)/font_h + 1 ); 823 (ev->y()-tLy-bY)/font_h + 1 );
824 releaseMouse(); 824 releaseMouse();
825 } 825 }
826} 826}
827 827
828void TEWidget::mouseDoubleClickEvent(QMouseEvent* ev) 828void TEWidget::mouseDoubleClickEvent(QMouseEvent* ev)
829{ 829{
830 if ( ev->button() != LeftButton) return; 830 if ( ev->button() != LeftButton) return;
831 831
832 QPoint tL = contentsRect().topLeft(); 832 QPoint tL = contentsRect().topLeft();
833 int tLx = tL.x(); 833 int tLx = tL.x();
834 int tLy = tL.y(); 834 int tLy = tL.y();
835 QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); 835 QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h);
836 836
837 // pass on double click as two clicks. 837 // pass on double click as two clicks.
838 if (!mouse_marks && !(ev->state() & ShiftButton)) 838 if (!mouse_marks && !(ev->state() & ShiftButton))
839 { 839 {
840 emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button 840 emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button
841 emit mouseSignal( 3, pos.x()+1, pos.y()+1 ); // release 841 emit mouseSignal( 3, pos.x()+1, pos.y()+1 ); // release
842 emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button 842 emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button
843 return; 843 return;
844 } 844 }
845 845
846 846
847 emit clearSelectionSignal(); 847 emit clearSelectionSignal();
848 QPoint bgnSel = pos; 848 QPoint bgnSel = pos;
849 QPoint endSel = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); 849 QPoint endSel = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h);
850 int i = loc(bgnSel.x(),bgnSel.y()); 850 int i = loc(bgnSel.x(),bgnSel.y());
851 iPntSel = bgnSel; 851 iPntSel = bgnSel;
852 852
853 word_selection_mode = TRUE; 853 word_selection_mode = TRUE;
854 854
855 // find word boundaries... 855 // find word boundaries...
856 int selClass = charClass(image[i].c); 856 int selClass = charClass(image[i].c);
857 { 857 {
858 // set the start... 858 // set the start...
859 int x = bgnSel.x(); 859 int x = bgnSel.x();
860 while ( x > 0 && charClass(image[i-1].c) == selClass ) 860 while ( x > 0 && charClass(image[i-1].c) == selClass )
861 { i--; x--; } 861 { i--; x--; }
862 bgnSel.setX(x); 862 bgnSel.setX(x);
863 emit beginSelectionSignal( bgnSel.x(), bgnSel.y() ); 863 emit beginSelectionSignal( bgnSel.x(), bgnSel.y() );
864 864
865 // set the end... 865 // set the end...
866 i = loc( endSel.x(), endSel.y() ); 866 i = loc( endSel.x(), endSel.y() );
867 x = endSel.x(); 867 x = endSel.x();
868 while( x < columns-1 && charClass(image[i+1].c) == selClass ) 868 while( x < columns-1 && charClass(image[i+1].c) == selClass )
869 { i++; x++ ; } 869 { i++; x++ ; }
870 endSel.setX(x); 870 endSel.setX(x);
871 actSel = 2; // within selection 871 actSel = 2; // within selection
872 emit extendSelectionSignal( endSel.x(), endSel.y() ); 872 emit extendSelectionSignal( endSel.x(), endSel.y() );
873 emit endSelectionSignal(preserve_line_breaks); 873 emit endSelectionSignal(preserve_line_breaks);
874 preserve_line_breaks = TRUE; 874 preserve_line_breaks = TRUE;
875 } 875 }
876} 876}
877 877
878void TEWidget::focusInEvent( QFocusEvent * ) 878void TEWidget::focusInEvent( QFocusEvent * )
879{ 879{
880 880
881 // do nothing, to prevent repainting 881 // do nothing, to prevent repainting
882} 882}
883 883
884 884
885void TEWidget::focusOutEvent( QFocusEvent * ) 885void TEWidget::focusOutEvent( QFocusEvent * )
886{ 886{
887 // do nothing, to prevent repainting 887 // do nothing, to prevent repainting
888} 888}
889 889
890bool TEWidget::focusNextPrevChild( bool next ) 890bool TEWidget::focusNextPrevChild( bool next )
891{ 891{
892 if (next) 892 if (next)
893 return false; // This disables changing the active part in konqueror 893 return false; // This disables changing the active part in konqueror
894 // when pressing Tab 894 // when pressing Tab
895 return QFrame::focusNextPrevChild( next ); 895 return QFrame::focusNextPrevChild( next );
896} 896}
897 897
898 898
899int TEWidget::charClass(char ch) const 899int TEWidget::charClass(char ch) const
900{ 900{
901 // This might seem like overkill, but imagine if ch was a Unicode 901 // This might seem like overkill, but imagine if ch was a Unicode
902 // character (Qt 2.0 QChar) - it might then be sensible to separate 902 // character (Qt 2.0 QChar) - it might then be sensible to separate
903 // the different language ranges, etc. 903 // the different language ranges, etc.
904 904
905 if ( isspace(ch) ) return ' '; 905 if ( isspace(ch) ) return ' ';
906 906
907 static const char *word_characters = ":@-./_~"; 907 static const char *word_characters = ":@-./_~";
908 if ( isalnum(ch) || strchr(word_characters, ch) ) 908 if ( isalnum(ch) || strchr(word_characters, ch) )
909 return 'a'; 909 return 'a';
910 910
911 // Everything else is weird 911 // Everything else is weird
912 return 1; 912 return 1;
913} 913}
914 914
915void TEWidget::setMouseMarks(bool on) 915void TEWidget::setMouseMarks(bool on)
916{ 916{
917 mouse_marks = on; 917 mouse_marks = on;
918 setCursor( mouse_marks ? ibeamCursor : arrowCursor ); 918 setCursor( mouse_marks ? ibeamCursor : arrowCursor );
919} 919}
920 920
921/* ------------------------------------------------------------------------- */ 921/* ------------------------------------------------------------------------- */
922/* */ 922/* */
923/* Clipboard */ 923/* Clipboard */
924/* */ 924/* */
925/* ------------------------------------------------------------------------- */ 925/* ------------------------------------------------------------------------- */
926 926
927#undef KeyPress 927#undef KeyPress
928 928
929void TEWidget::emitSelection() 929void TEWidget::emitSelection()
930// Paste Clipboard by simulating keypress events 930// Paste Clipboard by simulating keypress events
931{ 931{
932#ifndef QT_NO_CLIPBOARD 932#ifndef QT_NO_CLIPBOARD
933 QString text = QApplication::clipboard()->text(); 933 QString text = QApplication::clipboard()->text();
934 //qDebug(text); 934 //qDebug(text);
935 if ( ! text.isNull()) 935 if ( ! text.isNull())
936 { 936 {
937 text.replace(QRegExp("\n"), "\r"); 937 text.replace(QRegExp("\n"), "\r");
938 QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); 938 QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text);
939 emit keyPressedSignal(&e); // expose as a big fat keypress event 939 emit keyPressedSignal(&e); // expose as a big fat keypress event
940 emit clearSelectionSignal(); 940 emit clearSelectionSignal();
941 } 941 }
942#endif 942#endif
943} 943}
944 944
945void TEWidget::emitText(QString text) 945void TEWidget::emitText(QString text)
946{ 946{
947 QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); 947 QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text);
948 emit keyPressedSignal(&e); // expose as a big fat keypress event 948 emit keyPressedSignal(&e); // expose as a big fat keypress event
949} 949}
950 950
951void TEWidget::pasteClipboard( ) 951void TEWidget::pasteClipboard( )
952{ 952{
953 emitSelection(); 953 emitSelection();
954} 954}
955 955
956void TEWidget::setSelection(const QString& t) 956void TEWidget::setSelection(const QString& t)
957{ 957{
958#ifndef QT_NO_CLIPBOARD 958#ifndef QT_NO_CLIPBOARD
959 // Disconnect signal while WE set the clipboard 959 // Disconnect signal while WE set the clipboard
960 QObject *cb = QApplication::clipboard(); 960 QObject *cb = QApplication::clipboard();
961 QObject::disconnect( cb, SIGNAL(dataChanged()), 961 QObject::disconnect( cb, SIGNAL(dataChanged()),
962 this, SLOT(onClearSelection()) ); 962 this, SLOT(onClearSelection()) );
963 963
964 QApplication::clipboard()->setText(t); 964 QApplication::clipboard()->setText(t);
965 965
966 QObject::connect( cb, SIGNAL(dataChanged()), 966 QObject::connect( cb, SIGNAL(dataChanged()),
967 this, SLOT(onClearSelection()) ); 967 this, SLOT(onClearSelection()) );
968#endif 968#endif
969} 969}
970 970
971void TEWidget::onClearSelection() 971void TEWidget::onClearSelection()
972{ 972{
973 emit clearSelectionSignal(); 973 emit clearSelectionSignal();
974} 974}
975 975
976/* ------------------------------------------------------------------------- */ 976/* ------------------------------------------------------------------------- */
977/* */ 977/* */
978/* Keyboard */ 978/* Keyboard */
979/* */ 979/* */
980/* ------------------------------------------------------------------------- */ 980/* ------------------------------------------------------------------------- */
981 981
982//FIXME: an `eventFilter' has been installed instead of a `keyPressEvent' 982//FIXME: an `eventFilter' has been installed instead of a `keyPressEvent'
983// due to a bug in `QT' or the ignorance of the author to prevent 983// due to a bug in `QT' or the ignorance of the author to prevent
984// repaint events being emitted to the screen whenever one leaves 984// repaint events being emitted to the screen whenever one leaves
985// or reenters the screen to/from another application. 985// or reenters the screen to/from another application.
986// 986//
987// Troll says one needs to change focusInEvent() and focusOutEvent(), 987// Troll says one needs to change focusInEvent() and focusOutEvent(),
988// which would also let you have an in-focus cursor and an out-focus 988// which would also let you have an in-focus cursor and an out-focus
989// cursor like xterm does. 989// cursor like xterm does.
990 990
991// for the auto-hide cursor feature, I added empty focusInEvent() and 991// for the auto-hide cursor feature, I added empty focusInEvent() and
992// focusOutEvent() so that update() isn't called. 992// focusOutEvent() so that update() isn't called.
993// For auto-hide, we need to get keypress-events, but we only get them when 993// For auto-hide, we need to get keypress-events, but we only get them when
994// we have focus. 994// we have focus.
995 995
996void TEWidget::doScroll(int lines) 996void TEWidget::doScroll(int lines)
997{ 997{
998 scrollbar->setValue(scrollbar->value()+lines); 998 scrollbar->setValue(scrollbar->value()+lines);
999} 999}
1000 1000
1001void TEWidget::doHScroll(int lines) { 1001void TEWidget::doHScroll(int lines) {
1002 hScrollbar->setValue( hScrollbar->value()+lines); 1002 hScrollbar->setValue( hScrollbar->value()+lines);
1003} 1003}
1004 1004
1005bool TEWidget::eventFilter( QObject *obj, QEvent *e ) 1005bool TEWidget::eventFilter( QObject *obj, QEvent *e )
1006{ 1006{
1007 if ( (e->type() == QEvent::Accel || 1007 if ( (e->type() == QEvent::Accel ||
1008 e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) { 1008 e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) {
1009 static_cast<QKeyEvent *>( e )->ignore(); 1009 static_cast<QKeyEvent *>( e )->ignore();
1010 return true; 1010 return true;
1011 } 1011 }
1012 if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ ) 1012 if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ )
1013 return FALSE; // not us 1013 return FALSE; // not us
1014 if ( e->type() == QEvent::Wheel) { 1014 if ( e->type() == QEvent::Wheel) {
1015 QApplication::sendEvent(scrollbar, e); 1015 QApplication::sendEvent(scrollbar, e);
1016 } 1016 }
1017 1017
1018#ifdef FAKE_CTRL_AND_ALT 1018#ifdef FAKE_CTRL_AND_ALT
1019 static bool control = FALSE; 1019 static bool control = FALSE;
1020 static bool alt = FALSE; 1020 static bool alt = FALSE;
1021// qDebug(" Has a keyboard with no CTRL and ALT keys, but we fake it:"); 1021// qDebug(" Has a keyboard with no CTRL and ALT keys, but we fake it:");
1022 bool dele=FALSE; 1022 bool dele=FALSE;
1023 if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { 1023 if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) {
1024 QKeyEvent* ke = (QKeyEvent*)e; 1024 QKeyEvent* ke = (QKeyEvent*)e;
1025 bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat(); 1025 bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat();
1026 switch (ke->key()) { 1026 switch (ke->key()) {
1027 case Key_F9: // let this be "Control" 1027 case Key_F9: // let this be "Control"
1028 control = keydown; 1028 control = keydown;
1029 e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state()); 1029 e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state());
1030 dele=TRUE; 1030 dele=TRUE;
1031 break; 1031 break;
1032 case Key_F13: // let this be "Alt" 1032 case Key_F13: // let this be "Alt"
1033 alt = keydown; 1033 alt = keydown;
1034 e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state()); 1034 e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state());
1035 dele=TRUE; 1035 dele=TRUE;
1036 break; 1036 break;
1037 default: 1037 default:
1038 if ( control ) { 1038 if ( control ) {
1039 int a = toupper(ke->ascii())-64; 1039 int a = toupper(ke->ascii())-64;
1040 if ( a >= 0 && a < ' ' ) { 1040 if ( a >= 0 && a < ' ' ) {
1041 e = new QKeyEvent(e->type(), ke->key(), 1041 e = new QKeyEvent(e->type(), ke->key(),
1042 a, ke->state()|ControlButton, QChar(a,0)); 1042 a, ke->state()|ControlButton, QChar(a,0));
1043 dele=TRUE; 1043 dele=TRUE;
1044 } 1044 }
1045 } 1045 }
1046 if ( alt ) { 1046 if ( alt ) {
1047 e = new QKeyEvent(e->type(), ke->key(), 1047 e = new QKeyEvent(e->type(), ke->key(),
1048 ke->ascii(), ke->state()|AltButton, ke->text()); 1048 ke->ascii(), ke->state()|AltButton, ke->text());
1049 dele=TRUE; 1049 dele=TRUE;
1050 } 1050 }
1051 } 1051 }
1052 } 1052 }
1053#endif 1053#endif
1054 1054
1055 if ( e->type() == QEvent::KeyPress ) { 1055 if ( e->type() == QEvent::KeyPress ) {
1056 QKeyEvent* ke = (QKeyEvent*)e; 1056 QKeyEvent* ke = (QKeyEvent*)e;
1057 actSel=0; // Key stroke implies a screen update, so TEWidget won't 1057 actSel=0; // Key stroke implies a screen update, so TEWidget won't
1058 // know where the current selection is. 1058 // know where the current selection is.
1059 1059
1060// qDebug("key pressed is 0x%x, ascii is 0x%x, state %d", ke->key(), ke->ascii(), ke->state()); 1060// qDebug("key pressed is 0x%x, ascii is 0x%x, state %d", ke->key(), ke->ascii(), ke->state());
1061 1061
1062 if( ke->state() == ShiftButton && ke->key() == Key_Tab) { 1062 if( ke->state() == ShiftButton && ke->key() == Key_Tab) {
1063 //lets hardcode this sucker 1063 //lets hardcode this sucker
1064 1064
1065// qDebug("key pressed 2 is 0x%x", ke->key()); 1065// qDebug("key pressed 2 is 0x%x", ke->key());
1066 emitText("\\"); // expose 1066 emitText("\\"); // expose
1067 } 1067 }
1068 else if( ke->state() == ControlButton && ke->key() == Key_V) { 1068 else if( ke->state() == ControlButton && ke->key() == Key_V) {
1069 pasteClipboard(); 1069 pasteClipboard();
1070 } 1070 }
1071// else if( ke->state() == ControlButton && ke->key() == Key_C) { 1071// else if( ke->state() == ControlButton && ke->key() == Key_C) {
1072// pasteClipboard(); 1072// pasteClipboard();
1073// } 1073// }
1074 else 1074 else
1075 emit keyPressedSignal(ke); // expose 1075 emit keyPressedSignal(ke); // expose
1076 ke->accept(); 1076 ke->accept();
1077#ifdef FAKE_CTRL_AND_ALT 1077#ifdef FAKE_CTRL_AND_ALT
1078 if ( dele ) delete e; 1078 if ( dele ) delete e;
1079#endif 1079#endif
1080 return true; // stop the event 1080 return true; // stop the event
1081 } 1081 }
1082 if ( e->type() == QEvent::Enter ) { 1082 if ( e->type() == QEvent::Enter ) {
1083 QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()), 1083 QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()),
1084 this, SLOT(onClearSelection()) ); 1084 this, SLOT(onClearSelection()) );
1085 } 1085 }
1086 if ( e->type() == QEvent::Leave ) { 1086 if ( e->type() == QEvent::Leave ) {
1087 QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), 1087 QObject::connect( (QObject*)cb, SIGNAL(dataChanged()),
1088 this, SLOT(onClearSelection()) ); 1088 this, SLOT(onClearSelection()) );
1089 } 1089 }
1090 return QFrame::eventFilter( obj, e ); 1090 return QFrame::eventFilter( obj, e );
1091} 1091}
1092 1092
1093/* ------------------------------------------------------------------------- */ 1093/* ------------------------------------------------------------------------- */
1094/* */ 1094/* */
1095/* Frame */ 1095/* Frame */
1096/* */ 1096/* */
1097/* ------------------------------------------------------------------------- */ 1097/* ------------------------------------------------------------------------- */
1098 1098
1099void TEWidget::frameChanged() 1099void TEWidget::frameChanged()
1100{ 1100{
1101 propagateSize(); 1101 propagateSize();
1102 update(); 1102 update();
1103} 1103}
1104 1104
1105/* ------------------------------------------------------------------------- */ 1105/* ------------------------------------------------------------------------- */
1106/* */ 1106/* */
1107/* Sound */ 1107/* Sound */
1108/* */ 1108/* */
1109/* ------------------------------------------------------------------------- */ 1109/* ------------------------------------------------------------------------- */
1110 1110
1111void TEWidget::Bell() 1111void TEWidget::Bell()
1112{ 1112{
1113//#ifdef QT_QWS_SHARP 1113//#ifdef QT_QWS_SL5XXX
1114//# ifndef QT_NO_COP 1114//# ifndef QT_NO_COP
1115 if(useBeep) 1115 if(useBeep)
1116 QCopEnvelope( "QPE/TaskBar", "soundAlarm()" ); 1116 QCopEnvelope( "QPE/TaskBar", "soundAlarm()" );
1117 1117
1118//# endif 1118//# endif
1119//#else 1119//#else
1120//# ifndef QT_NO_SOUND 1120//# ifndef QT_NO_SOUND
1121// QSound::play(Resource::findSound("alarm")); 1121// QSound::play(Resource::findSound("alarm"));
1122//# endif 1122//# endif
1123//#endif 1123//#endif
1124 1124
1125// QApplication::beep(); 1125// QApplication::beep();
1126} 1126}
1127 1127
1128/* ------------------------------------------------------------------------- */ 1128/* ------------------------------------------------------------------------- */
1129/* */ 1129/* */
1130/* Auxiluary */ 1130/* Auxiluary */
1131/* */ 1131/* */
1132/* ------------------------------------------------------------------------- */ 1132/* ------------------------------------------------------------------------- */
1133 1133
1134void TEWidget::clearImage() 1134void TEWidget::clearImage()
1135// initialize the image 1135// initialize the image
1136// for internal use only 1136// for internal use only
1137{ 1137{
1138 for (int y = 0; y < lines; y++) 1138 for (int y = 0; y < lines; y++)
1139 for (int x = 0; x < columns; x++) 1139 for (int x = 0; x < columns; x++)
1140 { 1140 {
1141 image[loc(x,y)].c = 0xff; //' '; 1141 image[loc(x,y)].c = 0xff; //' ';
1142 image[loc(x,y)].f = 0xff; //DEFAULT_FORE_COLOR; 1142 image[loc(x,y)].f = 0xff; //DEFAULT_FORE_COLOR;
1143 image[loc(x,y)].b = 0xff; //DEFAULT_BACK_COLOR; 1143 image[loc(x,y)].b = 0xff; //DEFAULT_BACK_COLOR;
1144 image[loc(x,y)].r = 0xff; //DEFAULT_RENDITION; 1144 image[loc(x,y)].r = 0xff; //DEFAULT_RENDITION;
1145 } 1145 }
1146} 1146}
1147 1147
1148// Create Image /////////////////////////////////////////////////////// 1148// Create Image ///////////////////////////////////////////////////////
1149 1149
1150void TEWidget::calcGeometry() 1150void TEWidget::calcGeometry()
1151{ 1151{
1152 int showhscrollbar = 1; 1152 int showhscrollbar = 1;
1153 int hwidth = 0; 1153 int hwidth = 0;
1154 int dcolumns; 1154 int dcolumns;
1155 Config cfg("Konsole"); 1155 Config cfg("Konsole");
1156 cfg.setGroup("ScrollBar"); 1156 cfg.setGroup("ScrollBar");
1157 useHorzScroll=cfg.readBoolEntry("HorzScroll",0); 1157 useHorzScroll=cfg.readBoolEntry("HorzScroll",0);
1158 1158
1159 if(vcolumns == 0) showhscrollbar = 0; 1159 if(vcolumns == 0) showhscrollbar = 0;
1160 if(showhscrollbar == 1) hwidth = QApplication::style().scrollBarExtent().width(); 1160 if(showhscrollbar == 1) hwidth = QApplication::style().scrollBarExtent().width();
1161 1161
1162 scrollbar->resize(QApplication::style().scrollBarExtent().width(), 1162 scrollbar->resize(QApplication::style().scrollBarExtent().width(),
1163 contentsRect().height() - hwidth); 1163 contentsRect().height() - hwidth);
1164 1164
1165 switch(scrollLoc) { 1165 switch(scrollLoc) {
1166 case SCRNONE : 1166 case SCRNONE :
1167 columns = ( contentsRect().width() - 2 * rimX ) / font_w; 1167 columns = ( contentsRect().width() - 2 * rimX ) / font_w;
1168 dcolumns = columns; 1168 dcolumns = columns;
1169 if(vcolumns) columns = vcolumns; 1169 if(vcolumns) columns = vcolumns;
1170 blX = (contentsRect().width() - (columns*font_w) ) / 2; 1170 blX = (contentsRect().width() - (columns*font_w) ) / 2;
1171 if(showhscrollbar) 1171 if(showhscrollbar)
1172 blX = -hposition * font_w; 1172 blX = -hposition * font_w;
1173 brX = blX; 1173 brX = blX;
1174 scrollbar->hide(); 1174 scrollbar->hide();
1175 break; 1175 break;
1176 case SCRLEFT : 1176 case SCRLEFT :
1177 columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; 1177 columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w;
1178 dcolumns = columns; 1178 dcolumns = columns;
1179 if(vcolumns) columns = vcolumns; 1179 if(vcolumns) columns = vcolumns;
1180 brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; 1180 brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2;
1181 if(showhscrollbar) 1181 if(showhscrollbar)
1182 brX = -hposition * font_w; 1182 brX = -hposition * font_w;
1183 blX = brX + scrollbar->width(); 1183 blX = brX + scrollbar->width();
1184 scrollbar->move(contentsRect().topLeft()); 1184 scrollbar->move(contentsRect().topLeft());
1185 scrollbar->show(); 1185 scrollbar->show();
1186 break; 1186 break;
1187 case SCRRIGHT: 1187 case SCRRIGHT:
1188 columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; 1188 columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w;
1189 dcolumns = columns; 1189 dcolumns = columns;
1190 if(vcolumns) columns = vcolumns; 1190 if(vcolumns) columns = vcolumns;
1191 blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; 1191 blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2;
1192 if(showhscrollbar) 1192 if(showhscrollbar)
1193 blX = -hposition * font_w; 1193 blX = -hposition * font_w;
1194 brX = blX; 1194 brX = blX;
1195 scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0)); 1195 scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0));
1196 scrollbar->show(); 1196 scrollbar->show();
1197 break; 1197 break;
1198 } 1198 }
1199 //FIXME: support 'rounding' styles 1199 //FIXME: support 'rounding' styles
1200 lines = ( contentsRect().height() - 2 * rimY ) / font_h; 1200 lines = ( contentsRect().height() - 2 * rimY ) / font_h;
1201 bY = (contentsRect().height() - (lines *font_h)) / 2; 1201 bY = (contentsRect().height() - (lines *font_h)) / 2;
1202 1202
1203 if(showhscrollbar == 1) { 1203 if(showhscrollbar == 1) {
1204 hScrollbar->resize(contentsRect().width() - hwidth, hwidth); 1204 hScrollbar->resize(contentsRect().width() - hwidth, hwidth);
1205 hScrollbar->setRange(0, vcolumns - dcolumns); 1205 hScrollbar->setRange(0, vcolumns - dcolumns);
1206 1206
1207 QPoint p = contentsRect().bottomLeft(); 1207 QPoint p = contentsRect().bottomLeft();
1208 if(scrollLoc == SCRLEFT) 1208 if(scrollLoc == SCRLEFT)
1209 hScrollbar->move(QPoint(p.x()+hwidth, p.y() - hwidth)); 1209 hScrollbar->move(QPoint(p.x()+hwidth, p.y() - hwidth));
1210 else 1210 else
1211 hScrollbar->move(QPoint(p.x(), p.y() - hwidth)); 1211 hScrollbar->move(QPoint(p.x(), p.y() - hwidth));
1212 1212
1213 hScrollbar->show(); 1213 hScrollbar->show();
1214 } 1214 }
1215 else hScrollbar->hide(); 1215 else hScrollbar->hide();
1216 1216
1217 if(showhscrollbar == 1) { 1217 if(showhscrollbar == 1) {
1218 lines = lines - (hwidth / font_h) - 1; 1218 lines = lines - (hwidth / font_h) - 1;
1219 if(lines < 1) lines = 1; 1219 if(lines < 1) lines = 1;
1220 } 1220 }
1221 //FIXME: support 'rounding' styles 1221 //FIXME: support 'rounding' styles
1222} 1222}
1223 1223
1224void TEWidget::makeImage() 1224void TEWidget::makeImage()
1225//FIXME: rename 'calcGeometry? 1225//FIXME: rename 'calcGeometry?
1226{ 1226{
1227 calcGeometry(); 1227 calcGeometry();
1228 image = (ca*) malloc(lines*columns*sizeof(ca)); 1228 image = (ca*) malloc(lines*columns*sizeof(ca));
1229 clearImage(); 1229 clearImage();
1230} 1230}
1231 1231
1232// calculate the needed size 1232// calculate the needed size
1233QSize TEWidget::calcSize(int cols, int lins) const 1233QSize TEWidget::calcSize(int cols, int lins) const
1234{ 1234{
1235 int frw = width() - contentsRect().width(); 1235 int frw = width() - contentsRect().width();
1236 int frh = height() - contentsRect().height(); 1236 int frh = height() - contentsRect().height();
1237 int scw = (scrollLoc==SCRNONE?0:scrollbar->width()); 1237 int scw = (scrollLoc==SCRNONE?0:scrollbar->width());
1238 return QSize( font_w*cols + 2*rimX + frw + scw, font_h*lins + 2*rimY + frh ); 1238 return QSize( font_w*cols + 2*rimX + frw + scw, font_h*lins + 2*rimY + frh );
1239} 1239}
1240 1240
1241QSize TEWidget::sizeHint() const 1241QSize TEWidget::sizeHint() const
1242{ 1242{
1243 return size(); 1243 return size();
1244} 1244}
1245 1245
1246void TEWidget::styleChange(QStyle &) 1246void TEWidget::styleChange(QStyle &)
1247{ 1247{
1248 propagateSize(); 1248 propagateSize();
1249} 1249}
1250 1250
1251#ifndef QT_NO_DRAGANDDROP 1251#ifndef QT_NO_DRAGANDDROP
1252 1252
1253/* --------------------------------------------------------------------- */ 1253/* --------------------------------------------------------------------- */
1254/* */ 1254/* */
1255/* Drag & Drop */ 1255/* Drag & Drop */
1256/* */ 1256/* */
1257/* --------------------------------------------------------------------- */ 1257/* --------------------------------------------------------------------- */
1258 1258
1259 1259
1260void TEWidget::dragEnterEvent(QDragEnterEvent* e) 1260void TEWidget::dragEnterEvent(QDragEnterEvent* e)
1261{ 1261{
1262 e->accept(QTextDrag::canDecode(e) || 1262 e->accept(QTextDrag::canDecode(e) ||
1263 QUriDrag::canDecode(e)); 1263 QUriDrag::canDecode(e));
1264} 1264}
1265 1265
1266void TEWidget::dropEvent(QDropEvent* event) 1266void TEWidget::dropEvent(QDropEvent* event)
1267{ 1267{
1268 // The current behaviour when url(s) are dropped is 1268 // The current behaviour when url(s) are dropped is
1269 // * if there is only ONE url and if it's a LOCAL one, ask for paste or cd 1269 // * if there is only ONE url and if it's a LOCAL one, ask for paste or cd
1270 // * in all other cases, just paste 1270 // * in all other cases, just paste
1271 // (for non-local ones, or for a list of URLs, 'cd' is nonsense) 1271 // (for non-local ones, or for a list of URLs, 'cd' is nonsense)
1272 QStrList strlist; 1272 QStrList strlist;
1273 int file_count = 0; 1273 int file_count = 0;
1274 dropText = ""; 1274 dropText = "";
1275 bool bPopup = true; 1275 bool bPopup = true;
1276 1276
1277 if(QUriDrag::decode(event, strlist)) { 1277 if(QUriDrag::decode(event, strlist)) {
1278 if (strlist.count()) { 1278 if (strlist.count()) {
1279 for(const char* p = strlist.first(); p; p = strlist.next()) { 1279 for(const char* p = strlist.first(); p; p = strlist.next()) {
1280 if(file_count++ > 0) { 1280 if(file_count++ > 0) {
1281 dropText += " "; 1281 dropText += " ";
1282 bPopup = false; // more than one file, don't popup 1282 bPopup = false; // more than one file, don't popup
1283 } 1283 }
1284 1284
1285/* 1285/*
1286 KURL url(p); 1286 KURL url(p);
1287 if (url.isLocalFile()) { 1287 if (url.isLocalFile()) {
1288 dropText += url.path(); // local URL : remove protocol 1288 dropText += url.path(); // local URL : remove protocol
1289 } 1289 }
1290 else { 1290 else {
1291 dropText += url.prettyURL(); 1291 dropText += url.prettyURL();
1292 bPopup = false; // a non-local file, don't popup 1292 bPopup = false; // a non-local file, don't popup
1293 } 1293 }
1294*/ 1294*/
1295 1295
1296 } 1296 }
1297 1297
1298 if (bPopup) 1298 if (bPopup)
1299 // m_drop->popup(pos() + event->pos()); 1299 // m_drop->popup(pos() + event->pos());
1300 m_drop->popup(mapToGlobal(event->pos())); 1300 m_drop->popup(mapToGlobal(event->pos()));
1301 else 1301 else
1302 { 1302 {
1303 if (currentSession) { 1303 if (currentSession) {
1304 currentSession->getEmulation()->sendString(dropText.local8Bit()); 1304 currentSession->getEmulation()->sendString(dropText.local8Bit());
1305 } 1305 }
1306// kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; 1306// kdDebug() << "Drop:" << dropText.local8Bit() << "\n";
1307 } 1307 }
1308 } 1308 }
1309 } 1309 }
1310 else if(QTextDrag::decode(event, dropText)) { 1310 else if(QTextDrag::decode(event, dropText)) {
1311// kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; 1311// kdDebug() << "Drop:" << dropText.local8Bit() << "\n";
1312 if (currentSession) { 1312 if (currentSession) {
1313 currentSession->getEmulation()->sendString(dropText.local8Bit()); 1313 currentSession->getEmulation()->sendString(dropText.local8Bit());
1314 } 1314 }
1315 // Paste it 1315 // Paste it
1316 } 1316 }
1317} 1317}
1318#endif 1318#endif
1319 1319
1320 1320
1321void TEWidget::drop_menu_activated(int item) 1321void TEWidget::drop_menu_activated(int item)
1322{ 1322{
1323#ifndef QT_NO_DRAGANDDROP 1323#ifndef QT_NO_DRAGANDDROP
1324 switch (item) 1324 switch (item)
1325 { 1325 {
1326 case 0: // paste 1326 case 0: // paste
1327 currentSession->getEmulation()->sendString(dropText.local8Bit()); 1327 currentSession->getEmulation()->sendString(dropText.local8Bit());
1328// KWM::activate((Window)this->winId()); 1328// KWM::activate((Window)this->winId());
1329 break; 1329 break;
1330 case 1: // cd ... 1330 case 1: // cd ...
1331 currentSession->getEmulation()->sendString("cd "); 1331 currentSession->getEmulation()->sendString("cd ");
1332 struct stat statbuf; 1332 struct stat statbuf;
1333 if ( ::stat( QFile::encodeName( dropText ), &statbuf ) == 0 ) 1333 if ( ::stat( QFile::encodeName( dropText ), &statbuf ) == 0 )
1334 { 1334 {
1335 if ( !S_ISDIR(statbuf.st_mode) ) 1335 if ( !S_ISDIR(statbuf.st_mode) )
1336 { 1336 {
1337/* 1337/*
1338 KURL url; 1338 KURL url;
1339 url.setPath( dropText ); 1339 url.setPath( dropText );
1340 dropText = url.directory( true, false ); // remove filename 1340 dropText = url.directory( true, false ); // remove filename
1341*/ 1341*/
1342 } 1342 }
1343 } 1343 }
1344 dropText.replace(QRegExp(" "), "\\ "); // escape spaces 1344 dropText.replace(QRegExp(" "), "\\ "); // escape spaces
1345 currentSession->getEmulation()->sendString(dropText.local8Bit()); 1345 currentSession->getEmulation()->sendString(dropText.local8Bit());
1346 currentSession->getEmulation()->sendString("\n"); 1346 currentSession->getEmulation()->sendString("\n");
1347// KWM::activate((Window)this->winId()); 1347// KWM::activate((Window)this->winId());
1348 break; 1348 break;
1349 } 1349 }
1350#endif 1350#endif
1351} 1351}
1352 1352
1353void TEWidget::setWrapAt(int columns) 1353void TEWidget::setWrapAt(int columns)
1354{ 1354{
1355 vcolumns = columns; 1355 vcolumns = columns;
1356 propagateSize(); 1356 propagateSize();
1357 update(); 1357 update();
1358} 1358}
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp
index ba4fd66..59f2aea 100644
--- a/core/launcher/desktop.cpp
+++ b/core/launcher/desktop.cpp
@@ -1,849 +1,849 @@
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 <syslog.h> 21#include <syslog.h>
22 22
23#include "desktop.h" 23#include "desktop.h"
24#include "info.h" 24#include "info.h"
25#include "launcher.h" 25#include "launcher.h"
26#include "qcopbridge.h" 26#include "qcopbridge.h"
27#include "shutdownimpl.h" 27#include "shutdownimpl.h"
28#include "startmenu.h" 28#include "startmenu.h"
29#include "taskbar.h" 29#include "taskbar.h"
30#include "transferserver.h" 30#include "transferserver.h"
31#include "irserver.h" 31#include "irserver.h"
32#include "packageslave.h" 32#include "packageslave.h"
33#include "screensaver.h" 33#include "screensaver.h"
34 34
35#include <qpe/applnk.h> 35#include <qpe/applnk.h>
36#include <qpe/mimetype.h> 36#include <qpe/mimetype.h>
37#include <qpe/password.h> 37#include <qpe/password.h>
38#include <qpe/config.h> 38#include <qpe/config.h>
39#include <qpe/power.h> 39#include <qpe/power.h>
40#include <qpe/timeconversion.h> 40#include <qpe/timeconversion.h>
41#include <qpe/qcopenvelope_qws.h> 41#include <qpe/qcopenvelope_qws.h>
42#include <qpe/network.h> 42#include <qpe/network.h>
43#include <qpe/global.h> 43#include <qpe/global.h>
44 44
45#if defined( QT_QWS_SHARP ) || defined( QT_QWS_IPAQ ) 45#if defined( QT_QWS_SL5XXX ) || defined( QT_QWS_IPAQ )
46#include <qpe/custom.h> 46#include <qpe/custom.h>
47#endif 47#endif
48 48
49#include <opie/odevice.h> 49#include <opie/odevice.h>
50 50
51#include <qgfx_qws.h> 51#include <qgfx_qws.h>
52#include <qmainwindow.h> 52#include <qmainwindow.h>
53#include <qmessagebox.h> 53#include <qmessagebox.h>
54#include <qtimer.h> 54#include <qtimer.h>
55#include <qwindowsystem_qws.h> 55#include <qwindowsystem_qws.h>
56 56
57#include <qvaluelist.h> 57#include <qvaluelist.h>
58 58
59#include <stdlib.h> 59#include <stdlib.h>
60#include <unistd.h> 60#include <unistd.h>
61#include <fcntl.h> 61#include <fcntl.h>
62 62
63 63
64using namespace Opie; 64using namespace Opie;
65 65
66class QCopKeyRegister 66class QCopKeyRegister
67{ 67{
68public: 68public:
69 QCopKeyRegister() : keyCode( 0 ) 69 QCopKeyRegister() : keyCode( 0 )
70 { } 70 { }
71 QCopKeyRegister( int k, const QCString &c, const QCString &m ) 71 QCopKeyRegister( int k, const QCString &c, const QCString &m )
72 : keyCode( k ), channel( c ), message( m ) 72 : keyCode( k ), channel( c ), message( m )
73 { } 73 { }
74 74
75 int getKeyCode() const 75 int getKeyCode() const
76 { 76 {
77 return keyCode; 77 return keyCode;
78 } 78 }
79 QCString getChannel() const 79 QCString getChannel() const
80 { 80 {
81 return channel; 81 return channel;
82 } 82 }
83 QCString getMessage() const 83 QCString getMessage() const
84 { 84 {
85 return message; 85 return message;
86 } 86 }
87 87
88private: 88private:
89 int keyCode; 89 int keyCode;
90 QCString channel, message; 90 QCString channel, message;
91}; 91};
92 92
93typedef QValueList<QCopKeyRegister> KeyRegisterList; 93typedef QValueList<QCopKeyRegister> KeyRegisterList;
94KeyRegisterList keyRegisterList; 94KeyRegisterList keyRegisterList;
95 95
96static Desktop* qpedesktop = 0; 96static Desktop* qpedesktop = 0;
97static int loggedin = 0; 97static int loggedin = 0;
98static void login( bool at_poweron ) 98static void login( bool at_poweron )
99{ 99{
100 if ( !loggedin ) { 100 if ( !loggedin ) {
101 Global::terminateBuiltin( "calibrate" ); 101 Global::terminateBuiltin( "calibrate" );
102 Password::authenticate( at_poweron ); 102 Password::authenticate( at_poweron );
103 loggedin = 1; 103 loggedin = 1;
104 QCopEnvelope e( "QPE/Desktop", "unlocked()" ); 104 QCopEnvelope e( "QPE/Desktop", "unlocked()" );
105 } 105 }
106} 106}
107 107
108bool Desktop::screenLocked() 108bool Desktop::screenLocked()
109{ 109{
110 return loggedin == 0; 110 return loggedin == 0;
111} 111}
112 112
113/* 113/*
114 Priority is number of alerts that are needed to pop up 114 Priority is number of alerts that are needed to pop up
115 alert. 115 alert.
116 */ 116 */
117class DesktopPowerAlerter : public QMessageBox 117class DesktopPowerAlerter : public QMessageBox
118{ 118{
119public: 119public:
120 DesktopPowerAlerter( QWidget *parent, const char *name = 0 ) 120 DesktopPowerAlerter( QWidget *parent, const char *name = 0 )
121 : QMessageBox( tr( "Battery Status" ), "Low Battery", 121 : QMessageBox( tr( "Battery Status" ), "Low Battery",
122 QMessageBox::Critical, 122 QMessageBox::Critical,
123 QMessageBox::Ok | QMessageBox::Default, 123 QMessageBox::Ok | QMessageBox::Default,
124 QMessageBox::NoButton, QMessageBox::NoButton, 124 QMessageBox::NoButton, QMessageBox::NoButton,
125 parent, name, FALSE ) 125 parent, name, FALSE )
126 { 126 {
127 currentPriority = INT_MAX; 127 currentPriority = INT_MAX;
128 alertCount = 0; 128 alertCount = 0;
129 } 129 }
130 130
131 void alert( const QString &text, int priority ); 131 void alert( const QString &text, int priority );
132 void hideEvent( QHideEvent * ); 132 void hideEvent( QHideEvent * );
133private: 133private:
134 int currentPriority; 134 int currentPriority;
135 int alertCount; 135 int alertCount;
136}; 136};
137 137
138void DesktopPowerAlerter::alert( const QString &text, int priority ) 138void DesktopPowerAlerter::alert( const QString &text, int priority )
139{ 139{
140 alertCount++; 140 alertCount++;
141 if ( alertCount < priority ) 141 if ( alertCount < priority )
142 return ; 142 return ;
143 if ( priority > currentPriority ) 143 if ( priority > currentPriority )
144 return ; 144 return ;
145 currentPriority = priority; 145 currentPriority = priority;
146 setText( text ); 146 setText( text );
147 show(); 147 show();
148} 148}
149 149
150 150
151void DesktopPowerAlerter::hideEvent( QHideEvent *e ) 151void DesktopPowerAlerter::hideEvent( QHideEvent *e )
152{ 152{
153 QMessageBox::hideEvent( e ); 153 QMessageBox::hideEvent( e );
154 alertCount = 0; 154 alertCount = 0;
155 currentPriority = INT_MAX; 155 currentPriority = INT_MAX;
156} 156}
157 157
158 158
159void DesktopApplication::switchLCD ( bool on ) 159void DesktopApplication::switchLCD ( bool on )
160{ 160{
161 if ( qApp ) { 161 if ( qApp ) {
162 DesktopApplication *dapp = (DesktopApplication *) qApp; 162 DesktopApplication *dapp = (DesktopApplication *) qApp;
163 163
164 if ( dapp-> m_screensaver ) { 164 if ( dapp-> m_screensaver ) {
165 if ( on ) { 165 if ( on ) {
166 dapp-> m_screensaver-> setDisplayState ( true ); 166 dapp-> m_screensaver-> setDisplayState ( true );
167 dapp-> m_screensaver-> setBacklight ( -3 ); 167 dapp-> m_screensaver-> setBacklight ( -3 );
168 } 168 }
169 else { 169 else {
170 dapp-> m_screensaver-> setDisplayState ( false ); 170 dapp-> m_screensaver-> setDisplayState ( false );
171 } 171 }
172 } 172 }
173 } 173 }
174} 174}
175 175
176 176
177DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType ) 177DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType )
178 : QPEApplication( argc, argv, appType ) 178 : QPEApplication( argc, argv, appType )
179{ 179{
180 m_ps = new PowerStatus; 180 m_ps = new PowerStatus;
181 m_ps_last = new PowerStatus; 181 m_ps_last = new PowerStatus;
182 pa = new DesktopPowerAlerter( 0 ); 182 pa = new DesktopPowerAlerter( 0 );
183 183
184 m_apm_timer = new QTimer ( this ); 184 m_apm_timer = new QTimer ( this );
185 connect ( m_apm_timer, SIGNAL( timeout ( )), this, SLOT( apmTimeout ( ))); 185 connect ( m_apm_timer, SIGNAL( timeout ( )), this, SLOT( apmTimeout ( )));
186 reloadPowerWarnSettings ( ); 186 reloadPowerWarnSettings ( );
187 187
188 m_last_button = 0; 188 m_last_button = 0;
189 m_button_timer = new QTimer ( ); 189 m_button_timer = new QTimer ( );
190 connect ( m_button_timer, SIGNAL( timeout ( )), this, SLOT( sendHeldAction ( ))); 190 connect ( m_button_timer, SIGNAL( timeout ( )), this, SLOT( sendHeldAction ( )));
191 191
192 channel = new QCopChannel( "QPE/System", this ); 192 channel = new QCopChannel( "QPE/System", this );
193 connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), 193 connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ),
194 this, SLOT( systemMessage( const QCString&, const QByteArray& ) ) ); 194 this, SLOT( systemMessage( const QCString&, const QByteArray& ) ) );
195 195
196 channel = new QCopChannel( "QPE/Launcher", this ); 196 channel = new QCopChannel( "QPE/Launcher", this );
197 connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), 197 connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ),
198 this, SLOT( launcherMessage( const QCString&, const QByteArray& ) ) ); 198 this, SLOT( launcherMessage( const QCString&, const QByteArray& ) ) );
199 199
200 m_screensaver = new OpieScreenSaver ( ); 200 m_screensaver = new OpieScreenSaver ( );
201 m_screensaver-> setInterval ( -1 ); 201 m_screensaver-> setInterval ( -1 );
202 QWSServer::setScreenSaver( m_screensaver ); 202 QWSServer::setScreenSaver( m_screensaver );
203 203
204 rereadVolumes(); 204 rereadVolumes();
205 connect( qApp, SIGNAL( volumeChanged( bool ) ), this, SLOT( rereadVolumes() ) ); 205 connect( qApp, SIGNAL( volumeChanged( bool ) ), this, SLOT( rereadVolumes() ) );
206 206
207 apmTimeout ( ); 207 apmTimeout ( );
208 208
209 grabKeyboard ( ); 209 grabKeyboard ( );
210} 210}
211 211
212 212
213DesktopApplication::~DesktopApplication() 213DesktopApplication::~DesktopApplication()
214{ 214{
215 ungrabKeyboard ( ); 215 ungrabKeyboard ( );
216 216
217 delete m_ps; 217 delete m_ps;
218 delete m_ps_last; 218 delete m_ps_last;
219 delete pa; 219 delete pa;
220} 220}
221 221
222void DesktopApplication::apmTimeout() 222void DesktopApplication::apmTimeout()
223{ 223{
224 qpedesktop-> checkMemory ( ); // in case no events are being generated 224 qpedesktop-> checkMemory ( ); // in case no events are being generated
225 225
226 *m_ps_last = *m_ps; 226 *m_ps_last = *m_ps;
227 *m_ps = PowerStatusManager::readStatus(); 227 *m_ps = PowerStatusManager::readStatus();
228 228
229 if ( m_ps-> acStatus ( ) != m_ps_last-> acStatus ( )) 229 if ( m_ps-> acStatus ( ) != m_ps_last-> acStatus ( ))
230 m_screensaver-> powerStatusChanged ( *m_ps ); 230 m_screensaver-> powerStatusChanged ( *m_ps );
231 231
232 if ( m_ps-> acStatus ( ) != PowerStatus::Online ) { 232 if ( m_ps-> acStatus ( ) != PowerStatus::Online ) {
233 int bat = m_ps-> batteryPercentRemaining ( ); 233 int bat = m_ps-> batteryPercentRemaining ( );
234 234
235 if ( bat < m_ps_last-> batteryPercentRemaining ( )) { 235 if ( bat < m_ps_last-> batteryPercentRemaining ( )) {
236 if ( bat <= m_powerCritical ) 236 if ( bat <= m_powerCritical )
237 pa->alert( tr( "Battery level is critical!\nKeep power off until power restored!" ), 1 ); 237 pa->alert( tr( "Battery level is critical!\nKeep power off until power restored!" ), 1 );
238 else if ( bat <= m_powerVeryLow ) 238 else if ( bat <= m_powerVeryLow )
239 pa->alert( tr( "Battery is running very low." ), 2 ); 239 pa->alert( tr( "Battery is running very low." ), 2 );
240 } 240 }
241 if ( m_ps-> backupBatteryStatus ( ) == PowerStatus::VeryLow ) 241 if ( m_ps-> backupBatteryStatus ( ) == PowerStatus::VeryLow )
242 pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 2 ); 242 pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 2 );
243 } 243 }
244} 244}
245 245
246 246
247void DesktopApplication::systemMessage( const QCString & msg, const QByteArray & data ) 247void DesktopApplication::systemMessage( const QCString & msg, const QByteArray & data )
248{ 248{
249 QDataStream stream ( data, IO_ReadOnly ); 249 QDataStream stream ( data, IO_ReadOnly );
250 250
251 if ( msg == "setScreenSaverInterval(int)" ) { 251 if ( msg == "setScreenSaverInterval(int)" ) {
252 int time; 252 int time;
253 stream >> time; 253 stream >> time;
254 m_screensaver-> setInterval( time ); 254 m_screensaver-> setInterval( time );
255 } 255 }
256 else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { 256 else if ( msg == "setScreenSaverIntervals(int,int,int)" ) {
257 int t1, t2, t3; 257 int t1, t2, t3;
258 stream >> t1 >> t2 >> t3; 258 stream >> t1 >> t2 >> t3;
259 m_screensaver-> setIntervals( t1, t2, t3 ); 259 m_screensaver-> setIntervals( t1, t2, t3 );
260 } 260 }
261 else if ( msg == "setBacklight(int)" ) { 261 else if ( msg == "setBacklight(int)" ) {
262 int bright; 262 int bright;
263 stream >> bright; 263 stream >> bright;
264 m_screensaver-> setBacklight( bright ); 264 m_screensaver-> setBacklight( bright );
265 } 265 }
266 else if ( msg == "setScreenSaverMode(int)" ) { 266 else if ( msg == "setScreenSaverMode(int)" ) {
267 int mode; 267 int mode;
268 stream >> mode; 268 stream >> mode;
269 m_screensaver-> setMode ( mode ); 269 m_screensaver-> setMode ( mode );
270 } 270 }
271 else if ( msg == "reloadPowerWarnSettings()" ) { 271 else if ( msg == "reloadPowerWarnSettings()" ) {
272 reloadPowerWarnSettings(); 272 reloadPowerWarnSettings();
273 } 273 }
274 else if ( msg == "setDisplayState(int)" ) { 274 else if ( msg == "setDisplayState(int)" ) {
275 int state; 275 int state;
276 stream >> state; 276 stream >> state;
277 m_screensaver-> setDisplayState ( state != 0 ); 277 m_screensaver-> setDisplayState ( state != 0 );
278 } 278 }
279 else if ( msg == "suspend()" ) { 279 else if ( msg == "suspend()" ) {
280 emit power(); 280 emit power();
281 } 281 }
282 else if ( msg == "sendBusinessCard()" ) { 282 else if ( msg == "sendBusinessCard()" ) {
283 QString card = ::getenv ( "HOME" ); 283 QString card = ::getenv ( "HOME" );
284 card += "/Applications/addressbook/businesscard.vcf"; 284 card += "/Applications/addressbook/businesscard.vcf";
285 285
286 if ( QFile::exists( card ) ) { 286 if ( QFile::exists( card ) ) {
287 QCopEnvelope e ( "QPE/Obex", "send(QString,QString,QString)" ); 287 QCopEnvelope e ( "QPE/Obex", "send(QString,QString,QString)" );
288 QString mimetype = "text/x-vCard"; 288 QString mimetype = "text/x-vCard";
289 e << tr( "business card" ) << card << mimetype; 289 e << tr( "business card" ) << card << mimetype;
290 } 290 }
291 } 291 }
292} 292}
293 293
294void DesktopApplication::reloadPowerWarnSettings ( ) 294void DesktopApplication::reloadPowerWarnSettings ( )
295{ 295{
296 Config cfg ( "apm" ); 296 Config cfg ( "apm" );
297 cfg. setGroup ( "Warnings" ); 297 cfg. setGroup ( "Warnings" );
298 298
299 int iv = cfg. readNumEntry ( "checkinterval", 10000 ); 299 int iv = cfg. readNumEntry ( "checkinterval", 10000 );
300 300
301 m_apm_timer-> stop ( ); 301 m_apm_timer-> stop ( );
302 if ( iv ) 302 if ( iv )
303 m_apm_timer-> start ( iv ); 303 m_apm_timer-> start ( iv );
304 304
305 m_powerVeryLow = cfg. readNumEntry ( "powerverylow", 10 ); 305 m_powerVeryLow = cfg. readNumEntry ( "powerverylow", 10 );
306 m_powerCritical = cfg. readNumEntry ( "powervcritical", 5 ); 306 m_powerCritical = cfg. readNumEntry ( "powervcritical", 5 );
307} 307}
308 308
309 309
310enum MemState { Unknown, VeryLow, Low, Normal } memstate = Unknown; 310enum MemState { Unknown, VeryLow, Low, Normal } memstate = Unknown;
311 311
312 312
313void DesktopApplication::launcherMessage( const QCString & msg, const QByteArray & data ) 313void DesktopApplication::launcherMessage( const QCString & msg, const QByteArray & data )
314{ 314{
315 QDataStream stream ( data, IO_ReadOnly ); 315 QDataStream stream ( data, IO_ReadOnly );
316 316
317 if ( msg == "deviceButton(int,int,int)" ) { 317 if ( msg == "deviceButton(int,int,int)" ) {
318 int keycode, press, autoRepeat; 318 int keycode, press, autoRepeat;
319 stream >> keycode >> press >> autoRepeat; 319 stream >> keycode >> press >> autoRepeat;
320 320
321 const ODeviceButton *db = ODevice::inst ( )-> buttonForKeycode ( keycode ); 321 const ODeviceButton *db = ODevice::inst ( )-> buttonForKeycode ( keycode );
322 322
323 if ( db ) 323 if ( db )
324 checkButtonAction ( db, keycode, press, autoRepeat ); 324 checkButtonAction ( db, keycode, press, autoRepeat );
325 } 325 }
326 else if ( msg == "keyRegister(int,QCString,QCString)" ) { 326 else if ( msg == "keyRegister(int,QCString,QCString)" ) {
327 int k; 327 int k;
328 QCString c, m; 328 QCString c, m;
329 stream >> k >> c >> m; 329 stream >> k >> c >> m;
330 330
331 keyRegisterList.append ( QCopKeyRegister ( k, c, m )); 331 keyRegisterList.append ( QCopKeyRegister ( k, c, m ));
332 } 332 }
333} 333}
334 334
335void DesktopApplication::sendHeldAction ( ) 335void DesktopApplication::sendHeldAction ( )
336{ 336{
337 if ( m_last_button ) { 337 if ( m_last_button ) {
338 m_last_button-> heldAction ( ). send ( ); 338 m_last_button-> heldAction ( ). send ( );
339 m_last_button = 0; 339 m_last_button = 0;
340 } 340 }
341} 341}
342 342
343 343
344 344
345void DesktopApplication::checkButtonAction ( const ODeviceButton *db, int /*keycode*/, bool press, bool autoRepeat ) 345void DesktopApplication::checkButtonAction ( const ODeviceButton *db, int /*keycode*/, bool press, bool autoRepeat )
346 { 346 {
347 if ( db ) { 347 if ( db ) {
348 if ( !press && !autoRepeat && m_button_timer-> isActive ( )) { 348 if ( !press && !autoRepeat && m_button_timer-> isActive ( )) {
349 m_button_timer-> stop ( ); 349 m_button_timer-> stop ( );
350 if ( !db-> pressedAction ( ). channel ( ). isEmpty ( )) { 350 if ( !db-> pressedAction ( ). channel ( ). isEmpty ( )) {
351 db-> pressedAction ( ). send ( ); 351 db-> pressedAction ( ). send ( );
352 } 352 }
353 } 353 }
354 else if ( press && !autoRepeat ) { 354 else if ( press && !autoRepeat ) {
355 m_button_timer-> stop ( ); 355 m_button_timer-> stop ( );
356 356
357 if ( !db-> heldAction ( ). channel ( ). isEmpty ( )) { 357 if ( !db-> heldAction ( ). channel ( ). isEmpty ( )) {
358 m_last_button = db; 358 m_last_button = db;
359 m_button_timer-> start ( ODevice::inst ( )-> buttonHoldTime ( ), true ); 359 m_button_timer-> start ( ODevice::inst ( )-> buttonHoldTime ( ), true );
360 } 360 }
361 } 361 }
362 } 362 }
363} 363}
364 364
365bool DesktopApplication::eventFilter ( QObject *o, QEvent *e ) 365bool DesktopApplication::eventFilter ( QObject *o, QEvent *e )
366{ 366{
367 if ( e-> type ( ) == QEvent::KeyPress || e-> type ( ) == QEvent::KeyRelease ) { 367 if ( e-> type ( ) == QEvent::KeyPress || e-> type ( ) == QEvent::KeyRelease ) {
368 QKeyEvent *ke = (QKeyEvent *) e; 368 QKeyEvent *ke = (QKeyEvent *) e;
369 369
370 const ODeviceButton *db = ODevice::inst ( )-> buttonForKeycode ( ke-> key ( )); 370 const ODeviceButton *db = ODevice::inst ( )-> buttonForKeycode ( ke-> key ( ));
371 371
372 if ( db ) { 372 if ( db ) {
373 checkButtonAction ( db, ke-> key ( ), e-> type ( ) == QEvent::KeyPress, ke-> isAutoRepeat ( )); 373 checkButtonAction ( db, ke-> key ( ), e-> type ( ) == QEvent::KeyPress, ke-> isAutoRepeat ( ));
374 return true; 374 return true;
375 } 375 }
376 } 376 }
377 return QPEApplication::eventFilter ( o, e ); 377 return QPEApplication::eventFilter ( o, e );
378} 378}
379 379
380#ifdef Q_WS_QWS 380#ifdef Q_WS_QWS
381 381
382bool DesktopApplication::qwsEventFilter( QWSEvent *e ) 382bool DesktopApplication::qwsEventFilter( QWSEvent *e )
383{ 383{
384 qpedesktop->checkMemory(); 384 qpedesktop->checkMemory();
385 385
386 if ( e->type == QWSEvent::Key ) { 386 if ( e->type == QWSEvent::Key ) {
387 QWSKeyEvent * ke = (QWSKeyEvent *) e; 387 QWSKeyEvent * ke = (QWSKeyEvent *) e;
388 ushort keycode = ke-> simpleData. keycode; 388 ushort keycode = ke-> simpleData. keycode;
389 389
390 if ( !loggedin && keycode != Key_F34 ) 390 if ( !loggedin && keycode != Key_F34 )
391 return true; 391 return true;
392 392
393 bool press = ke-> simpleData. is_press; 393 bool press = ke-> simpleData. is_press;
394 bool autoRepeat = ke-> simpleData. is_auto_repeat; 394 bool autoRepeat = ke-> simpleData. is_auto_repeat;
395 395
396 if ( !keyboardGrabbed ( )) { 396 if ( !keyboardGrabbed ( )) {
397 // app that registers key/message to be sent back to the app, when it doesn't have focus, 397 // app that registers key/message to be sent back to the app, when it doesn't have focus,
398 // when user presses key, unless keyboard has been requested from app. 398 // when user presses key, unless keyboard has been requested from app.
399 // will not send multiple repeats if user holds key 399 // will not send multiple repeats if user holds key
400 // i.e. one shot 400 // i.e. one shot
401 401
402 if ( keycode != 0 && press && !autoRepeat ) { 402 if ( keycode != 0 && press && !autoRepeat ) {
403 for ( KeyRegisterList::Iterator it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) { 403 for ( KeyRegisterList::Iterator it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) {
404 if (( *it ). getKeyCode ( ) == keycode ) { 404 if (( *it ). getKeyCode ( ) == keycode ) {
405 QCopEnvelope (( *it ). getChannel ( ), ( *it ). getMessage ( )); 405 QCopEnvelope (( *it ). getChannel ( ), ( *it ). getMessage ( ));
406 return true; 406 return true;
407 } 407 }
408 } 408 }
409 } 409 }
410 } 410 }
411 411
412 if ( keycode == HardKey_Suspend ) { 412 if ( keycode == HardKey_Suspend ) {
413 if ( press ) 413 if ( press )
414 emit power ( ); 414 emit power ( );
415 return true; 415 return true;
416 } 416 }
417 else if ( keycode == HardKey_Backlight ) { 417 else if ( keycode == HardKey_Backlight ) {
418 if ( press ) 418 if ( press )
419 emit backlight ( ); 419 emit backlight ( );
420 return true; 420 return true;
421 } 421 }
422 else if ( keycode == Key_F32 ) { 422 else if ( keycode == Key_F32 ) {
423 if ( press ) 423 if ( press )
424 QCopEnvelope e( "QPE/Desktop", "startSync()" ); 424 QCopEnvelope e( "QPE/Desktop", "startSync()" );
425 return true; 425 return true;
426 } 426 }
427 else if ( keycode == Key_F31 && !ke-> simpleData. modifiers ) { // Symbol Key -> show Unicode IM 427 else if ( keycode == Key_F31 && !ke-> simpleData. modifiers ) { // Symbol Key -> show Unicode IM
428 if ( press ) 428 if ( press )
429 emit symbol ( ); 429 emit symbol ( );
430 return true; 430 return true;
431 } 431 }
432 else if ( keycode == Key_NumLock ) { 432 else if ( keycode == Key_NumLock ) {
433 if ( press ) 433 if ( press )
434 emit numLockStateToggle ( ); 434 emit numLockStateToggle ( );
435 } 435 }
436 else if ( keycode == Key_CapsLock ) { 436 else if ( keycode == Key_CapsLock ) {
437 if ( press ) 437 if ( press )
438 emit capsLockStateToggle(); 438 emit capsLockStateToggle();
439 } 439 }
440 if (( press && !autoRepeat ) || ( !press && autoRepeat )) { 440 if (( press && !autoRepeat ) || ( !press && autoRepeat )) {
441 if ( m_keyclick_sound ) 441 if ( m_keyclick_sound )
442 ODevice::inst ( )-> keySound ( ); 442 ODevice::inst ( )-> keySound ( );
443 } 443 }
444 } 444 }
445 else if ( e-> type == QWSEvent::Mouse ) { 445 else if ( e-> type == QWSEvent::Mouse ) {
446 QWSMouseEvent * me = ( QWSMouseEvent * ) e; 446 QWSMouseEvent * me = ( QWSMouseEvent * ) e;
447 static bool up = true; 447 static bool up = true;
448 448
449 if ( me-> simpleData. state & LeftButton ) { 449 if ( me-> simpleData. state & LeftButton ) {
450 if ( up ) { 450 if ( up ) {
451 up = false; 451 up = false;
452 if ( m_screentap_sound ) 452 if ( m_screentap_sound )
453 ODevice::inst ( ) -> touchSound ( ); 453 ODevice::inst ( ) -> touchSound ( );
454 } 454 }
455 } 455 }
456 else { 456 else {
457 up = true; 457 up = true;
458 } 458 }
459 } 459 }
460 460
461 return QPEApplication::qwsEventFilter ( e ); 461 return QPEApplication::qwsEventFilter ( e );
462} 462}
463#endif 463#endif
464 464
465 465
466 466
467#if defined(QPE_HAVE_MEMALERTER) 467#if defined(QPE_HAVE_MEMALERTER)
468QPE_MEMALERTER_IMPL 468QPE_MEMALERTER_IMPL
469#endif 469#endif
470 470
471//=========================================================================== 471//===========================================================================
472 472
473Desktop::Desktop() : 473Desktop::Desktop() :
474 QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), 474 QWidget( 0, 0, WStyle_Tool | WStyle_Customize ),
475 qcopBridge( 0 ), 475 qcopBridge( 0 ),
476 transferServer( 0 ), 476 transferServer( 0 ),
477 packageSlave( 0 ) 477 packageSlave( 0 )
478{ 478{
479 qpedesktop = this; 479 qpedesktop = this;
480 480
481 // bg = new Info( this ); 481 // bg = new Info( this );
482 tb = new TaskBar; 482 tb = new TaskBar;
483 483
484 launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader ); 484 launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader );
485 485
486 connect( launcher, SIGNAL( busy() ), tb, SLOT( startWait() ) ); 486 connect( launcher, SIGNAL( busy() ), tb, SLOT( startWait() ) );
487 connect( launcher, SIGNAL( notBusy( const QString& ) ), tb, SLOT( stopWait( const QString& ) ) ); 487 connect( launcher, SIGNAL( notBusy( const QString& ) ), tb, SLOT( stopWait( const QString& ) ) );
488 488
489 int displayw = qApp->desktop() ->width(); 489 int displayw = qApp->desktop() ->width();
490 int displayh = qApp->desktop() ->height(); 490 int displayh = qApp->desktop() ->height();
491 491
492 492
493 QSize sz = tb->sizeHint(); 493 QSize sz = tb->sizeHint();
494 494
495 setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); 495 setGeometry( 0, displayh - sz.height(), displayw, sz.height() );
496 tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); 496 tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() );
497 497
498 tb->show(); 498 tb->show();
499 launcher->showMaximized(); 499 launcher->showMaximized();
500 launcher->show(); 500 launcher->show();
501 launcher->raise(); 501 launcher->raise();
502#if defined(QPE_HAVE_MEMALERTER) 502#if defined(QPE_HAVE_MEMALERTER)
503 503
504 initMemalerter(); 504 initMemalerter();
505#endif 505#endif
506 // start services 506 // start services
507 startTransferServer(); 507 startTransferServer();
508 ( void ) new IrServer( this ); 508 ( void ) new IrServer( this );
509 509
510 packageSlave = new PackageSlave( this ); 510 packageSlave = new PackageSlave( this );
511 511
512 qApp->installEventFilter( this ); 512 qApp->installEventFilter( this );
513 513
514 qApp-> setMainWidget ( launcher ); 514 qApp-> setMainWidget ( launcher );
515} 515}
516 516
517void Desktop::show() 517void Desktop::show()
518{ 518{
519 login( TRUE ); 519 login( TRUE );
520 QWidget::show(); 520 QWidget::show();
521} 521}
522 522
523Desktop::~Desktop() 523Desktop::~Desktop()
524{ 524{
525 delete launcher; 525 delete launcher;
526 delete tb; 526 delete tb;
527 delete qcopBridge; 527 delete qcopBridge;
528 delete transferServer; 528 delete transferServer;
529} 529}
530 530
531bool Desktop::recoverMemory() 531bool Desktop::recoverMemory()
532{ 532{
533 return tb->recoverMemory(); 533 return tb->recoverMemory();
534} 534}
535 535
536void Desktop::checkMemory() 536void Desktop::checkMemory()
537{ 537{
538#if defined(QPE_HAVE_MEMALERTER) 538#if defined(QPE_HAVE_MEMALERTER)
539 static bool ignoreNormal = FALSE; 539 static bool ignoreNormal = FALSE;
540 static bool existingMessage = FALSE; 540 static bool existingMessage = FALSE;
541 541
542 if ( existingMessage ) 542 if ( existingMessage )
543 return ; // don't show a second message while still on first 543 return ; // don't show a second message while still on first
544 544
545 existingMessage = TRUE; 545 existingMessage = TRUE;
546 switch ( memstate ) { 546 switch ( memstate ) {
547 case Unknown: 547 case Unknown:
548 break; 548 break;
549 case Low: 549 case Low:
550 memstate = Unknown; 550 memstate = Unknown;
551 if ( recoverMemory() ) 551 if ( recoverMemory() )
552 ignoreNormal = TRUE; 552 ignoreNormal = TRUE;
553 else 553 else
554 QMessageBox::warning( 0 , "Memory Status", 554 QMessageBox::warning( 0 , "Memory Status",
555 "The memory smacks of shortage. \n" 555 "The memory smacks of shortage. \n"
556 "Please save data. " ); 556 "Please save data. " );
557 break; 557 break;
558 case Normal: 558 case Normal:
559 memstate = Unknown; 559 memstate = Unknown;
560 if ( ignoreNormal ) 560 if ( ignoreNormal )
561 ignoreNormal = FALSE; 561 ignoreNormal = FALSE;
562 // else 562 // else
563 // QMessageBox::information ( 0 , "Memory Status", 563 // QMessageBox::information ( 0 , "Memory Status",
564 // "There is enough memory again." ); 564 // "There is enough memory again." );
565 break; 565 break;
566 case VeryLow: 566 case VeryLow:
567 memstate = Unknown; 567 memstate = Unknown;
568 QMessageBox::critical( 0 , "Memory Status", 568 QMessageBox::critical( 0 , "Memory Status",
569 "The memory is very low. \n" 569 "The memory is very low. \n"
570 "Please end this application \n" 570 "Please end this application \n"
571 "immediately." ); 571 "immediately." );
572 recoverMemory(); 572 recoverMemory();
573 } 573 }
574 existingMessage = FALSE; 574 existingMessage = FALSE;
575#endif 575#endif
576} 576}
577 577
578static bool isVisibleWindow( int wid ) 578static bool isVisibleWindow( int wid )
579{ 579{
580#ifdef QWS 580#ifdef QWS
581 const QList<QWSWindow> &list = qwsServer->clientWindows(); 581 const QList<QWSWindow> &list = qwsServer->clientWindows();
582 QWSWindow* w; 582 QWSWindow* w;
583 for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) { 583 for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) {
584 if ( w->winId() == wid ) 584 if ( w->winId() == wid )
585 return !w->isFullyObscured(); 585 return !w->isFullyObscured();
586 } 586 }
587#endif 587#endif
588 return FALSE; 588 return FALSE;
589} 589}
590 590
591static bool hasVisibleWindow( const QString& clientname ) 591static bool hasVisibleWindow( const QString& clientname )
592{ 592{
593#ifdef QWS 593#ifdef QWS
594 const QList<QWSWindow> &list = qwsServer->clientWindows(); 594 const QList<QWSWindow> &list = qwsServer->clientWindows();
595 QWSWindow* w; 595 QWSWindow* w;
596 for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) { 596 for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) {
597 if ( w->client() ->identity() == clientname && !w->isFullyObscured() ) 597 if ( w->client() ->identity() == clientname && !w->isFullyObscured() )
598 return TRUE; 598 return TRUE;
599 } 599 }
600#endif 600#endif
601 return FALSE; 601 return FALSE;
602} 602}
603 603
604 604
605void Desktop::executeOrModify( const QString& appLnkFile ) 605void Desktop::executeOrModify( const QString& appLnkFile )
606{ 606{
607 AppLnk lnk( MimeType::appsFolderName() + "/" + appLnkFile ); 607 AppLnk lnk( MimeType::appsFolderName() + "/" + appLnkFile );
608 if ( lnk.isValid() ) { 608 if ( lnk.isValid() ) {
609 QCString app = lnk.exec().utf8(); 609 QCString app = lnk.exec().utf8();
610 Global::terminateBuiltin( "calibrate" ); 610 Global::terminateBuiltin( "calibrate" );
611 if ( QCopChannel::isRegistered( "QPE/Application/" + app ) ) { 611 if ( QCopChannel::isRegistered( "QPE/Application/" + app ) ) {
612 // MRUList::addTask( &lnk ); 612 // MRUList::addTask( &lnk );
613 if ( hasVisibleWindow( app ) ) 613 if ( hasVisibleWindow( app ) )
614 QCopChannel::send( "QPE/Application/" + app, "nextView()" ); 614 QCopChannel::send( "QPE/Application/" + app, "nextView()" );
615 else 615 else
616 QCopChannel::send( "QPE/Application/" + app, "raise()" ); 616 QCopChannel::send( "QPE/Application/" + app, "raise()" );
617 } 617 }
618 else { 618 else {
619 lnk.execute(); 619 lnk.execute();
620 } 620 }
621 } 621 }
622} 622}
623 623
624// autoStarts apps on resume and start 624// autoStarts apps on resume and start
625void Desktop::execAutoStart() 625void Desktop::execAutoStart()
626{ 626{
627 QString appName; 627 QString appName;
628 int delay; 628 int delay;
629 QDateTime now = QDateTime::currentDateTime(); 629 QDateTime now = QDateTime::currentDateTime();
630 Config cfg( "autostart" ); 630 Config cfg( "autostart" );
631 cfg.setGroup( "AutoStart" ); 631 cfg.setGroup( "AutoStart" );
632 appName = cfg.readEntry( "Apps", "" ); 632 appName = cfg.readEntry( "Apps", "" );
633 delay = ( cfg.readEntry( "Delay", "0" ) ).toInt(); 633 delay = ( cfg.readEntry( "Delay", "0" ) ).toInt();
634 // If the time between suspend and resume was longer then the 634 // If the time between suspend and resume was longer then the
635 // value saved as delay, start the app 635 // value saved as delay, start the app
636 if ( suspendTime.secsTo( now ) >= ( delay * 60 ) && !appName.isEmpty() ) { 636 if ( suspendTime.secsTo( now ) >= ( delay * 60 ) && !appName.isEmpty() ) {
637 QCopEnvelope e( "QPE/System", "execute(QString)" ); 637 QCopEnvelope e( "QPE/System", "execute(QString)" );
638 e << QString( appName ); 638 e << QString( appName );
639 } 639 }
640} 640}
641 641
642#if defined(QPE_HAVE_TOGGLELIGHT) 642#if defined(QPE_HAVE_TOGGLELIGHT)
643#include <qpe/config.h> 643#include <qpe/config.h>
644 644
645#include <sys/ioctl.h> 645#include <sys/ioctl.h>
646#include <sys/types.h> 646#include <sys/types.h>
647#include <fcntl.h> 647#include <fcntl.h>
648#include <unistd.h> 648#include <unistd.h>
649#include <errno.h> 649#include <errno.h>
650#include <linux/ioctl.h> 650#include <linux/ioctl.h>
651#include <time.h> 651#include <time.h>
652#endif 652#endif
653 653
654 654
655void Desktop::togglePower() 655void Desktop::togglePower()
656{ 656{
657 static bool excllock = false; 657 static bool excllock = false;
658 658
659 qDebug ( "togglePower (locked == %d)", excllock ? 1 : 0 ); 659 qDebug ( "togglePower (locked == %d)", excllock ? 1 : 0 );
660 660
661 if ( excllock ) 661 if ( excllock )
662 return ; 662 return ;
663 663
664 excllock = true; 664 excllock = true;
665 665
666 bool wasloggedin = loggedin; 666 bool wasloggedin = loggedin;
667 loggedin = 0; 667 loggedin = 0;
668 suspendTime = QDateTime::currentDateTime(); 668 suspendTime = QDateTime::currentDateTime();
669 669
670#ifdef QWS 670#ifdef QWS
671 671
672 if ( Password::needToAuthenticate ( true ) && qt_screen ) { 672 if ( Password::needToAuthenticate ( true ) && qt_screen ) {
673 // Should use a big black window instead. 673 // Should use a big black window instead.
674 // But this would not show up fast enough 674 // But this would not show up fast enough
675 QGfx *g = qt_screen-> screenGfx ( ); 675 QGfx *g = qt_screen-> screenGfx ( );
676 g-> fillRect ( 0, 0, qt_screen-> width ( ), qt_screen-> height ( )); 676 g-> fillRect ( 0, 0, qt_screen-> width ( ), qt_screen-> height ( ));
677 delete g; 677 delete g;
678 } 678 }
679#endif 679#endif
680 680
681 ODevice::inst ( )-> suspend ( ); 681 ODevice::inst ( )-> suspend ( );
682 682
683 DesktopApplication::switchLCD ( true ); // force LCD on without slow qcop call 683 DesktopApplication::switchLCD ( true ); // force LCD on without slow qcop call
684 QWSServer::screenSaverActivate ( false ); 684 QWSServer::screenSaverActivate ( false );
685 685
686 { 686 {
687 QCopEnvelope( "QPE/Card", "mtabChanged()" ); // might have changed while asleep 687 QCopEnvelope( "QPE/Card", "mtabChanged()" ); // might have changed while asleep
688 } 688 }
689 689
690 if ( wasloggedin ) 690 if ( wasloggedin )
691 login ( true ); 691 login ( true );
692 692
693 execAutoStart(); 693 execAutoStart();
694 //qcopBridge->closeOpenConnections(); 694 //qcopBridge->closeOpenConnections();
695 695
696 excllock = false; 696 excllock = false;
697} 697}
698 698
699void Desktop::toggleLight() 699void Desktop::toggleLight()
700{ 700{
701 QCopEnvelope e( "QPE/System", "setBacklight(int)" ); 701 QCopEnvelope e( "QPE/System", "setBacklight(int)" );
702 e << -2; // toggle 702 e << -2; // toggle
703} 703}
704 704
705void Desktop::toggleSymbolInput() 705void Desktop::toggleSymbolInput()
706{ 706{
707 tb->toggleSymbolInput(); 707 tb->toggleSymbolInput();
708} 708}
709 709
710void Desktop::toggleNumLockState() 710void Desktop::toggleNumLockState()
711{ 711{
712 tb->toggleNumLockState(); 712 tb->toggleNumLockState();
713} 713}
714 714
715void Desktop::toggleCapsLockState() 715void Desktop::toggleCapsLockState()
716{ 716{
717 tb->toggleCapsLockState(); 717 tb->toggleCapsLockState();
718} 718}
719 719
720void Desktop::styleChange( QStyle &s ) 720void Desktop::styleChange( QStyle &s )
721{ 721{
722 QWidget::styleChange( s ); 722 QWidget::styleChange( s );
723 int displayw = qApp->desktop() ->width(); 723 int displayw = qApp->desktop() ->width();
724 int displayh = qApp->desktop() ->height(); 724 int displayh = qApp->desktop() ->height();
725 725
726 QSize sz = tb->sizeHint(); 726 QSize sz = tb->sizeHint();
727 727
728 tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); 728 tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() );
729} 729}
730 730
731void DesktopApplication::shutdown() 731void DesktopApplication::shutdown()
732{ 732{
733 if ( type() != GuiServer ) 733 if ( type() != GuiServer )
734 return ; 734 return ;
735 ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); 735 ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose );
736 connect( sd, SIGNAL( shutdown( ShutdownImpl::Type ) ), 736 connect( sd, SIGNAL( shutdown( ShutdownImpl::Type ) ),
737 this, SLOT( shutdown( ShutdownImpl::Type ) ) ); 737 this, SLOT( shutdown( ShutdownImpl::Type ) ) );
738 sd->showMaximized(); 738 sd->showMaximized();
739} 739}
740 740
741void DesktopApplication::shutdown( ShutdownImpl::Type t ) 741void DesktopApplication::shutdown( ShutdownImpl::Type t )
742{ 742{
743 char *opt = 0; 743 char *opt = 0;
744 744
745 switch ( t ) { 745 switch ( t ) {
746 case ShutdownImpl::ShutdownSystem: 746 case ShutdownImpl::ShutdownSystem:
747 opt = "-h"; 747 opt = "-h";
748 // fall through 748 // fall through
749 case ShutdownImpl::RebootSystem: 749 case ShutdownImpl::RebootSystem:
750 if ( opt == 0 ) 750 if ( opt == 0 )
751 opt = "-r"; 751 opt = "-r";
752 752
753 if ( execl( "/sbin/shutdown", "shutdown", opt, "now", ( void* ) 0) < 0 ) 753 if ( execl( "/sbin/shutdown", "shutdown", opt, "now", ( void* ) 0) < 0 )
754 perror("shutdown"); 754 perror("shutdown");
755 // ::syslog ( LOG_ERR, "Erroring execing shutdown\n" ); 755 // ::syslog ( LOG_ERR, "Erroring execing shutdown\n" );
756 756
757 break; 757 break;
758 case ShutdownImpl::RestartDesktop: 758 case ShutdownImpl::RestartDesktop:
759 restart(); 759 restart();
760 break; 760 break;
761 case ShutdownImpl::TerminateDesktop: 761 case ShutdownImpl::TerminateDesktop:
762 prepareForTermination( FALSE ); 762 prepareForTermination( FALSE );
763 763
764 // This is a workaround for a Qt bug 764 // This is a workaround for a Qt bug
765 // clipboard applet has to stop its poll timer, or Qt/E 765 // clipboard applet has to stop its poll timer, or Qt/E
766 // will hang on quit() right before it emits aboutToQuit() 766 // will hang on quit() right before it emits aboutToQuit()
767 emit aboutToQuit ( ); 767 emit aboutToQuit ( );
768 768
769 quit(); 769 quit();
770 break; 770 break;
771 } 771 }
772} 772}
773 773
774void DesktopApplication::restart() 774void DesktopApplication::restart()
775{ 775{
776 prepareForTermination( TRUE ); 776 prepareForTermination( TRUE );
777 777
778#ifdef Q_WS_QWS 778#ifdef Q_WS_QWS
779 779
780 for ( int fd = 3; fd < 100; fd++ ) 780 for ( int fd = 3; fd < 100; fd++ )
781 close( fd ); 781 close( fd );
782#if defined(QT_DEMO_SINGLE_FLOPPY) 782#if defined(QT_DEMO_SINGLE_FLOPPY)
783 783
784 execl( "/sbin/init", "qpe", 0 ); 784 execl( "/sbin/init", "qpe", 0 );
785#elif defined(QT_QWS_CASSIOPEIA) 785#elif defined(QT_QWS_CASSIOPEIA)
786 786
787 execl( "/bin/sh", "sh", 0 ); 787 execl( "/bin/sh", "sh", 0 );
788#else 788#else
789 789
790 execl( ( qpeDir() + "/bin/qpe" ).latin1(), "qpe", 0 ); 790 execl( ( qpeDir() + "/bin/qpe" ).latin1(), "qpe", 0 );
791#endif 791#endif
792 792
793 exit( 1 ); 793 exit( 1 );
794#endif 794#endif
795} 795}
796 796
797void Desktop::startTransferServer() 797void Desktop::startTransferServer()
798{ 798{
799 // start qcop bridge server 799 // start qcop bridge server
800 qcopBridge = new QCopBridge( 4243 ); 800 qcopBridge = new QCopBridge( 4243 );
801 if ( !qcopBridge->ok() ) { 801 if ( !qcopBridge->ok() ) {
802 delete qcopBridge; 802 delete qcopBridge;
803 qcopBridge = 0; 803 qcopBridge = 0;
804 } 804 }
805 // start transfer server 805 // start transfer server
806 transferServer = new TransferServer( 4242 ); 806 transferServer = new TransferServer( 4242 );
807 if ( !transferServer->ok() ) { 807 if ( !transferServer->ok() ) {
808 delete transferServer; 808 delete transferServer;
809 transferServer = 0; 809 transferServer = 0;
810 } 810 }
811 if ( !transferServer || !qcopBridge ) 811 if ( !transferServer || !qcopBridge )
812 startTimer( 2000 ); 812 startTimer( 2000 );
813} 813}
814 814
815void Desktop::timerEvent( QTimerEvent *e ) 815void Desktop::timerEvent( QTimerEvent *e )
816{ 816{
817 killTimer( e->timerId() ); 817 killTimer( e->timerId() );
818 startTransferServer(); 818 startTransferServer();
819} 819}
820 820
821void Desktop::terminateServers() 821void Desktop::terminateServers()
822{ 822{
823 delete transferServer; 823 delete transferServer;
824 delete qcopBridge; 824 delete qcopBridge;
825 transferServer = 0; 825 transferServer = 0;
826 qcopBridge = 0; 826 qcopBridge = 0;
827} 827}
828 828
829void DesktopApplication::rereadVolumes() 829void DesktopApplication::rereadVolumes()
830{ 830{
831 Config cfg( "qpe" ); 831 Config cfg( "qpe" );
832 cfg. setGroup ( "Volume" ); 832 cfg. setGroup ( "Volume" );
833 833
834 m_screentap_sound = cfg. readBoolEntry ( "TouchSound" ); 834 m_screentap_sound = cfg. readBoolEntry ( "TouchSound" );
835 m_keyclick_sound = cfg. readBoolEntry ( "KeySound" ); 835 m_keyclick_sound = cfg. readBoolEntry ( "KeySound" );
836 m_alarm_sound = cfg. readBoolEntry ( "AlarmSound" ); 836 m_alarm_sound = cfg. readBoolEntry ( "AlarmSound" );
837} 837}
838 838
839void DesktopApplication::soundAlarm() 839void DesktopApplication::soundAlarm()
840{ 840{
841 if ( me ( )-> m_alarm_sound ) 841 if ( me ( )-> m_alarm_sound )
842 ODevice::inst ( )-> alarmSound ( ); 842 ODevice::inst ( )-> alarmSound ( );
843} 843}
844 844
845DesktopApplication *DesktopApplication::me ( ) 845DesktopApplication *DesktopApplication::me ( )
846{ 846{
847 return (DesktopApplication *) qApp; 847 return (DesktopApplication *) qApp;
848} 848}
849 849
diff --git a/core/launcher/main.cpp b/core/launcher/main.cpp
index 49b41d6..8eaea17 100644
--- a/core/launcher/main.cpp
+++ b/core/launcher/main.cpp
@@ -1,177 +1,177 @@
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 "desktop.h" 21#include "desktop.h"
22#include "taskbar.h" 22#include "taskbar.h"
23#include "stabmon.h" 23#include "stabmon.h"
24 24
25#include <qpe/qpeapplication.h> 25#include <qpe/qpeapplication.h>
26#include <qpe/network.h> 26#include <qpe/network.h>
27#include <qpe/config.h> 27#include <qpe/config.h>
28#if defined( QT_QWS_SHARP ) || defined( QT_QWS_IPAQ ) 28#if defined( QT_QWS_SL5XXX ) || defined( QT_QWS_IPAQ )
29#include <qpe/custom.h> 29#include <qpe/custom.h>
30#endif 30#endif
31 31
32#include <opie/odevice.h> 32#include <opie/odevice.h>
33 33
34#include <qmessagebox.h> 34#include <qmessagebox.h>
35#include <qfile.h> 35#include <qfile.h>
36#include <qimage.h> 36#include <qimage.h>
37#include <qwindowsystem_qws.h> 37#include <qwindowsystem_qws.h>
38#include <qpe/qcopenvelope_qws.h> 38#include <qpe/qcopenvelope_qws.h>
39#include <qpe/alarmserver.h> 39#include <qpe/alarmserver.h>
40 40
41#include <stdlib.h> 41#include <stdlib.h>
42#include <stdio.h> 42#include <stdio.h>
43#include <signal.h> 43#include <signal.h>
44#include <unistd.h> 44#include <unistd.h>
45 45
46#if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) 46#if defined(QT_QWS_IPAQ) || defined(QT_QWS_SL5XXX)
47#include "../calibrate/calibrate.h" 47#include "../calibrate/calibrate.h"
48#endif 48#endif
49 49
50using namespace Opie; 50using namespace Opie;
51 51
52void initEnvironment() 52void initEnvironment()
53{ 53{
54 Config config("locale"); 54 Config config("locale");
55 config.setGroup( "Location" ); 55 config.setGroup( "Location" );
56 QString tz = config.readEntry( "Timezone", getenv("TZ") ); 56 QString tz = config.readEntry( "Timezone", getenv("TZ") );
57 57
58 // if not timezone set, pick New York 58 // if not timezone set, pick New York
59 if (tz.isNull()) 59 if (tz.isNull())
60 tz = "America/New_York"; 60 tz = "America/New_York";
61 61
62 setenv( "TZ", tz, 1 ); 62 setenv( "TZ", tz, 1 );
63 config.writeEntry( "Timezone", tz); 63 config.writeEntry( "Timezone", tz);
64 64
65 config.setGroup( "Language" ); 65 config.setGroup( "Language" );
66 QString lang = config.readEntry( "Language", getenv("LANG") ); 66 QString lang = config.readEntry( "Language", getenv("LANG") );
67 if ( !lang.isNull() ) 67 if ( !lang.isNull() )
68 setenv( "LANG", lang, 1 ); 68 setenv( "LANG", lang, 1 );
69} 69}
70 70
71 71
72int initApplication( int argc, char ** argv ) 72int initApplication( int argc, char ** argv )
73{ 73{
74 initEnvironment(); 74 initEnvironment();
75 75
76#if !defined(QT_QWS_CASSIOPEIA) && !defined(QT_QWS_IPAQ) && !defined(QT_QWS_EBX) 76#if !defined(QT_QWS_CASSIOPEIA) && !defined(QT_QWS_IPAQ) && !defined(QT_QWS_SL5XXX)
77 setenv( "QWS_SIZE", "240x320", 0 ); 77 setenv( "QWS_SIZE", "240x320", 0 );
78#endif 78#endif
79 79
80 //Don't flicker at startup: 80 //Don't flicker at startup:
81 QWSServer::setDesktopBackground( QImage() ); 81 QWSServer::setDesktopBackground( QImage() );
82 DesktopApplication a( argc, argv, QApplication::GuiServer ); 82 DesktopApplication a( argc, argv, QApplication::GuiServer );
83 83
84 ODevice::inst ( )-> setSoftSuspend ( true ); 84 ODevice::inst ( )-> setSoftSuspend ( true );
85 85
86 { // init backlight 86 { // init backlight
87 QCopEnvelope e("QPE/System", "setBacklight(int)" ); 87 QCopEnvelope e("QPE/System", "setBacklight(int)" );
88 e << -3; // Forced on 88 e << -3; // Forced on
89 } 89 }
90 90
91 AlarmServer::initialize(); 91 AlarmServer::initialize();
92 92
93 Desktop *d = new Desktop(); 93 Desktop *d = new Desktop();
94 94
95 QObject::connect( &a, SIGNAL(power()), d, SLOT(togglePower()) ); 95 QObject::connect( &a, SIGNAL(power()), d, SLOT(togglePower()) );
96 QObject::connect( &a, SIGNAL(backlight()), d, SLOT(toggleLight()) ); 96 QObject::connect( &a, SIGNAL(backlight()), d, SLOT(toggleLight()) );
97 QObject::connect( &a, SIGNAL(symbol()), d, SLOT(toggleSymbolInput()) ); 97 QObject::connect( &a, SIGNAL(symbol()), d, SLOT(toggleSymbolInput()) );
98 QObject::connect( &a, SIGNAL(numLockStateToggle()), d, SLOT(toggleNumLockState()) ); 98 QObject::connect( &a, SIGNAL(numLockStateToggle()), d, SLOT(toggleNumLockState()) );
99 QObject::connect( &a, SIGNAL(capsLockStateToggle()), d, SLOT(toggleCapsLockState()) ); 99 QObject::connect( &a, SIGNAL(capsLockStateToggle()), d, SLOT(toggleCapsLockState()) );
100 QObject::connect( &a, SIGNAL(prepareForRestart()), d, SLOT(terminateServers()) ); 100 QObject::connect( &a, SIGNAL(prepareForRestart()), d, SLOT(terminateServers()) );
101 101
102 (void)new SysFileMonitor(d); 102 (void)new SysFileMonitor(d);
103 Network::createServer(d); 103 Network::createServer(d);
104 104
105#if defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) 105#if defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_IPAQ) || defined(QT_QWS_SL5XXX)
106 if ( !QFile::exists( "/etc/pointercal" ) ) { 106 if ( !QFile::exists( "/etc/pointercal" ) ) {
107 // Make sure calibration widget starts on top. 107 // Make sure calibration widget starts on top.
108 Calibrate *cal = new Calibrate; 108 Calibrate *cal = new Calibrate;
109 cal->exec(); 109 cal->exec();
110 delete cal; 110 delete cal;
111 } 111 }
112#endif 112#endif
113 113
114 d->show(); 114 d->show();
115 115
116 if ( QDate::currentDate ( ). year ( ) < 2000 ) { 116 if ( QDate::currentDate ( ). year ( ) < 2000 ) {
117 if ( QMessageBox::information ( 0, DesktopApplication::tr( "Information" ), DesktopApplication::tr( "<p>The system date doesn't seem to be valid.\n(%1)</p><p>Do you want to correct the clock ?</p>" ). arg( TimeString::dateString ( QDate::currentDate ( ))), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) { 117 if ( QMessageBox::information ( 0, DesktopApplication::tr( "Information" ), DesktopApplication::tr( "<p>The system date doesn't seem to be valid.\n(%1)</p><p>Do you want to correct the clock ?</p>" ). arg( TimeString::dateString ( QDate::currentDate ( ))), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) {
118 QCopEnvelope e ( "QPE/Application/systemtime", "setDocument(QString)" ); 118 QCopEnvelope e ( "QPE/Application/systemtime", "setDocument(QString)" );
119 e << QString ( ); 119 e << QString ( );
120 } 120 }
121 } 121 }
122 122
123 int rv = a.exec(); 123 int rv = a.exec();
124 124
125 delete d; 125 delete d;
126 126
127 ODevice::inst ( )-> setSoftSuspend ( false ); 127 ODevice::inst ( )-> setSoftSuspend ( false );
128 128
129 return rv; 129 return rv;
130} 130}
131 131
132static const char *pidfile_path = "/var/run/opie.pid"; 132static const char *pidfile_path = "/var/run/opie.pid";
133 133
134void create_pidfile ( ) 134void create_pidfile ( )
135{ 135{
136 FILE *f; 136 FILE *f;
137 137
138 if (( f = ::fopen ( pidfile_path, "w" ))) { 138 if (( f = ::fopen ( pidfile_path, "w" ))) {
139 ::fprintf ( f, "%d", getpid ( )); 139 ::fprintf ( f, "%d", getpid ( ));
140 ::fclose ( f ); 140 ::fclose ( f );
141 } 141 }
142} 142}
143 143
144void remove_pidfile ( ) 144void remove_pidfile ( )
145{ 145{
146 ::unlink ( pidfile_path ); 146 ::unlink ( pidfile_path );
147} 147}
148 148
149void handle_sigterm ( int /* sig */ ) 149void handle_sigterm ( int /* sig */ )
150{ 150{
151 if ( qApp ) 151 if ( qApp )
152 qApp-> quit ( ); 152 qApp-> quit ( );
153} 153}
154 154
155int main( int argc, char ** argv ) 155int main( int argc, char ** argv )
156{ 156{
157 ::signal ( SIGCHLD, SIG_IGN ); 157 ::signal ( SIGCHLD, SIG_IGN );
158 158
159 ::signal ( SIGTERM, handle_sigterm ); 159 ::signal ( SIGTERM, handle_sigterm );
160 ::signal ( SIGINT, handle_sigterm ); 160 ::signal ( SIGINT, handle_sigterm );
161 161
162 ::setsid ( ); 162 ::setsid ( );
163 ::setpgid ( 0, 0 ); 163 ::setpgid ( 0, 0 );
164 164
165 ::atexit ( remove_pidfile ); 165 ::atexit ( remove_pidfile );
166 create_pidfile ( ); 166 create_pidfile ( );
167 167
168 int retVal = initApplication ( argc, argv ); 168 int retVal = initApplication ( argc, argv );
169 169
170 // Kill them. Kill them all. 170 // Kill them. Kill them all.
171 ::kill ( 0, SIGTERM ); 171 ::kill ( 0, SIGTERM );
172 ::sleep ( 1 ); 172 ::sleep ( 1 );
173 ::kill ( 0, SIGKILL ); 173 ::kill ( 0, SIGKILL );
174 174
175 return retVal; 175 return retVal;
176} 176}
177 177
diff --git a/core/launcher/taskbar.cpp b/core/launcher/taskbar.cpp
index 77035a3..8af568d 100644
--- a/core/launcher/taskbar.cpp
+++ b/core/launcher/taskbar.cpp
@@ -1,344 +1,344 @@
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_SL5XXX ) || 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_SHARP) 85#if defined(QT_QWS_IPAQ) || defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_SL5XXX)
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 lockState = new LockKeyState( this ); 172 lockState = new LockKeyState( this );
173 173
174#if defined(Q_WS_QWS) 174#if defined(Q_WS_QWS)
175#if !defined(QT_NO_COP) 175#if !defined(QT_NO_COP)
176 QCopChannel *channel = new QCopChannel( "QPE/TaskBar", this ); 176 QCopChannel *channel = new QCopChannel( "QPE/TaskBar", this );
177 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 177 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
178 this, SLOT(receive(const QCString&, const QByteArray&)) ); 178 this, SLOT(receive(const QCString&, const QByteArray&)) );
179#endif 179#endif
180#endif 180#endif
181 waitTimer = new QTimer( this ); 181 waitTimer = new QTimer( this );
182 connect( waitTimer, SIGNAL( timeout() ), this, SLOT( stopWait() ) ); 182 connect( waitTimer, SIGNAL( timeout() ), this, SLOT( stopWait() ) );
183 clearer = new QTimer( this ); 183 clearer = new QTimer( this );
184 QObject::connect(clearer, SIGNAL(timeout()), SLOT(clearStatusBar())); 184 QObject::connect(clearer, SIGNAL(timeout()), SLOT(clearStatusBar()));
185 QObject::connect(clearer, SIGNAL(timeout()), sysTray, SLOT(show())); 185 QObject::connect(clearer, SIGNAL(timeout()), sysTray, SLOT(show()));
186} 186}
187 187
188void TaskBar::setStatusMessage( const QString &text ) 188void TaskBar::setStatusMessage( const QString &text )
189{ 189{
190 if ( !text.isEmpty() ) { 190 if ( !text.isEmpty() ) {
191 label->setText( text ); 191 label->setText( text );
192 stack->raiseWidget( label ); 192 stack->raiseWidget( label );
193 if ( sysTray && ( label->fontMetrics().width( text ) > label->width() ) ) 193 if ( sysTray && ( label->fontMetrics().width( text ) > label->width() ) )
194 sysTray->hide(); 194 sysTray->hide();
195 clearer->start( 3000, TRUE ); 195 clearer->start( 3000, TRUE );
196 } else { 196 } else {
197 clearStatusBar(); 197 clearStatusBar();
198 } 198 }
199} 199}
200 200
201void TaskBar::clearStatusBar() 201void TaskBar::clearStatusBar()
202{ 202{
203 label->clear(); 203 label->clear();
204 stack->raiseWidget(runningAppBar); 204 stack->raiseWidget(runningAppBar);
205 // stack->raiseWidget( mru ); 205 // stack->raiseWidget( mru );
206} 206}
207 207
208void TaskBar::startWait() 208void TaskBar::startWait()
209{ 209{
210 waitIcon->setWaiting( true ); 210 waitIcon->setWaiting( true );
211 // a catchall stop after 10 seconds... 211 // a catchall stop after 10 seconds...
212 waitTimer->start( 10 * 1000, true ); 212 waitTimer->start( 10 * 1000, true );
213} 213}
214 214
215void TaskBar::stopWait(const QString& /*app*/) 215void TaskBar::stopWait(const QString& /*app*/)
216{ 216{
217 waitTimer->stop(); 217 waitTimer->stop();
218 //mru->addTask(sm->execToLink(app)); 218 //mru->addTask(sm->execToLink(app));
219 waitIcon->setWaiting( false ); 219 waitIcon->setWaiting( false );
220} 220}
221 221
222void TaskBar::stopWait() 222void TaskBar::stopWait()
223{ 223{
224 waitTimer->stop(); 224 waitTimer->stop();
225 225
226 waitIcon->setWaiting( false ); 226 waitIcon->setWaiting( false );
227} 227}
228 228
229void TaskBar::resizeEvent( QResizeEvent *e ) 229void TaskBar::resizeEvent( QResizeEvent *e )
230{ 230{
231 QHBox::resizeEvent( e ); 231 QHBox::resizeEvent( e );
232 calcMaxWindowRect(); 232 calcMaxWindowRect();
233} 233}
234 234
235void TaskBar::styleChange( QStyle &s ) 235void TaskBar::styleChange( QStyle &s )
236{ 236{
237 QHBox::styleChange( s ); 237 QHBox::styleChange( s );
238 calcMaxWindowRect(); 238 calcMaxWindowRect();
239} 239}
240 240
241void TaskBar::calcMaxWindowRect() 241void TaskBar::calcMaxWindowRect()
242{ 242{
243#ifdef Q_WS_QWS 243#ifdef Q_WS_QWS
244 QRect wr; 244 QRect wr;
245 int displayWidth = qApp->desktop()->width(); 245 int displayWidth = qApp->desktop()->width();
246 QRect ir = inputMethods->inputRect(); 246 QRect ir = inputMethods->inputRect();
247 if ( ir.isValid() ) { 247 if ( ir.isValid() ) {
248 wr.setCoords( 0, 0, displayWidth-1, ir.top()-1 ); 248 wr.setCoords( 0, 0, displayWidth-1, ir.top()-1 );
249 } else { 249 } else {
250 wr.setCoords( 0, 0, displayWidth-1, y()-1 ); 250 wr.setCoords( 0, 0, displayWidth-1, y()-1 );
251 } 251 }
252 252
253#if QT_VERSION < 300 253#if QT_VERSION < 300
254 QWSServer::setMaxWindowRect( qt_screen->mapToDevice(wr, 254 QWSServer::setMaxWindowRect( qt_screen->mapToDevice(wr,
255 QSize(qt_screen->width(),qt_screen->height())) 255 QSize(qt_screen->width(),qt_screen->height()))
256 ); 256 );
257#else 257#else
258 QWSServer::setMaxWindowRect( wr ); 258 QWSServer::setMaxWindowRect( wr );
259#endif 259#endif
260#endif 260#endif
261} 261}
262 262
263void TaskBar::receive( const QCString &msg, const QByteArray &data ) 263void TaskBar::receive( const QCString &msg, const QByteArray &data )
264{ 264{
265 QDataStream stream( data, IO_ReadOnly ); 265 QDataStream stream( data, IO_ReadOnly );
266 if ( msg == "message(QString)" ) { 266 if ( msg == "message(QString)" ) {
267 QString text; 267 QString text;
268 stream >> text; 268 stream >> text;
269 setStatusMessage( text ); 269 setStatusMessage( text );
270 } else if ( msg == "hideInputMethod()" ) { 270 } else if ( msg == "hideInputMethod()" ) {
271 inputMethods->hideInputMethod(); 271 inputMethods->hideInputMethod();
272 } else if ( msg == "showInputMethod()" ) { 272 } else if ( msg == "showInputMethod()" ) {
273 inputMethods->showInputMethod(); 273 inputMethods->showInputMethod();
274 } else if ( msg == "reloadInputMethods()" ) { 274 } else if ( msg == "reloadInputMethods()" ) {
275 inputMethods->loadInputMethods(); 275 inputMethods->loadInputMethods();
276 } else if ( msg == "reloadApps()" ) { 276 } else if ( msg == "reloadApps()" ) {
277 sm->reloadApps(); 277 sm->reloadApps();
278 } else if ( msg == "reloadApplets()" ) { 278 } else if ( msg == "reloadApplets()" ) {
279 sysTray->clearApplets(); 279 sysTray->clearApplets();
280 sysTray->addApplets(); 280 sysTray->addApplets();
281 sm->reloadApplets(); 281 sm->reloadApplets();
282 } else if ( msg == "soundAlarm()" ) { 282 } else if ( msg == "soundAlarm()" ) {
283 DesktopApplication::soundAlarm ( ); 283 DesktopApplication::soundAlarm ( );
284 } 284 }
285 else if ( msg == "setLed(int,bool)" ) { 285 else if ( msg == "setLed(int,bool)" ) {
286 int led, status; 286 int led, status;
287 stream >> led >> status; 287 stream >> led >> status;
288 288
289 QValueList <OLed> ll = ODevice::inst ( )-> ledList ( ); 289 QValueList <OLed> ll = ODevice::inst ( )-> ledList ( );
290 if ( ll. count ( )){ 290 if ( ll. count ( )){
291 OLed l = ll. contains ( Led_Mail ) ? Led_Mail : ll [0]; 291 OLed l = ll. contains ( Led_Mail ) ? Led_Mail : ll [0];
292 bool canblink = ODevice::inst ( )-> ledStateList ( l ). contains ( Led_BlinkSlow ); 292 bool canblink = ODevice::inst ( )-> ledStateList ( l ). contains ( Led_BlinkSlow );
293 293
294 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 );
295 } 295 }
296 } 296 }
297 else if ( msg == "toggleMenu()" ) { 297 else if ( msg == "toggleMenu()" ) {
298 if ( sm-> launchMenu-> isVisible ( )) 298 if ( sm-> launchMenu-> isVisible ( ))
299 sm-> launch ( ); 299 sm-> launch ( );
300 else { 300 else {
301 QCopEnvelope e ( "QPE/System", "toggleApplicationMenu()" ); 301 QCopEnvelope e ( "QPE/System", "toggleApplicationMenu()" );
302 } 302 }
303 } 303 }
304 else if ( msg == "toggleStartMenu()" ) { 304 else if ( msg == "toggleStartMenu()" ) {
305 sm-> launch ( ); 305 sm-> launch ( );
306 } 306 }
307} 307}
308 308
309QWidget *TaskBar::calibrate(bool) 309QWidget *TaskBar::calibrate(bool)
310{ 310{
311#ifdef Q_WS_QWS 311#ifdef Q_WS_QWS
312 Calibrate *c = new Calibrate; 312 Calibrate *c = new Calibrate;
313 c->show(); 313 c->show();
314 return c; 314 return c;
315#else 315#else
316 return 0; 316 return 0;
317#endif 317#endif
318} 318}
319 319
320void TaskBar::toggleNumLockState() 320void TaskBar::toggleNumLockState()
321{ 321{
322 if ( lockState ) lockState->toggleNumLockState(); 322 if ( lockState ) lockState->toggleNumLockState();
323} 323}
324 324
325void TaskBar::toggleCapsLockState() 325void TaskBar::toggleCapsLockState()
326{ 326{
327 if ( lockState ) lockState->toggleCapsLockState(); 327 if ( lockState ) lockState->toggleCapsLockState();
328} 328}
329 329
330void TaskBar::toggleSymbolInput() 330void TaskBar::toggleSymbolInput()
331{ 331{
332 if ( inputMethods->currentShown() == "Unicode" ) { 332 if ( inputMethods->currentShown() == "Unicode" ) {
333 inputMethods->hideInputMethod(); 333 inputMethods->hideInputMethod();
334 } else { 334 } else {
335 inputMethods->showInputMethod("Unicode"); 335 inputMethods->showInputMethod("Unicode");
336 } 336 }
337} 337}
338 338
339bool TaskBar::recoverMemory() 339bool TaskBar::recoverMemory()
340{ 340{
341 //eturn mru->quitOldApps(); 341 //eturn mru->quitOldApps();
342 return true; 342 return true;
343} 343}
344 344
diff --git a/core/multimedia/opieplayer/loopcontrol_threaded.cpp b/core/multimedia/opieplayer/loopcontrol_threaded.cpp
index 1b89bc8..6817d5b 100644
--- a/core/multimedia/opieplayer/loopcontrol_threaded.cpp
+++ b/core/multimedia/opieplayer/loopcontrol_threaded.cpp
@@ -1,625 +1,625 @@
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#define _REENTRANT 20#define _REENTRANT
21 21
22#include <qpe/qpeapplication.h> 22#include <qpe/qpeapplication.h>
23#include <qimage.h> 23#include <qimage.h>
24#include <qpainter.h> 24#include <qpainter.h>
25#ifdef Q_WS_QWS 25#ifdef Q_WS_QWS
26#include <qpe/qcopenvelope_qws.h> 26#include <qpe/qcopenvelope_qws.h>
27#endif 27#endif
28#include "mediaplayerplugininterface.h" 28#include "mediaplayerplugininterface.h"
29#include <stdio.h> 29#include <stdio.h>
30#include <stdlib.h> 30#include <stdlib.h>
31#include <string.h> 31#include <string.h>
32#include <time.h> 32#include <time.h>
33#include <unistd.h> 33#include <unistd.h>
34#include <pthread.h> 34#include <pthread.h>
35#include "loopcontrol.h" 35#include "loopcontrol.h"
36#include "audiodevice.h" 36#include "audiodevice.h"
37#include "videowidget.h" 37#include "videowidget.h"
38#include "audiowidget.h" 38#include "audiowidget.h"
39#include "mediaplayerstate.h" 39#include "mediaplayerstate.h"
40 40
41 41
42#if defined(QT_QWS_SHARP) || defined(QT_QWS_IPAQ) 42#if defined(QT_QWS_SL5XXX) || defined(QT_QWS_IPAQ)
43#define USE_REALTIME_AUDIO_THREAD 43#define USE_REALTIME_AUDIO_THREAD
44#endif 44#endif
45 45
46 46
47extern VideoWidget *videoUI; // now only needed to tell it to play a frame 47extern VideoWidget *videoUI; // now only needed to tell it to play a frame
48extern MediaPlayerState *mediaPlayerState; 48extern MediaPlayerState *mediaPlayerState;
49 49
50 50
51#define DecodeLoopDebug(x) qDebug x 51#define DecodeLoopDebug(x) qDebug x
52//#define DecodeLoopDebug(x) 52//#define DecodeLoopDebug(x)
53 53
54 54
55 static char *audioBuffer = NULL; 55 static char *audioBuffer = NULL;
56static AudioDevice *audioDevice = NULL; 56static AudioDevice *audioDevice = NULL;
57 static bool disabledSuspendScreenSaver = FALSE; 57 static bool disabledSuspendScreenSaver = FALSE;
58 58
59 59
60 pthread_tvideo_tid; 60 pthread_tvideo_tid;
61pthread_attr_t video_attr; 61pthread_attr_t video_attr;
62 pthread_taudio_tid; 62 pthread_taudio_tid;
63pthread_attr_t audio_attr; 63pthread_attr_t audio_attr;
64 64
65 65
66bool emitPlayFinished = FALSE; 66bool emitPlayFinished = FALSE;
67bool emitChangePos = FALSE; 67bool emitChangePos = FALSE;
68 68
69 69
70class Mutex { 70class Mutex {
71public: 71public:
72 Mutex() { 72 Mutex() {
73 pthread_mutexattr_t attr; 73 pthread_mutexattr_t attr;
74 pthread_mutexattr_init( &attr ); 74 pthread_mutexattr_init( &attr );
75 pthread_mutex_init( &mutex, &attr ); 75 pthread_mutex_init( &mutex, &attr );
76 pthread_mutexattr_destroy( &attr ); 76 pthread_mutexattr_destroy( &attr );
77 } 77 }
78 78
79 ~Mutex() { 79 ~Mutex() {
80 pthread_mutex_destroy( &mutex ); 80 pthread_mutex_destroy( &mutex );
81 } 81 }
82 82
83 void lock() { 83 void lock() {
84 pthread_mutex_lock( &mutex ); 84 pthread_mutex_lock( &mutex );
85 } 85 }
86 86
87 void unlock() { 87 void unlock() {
88 pthread_mutex_unlock( &mutex ); 88 pthread_mutex_unlock( &mutex );
89 } 89 }
90/* 90/*
91 bool locked() { 91 bool locked() {
92 switch ( pthread_mutex_trylock( &mutex ) ) { 92 switch ( pthread_mutex_trylock( &mutex ) ) {
93 case EBUSY: 93 case EBUSY:
94 return TRUE; 94 return TRUE;
95 case 0: 95 case 0:
96 pthread_mutex_unlock( &mutex ); 96 pthread_mutex_unlock( &mutex );
97 default: 97 default:
98 return FALSE; 98 return FALSE;
99 } 99 }
100 } 100 }
101*/ 101*/
102private: 102private:
103 pthread_mutex_t mutex; 103 pthread_mutex_t mutex;
104}; 104};
105 105
106 106
107class currentFrameObj { 107class currentFrameObj {
108public: 108public:
109 currentFrameObj() : value( 0 ) { } 109 currentFrameObj() : value( 0 ) { }
110 void set( long f ) { 110 void set( long f ) {
111 mutex.lock(); 111 mutex.lock();
112 value = f; 112 value = f;
113 mediaPlayerState->curDecoder()->videoSetFrame( f, 0 ); 113 mediaPlayerState->curDecoder()->videoSetFrame( f, 0 );
114 mutex.unlock(); 114 mutex.unlock();
115 } 115 }
116 long get() { 116 long get() {
117 return value; 117 return value;
118 } 118 }
119private: 119private:
120 long value; 120 long value;
121 Mutex mutex; 121 Mutex mutex;
122}; 122};
123 123
124 124
125Mutex *videoMutex; 125Mutex *videoMutex;
126Mutex *audioMutex; 126Mutex *audioMutex;
127Mutex *globalMutex; 127Mutex *globalMutex;
128 128
129 129
130 clock_tbegin; 130 clock_tbegin;
131 131
132 132
133LoopControl::LoopControl( QObject *parent, const char *name ) 133LoopControl::LoopControl( QObject *parent, const char *name )
134 : QObject( parent, name ) { 134 : QObject( parent, name ) {
135 isMuted = FALSE; 135 isMuted = FALSE;
136 connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( setMute(bool) ) ); 136 connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( setMute(bool) ) );
137 timerid = startTimer( 200 ); 137 timerid = startTimer( 200 );
138 videoMutex = new Mutex; 138 videoMutex = new Mutex;
139 audioMutex = new Mutex; 139 audioMutex = new Mutex;
140 globalMutex = new Mutex; 140 globalMutex = new Mutex;
141 //begin = clock(); 141 //begin = clock();
142} 142}
143 143
144 144
145LoopControl::~LoopControl() { 145LoopControl::~LoopControl() {
146 stop(); 146 stop();
147 killTimer( timerid ); 147 killTimer( timerid );
148} 148}
149 149
150 150
151static bool sendingNewPos = FALSE; 151static bool sendingNewPos = FALSE;
152static long prev_frame = 0; 152static long prev_frame = 0;
153static int currentSample = 0; 153static int currentSample = 0;
154 154
155 155
156void LoopControl::timerEvent( QTimerEvent* ) { 156void LoopControl::timerEvent( QTimerEvent* ) {
157 // We need to emit playFinished from the main thread, not one of the 157 // We need to emit playFinished from the main thread, not one of the
158 // decoding threads else we'll have all kinds of yucky things happen (reentrance). 158 // decoding threads else we'll have all kinds of yucky things happen (reentrance).
159 // playFinished will eventually call stop() which stops these threads. 159 // playFinished will eventually call stop() which stops these threads.
160 if ( emitPlayFinished ) { 160 if ( emitPlayFinished ) {
161 emitPlayFinished = FALSE; 161 emitPlayFinished = FALSE;
162 mediaPlayerState->setPlaying( FALSE ); 162 mediaPlayerState->setPlaying( FALSE );
163 } 163 }
164 164
165 if ( emitChangePos ) { 165 if ( emitChangePos ) {
166 166
167 emitChangePos = FALSE; 167 emitChangePos = FALSE;
168 168
169 if ( hasVideoChannel && hasAudioChannel ) { 169 if ( hasVideoChannel && hasAudioChannel ) {
170 sendingNewPos = TRUE; 170 sendingNewPos = TRUE;
171 mediaPlayerState->setPosition( current_frame ); 171 mediaPlayerState->setPosition( current_frame );
172 } else if ( hasVideoChannel ) { 172 } else if ( hasVideoChannel ) {
173 sendingNewPos = TRUE; 173 sendingNewPos = TRUE;
174 mediaPlayerState->setPosition( current_frame ); 174 mediaPlayerState->setPosition( current_frame );
175 } else if ( hasAudioChannel ) { 175 } else if ( hasAudioChannel ) {
176 sendingNewPos = TRUE; 176 sendingNewPos = TRUE;
177 mediaPlayerState->setPosition( audioSampleCounter ); 177 mediaPlayerState->setPosition( audioSampleCounter );
178 } 178 }
179 179
180 } 180 }
181} 181}
182 182
183 183
184 184
185 185
186void LoopControl::setPosition( long pos ) { 186void LoopControl::setPosition( long pos ) {
187 if ( sendingNewPos ) { 187 if ( sendingNewPos ) {
188 sendingNewPos = FALSE; 188 sendingNewPos = FALSE;
189 return; 189 return;
190 } 190 }
191 191
192 if ( hasVideoChannel && hasAudioChannel ) { 192 if ( hasVideoChannel && hasAudioChannel ) {
193 videoMutex->lock(); 193 videoMutex->lock();
194 audioMutex->lock(); 194 audioMutex->lock();
195qDebug("setting position"); 195qDebug("setting position");
196 playtime.restart(); 196 playtime.restart();
197 playtime = playtime.addMSecs( -pos * 1000 / framerate ); 197 playtime = playtime.addMSecs( -pos * 1000 / framerate );
198 //begin = clock() - (double)pos * CLOCKS_PER_SEC / framerate; 198 //begin = clock() - (double)pos * CLOCKS_PER_SEC / framerate;
199 current_frame = pos + 1; 199 current_frame = pos + 1;
200 mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream ); 200 mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream );
201 prev_frame = current_frame - 1; 201 prev_frame = current_frame - 1;
202 currentSample = (int)( current_frame * freq / framerate ); 202 currentSample = (int)( current_frame * freq / framerate );
203 mediaPlayerState->curDecoder()->audioSetSample( currentSample, stream ); 203 mediaPlayerState->curDecoder()->audioSetSample( currentSample, stream );
204 audioSampleCounter = currentSample - 1; 204 audioSampleCounter = currentSample - 1;
205 audioMutex->unlock(); 205 audioMutex->unlock();
206 videoMutex->unlock(); 206 videoMutex->unlock();
207 } else if ( hasVideoChannel ) { 207 } else if ( hasVideoChannel ) {
208 videoMutex->lock(); 208 videoMutex->lock();
209 playtime.restart(); 209 playtime.restart();
210 playtime = playtime.addMSecs( -pos * 1000 / framerate ); 210 playtime = playtime.addMSecs( -pos * 1000 / framerate );
211 //begin = clock() - (double)pos * CLOCKS_PER_SEC / framerate; 211 //begin = clock() - (double)pos * CLOCKS_PER_SEC / framerate;
212 current_frame = pos + 1; 212 current_frame = pos + 1;
213 mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream ); 213 mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream );
214 videoMutex->unlock(); 214 videoMutex->unlock();
215 prev_frame = current_frame - 1; 215 prev_frame = current_frame - 1;
216 } else if ( hasAudioChannel ) { 216 } else if ( hasAudioChannel ) {
217 audioMutex->lock(); 217 audioMutex->lock();
218 playtime.restart(); 218 playtime.restart();
219 playtime = playtime.addMSecs( -pos * 1000 / freq ); 219 playtime = playtime.addMSecs( -pos * 1000 / freq );
220 //begin = clock() - (double)pos * CLOCKS_PER_SEC / freq; 220 //begin = clock() - (double)pos * CLOCKS_PER_SEC / freq;
221 currentSample = pos + 1; // (int)( current_frame * freq / framerate ); 221 currentSample = pos + 1; // (int)( current_frame * freq / framerate );
222 mediaPlayerState->curDecoder()->audioSetSample( currentSample, stream ); 222 mediaPlayerState->curDecoder()->audioSetSample( currentSample, stream );
223 audioSampleCounter = currentSample - 1; 223 audioSampleCounter = currentSample - 1;
224 audioMutex->unlock(); 224 audioMutex->unlock();
225 } 225 }
226} 226}
227 227
228 228
229void *startVideoThread( void *ptr ) { 229void *startVideoThread( void *ptr ) {
230 LoopControl *mpegView = (LoopControl *)ptr; 230 LoopControl *mpegView = (LoopControl *)ptr;
231 mpegView->startVideo(); 231 mpegView->startVideo();
232 return 0; 232 return 0;
233} 233}
234 234
235void *startAudioThread( void *ptr ) { 235void *startAudioThread( void *ptr ) {
236 LoopControl *mpegView = (LoopControl *)ptr; 236 LoopControl *mpegView = (LoopControl *)ptr;
237 mpegView->startAudio(); 237 mpegView->startAudio();
238 return 0; 238 return 0;
239} 239}
240 240
241void LoopControl::startVideo() { 241void LoopControl::startVideo() {
242 moreVideo = TRUE; 242 moreVideo = TRUE;
243 243
244 while ( moreVideo ) { 244 while ( moreVideo ) {
245 245
246 if ( mediaPlayerState->curDecoder() && hasVideoChannel ) { 246 if ( mediaPlayerState->curDecoder() && hasVideoChannel ) {
247 247
248 if ( hasAudioChannel && !isMuted ) { 248 if ( hasAudioChannel && !isMuted ) {
249 249
250 bool done = FALSE; 250 bool done = FALSE;
251 251
252 do { 252 do {
253 253
254 254
255/* 255/*
256 videoMutex->lock(); 256 videoMutex->lock();
257 current_frame = int( (double)playtime.elapsed() * (double)framerate / 1000.0 ); 257 current_frame = int( (double)playtime.elapsed() * (double)framerate / 1000.0 );
258 //current_frame = ( clock() - begin ) * (double)framerate / CLOCKS_PER_SEC; 258 //current_frame = ( clock() - begin ) * (double)framerate / CLOCKS_PER_SEC;
259 259
260 // Sync to Audio 260 // Sync to Audio
261 // current_frame = (long)((double)(audioSampleCounter - 1000) * framerate / (double)freq); 261 // current_frame = (long)((double)(audioSampleCounter - 1000) * framerate / (double)freq);
262 262
263 long mSecsToNextFrame = 0; 263 long mSecsToNextFrame = 0;
264 264
265 if ( current_frame == prev_frame ) { 265 if ( current_frame == prev_frame ) {
266 int nf = current_frame + 1; 266 int nf = current_frame + 1;
267 if ( nf > 0 && nf != total_video_frames ) 267 if ( nf > 0 && nf != total_video_frames )
268 // mSecsToNextFrame = long(double(nf * CLOCKS_PER_SEC) / framerate) - ( clock() - begin ); 268 // mSecsToNextFrame = long(double(nf * CLOCKS_PER_SEC) / framerate) - ( clock() - begin );
269 mSecsToNextFrame = long(double(nf * 1000) / framerate) - ( playtime.elapsed() ); 269 mSecsToNextFrame = long(double(nf * 1000) / framerate) - ( playtime.elapsed() );
270 } 270 }
271 videoMutex->unlock(); 271 videoMutex->unlock();
272 272
273 if ( mSecsToNextFrame ) { 273 if ( mSecsToNextFrame ) {
274 usleep( mSecsToNextFrame ); // wait a bit 274 usleep( mSecsToNextFrame ); // wait a bit
275 275
276 videoMutex->lock(); 276 videoMutex->lock();
277 // This should now be the next frame 277 // This should now be the next frame
278 current_frame = int( (double)playtime.elapsed() * (double)framerate / 1000.0 ); 278 current_frame = int( (double)playtime.elapsed() * (double)framerate / 1000.0 );
279 //current_frame = ( clock() - begin ) * (double)framerate / CLOCKS_PER_SEC; 279 //current_frame = ( clock() - begin ) * (double)framerate / CLOCKS_PER_SEC;
280 videoMutex->unlock(); 280 videoMutex->unlock();
281 } 281 }
282 282
283 videoMutex->lock(); 283 videoMutex->lock();
284 done = current_frame >= prev_frame; 284 done = current_frame >= prev_frame;
285 videoMutex->unlock(); 285 videoMutex->unlock();
286*/ 286*/
287 videoMutex->lock(); 287 videoMutex->lock();
288 current_frame = int( (double)playtime.elapsed() * (double)framerate / 1000.0 ); 288 current_frame = int( (double)playtime.elapsed() * (double)framerate / 1000.0 );
289 done = current_frame >= prev_frame; 289 done = current_frame >= prev_frame;
290 videoMutex->unlock(); 290 videoMutex->unlock();
291 if ( !done ) 291 if ( !done )
292 usleep( 1000 ); // wait a bit 292 usleep( 1000 ); // wait a bit
293 293
294 } while ( !done ); 294 } while ( !done );
295 295
296 // qDebug("elapsed: %i %i (%f)", int( playtime.elapsed() ), current_frame, framerate ); 296 // qDebug("elapsed: %i %i (%f)", int( playtime.elapsed() ), current_frame, framerate );
297 297
298 } else { 298 } else {
299 videoMutex->lock(); 299 videoMutex->lock();
300 current_frame++; 300 current_frame++;
301 videoMutex->unlock(); 301 videoMutex->unlock();
302 } 302 }
303 303
304 videoMutex->lock(); 304 videoMutex->lock();
305 bool check = current_frame && current_frame > prev_frame; 305 bool check = current_frame && current_frame > prev_frame;
306 videoMutex->unlock(); 306 videoMutex->unlock();
307 307
308 if ( check ) { 308 if ( check ) {
309 videoMutex->lock(); 309 videoMutex->lock();
310 if ( current_frame > prev_frame + 1 ) { 310 if ( current_frame > prev_frame + 1 ) {
311 qDebug("skipped a frame"); 311 qDebug("skipped a frame");
312 mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream ); 312 mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream );
313 } 313 }
314 prev_frame = current_frame; 314 prev_frame = current_frame;
315 if ( moreVideo = videoUI->playVideo() ) 315 if ( moreVideo = videoUI->playVideo() )
316 emitChangePos = TRUE; 316 emitChangePos = TRUE;
317 videoMutex->unlock(); 317 videoMutex->unlock();
318 } 318 }
319 319
320 } else 320 } else
321 moreVideo = FALSE; 321 moreVideo = FALSE;
322 322
323 } 323 }
324 324
325 if ( !moreVideo && !moreAudio ) 325 if ( !moreVideo && !moreAudio )
326 emitPlayFinished = TRUE; 326 emitPlayFinished = TRUE;
327 327
328 pthread_exit(NULL); 328 pthread_exit(NULL);
329} 329}
330 330
331void LoopControl::startAudio() { 331void LoopControl::startAudio() {
332 moreAudio = TRUE; 332 moreAudio = TRUE;
333 333
334 while ( moreAudio ) { 334 while ( moreAudio ) {
335 335
336 if ( !isMuted && mediaPlayerState->curDecoder() && hasAudioChannel ) { 336 if ( !isMuted && mediaPlayerState->curDecoder() && hasAudioChannel ) {
337 337
338 audioMutex->lock(); 338 audioMutex->lock();
339 currentSample = mediaPlayerState->curDecoder()->audioGetSample( stream ); 339 currentSample = mediaPlayerState->curDecoder()->audioGetSample( stream );
340 340
341 if ( currentSample == 0 ) 341 if ( currentSample == 0 )
342 currentSample = audioSampleCounter + 1; 342 currentSample = audioSampleCounter + 1;
343 343
344 if ( currentSample != audioSampleCounter + 1 ) 344 if ( currentSample != audioSampleCounter + 1 )
345 qDebug("out of sync with decoder %i %i", currentSample, audioSampleCounter); 345 qDebug("out of sync with decoder %i %i", currentSample, audioSampleCounter);
346 audioMutex->unlock(); 346 audioMutex->unlock();
347 347
348/* 348/*
349 int sampleWeShouldBeAt = int( playtime.elapsed() ) * freq / 1000; 349 int sampleWeShouldBeAt = int( playtime.elapsed() ) * freq / 1000;
350 350
351 if ( sampleWeShouldBeAt - currentSample > 20000 ) { 351 if ( sampleWeShouldBeAt - currentSample > 20000 ) {
352 mediaPlayerState->curDecoder()->audioSetSample( sampleWeShouldBeAt, stream ); 352 mediaPlayerState->curDecoder()->audioSetSample( sampleWeShouldBeAt, stream );
353 currentSample = sampleWeShouldBeAt; 353 currentSample = sampleWeShouldBeAt;
354 } 354 }
355*/ 355*/
356 long samplesRead = 0; 356 long samplesRead = 0;
357 357
358 const long samples = 1024; 358 const long samples = 1024;
359 359
360 moreAudio = !mediaPlayerState->curDecoder()->audioReadSamples( (short*)audioBuffer, channels, samples, samplesRead, stream ); 360 moreAudio = !mediaPlayerState->curDecoder()->audioReadSamples( (short*)audioBuffer, channels, samples, samplesRead, stream );
361 361
362 audioMutex->lock(); 362 audioMutex->lock();
363 long sampleWeShouldBeAt = long( playtime.elapsed() ) * freq / 1000; 363 long sampleWeShouldBeAt = long( playtime.elapsed() ) * freq / 1000;
364 //long sampleWeShouldBeAt = long( clock() - begin ) * (double) freq / CLOCKS_PER_SEC; 364 //long sampleWeShouldBeAt = long( clock() - begin ) * (double) freq / CLOCKS_PER_SEC;
365 long sampleWaitTime = currentSample - sampleWeShouldBeAt; 365 long sampleWaitTime = currentSample - sampleWeShouldBeAt;
366 audioMutex->unlock(); 366 audioMutex->unlock();
367 367
368 if ( sampleWaitTime >= 0 && sampleWaitTime <= 2000 ) { 368 if ( sampleWaitTime >= 0 && sampleWaitTime <= 2000 ) {
369 //qDebug("sampleWaitTime: %i", sampleWaitTime); 369 //qDebug("sampleWaitTime: %i", sampleWaitTime);
370 usleep( ( sampleWaitTime * 1000000 ) / ( freq ) ); 370 usleep( ( sampleWaitTime * 1000000 ) / ( freq ) );
371 } else { 371 } else {
372 audioMutex->lock(); 372 audioMutex->lock();
373 if ( sampleWaitTime <= -2000 ) { 373 if ( sampleWaitTime <= -2000 ) {
374 qDebug("need to catch up by: %li (%i,%li)", -sampleWaitTime, currentSample, sampleWeShouldBeAt ); 374 qDebug("need to catch up by: %li (%i,%li)", -sampleWaitTime, currentSample, sampleWeShouldBeAt );
375 mediaPlayerState->curDecoder()->audioSetSample( sampleWeShouldBeAt, stream ); 375 mediaPlayerState->curDecoder()->audioSetSample( sampleWeShouldBeAt, stream );
376 currentSample = sampleWeShouldBeAt; 376 currentSample = sampleWeShouldBeAt;
377 } 377 }
378 audioMutex->unlock(); 378 audioMutex->unlock();
379 } 379 }
380 380
381 audioDevice->write( audioBuffer, samplesRead * 2 * channels ); 381 audioDevice->write( audioBuffer, samplesRead * 2 * channels );
382 382
383 audioMutex->lock(); 383 audioMutex->lock();
384 // audioSampleCounter += samplesRead; 384 // audioSampleCounter += samplesRead;
385 audioSampleCounter = currentSample + samplesRead - 1; 385 audioSampleCounter = currentSample + samplesRead - 1;
386 audioMutex->unlock(); 386 audioMutex->unlock();
387 387
388 if ( !hasVideoChannel ) 388 if ( !hasVideoChannel )
389 emitChangePos = TRUE; 389 emitChangePos = TRUE;
390 390
391 //qDebug("currentSample: %i audioSampleCounter: %i total_audio_samples: %i", currentSample, audioSampleCounter, total_audio_samples); 391 //qDebug("currentSample: %i audioSampleCounter: %i total_audio_samples: %i", currentSample, audioSampleCounter, total_audio_samples);
392 // qDebug("current: %i counter: %i total: %i", currentSample, audioSampleCounter, (int)total_audio_samples); 392 // qDebug("current: %i counter: %i total: %i", currentSample, audioSampleCounter, (int)total_audio_samples);
393 moreAudio = audioSampleCounter <= total_audio_samples; 393 moreAudio = audioSampleCounter <= total_audio_samples;
394 394
395 } else { 395 } else {
396 396
397 if ( mediaPlayerState->curDecoder() && hasAudioChannel ) 397 if ( mediaPlayerState->curDecoder() && hasAudioChannel )
398 usleep( 100000 ); // Check every 1/10 sec to see if mute is off 398 usleep( 100000 ); // Check every 1/10 sec to see if mute is off
399 else 399 else
400 moreAudio = FALSE; 400 moreAudio = FALSE;
401 401
402 } 402 }
403 } 403 }
404 404
405 qDebug( "End of file" ); 405 qDebug( "End of file" );
406 406
407 if ( !moreVideo && !moreAudio ) 407 if ( !moreVideo && !moreAudio )
408 emitPlayFinished = TRUE; 408 emitPlayFinished = TRUE;
409 409
410 pthread_exit(NULL); 410 pthread_exit(NULL);
411} 411}
412 412
413void LoopControl::killTimers() { 413void LoopControl::killTimers() {
414 if ( hasVideoChannel ) { 414 if ( hasVideoChannel ) {
415 if ( pthread_self() != video_tid ) { 415 if ( pthread_self() != video_tid ) {
416 if ( pthread_cancel(video_tid) == 0 ) { 416 if ( pthread_cancel(video_tid) == 0 ) {
417 void *thread_result = 0; 417 void *thread_result = 0;
418 if ( pthread_join(video_tid,&thread_result) != 0 ) 418 if ( pthread_join(video_tid,&thread_result) != 0 )
419 qDebug("thread join error 1"); 419 qDebug("thread join error 1");
420 pthread_attr_destroy(&video_attr); 420 pthread_attr_destroy(&video_attr);
421 } 421 }
422 } 422 }
423 } 423 }
424 if ( hasAudioChannel ) { 424 if ( hasAudioChannel ) {
425 if ( pthread_self() != audio_tid ) { 425 if ( pthread_self() != audio_tid ) {
426 if ( pthread_cancel(audio_tid) == 0 ) { 426 if ( pthread_cancel(audio_tid) == 0 ) {
427 void *thread_result = 0; 427 void *thread_result = 0;
428 if ( pthread_join(audio_tid,&thread_result) != 0 ) 428 if ( pthread_join(audio_tid,&thread_result) != 0 )
429 qDebug("thread join error 2"); 429 qDebug("thread join error 2");
430 pthread_attr_destroy(&audio_attr); 430 pthread_attr_destroy(&audio_attr);
431 } 431 }
432 } 432 }
433 } 433 }
434} 434}
435 435
436void LoopControl::startTimers() { 436void LoopControl::startTimers() {
437 moreVideo = FALSE; 437 moreVideo = FALSE;
438 moreAudio = FALSE; 438 moreAudio = FALSE;
439 439
440 if ( hasVideoChannel ) { 440 if ( hasVideoChannel ) {
441 moreVideo = TRUE; 441 moreVideo = TRUE;
442 pthread_attr_init(&video_attr); 442 pthread_attr_init(&video_attr);
443 pthread_create(&video_tid, &video_attr, (void * (*)(void *))startVideoThread, this); 443 pthread_create(&video_tid, &video_attr, (void * (*)(void *))startVideoThread, this);
444 } 444 }
445 445
446 if ( hasAudioChannel ) { 446 if ( hasAudioChannel ) {
447 moreAudio = TRUE; 447 moreAudio = TRUE;
448 pthread_attr_init(&audio_attr); 448 pthread_attr_init(&audio_attr);
449#ifdef USE_REALTIME_AUDIO_THREAD 449#ifdef USE_REALTIME_AUDIO_THREAD
450 pthread_attr_setschedpolicy(&audio_attr,SCHED_RR); // Real-time round robin 450 pthread_attr_setschedpolicy(&audio_attr,SCHED_RR); // Real-time round robin
451 //qDebug("min: %i, max: %i", sched_get_priority_min( SCHED_RR ), sched_get_priority_max( SCHED_RR ) ); 451 //qDebug("min: %i, max: %i", sched_get_priority_min( SCHED_RR ), sched_get_priority_max( SCHED_RR ) );
452 sched_param params; 452 sched_param params;
453 params.sched_priority = 50; 453 params.sched_priority = 50;
454 pthread_attr_setschedparam(&audio_attr,&params); 454 pthread_attr_setschedparam(&audio_attr,&params);
455#endif 455#endif
456 pthread_create(&audio_tid, &audio_attr, (void * (*)(void *))startAudioThread, this); 456 pthread_create(&audio_tid, &audio_attr, (void * (*)(void *))startAudioThread, this);
457 } 457 }
458} 458}
459 459
460 460
461 461
462 462
463void LoopControl::setPaused( bool pause ) { 463void LoopControl::setPaused( bool pause ) {
464 static int whenPaused = 0; 464 static int whenPaused = 0;
465 465
466 if ( !mediaPlayerState->curDecoder() || !mediaPlayerState->curDecoder()->isOpen() ) 466 if ( !mediaPlayerState->curDecoder() || !mediaPlayerState->curDecoder()->isOpen() )
467 return; 467 return;
468 468
469 if ( pause ) { 469 if ( pause ) {
470 // Remember where we are 470 // Remember where we are
471 whenPaused = playtime.elapsed(); 471 whenPaused = playtime.elapsed();
472 killTimers(); 472 killTimers();
473 } else { 473 } else {
474 // Just like we never stopped 474 // Just like we never stopped
475 playtime.restart(); 475 playtime.restart();
476 playtime = playtime.addMSecs( -whenPaused ); 476 playtime = playtime.addMSecs( -whenPaused );
477 whenPaused = 0; 477 whenPaused = 0;
478 startTimers(); 478 startTimers();
479 } 479 }
480} 480}
481 481
482 482
483void LoopControl::stop( bool willPlayAgainShortly ) { 483void LoopControl::stop( bool willPlayAgainShortly ) {
484 484
485#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 485#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
486 if ( !willPlayAgainShortly && disabledSuspendScreenSaver ) { 486 if ( !willPlayAgainShortly && disabledSuspendScreenSaver ) {
487 disabledSuspendScreenSaver = FALSE; 487 disabledSuspendScreenSaver = FALSE;
488 // Re-enable the suspend mode 488 // Re-enable the suspend mode
489 QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; 489 QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
490 } 490 }
491#endif 491#endif
492 492
493 if ( mediaPlayerState->curDecoder() && mediaPlayerState->curDecoder()->isOpen() ) { 493 if ( mediaPlayerState->curDecoder() && mediaPlayerState->curDecoder()->isOpen() ) {
494 494
495 killTimers(); 495 killTimers();
496 496
497 mediaPlayerState->curDecoder()->close(); 497 mediaPlayerState->curDecoder()->close();
498 498
499 if ( audioDevice ) { 499 if ( audioDevice ) {
500 delete audioDevice; 500 delete audioDevice;
501 delete audioBuffer; 501 delete audioBuffer;
502 audioDevice = 0; 502 audioDevice = 0;
503 audioBuffer = 0; 503 audioBuffer = 0;
504 } 504 }
505 505
506 } 506 }
507} 507}
508 508
509 509
510bool LoopControl::init( const QString& filename ) { 510bool LoopControl::init( const QString& filename ) {
511 stop(); 511 stop();
512 fileName = filename; 512 fileName = filename;
513 stream = 0; // only play stream 0 for now 513 stream = 0; // only play stream 0 for now
514 current_frame = total_video_frames = total_audio_samples = 0; 514 current_frame = total_video_frames = total_audio_samples = 0;
515 515
516 qDebug( "Using the %s decoder", mediaPlayerState->curDecoder()->pluginName() ); 516 qDebug( "Using the %s decoder", mediaPlayerState->curDecoder()->pluginName() );
517 517
518 // ### Hack to use libmpeg3plugin to get the number of audio samples if we are using the libmad plugin 518 // ### Hack to use libmpeg3plugin to get the number of audio samples if we are using the libmad plugin
519 if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibMadPlugin") ) { 519 if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibMadPlugin") ) {
520 if ( mediaPlayerState->libMpeg3Decoder() && mediaPlayerState->libMpeg3Decoder()->open( filename ) ) { 520 if ( mediaPlayerState->libMpeg3Decoder() && mediaPlayerState->libMpeg3Decoder()->open( filename ) ) {
521 total_audio_samples = mediaPlayerState->libMpeg3Decoder()->audioSamples( 0 ); 521 total_audio_samples = mediaPlayerState->libMpeg3Decoder()->audioSamples( 0 );
522 mediaPlayerState->libMpeg3Decoder()->close(); 522 mediaPlayerState->libMpeg3Decoder()->close();
523 } 523 }
524 } 524 }
525 525
526 if ( !mediaPlayerState->curDecoder()|| !mediaPlayerState->curDecoder()->open( filename ) ) 526 if ( !mediaPlayerState->curDecoder()|| !mediaPlayerState->curDecoder()->open( filename ) )
527 return FALSE; 527 return FALSE;
528 528
529 hasAudioChannel = mediaPlayerState->curDecoder()->audioStreams() > 0; 529 hasAudioChannel = mediaPlayerState->curDecoder()->audioStreams() > 0;
530 hasVideoChannel = mediaPlayerState->curDecoder()->videoStreams() > 0; 530 hasVideoChannel = mediaPlayerState->curDecoder()->videoStreams() > 0;
531 531
532 if ( hasAudioChannel ) { 532 if ( hasAudioChannel ) {
533 int astream = 0; 533 int astream = 0;
534 534
535 channels = mediaPlayerState->curDecoder()->audioChannels( astream ); 535 channels = mediaPlayerState->curDecoder()->audioChannels( astream );
536 DecodeLoopDebug(( "channels = %d\n", channels )); 536 DecodeLoopDebug(( "channels = %d\n", channels ));
537 537
538 if ( !total_audio_samples ) 538 if ( !total_audio_samples )
539 total_audio_samples = mediaPlayerState->curDecoder()->audioSamples( astream ); 539 total_audio_samples = mediaPlayerState->curDecoder()->audioSamples( astream );
540 540
541 mediaPlayerState->setLength( total_audio_samples ); 541 mediaPlayerState->setLength( total_audio_samples );
542 542
543 freq = mediaPlayerState->curDecoder()->audioFrequency( astream ); 543 freq = mediaPlayerState->curDecoder()->audioFrequency( astream );
544 DecodeLoopDebug(( "frequency = %d\n", freq )); 544 DecodeLoopDebug(( "frequency = %d\n", freq ));
545 545
546 audioSampleCounter = 0; 546 audioSampleCounter = 0;
547 547
548 static const int bytes_per_sample = 2; //16 bit 548 static const int bytes_per_sample = 2; //16 bit
549 549
550 audioDevice = new AudioDevice( freq, channels, bytes_per_sample ); 550 audioDevice = new AudioDevice( freq, channels, bytes_per_sample );
551 audioBuffer = new char[ audioDevice->bufferSize() ]; 551 audioBuffer = new char[ audioDevice->bufferSize() ];
552 channels = audioDevice->channels(); 552 channels = audioDevice->channels();
553 553
554 //### must check which frequency is actually used. 554 //### must check which frequency is actually used.
555 static const int size = 1; 555 static const int size = 1;
556 short int buf[size]; 556 short int buf[size];
557 long samplesRead = 0; 557 long samplesRead = 0;
558 mediaPlayerState->curDecoder()->audioReadSamples( buf, channels, size, samplesRead, stream ); 558 mediaPlayerState->curDecoder()->audioReadSamples( buf, channels, size, samplesRead, stream );
559 } 559 }
560 560
561 if ( hasVideoChannel ) { 561 if ( hasVideoChannel ) {
562 total_video_frames = mediaPlayerState->curDecoder()->videoFrames( stream ); 562 total_video_frames = mediaPlayerState->curDecoder()->videoFrames( stream );
563 563
564 mediaPlayerState->setLength( total_video_frames ); 564 mediaPlayerState->setLength( total_video_frames );
565 565
566 framerate = mediaPlayerState->curDecoder()->videoFrameRate( stream ); 566 framerate = mediaPlayerState->curDecoder()->videoFrameRate( stream );
567 DecodeLoopDebug(( "Frame rate %g total %ld", framerate, total_video_frames )); 567 DecodeLoopDebug(( "Frame rate %g total %ld", framerate, total_video_frames ));
568 568
569 if ( framerate <= 1.0 ) { 569 if ( framerate <= 1.0 ) {
570 DecodeLoopDebug(( "Crazy frame rate, resetting to sensible" )); 570 DecodeLoopDebug(( "Crazy frame rate, resetting to sensible" ));
571 framerate = 25; 571 framerate = 25;
572 } 572 }
573 573
574 if ( total_video_frames == 1 ) { 574 if ( total_video_frames == 1 ) {
575 DecodeLoopDebug(( "Cannot seek to frame" )); 575 DecodeLoopDebug(( "Cannot seek to frame" ));
576 } 576 }
577 577
578 } 578 }
579 579
580 videoMutex->lock(); 580 videoMutex->lock();
581 current_frame = 0; 581 current_frame = 0;
582 prev_frame = -1; 582 prev_frame = -1;
583 videoMutex->unlock(); 583 videoMutex->unlock();
584 584
585 connect( mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( setPosition( long ) ) ); 585 connect( mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( setPosition( long ) ) );
586 connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( setPaused( bool ) ) ); 586 connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( setPaused( bool ) ) );
587 587
588 //setBackgroundColor( black ); 588 //setBackgroundColor( black );
589 return TRUE; 589 return TRUE;
590} 590}
591 591
592 592
593void LoopControl::play() { 593void LoopControl::play() {
594 594
595#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 595#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
596 if ( !disabledSuspendScreenSaver ) { 596 if ( !disabledSuspendScreenSaver ) {
597 disabledSuspendScreenSaver = TRUE; 597 disabledSuspendScreenSaver = TRUE;
598 // Stop the screen from blanking and power saving state 598 // Stop the screen from blanking and power saving state
599 QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) 599 QCopEnvelope("QPE/System", "setScreenSaverMode(int)" )
600 << ( hasVideoChannel ? QPEApplication::Disable : QPEApplication::DisableSuspend ); 600 << ( hasVideoChannel ? QPEApplication::Disable : QPEApplication::DisableSuspend );
601 } 601 }
602#endif 602#endif
603 603
604 //begin = clock(); 604 //begin = clock();
605 playtime.start(); 605 playtime.start();
606 startTimers(); 606 startTimers();
607 //updateGeometry(); 607 //updateGeometry();
608} 608}
609 609
610 610
611void LoopControl::setMute( bool on ) { 611void LoopControl::setMute( bool on ) {
612 if ( isMuted != on ) { 612 if ( isMuted != on ) {
613 isMuted = on; 613 isMuted = on;
614 if ( isMuted ) { 614 if ( isMuted ) {
615 } else { 615 } else {
616 int frame = current_frame; // mediaPlayerState->curDecoder()->videoGetFrame( stream ); 616 int frame = current_frame; // mediaPlayerState->curDecoder()->videoGetFrame( stream );
617 playtime.restart(); 617 playtime.restart();
618 playtime = playtime.addMSecs( -frame * 1000 / framerate ); 618 playtime = playtime.addMSecs( -frame * 1000 / framerate );
619 //begin = clock() - (double)frame * CLOCKS_PER_SEC / framerate; 619 //begin = clock() - (double)frame * CLOCKS_PER_SEC / framerate;
620 mediaPlayerState->curDecoder()->audioSetSample( frame*freq/framerate, stream ); 620 mediaPlayerState->curDecoder()->audioSetSample( frame*freq/framerate, stream );
621 } 621 }
622 } 622 }
623} 623}
624 624
625 625
diff --git a/core/opie-login/main.cpp b/core/opie-login/main.cpp
index 81f4d1e..1800be0 100644
--- a/core/opie-login/main.cpp
+++ b/core/opie-login/main.cpp
@@ -1,368 +1,368 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> 3             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org>
4           .>+-= 4           .>+-=
5 _;:,     .>    :=|. This file is free software; you can 5 _;:,     .>    :=|. This file is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under 6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU General Public 7:`=1 )Y*s>-.--   : the terms of the GNU General Public
8.="- .-=="i,     .._ License as published by the Free Software 8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License, 9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version. 10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_. 11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This file is distributed in the hope that 12    .i_,=:_.      -<s. This file is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of 14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General 16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
17..}^=.=       =       ; Public License for more details. 17..}^=.=       =       ; Public License for more details.
18++=   -.     .`     .: 18++=   -.     .`     .:
19 :     =  ...= . :.=- You should have received a copy of the GNU 19 :     =  ...= . :.=- You should have received a copy of the GNU
20 -.   .:....=;==+<; General Public License along with this file; 20 -.   .:....=;==+<; General Public License along with this file;
21  -_. . .   )=.  = see the file COPYING. If not, write to the 21  -_. . .   )=.  = see the file COPYING. If not, write to the
22    --        :-=` Free Software Foundation, Inc., 22    --        :-=` Free Software Foundation, Inc.,
23 59 Temple Place - Suite 330, 23 59 Temple Place - Suite 330,
24 Boston, MA 02111-1307, USA. 24 Boston, MA 02111-1307, USA.
25 25
26*/ 26*/
27 27
28#define _GNU_SOURCE 28#define _GNU_SOURCE
29 29
30#include <sys/types.h> 30#include <sys/types.h>
31#include <time.h> 31#include <time.h>
32#include <sys/time.h> 32#include <sys/time.h>
33#include <sys/resource.h> 33#include <sys/resource.h>
34#include <unistd.h> 34#include <unistd.h>
35#include <syslog.h> 35#include <syslog.h>
36#include <sys/wait.h> 36#include <sys/wait.h>
37#include <stdio.h> 37#include <stdio.h>
38#include <stdlib.h> 38#include <stdlib.h>
39#include <signal.h> 39#include <signal.h>
40#include <getopt.h> 40#include <getopt.h>
41#include <string.h> 41#include <string.h>
42 42
43#include <qpe/qpeapplication.h> 43#include <qpe/qpeapplication.h>
44#include <qpe/qcopenvelope_qws.h> 44#include <qpe/qcopenvelope_qws.h>
45#include <qpe/qpestyle.h> 45#include <qpe/qpestyle.h>
46#include <qpe/power.h> 46#include <qpe/power.h>
47#include <qpe/config.h> 47#include <qpe/config.h>
48 48
49#include <opie/odevice.h> 49#include <opie/odevice.h>
50 50
51#include <qwindowsystem_qws.h> 51#include <qwindowsystem_qws.h>
52#include <qmessagebox.h> 52#include <qmessagebox.h>
53#include <qlabel.h> 53#include <qlabel.h>
54#include <qtimer.h> 54#include <qtimer.h>
55#include <qfile.h> 55#include <qfile.h>
56 56
57#include "loginapplication.h" 57#include "loginapplication.h"
58#include "loginwindowimpl.h" 58#include "loginwindowimpl.h"
59#include "calibrate.h" 59#include "calibrate.h"
60 60
61using namespace Opie; 61using namespace Opie;
62 62
63int login_main ( int argc, char **argv, pid_t ppid ); 63int login_main ( int argc, char **argv, pid_t ppid );
64void sigterm ( int sig ); 64void sigterm ( int sig );
65void sigint ( int sig ); 65void sigint ( int sig );
66void exit_closelog ( ); 66void exit_closelog ( );
67 67
68static struct option long_options [] = { 68static struct option long_options [] = {
69 { "autologin", 1, 0, 'a' }, 69 { "autologin", 1, 0, 'a' },
70 { 0, 0, 0, 0 } 70 { 0, 0, 0, 0 }
71}; 71};
72 72
73 73
74int main ( int argc, char **argv ) 74int main ( int argc, char **argv )
75{ 75{
76 pid_t ppid = ::getpid ( ); 76 pid_t ppid = ::getpid ( );
77 77
78 if ( ::geteuid ( ) != 0 ) { 78 if ( ::geteuid ( ) != 0 ) {
79 ::fprintf ( stderr, "%s can only be executed by root. (or chmod +s)", argv [0] ); 79 ::fprintf ( stderr, "%s can only be executed by root. (or chmod +s)", argv [0] );
80 return 1; 80 return 1;
81 } 81 }
82 if ( ::getuid ( ) != 0 ) // qt doesn't really like SUID and 82 if ( ::getuid ( ) != 0 ) // qt doesn't really like SUID and
83 ::setuid ( 0 ); // messes up things like config files 83 ::setuid ( 0 ); // messes up things like config files
84 84
85 char *autolog = 0; 85 char *autolog = 0;
86 int c; 86 int c;
87 while (( c = ::getopt_long ( argc, argv, "a:", long_options, 0 )) != -1 ) { 87 while (( c = ::getopt_long ( argc, argv, "a:", long_options, 0 )) != -1 ) {
88 switch ( c ) { 88 switch ( c ) {
89 case 'a': 89 case 'a':
90 autolog = optarg; 90 autolog = optarg;
91 break; 91 break;
92 default: 92 default:
93 ::fprintf ( stderr, "Usage: %s [-a|--autologin=<user>]\n", argv [0] ); 93 ::fprintf ( stderr, "Usage: %s [-a|--autologin=<user>]\n", argv [0] );
94 return 2; 94 return 2;
95 } 95 }
96 } 96 }
97 97
98 //struct rlimit rl; 98 //struct rlimit rl;
99 //::getrlimit ( RLIMIT_NOFILE, &rl ); 99 //::getrlimit ( RLIMIT_NOFILE, &rl );
100 100
101 //for ( unsigned int i = 0; i < rl. rlim_cur; i++ ) 101 //for ( unsigned int i = 0; i < rl. rlim_cur; i++ )
102 // ::close ( i ); 102 // ::close ( i );
103 103
104 ::setpgid ( 0, 0 ); 104 ::setpgid ( 0, 0 );
105 ::setsid ( ); 105 ::setsid ( );
106 106
107 ::signal ( SIGTERM, sigterm ); 107 ::signal ( SIGTERM, sigterm );
108 ::signal ( SIGINT, sigterm ); 108 ::signal ( SIGINT, sigterm );
109 109
110 ::openlog ( "opie-login", LOG_CONS, LOG_AUTHPRIV ); 110 ::openlog ( "opie-login", LOG_CONS, LOG_AUTHPRIV );
111 ::atexit ( exit_closelog ); 111 ::atexit ( exit_closelog );
112 112
113 while ( true ) { 113 while ( true ) {
114 pid_t child = ::fork ( ); 114 pid_t child = ::fork ( );
115 115
116 if ( child < 0 ) { 116 if ( child < 0 ) {
117 ::syslog ( LOG_ERR, "Could not fork GUI process\n" ); 117 ::syslog ( LOG_ERR, "Could not fork GUI process\n" );
118 break; 118 break;
119 } 119 }
120 else if ( child > 0 ) { 120 else if ( child > 0 ) {
121 int status = 0; 121 int status = 0;
122 time_t started = ::time ( 0 ); 122 time_t started = ::time ( 0 );
123 123
124 while ( ::waitpid ( child, &status, 0 ) < 0 ) { } 124 while ( ::waitpid ( child, &status, 0 ) < 0 ) { }
125 125
126 LoginApplication::logout ( ); 126 LoginApplication::logout ( );
127 127
128 if (( ::time ( 0 ) - started ) < 3 ) { 128 if (( ::time ( 0 ) - started ) < 3 ) {
129 if ( autolog ) { 129 if ( autolog ) {
130 ::syslog ( LOG_ERR, "Respawning too fast -- disabling auto-login\n" ); 130 ::syslog ( LOG_ERR, "Respawning too fast -- disabling auto-login\n" );
131 autolog = 0; 131 autolog = 0;
132 } 132 }
133 else { 133 else {
134 ::syslog ( LOG_ERR, "Respawning too fast -- going down\n" ); 134 ::syslog ( LOG_ERR, "Respawning too fast -- going down\n" );
135 break; 135 break;
136 } 136 }
137 } 137 }
138 int killedbysig = 0; 138 int killedbysig = 0;
139 139
140 if ( WIFSIGNALED( status )) { 140 if ( WIFSIGNALED( status )) {
141 switch ( WTERMSIG( status )) { 141 switch ( WTERMSIG( status )) {
142 case SIGINT : 142 case SIGINT :
143 case SIGTERM: 143 case SIGTERM:
144 case SIGKILL: 144 case SIGKILL:
145 break; 145 break;
146 146
147 default : 147 default :
148 killedbysig = WTERMSIG( status ); 148 killedbysig = WTERMSIG( status );
149 break; 149 break;
150 } 150 }
151 } 151 }
152 if ( killedbysig ) { // qpe was killed by an uncaught signal 152 if ( killedbysig ) { // qpe was killed by an uncaught signal
153 qApp = 0; 153 qApp = 0;
154 154
155 ::syslog ( LOG_ERR, "Opie was killed by a signal #%d", killedbysig ); 155 ::syslog ( LOG_ERR, "Opie was killed by a signal #%d", killedbysig );
156 156
157 QWSServer::setDesktopBackground ( QImage ( )); 157 QWSServer::setDesktopBackground ( QImage ( ));
158 QApplication *app = new QApplication ( argc, argv, QApplication::GuiServer ); 158 QApplication *app = new QApplication ( argc, argv, QApplication::GuiServer );
159 app-> setFont ( QFont ( "Helvetica", 10 )); 159 app-> setFont ( QFont ( "Helvetica", 10 ));
160 app-> setStyle ( new QPEStyle ( )); 160 app-> setStyle ( new QPEStyle ( ));
161 161
162 const char *sig = ::strsignal ( killedbysig ); 162 const char *sig = ::strsignal ( killedbysig );
163 QLabel *l = new QLabel ( 0, "sig", Qt::WStyle_Customize | Qt::WStyle_NoBorder | Qt::WStyle_Tool ); 163 QLabel *l = new QLabel ( 0, "sig", Qt::WStyle_Customize | Qt::WStyle_NoBorder | Qt::WStyle_Tool );
164 l-> setText ( LoginWindowImpl::tr( "OPIE was terminated\nby an uncaught signal\n(%1)\n" ). arg ( sig )); 164 l-> setText ( LoginWindowImpl::tr( "OPIE was terminated\nby an uncaught signal\n(%1)\n" ). arg ( sig ));
165 l-> setAlignment ( Qt::AlignCenter ); 165 l-> setAlignment ( Qt::AlignCenter );
166 l-> move ( 0, 0 ); 166 l-> move ( 0, 0 );
167 l-> resize ( app-> desktop ( )-> width ( ), app-> desktop ( )-> height ( )); 167 l-> resize ( app-> desktop ( )-> width ( ), app-> desktop ( )-> height ( ));
168 l-> show ( ); 168 l-> show ( );
169 QTimer::singleShot ( 3000, app, SLOT( quit ( ))); 169 QTimer::singleShot ( 3000, app, SLOT( quit ( )));
170 app-> exec ( ); 170 app-> exec ( );
171 delete app; 171 delete app;
172 qApp = 0; 172 qApp = 0;
173 } 173 }
174 } 174 }
175 else { 175 else {
176 if ( !autolog ) { 176 if ( !autolog ) {
177 Config cfg ( "opie-login" ); 177 Config cfg ( "opie-login" );
178 cfg. setGroup ( "General" ); 178 cfg. setGroup ( "General" );
179 QString user = cfg. readEntry ( "AutoLogin" ); 179 QString user = cfg. readEntry ( "AutoLogin" );
180 180
181 if ( !user. isEmpty ( )) 181 if ( !user. isEmpty ( ))
182 autolog = ::strdup ( user. latin1 ( )); 182 autolog = ::strdup ( user. latin1 ( ));
183 } 183 }
184 184
185 if ( autolog ) { 185 if ( autolog ) {
186 LoginApplication::setLoginAs ( autolog ); 186 LoginApplication::setLoginAs ( autolog );
187 187
188 if ( LoginApplication::changeIdentity ( )) 188 if ( LoginApplication::changeIdentity ( ))
189 ::exit ( LoginApplication::login ( )); 189 ::exit ( LoginApplication::login ( ));
190 else 190 else
191 ::exit ( 0 ); 191 ::exit ( 0 );
192 } 192 }
193 else 193 else
194 ::exit ( login_main ( argc, argv, ppid )); 194 ::exit ( login_main ( argc, argv, ppid ));
195 } 195 }
196 } 196 }
197 return 0; 197 return 0;
198} 198}
199 199
200void sigterm ( int /*sig*/ ) 200void sigterm ( int /*sig*/ )
201{ 201{
202 ::exit ( 0 ); 202 ::exit ( 0 );
203} 203}
204 204
205 205
206void exit_closelog ( ) 206void exit_closelog ( )
207{ 207{
208 ::closelog ( ); 208 ::closelog ( );
209} 209}
210 210
211 211
212class LoginScreenSaver : public QWSScreenSaver 212class LoginScreenSaver : public QWSScreenSaver
213{ 213{
214public: 214public:
215 LoginScreenSaver ( ) 215 LoginScreenSaver ( )
216 { 216 {
217 m_lcd_status = true; 217 m_lcd_status = true;
218 218
219 m_backlight_bright = -1; 219 m_backlight_bright = -1;
220 m_backlight_forcedoff = false; 220 m_backlight_forcedoff = false;
221 221
222 // Make sure the LCD is in fact on, (if opie was killed while the LCD is off it would still be off) 222 // Make sure the LCD is in fact on, (if opie was killed while the LCD is off it would still be off)
223 ODevice::inst ( )-> setDisplayStatus ( true ); 223 ODevice::inst ( )-> setDisplayStatus ( true );
224 } 224 }
225 void restore() 225 void restore()
226 { 226 {
227 if ( !m_lcd_status ) // We must have turned it off 227 if ( !m_lcd_status ) // We must have turned it off
228 ODevice::inst ( ) -> setDisplayStatus ( true ); 228 ODevice::inst ( ) -> setDisplayStatus ( true );
229 229
230 setBacklight ( -3 ); 230 setBacklight ( -3 );
231 } 231 }
232 bool save( int level ) 232 bool save( int level )
233 { 233 {
234 switch ( level ) { 234 switch ( level ) {
235 case 0: 235 case 0:
236 if ( backlight() > 1 ) 236 if ( backlight() > 1 )
237 setBacklight( 1 ); // lowest non-off 237 setBacklight( 1 ); // lowest non-off
238 return true; 238 return true;
239 break; 239 break;
240 case 1: 240 case 1:
241 setBacklight( 0 ); // off 241 setBacklight( 0 ); // off
242 return true; 242 return true;
243 break; 243 break;
244 case 2: 244 case 2:
245 // We're going to suspend the whole machine 245 // We're going to suspend the whole machine
246 if ( PowerStatusManager::readStatus().acStatus() != PowerStatus::Online ) { 246 if ( PowerStatusManager::readStatus().acStatus() != PowerStatus::Online ) {
247 QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); 247 QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE );
248 return true; 248 return true;
249 } 249 }
250 break; 250 break;
251 } 251 }
252 return false; 252 return false;
253 } 253 }
254 254
255private: 255private:
256public: 256public:
257 void setIntervals( int i1 = 30, int i2 = 20, int i3 = 60 ) 257 void setIntervals( int i1 = 30, int i2 = 20, int i3 = 60 )
258 { 258 {
259 int v [4]; 259 int v [4];
260 260
261 v [ 0 ] = QMAX( 1000 * i1, 100 ); 261 v [ 0 ] = QMAX( 1000 * i1, 100 );
262 v [ 1 ] = QMAX( 1000 * i2, 100 ); 262 v [ 1 ] = QMAX( 1000 * i2, 100 );
263 v [ 2 ] = QMAX( 1000 * i3, 100 ); 263 v [ 2 ] = QMAX( 1000 * i3, 100 );
264 v [ 3 ] = 0; 264 v [ 3 ] = 0;
265 265
266 if ( !i1 && !i2 && !i3 ) 266 if ( !i1 && !i2 && !i3 )
267 QWSServer::setScreenSaverInterval ( 0 ); 267 QWSServer::setScreenSaverInterval ( 0 );
268 else 268 else
269 QWSServer::setScreenSaverIntervals ( v ); 269 QWSServer::setScreenSaverIntervals ( v );
270 } 270 }
271 271
272 int backlight ( ) 272 int backlight ( )
273 { 273 {
274 if ( m_backlight_bright == -1 ) 274 if ( m_backlight_bright == -1 )
275 m_backlight_bright = 255; 275 m_backlight_bright = 255;
276 276
277 return m_backlight_bright; 277 return m_backlight_bright;
278 } 278 }
279 279
280 void setBacklight ( int bright ) 280 void setBacklight ( int bright )
281 { 281 {
282 if ( bright == -3 ) { 282 if ( bright == -3 ) {
283 // Forced on 283 // Forced on
284 m_backlight_forcedoff = false; 284 m_backlight_forcedoff = false;
285 bright = -1; 285 bright = -1;
286 } 286 }
287 if ( m_backlight_forcedoff && bright != -2 ) 287 if ( m_backlight_forcedoff && bright != -2 )
288 return ; 288 return ;
289 if ( bright == -2 ) { 289 if ( bright == -2 ) {
290 // Toggle between off and on 290 // Toggle between off and on
291 bright = m_backlight_bright ? 0 : -1; 291 bright = m_backlight_bright ? 0 : -1;
292 m_backlight_forcedoff = !bright; 292 m_backlight_forcedoff = !bright;
293 } 293 }
294 294
295 m_backlight_bright = bright; 295 m_backlight_bright = bright;
296 296
297 bright = backlight ( ); 297 bright = backlight ( );
298 ODevice::inst ( ) -> setDisplayBrightness ( bright ); 298 ODevice::inst ( ) -> setDisplayBrightness ( bright );
299 299
300 m_backlight_bright = bright; 300 m_backlight_bright = bright;
301 } 301 }
302 302
303private: 303private:
304 bool m_lcd_status; 304 bool m_lcd_status;
305 305
306 int m_backlight_bright; 306 int m_backlight_bright;
307 bool m_backlight_forcedoff; 307 bool m_backlight_forcedoff;
308}; 308};
309 309
310 310
311namespace Opie { extern int force_appearance; } // HACK to get around the force-style setting 311namespace Opie { extern int force_appearance; } // HACK to get around the force-style setting
312 312
313 313
314int login_main ( int argc, char **argv, pid_t ppid ) 314int login_main ( int argc, char **argv, pid_t ppid )
315{ 315{
316 QWSServer::setDesktopBackground( QImage() ); 316 QWSServer::setDesktopBackground( QImage() );
317 LoginApplication *app = new LoginApplication ( argc, argv, ppid ); 317 LoginApplication *app = new LoginApplication ( argc, argv, ppid );
318 318
319 Opie::force_appearance = 0; 319 Opie::force_appearance = 0;
320 320
321 app-> setFont ( QFont ( "Helvetica", 10 )); 321 app-> setFont ( QFont ( "Helvetica", 10 ));
322 app-> setStyle ( new QPEStyle ( )); 322 app-> setStyle ( new QPEStyle ( ));
323 323
324 ODevice::inst ( )-> setSoftSuspend ( true ); 324 ODevice::inst ( )-> setSoftSuspend ( true );
325 325
326#if defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) 326#if defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_IPAQ) || defined(QT_QWS_SL5XXX)
327 if ( !QFile::exists ( "/etc/pointercal" )) { 327 if ( !QFile::exists ( "/etc/pointercal" )) {
328 // Make sure calibration widget starts on top. 328 // Make sure calibration widget starts on top.
329 Calibrate *cal = new Calibrate; 329 Calibrate *cal = new Calibrate;
330 cal-> exec ( ); 330 cal-> exec ( );
331 delete cal; 331 delete cal;
332 } 332 }
333#endif 333#endif
334 334
335 LoginScreenSaver *saver = new LoginScreenSaver; 335 LoginScreenSaver *saver = new LoginScreenSaver;
336 336
337 saver-> setIntervals ( ); 337 saver-> setIntervals ( );
338 QWSServer::setScreenSaver ( saver ); 338 QWSServer::setScreenSaver ( saver );
339 saver-> restore ( ); 339 saver-> restore ( );
340 340
341 341
342 LoginWindowImpl *lw = new LoginWindowImpl ( ); 342 LoginWindowImpl *lw = new LoginWindowImpl ( );
343 app-> setMainWidget ( lw ); 343 app-> setMainWidget ( lw );
344 lw-> setGeometry ( 0, 0, app-> desktop ( )-> width ( ), app-> desktop ( )-> height ( )); 344 lw-> setGeometry ( 0, 0, app-> desktop ( )-> width ( ), app-> desktop ( )-> height ( ));
345 lw-> show ( ); 345 lw-> show ( );
346 346
347 int rc = app-> exec ( ); 347 int rc = app-> exec ( );
348 348
349 ODevice::inst ( )-> setSoftSuspend ( false ); 349 ODevice::inst ( )-> setSoftSuspend ( false );
350 350
351 if ( app-> loginAs ( )) { 351 if ( app-> loginAs ( )) {
352 if ( app-> changeIdentity ( )) { 352 if ( app-> changeIdentity ( )) {
353 app-> login ( ); 353 app-> login ( );
354 354
355 // if login succeeds, it never comes back 355 // if login succeeds, it never comes back
356 356
357 QMessageBox::critical ( 0, LoginWindowImpl::tr( "Failure" ), LoginWindowImpl::tr( "Could not start OPIE." )); 357 QMessageBox::critical ( 0, LoginWindowImpl::tr( "Failure" ), LoginWindowImpl::tr( "Could not start OPIE." ));
358 rc = 1; 358 rc = 1;
359 } 359 }
360 else { 360 else {
361 QMessageBox::critical ( 0, LoginWindowImpl::tr( "Failure" ), LoginWindowImpl::tr( "Could not switch to new user identity" )); 361 QMessageBox::critical ( 0, LoginWindowImpl::tr( "Failure" ), LoginWindowImpl::tr( "Could not switch to new user identity" ));
362 rc = 2; 362 rc = 2;
363 } 363 }
364 364
365 } 365 }
366 return rc; 366 return rc;
367} 367}
368 368
diff --git a/library/power.cpp b/library/power.cpp
index 21c8960..5310b47 100644
--- a/library/power.cpp
+++ b/library/power.cpp
@@ -1,171 +1,171 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the 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 "power.h" 21#include "power.h"
22 22
23#ifdef QT_QWS_SHARP 23#ifdef QT_QWS_SL5XXX
24#include "custom.h" 24#include "custom.h"
25#endif 25#endif
26 26
27#include <unistd.h> 27#include <unistd.h>
28#include <stdlib.h> 28#include <stdlib.h>
29#include <stdio.h> 29#include <stdio.h>
30#include <fcntl.h> 30#include <fcntl.h>
31#include <sys/ioctl.h> 31#include <sys/ioctl.h>
32 32
33#ifdef QT_QWS_IPAQ_NO_APM 33#ifdef QT_QWS_IPAQ_NO_APM
34#include <linux/h3600_ts.h> 34#include <linux/h3600_ts.h>
35#endif 35#endif
36 36
37PowerStatusManager *PowerStatusManager::powerManager = 0; 37PowerStatusManager *PowerStatusManager::powerManager = 0;
38PowerStatus *PowerStatusManager::ps = 0; 38PowerStatus *PowerStatusManager::ps = 0;
39 39
40static bool haveProcApm = false; 40static bool haveProcApm = false;
41 41
42PowerStatusManager::PowerStatusManager() 42PowerStatusManager::PowerStatusManager()
43{ 43{
44 powerManager = this; 44 powerManager = this;
45 ps = new PowerStatus; 45 ps = new PowerStatus;
46 FILE *f = fopen("/proc/apm", "r"); 46 FILE *f = fopen("/proc/apm", "r");
47 if ( f ) { 47 if ( f ) {
48 fclose(f); 48 fclose(f);
49 haveProcApm = TRUE; 49 haveProcApm = TRUE;
50 } 50 }
51} 51}
52 52
53const PowerStatus &PowerStatusManager::readStatus() 53const PowerStatus &PowerStatusManager::readStatus()
54{ 54{
55 if ( !powerManager ) 55 if ( !powerManager )
56 (void)new PowerStatusManager; 56 (void)new PowerStatusManager;
57 57
58 powerManager->getStatus(); 58 powerManager->getStatus();
59 59
60 return *ps; 60 return *ps;
61} 61}
62 62
63// Standard /proc/apm reader 63// Standard /proc/apm reader
64bool PowerStatusManager::getProcApmStatus( int &ac, int &bs, int &bf, int &pc, int &sec ) 64bool PowerStatusManager::getProcApmStatus( int &ac, int &bs, int &bf, int &pc, int &sec )
65{ 65{
66 bool ok = false; 66 bool ok = false;
67 67
68 ac = 0xff; 68 ac = 0xff;
69 bs = 0xff; 69 bs = 0xff;
70 bf = 0xff; 70 bf = 0xff;
71 pc = -1; 71 pc = -1;
72 sec = -1; 72 sec = -1;
73 73
74 FILE *f = fopen("/proc/apm", "r"); 74 FILE *f = fopen("/proc/apm", "r");
75 if ( f ) { 75 if ( f ) {
76 //I 1.13 1.2 0x02 0x00 0xff 0xff 49% 147 sec 76 //I 1.13 1.2 0x02 0x00 0xff 0xff 49% 147 sec
77 char u; 77 char u;
78 fscanf(f, "%*[^ ] %*d.%*d 0x%*x 0x%x 0x%x 0x%x %d%% %i %c", 78 fscanf(f, "%*[^ ] %*d.%*d 0x%*x 0x%x 0x%x 0x%x %d%% %i %c",
79 &ac, &bs, &bf, &pc, &sec, &u); 79 &ac, &bs, &bf, &pc, &sec, &u);
80 fclose(f); 80 fclose(f);
81 switch ( u ) { 81 switch ( u ) {
82 case 'm': sec *= 60; 82 case 'm': sec *= 60;
83 case 's': break; // ok 83 case 's': break; // ok
84 default: sec = -1; // unknown 84 default: sec = -1; // unknown
85 } 85 }
86 86
87 // extract data 87 // extract data
88 switch ( bs ) { 88 switch ( bs ) {
89 case 0x00: 89 case 0x00:
90 ps->bs = PowerStatus::High; 90 ps->bs = PowerStatus::High;
91 break; 91 break;
92 case 0x01: 92 case 0x01:
93 ps->bs = PowerStatus::Low; 93 ps->bs = PowerStatus::Low;
94 break; 94 break;
95 case 0x7f: 95 case 0x7f:
96 ps->bs = PowerStatus::VeryLow; 96 ps->bs = PowerStatus::VeryLow;
97 break; 97 break;
98 case 0x02: 98 case 0x02:
99 ps->bs = PowerStatus::Critical; 99 ps->bs = PowerStatus::Critical;
100 break; 100 break;
101 case 0x03: 101 case 0x03:
102 ps->bs = PowerStatus::Charging; 102 ps->bs = PowerStatus::Charging;
103 break; 103 break;
104 case 0x04: 104 case 0x04:
105 case 0xff: // 0xff is Unknown but we map to NotPresent 105 case 0xff: // 0xff is Unknown but we map to NotPresent
106 default: 106 default:
107 ps->bs = PowerStatus::NotPresent; 107 ps->bs = PowerStatus::NotPresent;
108 break; 108 break;
109 } 109 }
110 110
111 switch ( ac ) { 111 switch ( ac ) {
112 case 0x00: 112 case 0x00:
113 ps->ac = PowerStatus::Offline; 113 ps->ac = PowerStatus::Offline;
114 break; 114 break;
115 case 0x01: 115 case 0x01:
116 ps->ac = PowerStatus::Online; 116 ps->ac = PowerStatus::Online;
117 break; 117 break;
118 case 0x02: 118 case 0x02:
119 ps->ac = PowerStatus::Backup; 119 ps->ac = PowerStatus::Backup;
120 break; 120 break;
121 } 121 }
122 122
123 if ( pc > 100 ) pc = 100; 123 if ( pc > 100 ) pc = 100;
124 if ( pc < 0 ) pc = 0; 124 if ( pc < 0 ) pc = 0;
125 125
126 ps->percentRemain = pc; 126 ps->percentRemain = pc;
127 ps->secsRemain = sec; 127 ps->secsRemain = sec;
128 128
129 ok = true; 129 ok = true;
130 } 130 }
131 131
132 return ok; 132 return ok;
133} 133}
134 134
135void PowerStatusManager::getStatus() 135void PowerStatusManager::getStatus()
136{ 136{
137 bool usedApm = FALSE; 137 bool usedApm = FALSE;
138 138
139 ps->percentAccurate = TRUE; 139 ps->percentAccurate = TRUE;
140 140
141 // Some iPAQ kernel builds don't have APM. If this is not the case we 141 // Some iPAQ kernel builds don't have APM. If this is not the case we
142 // save ourselves an ioctl by testing if /proc/apm exists in the 142 // save ourselves an ioctl by testing if /proc/apm exists in the
143 // constructor and we use /proc/apm instead 143 // constructor and we use /proc/apm instead
144 int ac, bs, bf, pc, sec; 144 int ac, bs, bf, pc, sec;
145 if ( haveProcApm ) 145 if ( haveProcApm )
146 usedApm = getProcApmStatus( ac, bs, bf, pc, sec ); 146 usedApm = getProcApmStatus( ac, bs, bf, pc, sec );
147 147
148 if ( !usedApm ) { 148 if ( !usedApm ) {
149#ifdef QT_QWS_IPAQ_NO_APM 149#ifdef QT_QWS_IPAQ_NO_APM
150 int fd; 150 int fd;
151 int err; 151 int err;
152 struct bat_dev batt_info; 152 struct bat_dev batt_info;
153 153
154 memset(&batt_info, 0, sizeof(batt_info)); 154 memset(&batt_info, 0, sizeof(batt_info));
155 155
156 fd = ::open("/dev/ts",O_RDONLY); 156 fd = ::open("/dev/ts",O_RDONLY);
157 if( fd < 0 ) 157 if( fd < 0 )
158 return; 158 return;
159 159
160 ioctl(fd, GET_BATTERY_STATUS, &batt_info); 160 ioctl(fd, GET_BATTERY_STATUS, &batt_info);
161 ac_status = batt_info.ac_status; 161 ac_status = batt_info.ac_status;
162 ps->percentRemain = ( 425 * batt_info.batt1_voltage ) / 1000 - 298; // from h3600_ts.c 162 ps->percentRemain = ( 425 * batt_info.batt1_voltage ) / 1000 - 298; // from h3600_ts.c
163 ps->secsRemain = -1; // seconds is bogus on iPAQ 163 ps->secsRemain = -1; // seconds is bogus on iPAQ
164 ::close (fd); 164 ::close (fd);
165#else 165#else
166 ps->percentRemain = 100; 166 ps->percentRemain = 100;
167 ps->secsRemain = -1; 167 ps->secsRemain = -1;
168 ps->percentAccurate = FALSE; 168 ps->percentAccurate = FALSE;
169#endif 169#endif
170 } 170 }
171} 171}
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index 95c4a1b..7463074 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -1,1806 +1,1806 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the 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** $Id$ 19** $Id$
20** 20**
21**********************************************************************/ 21**********************************************************************/
22#define QTOPIA_INTERNAL_LANGLIST 22#define QTOPIA_INTERNAL_LANGLIST
23#include <stdlib.h> 23#include <stdlib.h>
24#include <unistd.h> 24#include <unistd.h>
25#include <linux/limits.h> // needed for some toolchains (PATH_MAX) 25#include <linux/limits.h> // needed for some toolchains (PATH_MAX)
26#include <qfile.h> 26#include <qfile.h>
27#ifdef Q_WS_QWS 27#ifdef Q_WS_QWS
28#ifndef QT_NO_COP 28#ifndef QT_NO_COP
29#if QT_VERSION <= 231 29#if QT_VERSION <= 231
30#define private public 30#define private public
31#define sendLocally processEvent 31#define sendLocally processEvent
32#include "qcopenvelope_qws.h" 32#include "qcopenvelope_qws.h"
33#undef private 33#undef private
34#else 34#else
35#include "qcopenvelope_qws.h" 35#include "qcopenvelope_qws.h"
36#endif 36#endif
37#endif 37#endif
38#include <qwindowsystem_qws.h> 38#include <qwindowsystem_qws.h>
39#endif 39#endif
40#include <qtextstream.h> 40#include <qtextstream.h>
41#include <qpalette.h> 41#include <qpalette.h>
42#include <qbuffer.h> 42#include <qbuffer.h>
43#include <qptrdict.h> 43#include <qptrdict.h>
44#include <qregexp.h> 44#include <qregexp.h>
45#include <qdir.h> 45#include <qdir.h>
46#include <qlabel.h> 46#include <qlabel.h>
47#include <qdialog.h> 47#include <qdialog.h>
48#include <qdragobject.h> 48#include <qdragobject.h>
49#include <qtextcodec.h> 49#include <qtextcodec.h>
50#include <qevent.h> 50#include <qevent.h>
51#include <qtooltip.h> 51#include <qtooltip.h>
52#include <qsignal.h> 52#include <qsignal.h>
53#include "qpeapplication.h" 53#include "qpeapplication.h"
54#include "qpestyle.h" 54#include "qpestyle.h"
55#include "styleinterface.h" 55#include "styleinterface.h"
56#if QT_VERSION >= 300 56#if QT_VERSION >= 300
57#include <qstylefactory.h> 57#include <qstylefactory.h>
58#else 58#else
59#include <qplatinumstyle.h> 59#include <qplatinumstyle.h>
60#include <qwindowsstyle.h> 60#include <qwindowsstyle.h>
61#include <qmotifstyle.h> 61#include <qmotifstyle.h>
62#include <qmotifplusstyle.h> 62#include <qmotifplusstyle.h>
63#include "lightstyle.h" 63#include "lightstyle.h"
64 64
65#include <qpe/qlibrary.h> 65#include <qpe/qlibrary.h>
66#endif 66#endif
67#include "global.h" 67#include "global.h"
68#include "resource.h" 68#include "resource.h"
69#if QT_VERSION <= 230 && defined(QT_NO_CODECS) 69#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
70#include "qutfcodec.h" 70#include "qutfcodec.h"
71#endif 71#endif
72#include "config.h" 72#include "config.h"
73#include "network.h" 73#include "network.h"
74#ifdef QWS 74#ifdef QWS
75#include "fontmanager.h" 75#include "fontmanager.h"
76#endif 76#endif
77 77
78#include "alarmserver.h" 78#include "alarmserver.h"
79#include "applnk.h" 79#include "applnk.h"
80#include "qpemenubar.h" 80#include "qpemenubar.h"
81#include "textcodecinterface.h" 81#include "textcodecinterface.h"
82#include "imagecodecinterface.h" 82#include "imagecodecinterface.h"
83 83
84#include <unistd.h> 84#include <unistd.h>
85#include <sys/file.h> 85#include <sys/file.h>
86#include <sys/ioctl.h> 86#include <sys/ioctl.h>
87#include <sys/soundcard.h> 87#include <sys/soundcard.h>
88 88
89#include "qt_override_p.h" 89#include "qt_override_p.h"
90 90
91 91
92class QPEApplicationData 92class QPEApplicationData
93{ 93{
94public: 94public:
95 QPEApplicationData ( ) 95 QPEApplicationData ( )
96 : presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ), 96 : presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ),
97 notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ), 97 notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ),
98 keep_running( true ), qpe_main_widget( 0 ) 98 keep_running( true ), qpe_main_widget( 0 )
99 99
100 { 100 {
101 qcopq.setAutoDelete( TRUE ); 101 qcopq.setAutoDelete( TRUE );
102 } 102 }
103 103
104 int presstimer; 104 int presstimer;
105 QWidget* presswidget; 105 QWidget* presswidget;
106 QPoint presspos; 106 QPoint presspos;
107 107
108 bool rightpressed : 1; 108 bool rightpressed : 1;
109 bool kbgrabbed : 1; 109 bool kbgrabbed : 1;
110 bool notbusysent : 1; 110 bool notbusysent : 1;
111 bool preloaded : 1; 111 bool preloaded : 1;
112 bool forceshow : 1; 112 bool forceshow : 1;
113 bool nomaximize : 1; 113 bool nomaximize : 1;
114 bool keep_running : 1; 114 bool keep_running : 1;
115 115
116 QString appName; 116 QString appName;
117 struct QCopRec 117 struct QCopRec
118 { 118 {
119 QCopRec( const QCString &ch, const QCString &msg, 119 QCopRec( const QCString &ch, const QCString &msg,
120 const QByteArray &d ) : 120 const QByteArray &d ) :
121 channel( ch ), message( msg ), data( d ) 121 channel( ch ), message( msg ), data( d )
122 { } 122 { }
123 123
124 QCString channel; 124 QCString channel;
125 QCString message; 125 QCString message;
126 QByteArray data; 126 QByteArray data;
127 }; 127 };
128 QWidget* qpe_main_widget; 128 QWidget* qpe_main_widget;
129 QList<QCopRec> qcopq; 129 QList<QCopRec> qcopq;
130 130
131 void enqueueQCop( const QCString &ch, const QCString &msg, 131 void enqueueQCop( const QCString &ch, const QCString &msg,
132 const QByteArray &data ) 132 const QByteArray &data )
133 { 133 {
134 qcopq.append( new QCopRec( ch, msg, data ) ); 134 qcopq.append( new QCopRec( ch, msg, data ) );
135 } 135 }
136 void sendQCopQ() 136 void sendQCopQ()
137 { 137 {
138 QCopRec * r; 138 QCopRec * r;
139#ifndef QT_NO_COP 139#ifndef QT_NO_COP
140 140
141 for ( QListIterator<QCopRec> it( qcopq ); ( r = it.current() ); ++it ) 141 for ( QListIterator<QCopRec> it( qcopq ); ( r = it.current() ); ++it )
142 QCopChannel::sendLocally( r->channel, r->message, r->data ); 142 QCopChannel::sendLocally( r->channel, r->message, r->data );
143#endif 143#endif
144 144
145 qcopq.clear(); 145 qcopq.clear();
146 } 146 }
147 static void show_mx(QWidget* mw, bool nomaximize) 147 static void show_mx(QWidget* mw, bool nomaximize)
148 { 148 {
149 if ( mw->layout() && mw->inherits("QDialog") ) { 149 if ( mw->layout() && mw->inherits("QDialog") ) {
150 QPEApplication::showDialog((QDialog*)mw, nomaximize); 150 QPEApplication::showDialog((QDialog*)mw, nomaximize);
151 } 151 }
152 else { 152 else {
153#ifdef Q_WS_QWS 153#ifdef Q_WS_QWS
154 if ( !nomaximize ) 154 if ( !nomaximize )
155 mw->showMaximized(); 155 mw->showMaximized();
156 else 156 else
157#endif 157#endif
158 158
159 mw->show(); 159 mw->show();
160 } 160 }
161 } 161 }
162 static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) 162 static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ )
163 { 163 {
164 /* 164 /*
165 // This works but disable it for now until it is safe to apply 165 // This works but disable it for now until it is safe to apply
166 // What is does is scan the .desktop files of all the apps for 166 // What is does is scan the .desktop files of all the apps for
167 // the applnk that has the corresponding argv[0] as this program 167 // the applnk that has the corresponding argv[0] as this program
168 // then it uses the name stored in the .desktop file as the caption 168 // then it uses the name stored in the .desktop file as the caption
169 // for the main widget. This saves duplicating translations for 169 // for the main widget. This saves duplicating translations for
170 // the app name in the program and in the .desktop files. 170 // the app name in the program and in the .desktop files.
171 171
172 AppLnkSet apps( appsPath ); 172 AppLnkSet apps( appsPath );
173 173
174 QList<AppLnk> appsList = apps.children(); 174 QList<AppLnk> appsList = apps.children();
175 for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { 175 for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) {
176 if ( (*it)->exec() == appName ) { 176 if ( (*it)->exec() == appName ) {
177 mw->setCaption( (*it)->name() ); 177 mw->setCaption( (*it)->name() );
178 return TRUE; 178 return TRUE;
179 } 179 }
180 } 180 }
181 */ 181 */
182 return FALSE; 182 return FALSE;
183 } 183 }
184 184
185 185
186 void show(QWidget* mw, bool nomax) 186 void show(QWidget* mw, bool nomax)
187 { 187 {
188 setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); 188 setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" );
189 nomaximize = nomax; 189 nomaximize = nomax;
190 qpe_main_widget = mw; 190 qpe_main_widget = mw;
191#ifndef QT_NO_COP 191#ifndef QT_NO_COP
192 192
193 sendQCopQ(); 193 sendQCopQ();
194#endif 194#endif
195 195
196 if ( preloaded ) { 196 if ( preloaded ) {
197 if (forceshow) 197 if (forceshow)
198 show_mx(mw, nomax); 198 show_mx(mw, nomax);
199 } 199 }
200 else if ( keep_running ) { 200 else if ( keep_running ) {
201 show_mx(mw, nomax); 201 show_mx(mw, nomax);
202 } 202 }
203 } 203 }
204 204
205 void loadTextCodecs() 205 void loadTextCodecs()
206 { 206 {
207 QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; 207 QString path = QPEApplication::qpeDir() + "/plugins/textcodecs";
208 QDir dir( path, "lib*.so" ); 208 QDir dir( path, "lib*.so" );
209 QStringList list; 209 QStringList list;
210 if ( dir. exists ( )) 210 if ( dir. exists ( ))
211 list = dir.entryList(); 211 list = dir.entryList();
212 QStringList::Iterator it; 212 QStringList::Iterator it;
213 for ( it = list.begin(); it != list.end(); ++it ) { 213 for ( it = list.begin(); it != list.end(); ++it ) {
214 TextCodecInterface *iface = 0; 214 TextCodecInterface *iface = 0;
215 QLibrary *lib = new QLibrary( path + "/" + *it ); 215 QLibrary *lib = new QLibrary( path + "/" + *it );
216 if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { 216 if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) {
217 QValueList<int> mibs = iface->mibEnums(); 217 QValueList<int> mibs = iface->mibEnums();
218 for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { 218 for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) {
219 (void)iface->createForMib(*i); 219 (void)iface->createForMib(*i);
220 // ### it exists now; need to remember if we can delete it 220 // ### it exists now; need to remember if we can delete it
221 } 221 }
222 } 222 }
223 else { 223 else {
224 lib->unload(); 224 lib->unload();
225 delete lib; 225 delete lib;
226 } 226 }
227 } 227 }
228 } 228 }
229 229
230 void loadImageCodecs() 230 void loadImageCodecs()
231 { 231 {
232 QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; 232 QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs";
233 QDir dir( path, "lib*.so" ); 233 QDir dir( path, "lib*.so" );
234 QStringList list; 234 QStringList list;
235 if ( dir. exists ( )) 235 if ( dir. exists ( ))
236 list = dir.entryList(); 236 list = dir.entryList();
237 QStringList::Iterator it; 237 QStringList::Iterator it;
238 for ( it = list.begin(); it != list.end(); ++it ) { 238 for ( it = list.begin(); it != list.end(); ++it ) {
239 ImageCodecInterface *iface = 0; 239 ImageCodecInterface *iface = 0;
240 QLibrary *lib = new QLibrary( path + "/" + *it ); 240 QLibrary *lib = new QLibrary( path + "/" + *it );
241 if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { 241 if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) {
242 QStringList formats = iface->keys(); 242 QStringList formats = iface->keys();
243 for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { 243 for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) {
244 (void)iface->installIOHandler(*i); 244 (void)iface->installIOHandler(*i);
245 // ### it exists now; need to remember if we can delete it 245 // ### it exists now; need to remember if we can delete it
246 } 246 }
247 } 247 }
248 else { 248 else {
249 lib->unload(); 249 lib->unload();
250 delete lib; 250 delete lib;
251 } 251 }
252 } 252 }
253 } 253 }
254 QString styleName; 254 QString styleName;
255 QString decorationName; 255 QString decorationName;
256}; 256};
257 257
258class ResourceMimeFactory : public QMimeSourceFactory 258class ResourceMimeFactory : public QMimeSourceFactory
259{ 259{
260public: 260public:
261 ResourceMimeFactory() 261 ResourceMimeFactory()
262 { 262 {
263 setFilePath( Global::helpPath() ); 263 setFilePath( Global::helpPath() );
264 setExtensionType( "html", "text/html;charset=UTF-8" ); 264 setExtensionType( "html", "text/html;charset=UTF-8" );
265 } 265 }
266 266
267 const QMimeSource* data( const QString& abs_name ) const 267 const QMimeSource* data( const QString& abs_name ) const
268 { 268 {
269 const QMimeSource * r = QMimeSourceFactory::data( abs_name ); 269 const QMimeSource * r = QMimeSourceFactory::data( abs_name );
270 if ( !r ) { 270 if ( !r ) {
271 int sl = abs_name.length(); 271 int sl = abs_name.length();
272 do { 272 do {
273 sl = abs_name.findRev( '/', sl - 1 ); 273 sl = abs_name.findRev( '/', sl - 1 );
274 QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; 274 QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name;
275 int dot = name.findRev( '.' ); 275 int dot = name.findRev( '.' );
276 if ( dot >= 0 ) 276 if ( dot >= 0 )
277 name = name.left( dot ); 277 name = name.left( dot );
278 QImage img = Resource::loadImage( name ); 278 QImage img = Resource::loadImage( name );
279 if ( !img.isNull() ) 279 if ( !img.isNull() )
280 r = new QImageDrag( img ); 280 r = new QImageDrag( img );
281 } 281 }
282 while ( !r && sl > 0 ); 282 while ( !r && sl > 0 );
283 } 283 }
284 return r; 284 return r;
285 } 285 }
286}; 286};
287 287
288static int muted = 0; 288static int muted = 0;
289static int micMuted = 0; 289static int micMuted = 0;
290 290
291static void setVolume( int t = 0, int percent = -1 ) 291static void setVolume( int t = 0, int percent = -1 )
292{ 292{
293 switch ( t ) { 293 switch ( t ) {
294 case 0: { 294 case 0: {
295 Config cfg( "qpe" ); 295 Config cfg( "qpe" );
296 cfg.setGroup( "Volume" ); 296 cfg.setGroup( "Volume" );
297 if ( percent < 0 ) 297 if ( percent < 0 )
298 percent = cfg.readNumEntry( "VolumePercent", 50 ); 298 percent = cfg.readNumEntry( "VolumePercent", 50 );
299 int fd = 0; 299 int fd = 0;
300 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 300 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
301 int vol = muted ? 0 : percent; 301 int vol = muted ? 0 : percent;
302 // set both channels to same volume 302 // set both channels to same volume
303 vol |= vol << 8; 303 vol |= vol << 8;
304 ioctl( fd, MIXER_WRITE( 0 ), &vol ); 304 ioctl( fd, MIXER_WRITE( 0 ), &vol );
305 ::close( fd ); 305 ::close( fd );
306 } 306 }
307 } 307 }
308 break; 308 break;
309 } 309 }
310} 310}
311 311
312static void setMic( int t = 0, int percent = -1 ) 312static void setMic( int t = 0, int percent = -1 )
313{ 313{
314 switch ( t ) { 314 switch ( t ) {
315 case 0: { 315 case 0: {
316 Config cfg( "qpe" ); 316 Config cfg( "qpe" );
317 cfg.setGroup( "Volume" ); 317 cfg.setGroup( "Volume" );
318 if ( percent < 0 ) 318 if ( percent < 0 )
319 percent = cfg.readNumEntry( "Mic", 50 ); 319 percent = cfg.readNumEntry( "Mic", 50 );
320 320
321 int fd = 0; 321 int fd = 0;
322 int mic = micMuted ? 0 : percent; 322 int mic = micMuted ? 0 : percent;
323 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 323 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
324 ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); 324 ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic );
325 ::close( fd ); 325 ::close( fd );
326 } 326 }
327 } 327 }
328 break; 328 break;
329 } 329 }
330} 330}
331 331
332 332
333static void setBass( int t = 0, int percent = -1 ) 333static void setBass( int t = 0, int percent = -1 )
334{ 334{
335 switch ( t ) { 335 switch ( t ) {
336 case 0: { 336 case 0: {
337 Config cfg( "qpe" ); 337 Config cfg( "qpe" );
338 cfg.setGroup( "Volume" ); 338 cfg.setGroup( "Volume" );
339 if ( percent < 0 ) 339 if ( percent < 0 )
340 percent = cfg.readNumEntry( "BassPercent", 50 ); 340 percent = cfg.readNumEntry( "BassPercent", 50 );
341 341
342 int fd = 0; 342 int fd = 0;
343 int bass = percent; 343 int bass = percent;
344 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 344 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
345 ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass ); 345 ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass );
346 ::close( fd ); 346 ::close( fd );
347 } 347 }
348 } 348 }
349 break; 349 break;
350 } 350 }
351} 351}
352 352
353 353
354static void setTreble( int t = 0, int percent = -1 ) 354static void setTreble( int t = 0, int percent = -1 )
355{ 355{
356 switch ( t ) { 356 switch ( t ) {
357 case 0: { 357 case 0: {
358 Config cfg( "qpe" ); 358 Config cfg( "qpe" );
359 cfg.setGroup( "Volume" ); 359 cfg.setGroup( "Volume" );
360 if ( percent < 0 ) 360 if ( percent < 0 )
361 percent = cfg.readNumEntry( "TreblePercent", 50 ); 361 percent = cfg.readNumEntry( "TreblePercent", 50 );
362 362
363 int fd = 0; 363 int fd = 0;
364 int treble = percent; 364 int treble = percent;
365 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 365 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
366 ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble ); 366 ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble );
367 ::close( fd ); 367 ::close( fd );
368 } 368 }
369 } 369 }
370 break; 370 break;
371 } 371 }
372} 372}
373 373
374 374
375/*! 375/*!
376 \class QPEApplication qpeapplication.h 376 \class QPEApplication qpeapplication.h
377 \brief The QPEApplication class implements various system services 377 \brief The QPEApplication class implements various system services
378 that are available to all Qtopia applications. 378 that are available to all Qtopia applications.
379 379
380 Simply by using QPEApplication instead of QApplication, a standard Qt 380 Simply by using QPEApplication instead of QApplication, a standard Qt
381 application becomes a Qtopia application. It automatically follows 381 application becomes a Qtopia application. It automatically follows
382 style changes, quits and raises, and in the 382 style changes, quits and raises, and in the
383 case of \link docwidget.html document-oriented\endlink applications, 383 case of \link docwidget.html document-oriented\endlink applications,
384 changes the currently displayed document in response to the environment. 384 changes the currently displayed document in response to the environment.
385 385
386 To create a \link docwidget.html document-oriented\endlink 386 To create a \link docwidget.html document-oriented\endlink
387 application use showMainDocumentWidget(); to create a 387 application use showMainDocumentWidget(); to create a
388 non-document-oriented application use showMainWidget(). The 388 non-document-oriented application use showMainWidget(). The
389 keepRunning() function indicates whether the application will 389 keepRunning() function indicates whether the application will
390 continue running after it's processed the last \link qcop.html 390 continue running after it's processed the last \link qcop.html
391 QCop\endlink message. This can be changed using setKeepRunning(). 391 QCop\endlink message. This can be changed using setKeepRunning().
392 392
393 A variety of signals are emitted when certain events occur, for 393 A variety of signals are emitted when certain events occur, for
394 example, timeChanged(), clockChanged(), weekChanged(), 394 example, timeChanged(), clockChanged(), weekChanged(),
395 dateFormatChanged() and volumeChanged(). If the application receives 395 dateFormatChanged() and volumeChanged(). If the application receives
396 a \link qcop.html QCop\endlink message on the application's 396 a \link qcop.html QCop\endlink message on the application's
397 QPE/Application/\e{appname} channel, the appMessage() signal is 397 QPE/Application/\e{appname} channel, the appMessage() signal is
398 emitted. There are also flush() and reload() signals, which 398 emitted. There are also flush() and reload() signals, which
399 are emitted when synching begins and ends respectively - upon these 399 are emitted when synching begins and ends respectively - upon these
400 signals, the application should save and reload any data 400 signals, the application should save and reload any data
401 files that are involved in synching. Most of these signals will initially 401 files that are involved in synching. Most of these signals will initially
402 be received and unfiltered through the appMessage() signal. 402 be received and unfiltered through the appMessage() signal.
403 403
404 This class also provides a set of useful static functions. The 404 This class also provides a set of useful static functions. The
405 qpeDir() and documentDir() functions return the respective paths. 405 qpeDir() and documentDir() functions return the respective paths.
406 The grabKeyboard() and ungrabKeyboard() functions are used to 406 The grabKeyboard() and ungrabKeyboard() functions are used to
407 control whether the application takes control of the device's 407 control whether the application takes control of the device's
408 physical buttons (e.g. application launch keys). The stylus' mode of 408 physical buttons (e.g. application launch keys). The stylus' mode of
409 operation is set with setStylusOperation() and retrieved with 409 operation is set with setStylusOperation() and retrieved with
410 stylusOperation(). There are also setInputMethodHint() and 410 stylusOperation(). There are also setInputMethodHint() and
411 inputMethodHint() functions. 411 inputMethodHint() functions.
412 412
413 \ingroup qtopiaemb 413 \ingroup qtopiaemb
414*/ 414*/
415 415
416/*! 416/*!
417 \fn void QPEApplication::clientMoused() 417 \fn void QPEApplication::clientMoused()
418 418
419 \internal 419 \internal
420*/ 420*/
421 421
422/*! 422/*!
423 \fn void QPEApplication::timeChanged(); 423 \fn void QPEApplication::timeChanged();
424 This signal is emitted when the time changes outside the normal 424 This signal is emitted when the time changes outside the normal
425 passage of time, i.e. if the time is set backwards or forwards. 425 passage of time, i.e. if the time is set backwards or forwards.
426*/ 426*/
427 427
428/*! 428/*!
429 \fn void QPEApplication::clockChanged( bool ampm ); 429 \fn void QPEApplication::clockChanged( bool ampm );
430 430
431 This signal is emitted when the user changes the clock's style. If 431 This signal is emitted when the user changes the clock's style. If
432 \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise, 432 \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise,
433 they want a 24-hour clock. 433 they want a 24-hour clock.
434*/ 434*/
435 435
436/*! 436/*!
437 \fn void QPEApplication::volumeChanged( bool muted ) 437 \fn void QPEApplication::volumeChanged( bool muted )
438 438
439 This signal is emitted whenever the mute state is changed. If \a 439 This signal is emitted whenever the mute state is changed. If \a
440 muted is TRUE, then sound output has been muted. 440 muted is TRUE, then sound output has been muted.
441*/ 441*/
442 442
443/*! 443/*!
444 \fn void QPEApplication::weekChanged( bool startOnMonday ) 444 \fn void QPEApplication::weekChanged( bool startOnMonday )
445 445
446 This signal is emitted if the week start day is changed. If \a 446 This signal is emitted if the week start day is changed. If \a
447 startOnMonday is TRUE then the first day of the week is Monday; if 447 startOnMonday is TRUE then the first day of the week is Monday; if
448 \a startOnMonday is FALSE then the first day of the week is 448 \a startOnMonday is FALSE then the first day of the week is
449 Sunday. 449 Sunday.
450*/ 450*/
451 451
452/*! 452/*!
453 \fn void QPEApplication::dateFormatChanged() 453 \fn void QPEApplication::dateFormatChanged()
454 454
455 This signal is emitted whenever the date format is changed. 455 This signal is emitted whenever the date format is changed.
456*/ 456*/
457 457
458/*! 458/*!
459 \fn void QPEApplication::flush() 459 \fn void QPEApplication::flush()
460 460
461 ### 461 ###
462*/ 462*/
463 463
464/*! 464/*!
465 \fn void QPEApplication::reload() 465 \fn void QPEApplication::reload()
466 466
467*/ 467*/
468 468
469/*! 469/*!
470 \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) 470 \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data )
471 471
472 This signal is emitted when a message is received on this 472 This signal is emitted when a message is received on this
473 application's QPE/Application/<i>appname</i> \link qcop.html 473 application's QPE/Application/<i>appname</i> \link qcop.html
474 QCop\endlink channel. 474 QCop\endlink channel.
475 475
476 The slot to which you connect this signal uses \a msg and \a data 476 The slot to which you connect this signal uses \a msg and \a data
477 in the following way: 477 in the following way:
478 478
479\code 479\code
480 void MyWidget::receive( const QCString& msg, const QByteArray& data ) 480 void MyWidget::receive( const QCString& msg, const QByteArray& data )
481 { 481 {
482 QDataStream stream( data, IO_ReadOnly ); 482 QDataStream stream( data, IO_ReadOnly );
483 if ( msg == "someMessage(int,int,int)" ) { 483 if ( msg == "someMessage(int,int,int)" ) {
484 int a,b,c; 484 int a,b,c;
485 stream >> a >> b >> c; 485 stream >> a >> b >> c;
486 ... 486 ...
487 } else if ( msg == "otherMessage(QString)" ) { 487 } else if ( msg == "otherMessage(QString)" ) {
488 ... 488 ...
489 } 489 }
490 } 490 }
491\endcode 491\endcode
492 492
493 \sa qcop.html 493 \sa qcop.html
494 Note that messages received here may be processed by qpe application 494 Note that messages received here may be processed by qpe application
495 and emitted as signals, such as flush() and reload(). 495 and emitted as signals, such as flush() and reload().
496*/ 496*/
497 497
498/*! 498/*!
499 Constructs a QPEApplication just as you would construct 499 Constructs a QPEApplication just as you would construct
500 a QApplication, passing \a argc, \a argv, and \a t. 500 a QApplication, passing \a argc, \a argv, and \a t.
501 501
502 For applications, \a t should be the default, GuiClient. Only 502 For applications, \a t should be the default, GuiClient. Only
503 the Qtopia server passes GuiServer. 503 the Qtopia server passes GuiServer.
504*/ 504*/
505QPEApplication::QPEApplication( int & argc, char **argv, Type t ) 505QPEApplication::QPEApplication( int & argc, char **argv, Type t )
506 : QApplication( argc, argv, t ) 506 : QApplication( argc, argv, t )
507{ 507{
508 d = new QPEApplicationData; 508 d = new QPEApplicationData;
509 d->loadTextCodecs(); 509 d->loadTextCodecs();
510 d->loadImageCodecs(); 510 d->loadImageCodecs();
511 int dw = desktop() ->width(); 511 int dw = desktop() ->width();
512 512
513 if ( dw < 200 ) { 513 if ( dw < 200 ) {
514 setFont( QFont( "helvetica", 8 ) ); 514 setFont( QFont( "helvetica", 8 ) );
515 AppLnk::setSmallIconSize( 10 ); 515 AppLnk::setSmallIconSize( 10 );
516 AppLnk::setBigIconSize( 28 ); 516 AppLnk::setBigIconSize( 28 );
517 } 517 }
518 else if ( dw > 600 ) { 518 else if ( dw > 600 ) {
519 setFont( QFont( "helvetica", 12 ) ); 519 setFont( QFont( "helvetica", 12 ) );
520 AppLnk::setSmallIconSize( 24 ); 520 AppLnk::setSmallIconSize( 24 );
521 AppLnk::setBigIconSize( 48 ); 521 AppLnk::setBigIconSize( 48 );
522 } 522 }
523 else if ( dw > 200 ) { 523 else if ( dw > 200 ) {
524 setFont( QFont( "helvetica", 10 ) ); 524 setFont( QFont( "helvetica", 10 ) );
525 AppLnk::setSmallIconSize( 16 ); 525 AppLnk::setSmallIconSize( 16 );
526 AppLnk::setBigIconSize( 32 ); 526 AppLnk::setBigIconSize( 32 );
527 } 527 }
528 528
529 529
530 QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); 530 QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory );
531 531
532 connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); 532 connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) );
533#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 533#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
534 534
535 QString qcopfn( "/tmp/qcop-msg-" ); 535 QString qcopfn( "/tmp/qcop-msg-" );
536 qcopfn += QString( argv[ 0 ] ); // append command name 536 qcopfn += QString( argv[ 0 ] ); // append command name
537 537
538 QFile f( qcopfn ); 538 QFile f( qcopfn );
539 if ( f.open( IO_ReadOnly ) ) { 539 if ( f.open( IO_ReadOnly ) ) {
540 flock( f.handle(), LOCK_EX ); 540 flock( f.handle(), LOCK_EX );
541 } 541 }
542 542
543 sysChannel = new QCopChannel( "QPE/System", this ); 543 sysChannel = new QCopChannel( "QPE/System", this );
544 connect( sysChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), 544 connect( sysChannel, SIGNAL( received( const QCString &, const QByteArray & ) ),
545 this, SLOT( systemMessage( const QCString &, const QByteArray & ) ) ); 545 this, SLOT( systemMessage( const QCString &, const QByteArray & ) ) );
546 546
547 QCString channel = QCString( argv[ 0 ] ); 547 QCString channel = QCString( argv[ 0 ] );
548 channel.replace( QRegExp( ".*/" ), "" ); 548 channel.replace( QRegExp( ".*/" ), "" );
549 d->appName = channel; 549 d->appName = channel;
550 channel = "QPE/Application/" + channel; 550 channel = "QPE/Application/" + channel;
551 pidChannel = new QCopChannel( channel, this ); 551 pidChannel = new QCopChannel( channel, this );
552 connect( pidChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), 552 connect( pidChannel, SIGNAL( received( const QCString &, const QByteArray & ) ),
553 this, SLOT( pidMessage( const QCString &, const QByteArray & ) ) ); 553 this, SLOT( pidMessage( const QCString &, const QByteArray & ) ) );
554 554
555 if ( f.isOpen() ) { 555 if ( f.isOpen() ) {
556 d->keep_running = FALSE; 556 d->keep_running = FALSE;
557 QDataStream ds( &f ); 557 QDataStream ds( &f );
558 QCString channel, message; 558 QCString channel, message;
559 QByteArray data; 559 QByteArray data;
560 while ( !ds.atEnd() ) { 560 while ( !ds.atEnd() ) {
561 ds >> channel >> message >> data; 561 ds >> channel >> message >> data;
562 d->enqueueQCop( channel, message, data ); 562 d->enqueueQCop( channel, message, data );
563 } 563 }
564 564
565 flock( f.handle(), LOCK_UN ); 565 flock( f.handle(), LOCK_UN );
566 f.close(); 566 f.close();
567 f.remove(); 567 f.remove();
568 } 568 }
569 569
570 for ( int a = 0; a < argc; a++ ) { 570 for ( int a = 0; a < argc; a++ ) {
571 if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { 571 if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) {
572 argv[ a ] = argv[ a + 1 ]; 572 argv[ a ] = argv[ a + 1 ];
573 a++; 573 a++;
574 d->preloaded = TRUE; 574 d->preloaded = TRUE;
575 argc -= 1; 575 argc -= 1;
576 } 576 }
577 else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { 577 else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) {
578 argv[ a ] = argv[ a + 1 ]; 578 argv[ a ] = argv[ a + 1 ];
579 a++; 579 a++;
580 d->preloaded = TRUE; 580 d->preloaded = TRUE;
581 d->forceshow = TRUE; 581 d->forceshow = TRUE;
582 argc -= 1; 582 argc -= 1;
583 } 583 }
584 } 584 }
585 585
586 /* overide stored arguments */ 586 /* overide stored arguments */
587 setArgs( argc, argv ); 587 setArgs( argc, argv );
588 588
589#endif 589#endif
590 590
591 // qwsSetDecoration( new QPEDecoration() ); 591 // qwsSetDecoration( new QPEDecoration() );
592 592
593#ifndef QT_NO_TRANSLATION 593#ifndef QT_NO_TRANSLATION
594 594
595 QStringList langs = Global::languageList(); 595 QStringList langs = Global::languageList();
596 for ( QStringList::ConstIterator it = langs.begin(); it != langs.end(); ++it ) { 596 for ( QStringList::ConstIterator it = langs.begin(); it != langs.end(); ++it ) {
597 QString lang = *it; 597 QString lang = *it;
598 598
599 QTranslator * trans; 599 QTranslator * trans;
600 QString tfn; 600 QString tfn;
601 601
602 trans = new QTranslator( this ); 602 trans = new QTranslator( this );
603 tfn = qpeDir() + "/i18n/" + lang + "/libqpe.qm"; 603 tfn = qpeDir() + "/i18n/" + lang + "/libqpe.qm";
604 if ( trans->load( tfn ) ) 604 if ( trans->load( tfn ) )
605 installTranslator( trans ); 605 installTranslator( trans );
606 else 606 else
607 delete trans; 607 delete trans;
608 608
609 trans = new QTranslator( this ); 609 trans = new QTranslator( this );
610 tfn = qpeDir() + "/i18n/" + lang + "/" + d->appName + ".qm"; 610 tfn = qpeDir() + "/i18n/" + lang + "/" + d->appName + ".qm";
611 if ( trans->load( tfn ) ) 611 if ( trans->load( tfn ) )
612 installTranslator( trans ); 612 installTranslator( trans );
613 else 613 else
614 delete trans; 614 delete trans;
615 615
616 //###language/font hack; should look it up somewhere 616 //###language/font hack; should look it up somewhere
617#ifdef QWS 617#ifdef QWS
618 618
619 if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { 619 if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) {
620 QFont fn = FontManager::unicodeFont( FontManager::Proportional ); 620 QFont fn = FontManager::unicodeFont( FontManager::Proportional );
621 setFont( fn ); 621 setFont( fn );
622 } 622 }
623#endif 623#endif
624 624
625 } 625 }
626#endif 626#endif
627 627
628 applyStyle(); 628 applyStyle();
629 629
630 if ( type() == GuiServer ) { 630 if ( type() == GuiServer ) {
631 setVolume(); 631 setVolume();
632 } 632 }
633 633
634 installEventFilter( this ); 634 installEventFilter( this );
635 635
636 QPEMenuToolFocusManager::initialize(); 636 QPEMenuToolFocusManager::initialize();
637 637
638#ifdef QT_NO_QWS_CURSOR 638#ifdef QT_NO_QWS_CURSOR
639 // if we have no cursor, probably don't want tooltips 639 // if we have no cursor, probably don't want tooltips
640 QToolTip::setEnabled( FALSE ); 640 QToolTip::setEnabled( FALSE );
641#endif 641#endif
642} 642}
643 643
644static QPtrDict<void>* inputMethodDict = 0; 644static QPtrDict<void>* inputMethodDict = 0;
645static void createInputMethodDict() 645static void createInputMethodDict()
646{ 646{
647 if ( !inputMethodDict ) 647 if ( !inputMethodDict )
648 inputMethodDict = new QPtrDict<void>; 648 inputMethodDict = new QPtrDict<void>;
649} 649}
650 650
651/*! 651/*!
652 Returns the currently set hint to the system as to whether 652 Returns the currently set hint to the system as to whether
653 widget \a w has any use for text input methods. 653 widget \a w has any use for text input methods.
654 654
655 655
656 \sa setInputMethodHint() InputMethodHint 656 \sa setInputMethodHint() InputMethodHint
657*/ 657*/
658QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) 658QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w )
659{ 659{
660 if ( inputMethodDict && w ) 660 if ( inputMethodDict && w )
661 return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); 661 return ( InputMethodHint ) ( int ) inputMethodDict->find( w );
662 return Normal; 662 return Normal;
663} 663}
664 664
665/*! 665/*!
666 \enum QPEApplication::InputMethodHint 666 \enum QPEApplication::InputMethodHint
667 667
668 \value Normal the application sometimes needs text input (the default). 668 \value Normal the application sometimes needs text input (the default).
669 \value AlwaysOff the application never needs text input. 669 \value AlwaysOff the application never needs text input.
670 \value AlwaysOn the application always needs text input. 670 \value AlwaysOn the application always needs text input.
671*/ 671*/
672 672
673/*! 673/*!
674 Hints to the system that widget \a w has use for text input methods 674 Hints to the system that widget \a w has use for text input methods
675 as specified by \a mode. 675 as specified by \a mode.
676 676
677 \sa inputMethodHint() InputMethodHint 677 \sa inputMethodHint() InputMethodHint
678*/ 678*/
679void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) 679void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode )
680{ 680{
681 createInputMethodDict(); 681 createInputMethodDict();
682 if ( mode == Normal ) { 682 if ( mode == Normal ) {
683 inputMethodDict->remove 683 inputMethodDict->remove
684 ( w ); 684 ( w );
685 } 685 }
686 else { 686 else {
687 inputMethodDict->insert( w, ( void* ) mode ); 687 inputMethodDict->insert( w, ( void* ) mode );
688 } 688 }
689} 689}
690 690
691class HackDialog : public QDialog 691class HackDialog : public QDialog
692{ 692{
693public: 693public:
694 void acceptIt() 694 void acceptIt()
695 { 695 {
696 accept(); 696 accept();
697 } 697 }
698 void rejectIt() 698 void rejectIt()
699 { 699 {
700 reject(); 700 reject();
701 } 701 }
702}; 702};
703 703
704 704
705void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) 705void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key )
706{ 706{
707 // specialised actions for certain widgets. May want to 707 // specialised actions for certain widgets. May want to
708 // add more stuff here. 708 // add more stuff here.
709 if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" ) 709 if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" )
710 && activePopupWidget() ->parentWidget() 710 && activePopupWidget() ->parentWidget()
711 && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) ) 711 && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) )
712 key = Qt::Key_Return; 712 key = Qt::Key_Return;
713 713
714 if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) ) 714 if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) )
715 key = Qt::Key_Return; 715 key = Qt::Key_Return;
716 716
717#ifdef QWS 717#ifdef QWS
718 718
719 ke->simpleData.keycode = key; 719 ke->simpleData.keycode = key;
720#endif 720#endif
721} 721}
722 722
723class HackWidget : public QWidget 723class HackWidget : public QWidget
724{ 724{
725public: 725public:
726 bool needsOk() 726 bool needsOk()
727 { 727 {
728 return ( getWState() & WState_Reserved1 ); 728 return ( getWState() & WState_Reserved1 );
729 } 729 }
730}; 730};
731 731
732/*! 732/*!
733 \internal 733 \internal
734*/ 734*/
735 735
736#ifdef QWS 736#ifdef QWS
737bool QPEApplication::qwsEventFilter( QWSEvent * e ) 737bool QPEApplication::qwsEventFilter( QWSEvent * e )
738{ 738{
739 if ( !d->notbusysent && e->type == QWSEvent::Focus ) { 739 if ( !d->notbusysent && e->type == QWSEvent::Focus ) {
740 if ( qApp->type() != QApplication::GuiServer ) { 740 if ( qApp->type() != QApplication::GuiServer ) {
741 QCopEnvelope e( "QPE/System", "notBusy(QString)" ); 741 QCopEnvelope e( "QPE/System", "notBusy(QString)" );
742 e << d->appName; 742 e << d->appName;
743 } 743 }
744 d->notbusysent = TRUE; 744 d->notbusysent = TRUE;
745 } 745 }
746 if ( type() == GuiServer ) { 746 if ( type() == GuiServer ) {
747 switch ( e->type ) { 747 switch ( e->type ) {
748 case QWSEvent::Mouse: 748 case QWSEvent::Mouse:
749 if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) ) 749 if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) )
750 emit clientMoused(); 750 emit clientMoused();
751 break; 751 break;
752 default: 752 default:
753 break; 753 break;
754 } 754 }
755 } 755 }
756 if ( e->type == QWSEvent::Key ) { 756 if ( e->type == QWSEvent::Key ) {
757 QWSKeyEvent *ke = ( QWSKeyEvent * ) e; 757 QWSKeyEvent *ke = ( QWSKeyEvent * ) e;
758 if ( ke->simpleData.keycode == Qt::Key_F33 ) { 758 if ( ke->simpleData.keycode == Qt::Key_F33 ) {
759 // Use special "OK" key to press "OK" on top level widgets 759 // Use special "OK" key to press "OK" on top level widgets
760 QWidget * active = activeWindow(); 760 QWidget * active = activeWindow();
761 QWidget *popup = 0; 761 QWidget *popup = 0;
762 if ( active && active->isPopup() ) { 762 if ( active && active->isPopup() ) {
763 popup = active; 763 popup = active;
764 active = active->parentWidget(); 764 active = active->parentWidget();
765 } 765 }
766 if ( active && ( int ) active->winId() == ke->simpleData.window && 766 if ( active && ( int ) active->winId() == ke->simpleData.window &&
767 !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) { 767 !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) {
768 if ( ke->simpleData.is_press ) { 768 if ( ke->simpleData.is_press ) {
769 if ( popup ) 769 if ( popup )
770 popup->close(); 770 popup->close();
771 if ( active->inherits( "QDialog" ) ) { 771 if ( active->inherits( "QDialog" ) ) {
772 HackDialog * d = ( HackDialog * ) active; 772 HackDialog * d = ( HackDialog * ) active;
773 d->acceptIt(); 773 d->acceptIt();
774 return TRUE; 774 return TRUE;
775 } 775 }
776 else if ( ( ( HackWidget * ) active ) ->needsOk() ) { 776 else if ( ( ( HackWidget * ) active ) ->needsOk() ) {
777 QSignal s; 777 QSignal s;
778 s.connect( active, SLOT( accept() ) ); 778 s.connect( active, SLOT( accept() ) );
779 s.activate(); 779 s.activate();
780 } 780 }
781 else { 781 else {
782 // do the same as with the select key: Map to the default action of the widget: 782 // do the same as with the select key: Map to the default action of the widget:
783 mapToDefaultAction( ke, Qt::Key_Return ); 783 mapToDefaultAction( ke, Qt::Key_Return );
784 } 784 }
785 } 785 }
786 } 786 }
787 } 787 }
788 else if ( ke->simpleData.keycode == Qt::Key_F30 ) { 788 else if ( ke->simpleData.keycode == Qt::Key_F30 ) {
789 // Use special "select" key to do whatever default action a widget has 789 // Use special "select" key to do whatever default action a widget has
790 mapToDefaultAction( ke, Qt::Key_Space ); 790 mapToDefaultAction( ke, Qt::Key_Space );
791 } 791 }
792 else if ( ke->simpleData.keycode == Qt::Key_Escape && 792 else if ( ke->simpleData.keycode == Qt::Key_Escape &&
793 ke->simpleData.is_press ) { 793 ke->simpleData.is_press ) {
794 // Escape key closes app if focus on toplevel 794 // Escape key closes app if focus on toplevel
795 QWidget * active = activeWindow(); 795 QWidget * active = activeWindow();
796 if ( active && active->testWFlags( WType_TopLevel ) && 796 if ( active && active->testWFlags( WType_TopLevel ) &&
797 ( int ) active->winId() == ke->simpleData.window && 797 ( int ) active->winId() == ke->simpleData.window &&
798 !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) { 798 !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) {
799 if ( active->inherits( "QDialog" ) ) { 799 if ( active->inherits( "QDialog" ) ) {
800 HackDialog * d = ( HackDialog * ) active; 800 HackDialog * d = ( HackDialog * ) active;
801 d->rejectIt(); 801 d->rejectIt();
802 return TRUE; 802 return TRUE;
803 } 803 }
804 else if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 ) { 804 else if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 ) {
805 active->close(); 805 active->close();
806 } 806 }
807 } 807 }
808 } 808 }
809 else if ( ke->simpleData.keycode >= Qt::Key_F1 && ke->simpleData.keycode <= Qt::Key_F29 ) { 809 else if ( ke->simpleData.keycode >= Qt::Key_F1 && ke->simpleData.keycode <= Qt::Key_F29 ) {
810 // this should be if ( ODevice::inst ( )-> buttonForKeycode ( ... )) 810 // this should be if ( ODevice::inst ( )-> buttonForKeycode ( ... ))
811 // but we cannot access libopie function within libqpe :( 811 // but we cannot access libopie function within libqpe :(
812 812
813 QWidget * active = activeWindow ( ); 813 QWidget * active = activeWindow ( );
814 if ( active && ((int) active-> winId ( ) == ke-> simpleData.window )) { 814 if ( active && ((int) active-> winId ( ) == ke-> simpleData.window )) {
815 if ( d-> kbgrabbed ) { // we grabbed the keyboard 815 if ( d-> kbgrabbed ) { // we grabbed the keyboard
816 QChar ch ( ke-> simpleData.unicode ); 816 QChar ch ( ke-> simpleData.unicode );
817 QKeyEvent qke ( ke-> simpleData. is_press ? QEvent::KeyPress : QEvent::KeyRelease, 817 QKeyEvent qke ( ke-> simpleData. is_press ? QEvent::KeyPress : QEvent::KeyRelease,
818 ke-> simpleData.keycode, 818 ke-> simpleData.keycode,
819 ch. latin1 ( ), 819 ch. latin1 ( ),
820 ke-> simpleData.modifiers, 820 ke-> simpleData.modifiers,
821 QString ( ch ), 821 QString ( ch ),
822 ke-> simpleData.is_auto_repeat, 1 ); 822 ke-> simpleData.is_auto_repeat, 1 );
823 823
824 QObject *which = QWidget::keyboardGrabber ( ); 824 QObject *which = QWidget::keyboardGrabber ( );
825 if ( !which ) 825 if ( !which )
826 which = QApplication::focusWidget ( ); 826 which = QApplication::focusWidget ( );
827 if ( !which ) 827 if ( !which )
828 which = QApplication::activeWindow ( ); 828 which = QApplication::activeWindow ( );
829 if ( !which ) 829 if ( !which )
830 which = qApp; 830 which = qApp;
831 831
832 QApplication::sendEvent ( which, &qke ); 832 QApplication::sendEvent ( which, &qke );
833 } 833 }
834 else { // we didn't grab the keyboard, so send the event to the launcher 834 else { // we didn't grab the keyboard, so send the event to the launcher
835 QCopEnvelope e ( "QPE/Launcher", "deviceButton(int,int,int)" ); 835 QCopEnvelope e ( "QPE/Launcher", "deviceButton(int,int,int)" );
836 e << int( ke-> simpleData.keycode ) << int( ke-> simpleData. is_press ) << int( ke-> simpleData.is_auto_repeat ); 836 e << int( ke-> simpleData.keycode ) << int( ke-> simpleData. is_press ) << int( ke-> simpleData.is_auto_repeat );
837 } 837 }
838 } 838 }
839 return true; 839 return true;
840 } 840 }
841 } 841 }
842 if ( e->type == QWSEvent::Focus ) { 842 if ( e->type == QWSEvent::Focus ) {
843 QWSFocusEvent * fe = ( QWSFocusEvent* ) e; 843 QWSFocusEvent * fe = ( QWSFocusEvent* ) e;
844 if ( !fe->simpleData.get_focus ) { 844 if ( !fe->simpleData.get_focus ) {
845 QWidget * active = activeWindow(); 845 QWidget * active = activeWindow();
846 while ( active && active->isPopup() ) { 846 while ( active && active->isPopup() ) {
847 active->close(); 847 active->close();
848 active = activeWindow(); 848 active = activeWindow();
849 } 849 }
850 } 850 }
851 else { 851 else {
852 // make sure our modal widget is ALWAYS on top 852 // make sure our modal widget is ALWAYS on top
853 QWidget *topm = activeModalWidget(); 853 QWidget *topm = activeModalWidget();
854 if ( topm ) { 854 if ( topm ) {
855 topm->raise(); 855 topm->raise();
856 } 856 }
857 } 857 }
858 if ( fe->simpleData.get_focus && inputMethodDict ) { 858 if ( fe->simpleData.get_focus && inputMethodDict ) {
859 InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) ); 859 InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) );
860 if ( m == AlwaysOff ) 860 if ( m == AlwaysOff )
861 Global::hideInputMethod(); 861 Global::hideInputMethod();
862 if ( m == AlwaysOn ) 862 if ( m == AlwaysOn )
863 Global::showInputMethod(); 863 Global::showInputMethod();
864 } 864 }
865 } 865 }
866 return QApplication::qwsEventFilter( e ); 866 return QApplication::qwsEventFilter( e );
867} 867}
868#endif 868#endif
869 869
870/*! 870/*!
871 Destroys the QPEApplication. 871 Destroys the QPEApplication.
872*/ 872*/
873QPEApplication::~QPEApplication() 873QPEApplication::~QPEApplication()
874{ 874{
875 ungrabKeyboard(); 875 ungrabKeyboard();
876#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 876#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
877 // Need to delete QCopChannels early, since the display will 877 // Need to delete QCopChannels early, since the display will
878 // be gone by the time we get to ~QObject(). 878 // be gone by the time we get to ~QObject().
879 delete sysChannel; 879 delete sysChannel;
880 delete pidChannel; 880 delete pidChannel;
881#endif 881#endif
882 882
883 delete d; 883 delete d;
884} 884}
885 885
886/*! 886/*!
887 Returns <tt>$OPIEDIR/</tt>. 887 Returns <tt>$OPIEDIR/</tt>.
888*/ 888*/
889QString QPEApplication::qpeDir() 889QString QPEApplication::qpeDir()
890{ 890{
891 const char * base = getenv( "OPIEDIR" ); 891 const char * base = getenv( "OPIEDIR" );
892 if ( base ) 892 if ( base )
893 return QString( base ) + "/"; 893 return QString( base ) + "/";
894 894
895 return QString( "../" ); 895 return QString( "../" );
896} 896}
897 897
898/*! 898/*!
899 Returns the user's current Document directory. There is a trailing "/". 899 Returns the user's current Document directory. There is a trailing "/".
900 .. well, it does now,, and there's no trailing '/' 900 .. well, it does now,, and there's no trailing '/'
901*/ 901*/
902QString QPEApplication::documentDir() 902QString QPEApplication::documentDir()
903{ 903{
904 const char* base = getenv( "HOME"); 904 const char* base = getenv( "HOME");
905 if ( base ) 905 if ( base )
906 return QString( base ) + "/Documents"; 906 return QString( base ) + "/Documents";
907 907
908 return QString( "../Documents" ); 908 return QString( "../Documents" );
909} 909}
910 910
911static int deforient = -1; 911static int deforient = -1;
912 912
913/*! 913/*!
914 \internal 914 \internal
915*/ 915*/
916int QPEApplication::defaultRotation() 916int QPEApplication::defaultRotation()
917{ 917{
918 if ( deforient < 0 ) { 918 if ( deforient < 0 ) {
919 QString d = getenv( "QWS_DISPLAY" ); 919 QString d = getenv( "QWS_DISPLAY" );
920 if ( d.contains( "Rot90" ) ) { 920 if ( d.contains( "Rot90" ) ) {
921 deforient = 90; 921 deforient = 90;
922 } 922 }
923 else if ( d.contains( "Rot180" ) ) { 923 else if ( d.contains( "Rot180" ) ) {
924 deforient = 180; 924 deforient = 180;
925 } 925 }
926 else if ( d.contains( "Rot270" ) ) { 926 else if ( d.contains( "Rot270" ) ) {
927 deforient = 270; 927 deforient = 270;
928 } 928 }
929 else { 929 else {
930 deforient = 0; 930 deforient = 0;
931 } 931 }
932 } 932 }
933 return deforient; 933 return deforient;
934} 934}
935 935
936/*! 936/*!
937 \internal 937 \internal
938*/ 938*/
939void QPEApplication::setDefaultRotation( int r ) 939void QPEApplication::setDefaultRotation( int r )
940{ 940{
941 if ( qApp->type() == GuiServer ) { 941 if ( qApp->type() == GuiServer ) {
942 deforient = r; 942 deforient = r;
943 setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); 943 setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 );
944 Config config("qpe"); 944 Config config("qpe");
945 config.setGroup( "Rotation" ); 945 config.setGroup( "Rotation" );
946 config.writeEntry( "Screen", getenv("QWS_DISPLAY") ); 946 config.writeEntry( "Screen", getenv("QWS_DISPLAY") );
947 } 947 }
948 else { 948 else {
949#ifndef QT_NO_COP 949#ifndef QT_NO_COP
950 { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); 950 { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" );
951 e << r; 951 e << r;
952 } 952 }
953#endif 953#endif
954 954
955 } 955 }
956} 956}
957 957
958 958
959/*! 959/*!
960 \internal 960 \internal
961*/ 961*/
962void QPEApplication::applyStyle() 962void QPEApplication::applyStyle()
963{ 963{
964 Config config( "qpe" ); 964 Config config( "qpe" );
965 config.setGroup( "Appearance" ); 965 config.setGroup( "Appearance" );
966 966
967 // don't block ourselves ... 967 // don't block ourselves ...
968 Opie::force_appearance = 0; 968 Opie::force_appearance = 0;
969 969
970 static QString appname = Opie::binaryName ( ); 970 static QString appname = Opie::binaryName ( );
971 971
972 QStringList ex = config. readListEntry ( "NoStyle", ';' ); 972 QStringList ex = config. readListEntry ( "NoStyle", ';' );
973 int nostyle = 0; 973 int nostyle = 0;
974 for ( QStringList::Iterator it = ex. begin ( ); it != ex. end ( ); ++it ) { 974 for ( QStringList::Iterator it = ex. begin ( ); it != ex. end ( ); ++it ) {
975 if ( QRegExp (( *it ). mid ( 1 ), false, true ). find ( appname, 0 ) >= 0 ) { 975 if ( QRegExp (( *it ). mid ( 1 ), false, true ). find ( appname, 0 ) >= 0 ) {
976 nostyle = ( *it ). left ( 1 ). toInt ( 0, 32 ); 976 nostyle = ( *it ). left ( 1 ). toInt ( 0, 32 );
977 break; 977 break;
978 } 978 }
979 } 979 }
980 980
981 // Widget style 981 // Widget style
982 QString style = config.readEntry( "Style", "Light" ); 982 QString style = config.readEntry( "Style", "Light" );
983 983
984 // don't set a custom style 984 // don't set a custom style
985 if ( nostyle & Opie::Force_Style ) 985 if ( nostyle & Opie::Force_Style )
986 style = "Light"; 986 style = "Light";
987 987
988 internalSetStyle ( style ); 988 internalSetStyle ( style );
989 989
990 // Colors 990 // Colors
991 QColor bgcolor( config.readEntry( "Background", "#E5E1D5" ) ); 991 QColor bgcolor( config.readEntry( "Background", "#E5E1D5" ) );
992 QColor btncolor( config.readEntry( "Button", "#D6CDBB" ) ); 992 QColor btncolor( config.readEntry( "Button", "#D6CDBB" ) );
993 QPalette pal( btncolor, bgcolor ); 993 QPalette pal( btncolor, bgcolor );
994 QString color = config.readEntry( "Highlight", "#800000" ); 994 QString color = config.readEntry( "Highlight", "#800000" );
995 pal.setColor( QColorGroup::Highlight, QColor( color ) ); 995 pal.setColor( QColorGroup::Highlight, QColor( color ) );
996 color = config.readEntry( "HighlightedText", "#FFFFFF" ); 996 color = config.readEntry( "HighlightedText", "#FFFFFF" );
997 pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); 997 pal.setColor( QColorGroup::HighlightedText, QColor( color ) );
998 color = config.readEntry( "Text", "#000000" ); 998 color = config.readEntry( "Text", "#000000" );
999 pal.setColor( QColorGroup::Text, QColor( color ) ); 999 pal.setColor( QColorGroup::Text, QColor( color ) );
1000 color = config.readEntry( "ButtonText", "#000000" ); 1000 color = config.readEntry( "ButtonText", "#000000" );
1001 pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); 1001 pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) );
1002 color = config.readEntry( "Base", "#FFFFFF" ); 1002 color = config.readEntry( "Base", "#FFFFFF" );
1003 pal.setColor( QColorGroup::Base, QColor( color ) ); 1003 pal.setColor( QColorGroup::Base, QColor( color ) );
1004 1004
1005 pal.setColor( QPalette::Disabled, QColorGroup::Text, 1005 pal.setColor( QPalette::Disabled, QColorGroup::Text,
1006 pal.color( QPalette::Active, QColorGroup::Background ).dark() ); 1006 pal.color( QPalette::Active, QColorGroup::Background ).dark() );
1007 1007
1008 setPalette( pal, TRUE ); 1008 setPalette( pal, TRUE );
1009 1009
1010 // Window Decoration 1010 // Window Decoration
1011 QString dec = config.readEntry( "Decoration", "Qtopia" ); 1011 QString dec = config.readEntry( "Decoration", "Qtopia" );
1012 1012
1013 // don't set a custom deco 1013 // don't set a custom deco
1014 if ( nostyle & Opie::Force_Decoration ) 1014 if ( nostyle & Opie::Force_Decoration )
1015 dec = ""; 1015 dec = "";
1016 1016
1017 //qDebug ( "Setting Deco: %s -- old %s (%d)", dec.latin1(), d-> decorationName.latin1(), nostyle); 1017 //qDebug ( "Setting Deco: %s -- old %s (%d)", dec.latin1(), d-> decorationName.latin1(), nostyle);
1018 1018
1019 if ( dec != d->decorationName ) { 1019 if ( dec != d->decorationName ) {
1020 qwsSetDecoration( new QPEDecoration( dec ) ); 1020 qwsSetDecoration( new QPEDecoration( dec ) );
1021 d->decorationName = dec; 1021 d->decorationName = dec;
1022 } 1022 }
1023 1023
1024 // Font 1024 // Font
1025 QString ff = config.readEntry( "FontFamily", font().family() ); 1025 QString ff = config.readEntry( "FontFamily", font().family() );
1026 int fs = config.readNumEntry( "FontSize", font().pointSize() ); 1026 int fs = config.readNumEntry( "FontSize", font().pointSize() );
1027 1027
1028 // don't set a custom font 1028 // don't set a custom font
1029 if ( nostyle & Opie::Force_Font ) { 1029 if ( nostyle & Opie::Force_Font ) {
1030 ff = "Helvetica"; 1030 ff = "Helvetica";
1031 fs = 10; 1031 fs = 10;
1032 } 1032 }
1033 1033
1034 setFont ( QFont ( ff, fs ), true ); 1034 setFont ( QFont ( ff, fs ), true );
1035 1035
1036 // revert to global blocking policy ... 1036 // revert to global blocking policy ...
1037 Opie::force_appearance = config. readBoolEntry ( "ForceStyle", false ) ? Opie::Force_All : Opie::Force_None; 1037 Opie::force_appearance = config. readBoolEntry ( "ForceStyle", false ) ? Opie::Force_All : Opie::Force_None;
1038 Opie::force_appearance &= ~nostyle; 1038 Opie::force_appearance &= ~nostyle;
1039} 1039}
1040 1040
1041void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data ) 1041void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data )
1042{ 1042{
1043#ifdef Q_WS_QWS 1043#ifdef Q_WS_QWS
1044 QDataStream stream( data, IO_ReadOnly ); 1044 QDataStream stream( data, IO_ReadOnly );
1045 if ( msg == "applyStyle()" ) { 1045 if ( msg == "applyStyle()" ) {
1046 applyStyle(); 1046 applyStyle();
1047 } 1047 }
1048 else if ( msg == "toggleApplicationMenu()" ) { 1048 else if ( msg == "toggleApplicationMenu()" ) {
1049 QWidget *active = activeWindow ( ); 1049 QWidget *active = activeWindow ( );
1050 1050
1051 if ( active ) { 1051 if ( active ) {
1052 QPEMenuToolFocusManager *man = QPEMenuToolFocusManager::manager ( ); 1052 QPEMenuToolFocusManager *man = QPEMenuToolFocusManager::manager ( );
1053 bool oldactive = man-> isActive ( ); 1053 bool oldactive = man-> isActive ( );
1054 1054
1055 man-> setActive( !man-> isActive() ); 1055 man-> setActive( !man-> isActive() );
1056 1056
1057 if ( !oldactive && !man-> isActive ( )) { // no menubar to toggle -> try O-Menu 1057 if ( !oldactive && !man-> isActive ( )) { // no menubar to toggle -> try O-Menu
1058 QCopEnvelope e ( "QPE/TaskBar", "toggleStartMenu()" ); 1058 QCopEnvelope e ( "QPE/TaskBar", "toggleStartMenu()" );
1059 } 1059 }
1060 } 1060 }
1061 } 1061 }
1062 else if ( msg == "setDefaultRotation(int)" ) { 1062 else if ( msg == "setDefaultRotation(int)" ) {
1063 if ( type() == GuiServer ) { 1063 if ( type() == GuiServer ) {
1064 int r; 1064 int r;
1065 stream >> r; 1065 stream >> r;
1066 setDefaultRotation( r ); 1066 setDefaultRotation( r );
1067 } 1067 }
1068 } 1068 }
1069 else if ( msg == "setCurrentRotation(int)" ) { 1069 else if ( msg == "setCurrentRotation(int)" ) {
1070 int r; 1070 int r;
1071 stream >> r; 1071 stream >> r;
1072 setCurrentRotation( r ); 1072 setCurrentRotation( r );
1073 } 1073 }
1074 else if ( msg == "shutdown()" ) { 1074 else if ( msg == "shutdown()" ) {
1075 if ( type() == GuiServer ) 1075 if ( type() == GuiServer )
1076 shutdown(); 1076 shutdown();
1077 } 1077 }
1078 else if ( msg == "quit()" ) { 1078 else if ( msg == "quit()" ) {
1079 if ( type() != GuiServer ) 1079 if ( type() != GuiServer )
1080 tryQuit(); 1080 tryQuit();
1081 } 1081 }
1082 else if ( msg == "forceQuit()" ) { 1082 else if ( msg == "forceQuit()" ) {
1083 if ( type() != GuiServer ) 1083 if ( type() != GuiServer )
1084 quit(); 1084 quit();
1085 } 1085 }
1086 else if ( msg == "restart()" ) { 1086 else if ( msg == "restart()" ) {
1087 if ( type() == GuiServer ) 1087 if ( type() == GuiServer )
1088 restart(); 1088 restart();
1089 } 1089 }
1090 else if ( msg == "language(QString)" ) { 1090 else if ( msg == "language(QString)" ) {
1091 if ( type() == GuiServer ) { 1091 if ( type() == GuiServer ) {
1092 QString l; 1092 QString l;
1093 stream >> l; 1093 stream >> l;
1094 QString cl = getenv( "LANG" ); 1094 QString cl = getenv( "LANG" );
1095 if ( cl != l ) { 1095 if ( cl != l ) {
1096 if ( l.isNull() ) 1096 if ( l.isNull() )
1097 unsetenv( "LANG" ); 1097 unsetenv( "LANG" );
1098 else 1098 else
1099 setenv( "LANG", l.latin1(), 1 ); 1099 setenv( "LANG", l.latin1(), 1 );
1100 restart(); 1100 restart();
1101 } 1101 }
1102 } 1102 }
1103 } 1103 }
1104 else if ( msg == "timeChange(QString)" ) { 1104 else if ( msg == "timeChange(QString)" ) {
1105 QString t; 1105 QString t;
1106 stream >> t; 1106 stream >> t;
1107 if ( t.isNull() ) 1107 if ( t.isNull() )
1108 unsetenv( "TZ" ); 1108 unsetenv( "TZ" );
1109 else 1109 else
1110 setenv( "TZ", t.latin1(), 1 ); 1110 setenv( "TZ", t.latin1(), 1 );
1111 // emit the signal so everyone else knows... 1111 // emit the signal so everyone else knows...
1112 emit timeChanged(); 1112 emit timeChanged();
1113 } 1113 }
1114 else if ( msg == "execute(QString)" ) { 1114 else if ( msg == "execute(QString)" ) {
1115 if ( type() == GuiServer ) { 1115 if ( type() == GuiServer ) {
1116 QString t; 1116 QString t;
1117 stream >> t; 1117 stream >> t;
1118 Global::execute( t ); 1118 Global::execute( t );
1119 } 1119 }
1120 } 1120 }
1121 else if ( msg == "execute(QString,QString)" ) { 1121 else if ( msg == "execute(QString,QString)" ) {
1122 if ( type() == GuiServer ) { 1122 if ( type() == GuiServer ) {
1123 QString t, d; 1123 QString t, d;
1124 stream >> t >> d; 1124 stream >> t >> d;
1125 Global::execute( t, d ); 1125 Global::execute( t, d );
1126 } 1126 }
1127 } 1127 }
1128 else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { 1128 else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) {
1129 if ( type() == GuiServer ) { 1129 if ( type() == GuiServer ) {
1130 QDateTime when; 1130 QDateTime when;
1131 QCString channel, message; 1131 QCString channel, message;
1132 int data; 1132 int data;
1133 stream >> when >> channel >> message >> data; 1133 stream >> when >> channel >> message >> data;
1134 AlarmServer::addAlarm( when, channel, message, data ); 1134 AlarmServer::addAlarm( when, channel, message, data );
1135 } 1135 }
1136 } 1136 }
1137 else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { 1137 else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) {
1138 if ( type() == GuiServer ) { 1138 if ( type() == GuiServer ) {
1139 QDateTime when; 1139 QDateTime when;
1140 QCString channel, message; 1140 QCString channel, message;
1141 int data; 1141 int data;
1142 stream >> when >> channel >> message >> data; 1142 stream >> when >> channel >> message >> data;
1143 AlarmServer::deleteAlarm( when, channel, message, data ); 1143 AlarmServer::deleteAlarm( when, channel, message, data );
1144 } 1144 }
1145 } 1145 }
1146 else if ( msg == "clockChange(bool)" ) { 1146 else if ( msg == "clockChange(bool)" ) {
1147 int tmp; 1147 int tmp;
1148 stream >> tmp; 1148 stream >> tmp;
1149 emit clockChanged( tmp ); 1149 emit clockChanged( tmp );
1150 } 1150 }
1151 else if ( msg == "weekChange(bool)" ) { 1151 else if ( msg == "weekChange(bool)" ) {
1152 int tmp; 1152 int tmp;
1153 stream >> tmp; 1153 stream >> tmp;
1154 emit weekChanged( tmp ); 1154 emit weekChanged( tmp );
1155 } 1155 }
1156 else if ( msg == "setDateFormat(DateFormat)" ) { 1156 else if ( msg == "setDateFormat(DateFormat)" ) {
1157 DateFormat tmp; 1157 DateFormat tmp;
1158 stream >> tmp; 1158 stream >> tmp;
1159 emit dateFormatChanged( tmp ); 1159 emit dateFormatChanged( tmp );
1160 } 1160 }
1161 else if ( msg == "setVolume(int,int)" ) { 1161 else if ( msg == "setVolume(int,int)" ) {
1162 int t, v; 1162 int t, v;
1163 stream >> t >> v; 1163 stream >> t >> v;
1164 setVolume( t, v ); 1164 setVolume( t, v );
1165 emit volumeChanged( muted ); 1165 emit volumeChanged( muted );
1166 } 1166 }
1167 else if ( msg == "volumeChange(bool)" ) { 1167 else if ( msg == "volumeChange(bool)" ) {
1168 stream >> muted; 1168 stream >> muted;
1169 setVolume(); 1169 setVolume();
1170 emit volumeChanged( muted ); 1170 emit volumeChanged( muted );
1171 } 1171 }
1172 else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> 1172 else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com>
1173 int t, v; 1173 int t, v;
1174 stream >> t >> v; 1174 stream >> t >> v;
1175 setMic( t, v ); 1175 setMic( t, v );
1176 emit micChanged( micMuted ); 1176 emit micChanged( micMuted );
1177 } 1177 }
1178 else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> 1178 else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com>
1179 stream >> micMuted; 1179 stream >> micMuted;
1180 setMic(); 1180 setMic();
1181 emit micChanged( micMuted ); 1181 emit micChanged( micMuted );
1182 } 1182 }
1183 else if ( msg == "setBass(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> 1183 else if ( msg == "setBass(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org>
1184 int t, v; 1184 int t, v;
1185 stream >> t >> v; 1185 stream >> t >> v;
1186 setBass( t, v ); 1186 setBass( t, v );
1187 } 1187 }
1188 else if ( msg == "bassChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> 1188 else if ( msg == "bassChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org>
1189 setBass(); 1189 setBass();
1190 } 1190 }
1191 else if ( msg == "setTreble(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> 1191 else if ( msg == "setTreble(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org>
1192 int t, v; 1192 int t, v;
1193 stream >> t >> v; 1193 stream >> t >> v;
1194 setTreble( t, v ); 1194 setTreble( t, v );
1195 } 1195 }
1196 else if ( msg == "trebleChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> 1196 else if ( msg == "trebleChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org>
1197 setTreble(); 1197 setTreble();
1198 } 1198 }
1199 1199
1200 1200
1201 1201
1202#endif 1202#endif
1203} 1203}
1204 1204
1205/*! 1205/*!
1206 \internal 1206 \internal
1207*/ 1207*/
1208bool QPEApplication::raiseAppropriateWindow() 1208bool QPEApplication::raiseAppropriateWindow()
1209{ 1209{
1210 bool r = FALSE; 1210 bool r = FALSE;
1211 // ########## raise()ing main window should raise and set active 1211 // ########## raise()ing main window should raise and set active
1212 // ########## it and then all childen. This belongs in Qt/Embedded 1212 // ########## it and then all childen. This belongs in Qt/Embedded
1213 QWidget *top = d->qpe_main_widget; 1213 QWidget *top = d->qpe_main_widget;
1214 if ( !top ) 1214 if ( !top )
1215 top = mainWidget(); 1215 top = mainWidget();
1216 if ( top && d->keep_running ) { 1216 if ( top && d->keep_running ) {
1217 if ( top->isVisible() ) 1217 if ( top->isVisible() )
1218 r = TRUE; 1218 r = TRUE;
1219 else if (d->preloaded) { 1219 else if (d->preloaded) {
1220 // We are preloaded and not visible.. pretend we just started.. 1220 // We are preloaded and not visible.. pretend we just started..
1221 QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); 1221 QCopEnvelope e("QPE/System", "fastAppShowing(QString)");
1222 e << d->appName; 1222 e << d->appName;
1223 } 1223 }
1224 1224
1225 d->show_mx(top, d->nomaximize); 1225 d->show_mx(top, d->nomaximize);
1226 top->raise(); 1226 top->raise();
1227 top->setActiveWindow(); 1227 top->setActiveWindow();
1228 } 1228 }
1229 QWidget *topm = activeModalWidget(); 1229 QWidget *topm = activeModalWidget();
1230 if ( topm && topm != top ) { 1230 if ( topm && topm != top ) {
1231 topm->show(); 1231 topm->show();
1232 topm->raise(); 1232 topm->raise();
1233 topm->setActiveWindow(); 1233 topm->setActiveWindow();
1234 // If we haven't already handled the fastAppShowing message 1234 // If we haven't already handled the fastAppShowing message
1235 if (!top && d->preloaded) { 1235 if (!top && d->preloaded) {
1236 QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); 1236 QCopEnvelope e("QPE/System", "fastAppShowing(QString)");
1237 e << d->appName; 1237 e << d->appName;
1238 } 1238 }
1239 r = FALSE; 1239 r = FALSE;
1240 } 1240 }
1241 return r; 1241 return r;
1242} 1242}
1243 1243
1244void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) 1244void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data)
1245{ 1245{
1246#ifdef Q_WS_QWS 1246#ifdef Q_WS_QWS
1247 1247
1248 if ( msg == "quit()" ) { 1248 if ( msg == "quit()" ) {
1249 tryQuit(); 1249 tryQuit();
1250 } 1250 }
1251 else if ( msg == "quitIfInvisible()" ) { 1251 else if ( msg == "quitIfInvisible()" ) {
1252 if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) 1252 if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() )
1253 quit(); 1253 quit();
1254 } 1254 }
1255 else if ( msg == "close()" ) { 1255 else if ( msg == "close()" ) {
1256 hideOrQuit(); 1256 hideOrQuit();
1257 } 1257 }
1258 else if ( msg == "disablePreload()" ) { 1258 else if ( msg == "disablePreload()" ) {
1259 d->preloaded = FALSE; 1259 d->preloaded = FALSE;
1260 d->keep_running = TRUE; 1260 d->keep_running = TRUE;
1261 /* so that quit will quit */ 1261 /* so that quit will quit */
1262 } 1262 }
1263 else if ( msg == "enablePreload()" ) { 1263 else if ( msg == "enablePreload()" ) {
1264 if (d->qpe_main_widget) 1264 if (d->qpe_main_widget)
1265 d->preloaded = TRUE; 1265 d->preloaded = TRUE;
1266 d->keep_running = TRUE; 1266 d->keep_running = TRUE;
1267 /* so next quit won't quit */ 1267 /* so next quit won't quit */
1268 } 1268 }
1269 else if ( msg == "raise()" ) { 1269 else if ( msg == "raise()" ) {
1270 d->keep_running = TRUE; 1270 d->keep_running = TRUE;
1271 d->notbusysent = FALSE; 1271 d->notbusysent = FALSE;
1272 raiseAppropriateWindow(); 1272 raiseAppropriateWindow();
1273 // Tell the system we're still chugging along... 1273 // Tell the system we're still chugging along...
1274 QCopEnvelope e("QPE/System", "appRaised(QString)"); 1274 QCopEnvelope e("QPE/System", "appRaised(QString)");
1275 e << d->appName; 1275 e << d->appName;
1276 } 1276 }
1277 else if ( msg == "flush()" ) { 1277 else if ( msg == "flush()" ) {
1278 emit flush(); 1278 emit flush();
1279 // we need to tell the desktop 1279 // we need to tell the desktop
1280 QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); 1280 QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" );
1281 e << d->appName; 1281 e << d->appName;
1282 } 1282 }
1283 else if ( msg == "reload()" ) { 1283 else if ( msg == "reload()" ) {
1284 emit reload(); 1284 emit reload();
1285 } 1285 }
1286 else if ( msg == "setDocument(QString)" ) { 1286 else if ( msg == "setDocument(QString)" ) {
1287 d->keep_running = TRUE; 1287 d->keep_running = TRUE;
1288 QDataStream stream( data, IO_ReadOnly ); 1288 QDataStream stream( data, IO_ReadOnly );
1289 QString doc; 1289 QString doc;
1290 stream >> doc; 1290 stream >> doc;
1291 QWidget *mw = mainWidget(); 1291 QWidget *mw = mainWidget();
1292 if ( !mw ) 1292 if ( !mw )
1293 mw = d->qpe_main_widget; 1293 mw = d->qpe_main_widget;
1294 if ( mw ) 1294 if ( mw )
1295 Global::setDocument( mw, doc ); 1295 Global::setDocument( mw, doc );
1296 } 1296 }
1297 else if ( msg == "nextView()" ) { 1297 else if ( msg == "nextView()" ) {
1298 qDebug("got nextView()"); 1298 qDebug("got nextView()");
1299 /* 1299 /*
1300 if ( raiseAppropriateWindow() ) 1300 if ( raiseAppropriateWindow() )
1301 */ 1301 */
1302 emit appMessage( msg, data); 1302 emit appMessage( msg, data);
1303 } 1303 }
1304 else { 1304 else {
1305 emit appMessage( msg, data); 1305 emit appMessage( msg, data);
1306 } 1306 }
1307 1307
1308#endif 1308#endif
1309} 1309}
1310 1310
1311 1311
1312/*! 1312/*!
1313 Sets widget \a mw as the mainWidget() and shows it. For small windows, 1313 Sets widget \a mw as the mainWidget() and shows it. For small windows,
1314 consider passing TRUE for \a nomaximize rather than the default FALSE. 1314 consider passing TRUE for \a nomaximize rather than the default FALSE.
1315 1315
1316 \sa showMainDocumentWidget() 1316 \sa showMainDocumentWidget()
1317*/ 1317*/
1318void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) 1318void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize )
1319{ 1319{
1320 d->show(mw, nomaximize ); 1320 d->show(mw, nomaximize );
1321} 1321}
1322 1322
1323/*! 1323/*!
1324 Sets widget \a mw as the mainWidget() and shows it. For small windows, 1324 Sets widget \a mw as the mainWidget() and shows it. For small windows,
1325 consider passing TRUE for \a nomaximize rather than the default FALSE. 1325 consider passing TRUE for \a nomaximize rather than the default FALSE.
1326 1326
1327 This calls designates the application as 1327 This calls designates the application as
1328 a \link docwidget.html document-oriented\endlink application. 1328 a \link docwidget.html document-oriented\endlink application.
1329 1329
1330 The \a mw widget \e must have this slot: setDocument(const QString&). 1330 The \a mw widget \e must have this slot: setDocument(const QString&).
1331 1331
1332 \sa showMainWidget() 1332 \sa showMainWidget()
1333*/ 1333*/
1334void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize ) 1334void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize )
1335{ 1335{
1336 if ( mw && argc() == 2 ) 1336 if ( mw && argc() == 2 )
1337 Global::setDocument( mw, QString::fromUtf8(argv()[1]) ); 1337 Global::setDocument( mw, QString::fromUtf8(argv()[1]) );
1338 1338
1339 d->show(mw, nomaximize ); 1339 d->show(mw, nomaximize );
1340} 1340}
1341 1341
1342 1342
1343/*! 1343/*!
1344 If an application is started via a \link qcop.html QCop\endlink 1344 If an application is started via a \link qcop.html QCop\endlink
1345 message, the application will process the \link qcop.html 1345 message, the application will process the \link qcop.html
1346 QCop\endlink message and then quit. If the application calls this 1346 QCop\endlink message and then quit. If the application calls this
1347 function while processing a \link qcop.html QCop\endlink message, 1347 function while processing a \link qcop.html QCop\endlink message,
1348 after processing its outstanding \link qcop.html QCop\endlink 1348 after processing its outstanding \link qcop.html QCop\endlink
1349 messages the application will start 'properly' and show itself. 1349 messages the application will start 'properly' and show itself.
1350 1350
1351 \sa keepRunning() 1351 \sa keepRunning()
1352*/ 1352*/
1353void QPEApplication::setKeepRunning() 1353void QPEApplication::setKeepRunning()
1354{ 1354{
1355 if ( qApp && qApp->inherits( "QPEApplication" ) ) { 1355 if ( qApp && qApp->inherits( "QPEApplication" ) ) {
1356 QPEApplication * qpeApp = ( QPEApplication* ) qApp; 1356 QPEApplication * qpeApp = ( QPEApplication* ) qApp;
1357 qpeApp->d->keep_running = TRUE; 1357 qpeApp->d->keep_running = TRUE;
1358 } 1358 }
1359} 1359}
1360 1360
1361/*! 1361/*!
1362 Returns TRUE if the application will quit after processing the 1362 Returns TRUE if the application will quit after processing the
1363 current list of qcop messages; otherwise returns FALSE. 1363 current list of qcop messages; otherwise returns FALSE.
1364 1364
1365 \sa setKeepRunning() 1365 \sa setKeepRunning()
1366*/ 1366*/
1367bool QPEApplication::keepRunning() const 1367bool QPEApplication::keepRunning() const
1368{ 1368{
1369 return d->keep_running; 1369 return d->keep_running;
1370} 1370}
1371 1371
1372/*! 1372/*!
1373 \internal 1373 \internal
1374*/ 1374*/
1375void QPEApplication::internalSetStyle( const QString &style ) 1375void QPEApplication::internalSetStyle( const QString &style )
1376{ 1376{
1377#if QT_VERSION >= 300 1377#if QT_VERSION >= 300
1378 if ( style == "QPE" ) { 1378 if ( style == "QPE" ) {
1379 setStyle( new QPEStyle ); 1379 setStyle( new QPEStyle );
1380 } 1380 }
1381 else { 1381 else {
1382 QStyle *s = QStyleFactory::create( style ); 1382 QStyle *s = QStyleFactory::create( style );
1383 if ( s ) 1383 if ( s )
1384 setStyle( s ); 1384 setStyle( s );
1385 } 1385 }
1386#else 1386#else
1387 if ( style == "Windows" ) { 1387 if ( style == "Windows" ) {
1388 setStyle( new QWindowsStyle ); 1388 setStyle( new QWindowsStyle );
1389 } 1389 }
1390 else if ( style == "QPE" ) { 1390 else if ( style == "QPE" ) {
1391 setStyle( new QPEStyle ); 1391 setStyle( new QPEStyle );
1392 } 1392 }
1393 else if ( style == "Light" ) { 1393 else if ( style == "Light" ) {
1394 setStyle( new LightStyle ); 1394 setStyle( new LightStyle );
1395 } 1395 }
1396#ifndef QT_NO_STYLE_PLATINUM 1396#ifndef QT_NO_STYLE_PLATINUM
1397 else if ( style == "Platinum" ) { 1397 else if ( style == "Platinum" ) {
1398 setStyle( new QPlatinumStyle ); 1398 setStyle( new QPlatinumStyle );
1399 } 1399 }
1400#endif 1400#endif
1401#ifndef QT_NO_STYLE_MOTIF 1401#ifndef QT_NO_STYLE_MOTIF
1402 else if ( style == "Motif" ) { 1402 else if ( style == "Motif" ) {
1403 setStyle( new QMotifStyle ); 1403 setStyle( new QMotifStyle );
1404 } 1404 }
1405#endif 1405#endif
1406#ifndef QT_NO_STYLE_MOTIFPLUS 1406#ifndef QT_NO_STYLE_MOTIFPLUS
1407 else if ( style == "MotifPlus" ) { 1407 else if ( style == "MotifPlus" ) {
1408 setStyle( new QMotifPlusStyle ); 1408 setStyle( new QMotifPlusStyle );
1409 } 1409 }
1410#endif 1410#endif
1411 1411
1412 else { 1412 else {
1413 QStyle *sty = 0; 1413 QStyle *sty = 0;
1414 QString path = QPEApplication::qpeDir ( ) + "/plugins/styles/"; 1414 QString path = QPEApplication::qpeDir ( ) + "/plugins/styles/";
1415 1415
1416 if ( style. find ( ".so" ) > 0 ) 1416 if ( style. find ( ".so" ) > 0 )
1417 path += style; 1417 path += style;
1418 else 1418 else
1419 path = path + "lib" + style. lower ( ) + ".so"; // compatibility 1419 path = path + "lib" + style. lower ( ) + ".so"; // compatibility
1420 1420
1421 static QLibrary *lastlib = 0; 1421 static QLibrary *lastlib = 0;
1422 static StyleInterface *lastiface = 0; 1422 static StyleInterface *lastiface = 0;
1423 1423
1424 QLibrary *lib = new QLibrary ( path ); 1424 QLibrary *lib = new QLibrary ( path );
1425 StyleInterface *iface = 0; 1425 StyleInterface *iface = 0;
1426 1426
1427 if (( lib-> queryInterface ( IID_Style, ( QUnknownInterface ** ) &iface ) == QS_OK ) && iface ) 1427 if (( lib-> queryInterface ( IID_Style, ( QUnknownInterface ** ) &iface ) == QS_OK ) && iface )
1428 sty = iface-> style ( ); 1428 sty = iface-> style ( );
1429 1429
1430 if ( sty ) { 1430 if ( sty ) {
1431 setStyle ( sty ); 1431 setStyle ( sty );
1432 1432
1433 if ( lastiface ) 1433 if ( lastiface )
1434 lastiface-> release ( ); 1434 lastiface-> release ( );
1435 lastiface = iface; 1435 lastiface = iface;
1436 1436
1437 if ( lastlib ) { 1437 if ( lastlib ) {
1438 lastlib-> unload ( ); 1438 lastlib-> unload ( );
1439 delete lastlib; 1439 delete lastlib;
1440 } 1440 }
1441 lastlib = lib; 1441 lastlib = lib;
1442 } 1442 }
1443 else { 1443 else {
1444 if ( iface ) 1444 if ( iface )
1445 iface-> release ( ); 1445 iface-> release ( );
1446 delete lib; 1446 delete lib;
1447 1447
1448 setStyle ( new LightStyle ( )); 1448 setStyle ( new LightStyle ( ));
1449 } 1449 }
1450 } 1450 }
1451#endif 1451#endif
1452} 1452}
1453 1453
1454/*! 1454/*!
1455 \internal 1455 \internal
1456*/ 1456*/
1457void QPEApplication::prepareForTermination( bool willrestart ) 1457void QPEApplication::prepareForTermination( bool willrestart )
1458{ 1458{
1459 if ( willrestart ) { 1459 if ( willrestart ) {
1460 // Draw a big wait icon, the image can be altered in later revisions 1460 // Draw a big wait icon, the image can be altered in later revisions
1461 // QWidget *d = QApplication::desktop(); 1461 // QWidget *d = QApplication::desktop();
1462 QImage img = Resource::loadImage( "launcher/new_wait" ); 1462 QImage img = Resource::loadImage( "launcher/new_wait" );
1463 QPixmap pix; 1463 QPixmap pix;
1464 pix.convertFromImage( img.smoothScale( 1 * img.width(), 1 * img.height() ) ); 1464 pix.convertFromImage( img.smoothScale( 1 * img.width(), 1 * img.height() ) );
1465 QLabel *lblWait = new QLabel( 0, "wait hack!", QWidget::WStyle_Customize | 1465 QLabel *lblWait = new QLabel( 0, "wait hack!", QWidget::WStyle_Customize |
1466 QWidget::WStyle_NoBorder | QWidget::WStyle_Tool ); 1466 QWidget::WStyle_NoBorder | QWidget::WStyle_Tool );
1467 lblWait->setPixmap( pix ); 1467 lblWait->setPixmap( pix );
1468 lblWait->setAlignment( QWidget::AlignCenter ); 1468 lblWait->setAlignment( QWidget::AlignCenter );
1469 lblWait->show(); 1469 lblWait->show();
1470 lblWait->showMaximized(); 1470 lblWait->showMaximized();
1471 } 1471 }
1472#ifndef SINGLE_APP 1472#ifndef SINGLE_APP
1473 { QCopEnvelope envelope( "QPE/System", "forceQuit()" ); 1473 { QCopEnvelope envelope( "QPE/System", "forceQuit()" );
1474 } 1474 }
1475 processEvents(); // ensure the message goes out. 1475 processEvents(); // ensure the message goes out.
1476 sleep( 1 ); // You have 1 second to comply. 1476 sleep( 1 ); // You have 1 second to comply.
1477#endif 1477#endif
1478} 1478}
1479 1479
1480/*! 1480/*!
1481 \internal 1481 \internal
1482*/ 1482*/
1483void QPEApplication::shutdown() 1483void QPEApplication::shutdown()
1484{ 1484{
1485 // Implement in server's QPEApplication subclass 1485 // Implement in server's QPEApplication subclass
1486} 1486}
1487 1487
1488/*! 1488/*!
1489 \internal 1489 \internal
1490*/ 1490*/
1491void QPEApplication::restart() 1491void QPEApplication::restart()
1492{ 1492{
1493 // Implement in server's QPEApplication subclass 1493 // Implement in server's QPEApplication subclass
1494} 1494}
1495 1495
1496static QPtrDict<void>* stylusDict = 0; 1496static QPtrDict<void>* stylusDict = 0;
1497static void createDict() 1497static void createDict()
1498{ 1498{
1499 if ( !stylusDict ) 1499 if ( !stylusDict )
1500 stylusDict = new QPtrDict<void>; 1500 stylusDict = new QPtrDict<void>;
1501} 1501}
1502 1502
1503/*! 1503/*!
1504 Returns the current StylusMode for widget \a w. 1504 Returns the current StylusMode for widget \a w.
1505 1505
1506 \sa setStylusOperation() StylusMode 1506 \sa setStylusOperation() StylusMode
1507*/ 1507*/
1508QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w ) 1508QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w )
1509{ 1509{
1510 if ( stylusDict ) 1510 if ( stylusDict )
1511 return ( StylusMode ) ( int ) stylusDict->find( w ); 1511 return ( StylusMode ) ( int ) stylusDict->find( w );
1512 return LeftOnly; 1512 return LeftOnly;
1513} 1513}
1514 1514
1515/*! 1515/*!
1516 \enum QPEApplication::StylusMode 1516 \enum QPEApplication::StylusMode
1517 1517
1518 \value LeftOnly the stylus only generates LeftButton 1518 \value LeftOnly the stylus only generates LeftButton
1519 events (the default). 1519 events (the default).
1520 \value RightOnHold the stylus generates RightButton events 1520 \value RightOnHold the stylus generates RightButton events
1521 if the user uses the press-and-hold gesture. 1521 if the user uses the press-and-hold gesture.
1522 1522
1523 \sa setStylusOperation() stylusOperation() 1523 \sa setStylusOperation() stylusOperation()
1524*/ 1524*/
1525 1525
1526/*! 1526/*!
1527 Causes widget \a w to receive mouse events according to the stylus 1527 Causes widget \a w to receive mouse events according to the stylus
1528 \a mode. 1528 \a mode.
1529 1529
1530 \sa stylusOperation() StylusMode 1530 \sa stylusOperation() StylusMode
1531*/ 1531*/
1532void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode ) 1532void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode )
1533{ 1533{
1534 createDict(); 1534 createDict();
1535 if ( mode == LeftOnly ) { 1535 if ( mode == LeftOnly ) {
1536 stylusDict->remove 1536 stylusDict->remove
1537 ( w ); 1537 ( w );
1538 w->removeEventFilter( qApp ); 1538 w->removeEventFilter( qApp );
1539 } 1539 }
1540 else { 1540 else {
1541 stylusDict->insert( w, ( void* ) mode ); 1541 stylusDict->insert( w, ( void* ) mode );
1542 connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) ); 1542 connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) );
1543 w->installEventFilter( qApp ); 1543 w->installEventFilter( qApp );
1544 } 1544 }
1545} 1545}
1546 1546
1547 1547
1548/*! 1548/*!
1549 \reimp 1549 \reimp
1550*/ 1550*/
1551bool QPEApplication::eventFilter( QObject *o, QEvent *e ) 1551bool QPEApplication::eventFilter( QObject *o, QEvent *e )
1552{ 1552{
1553 if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { 1553 if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) {
1554 QMouseEvent * me = ( QMouseEvent* ) e; 1554 QMouseEvent * me = ( QMouseEvent* ) e;
1555 StylusMode mode = (StylusMode)(int)stylusDict->find(o); 1555 StylusMode mode = (StylusMode)(int)stylusDict->find(o);
1556 switch (mode) { 1556 switch (mode) {
1557 case RightOnHold: 1557 case RightOnHold:
1558 switch ( me->type() ) { 1558 switch ( me->type() ) {
1559 case QEvent::MouseButtonPress: 1559 case QEvent::MouseButtonPress:
1560 if ( me->button() == LeftButton ) { 1560 if ( me->button() == LeftButton ) {
1561 d->presstimer = startTimer(500); // #### pref. 1561 d->presstimer = startTimer(500); // #### pref.
1562 d->presswidget = (QWidget*)o; 1562 d->presswidget = (QWidget*)o;
1563 d->presspos = me->pos(); 1563 d->presspos = me->pos();
1564 d->rightpressed = FALSE; 1564 d->rightpressed = FALSE;
1565 } 1565 }
1566 break; 1566 break;
1567 case QEvent::MouseMove: 1567 case QEvent::MouseMove:
1568 if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) { 1568 if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) {
1569 killTimer(d->presstimer); 1569 killTimer(d->presstimer);
1570 d->presstimer = 0; 1570 d->presstimer = 0;
1571 } 1571 }
1572 break; 1572 break;
1573 case QEvent::MouseButtonRelease: 1573 case QEvent::MouseButtonRelease:
1574 if ( me->button() == LeftButton ) { 1574 if ( me->button() == LeftButton ) {
1575 if ( d->presstimer ) { 1575 if ( d->presstimer ) {
1576 killTimer(d->presstimer); 1576 killTimer(d->presstimer);
1577 d->presstimer = 0; 1577 d->presstimer = 0;
1578 } 1578 }
1579 if ( d->rightpressed && d->presswidget ) { 1579 if ( d->rightpressed && d->presswidget ) {
1580 // Right released 1580 // Right released
1581 postEvent( d->presswidget, 1581 postEvent( d->presswidget,
1582 new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), 1582 new QMouseEvent( QEvent::MouseButtonRelease, me->pos(),
1583 RightButton, LeftButton + RightButton ) ); 1583 RightButton, LeftButton + RightButton ) );
1584 // Left released, off-widget 1584 // Left released, off-widget
1585 postEvent( d->presswidget, 1585 postEvent( d->presswidget,
1586 new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1), 1586 new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1),
1587 LeftButton, LeftButton ) ); 1587 LeftButton, LeftButton ) );
1588 postEvent( d->presswidget, 1588 postEvent( d->presswidget,
1589 new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1), 1589 new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1),
1590 LeftButton, LeftButton ) ); 1590 LeftButton, LeftButton ) );
1591 d->rightpressed = FALSE; 1591 d->rightpressed = FALSE;
1592 return TRUE; // don't send the real Left release 1592 return TRUE; // don't send the real Left release
1593 } 1593 }
1594 } 1594 }
1595 break; 1595 break;
1596 default: 1596 default:
1597 break; 1597 break;
1598 } 1598 }
1599 break; 1599 break;
1600 default: 1600 default:
1601 ; 1601 ;
1602 } 1602 }
1603 } 1603 }
1604 else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { 1604 else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) {
1605 QKeyEvent *ke = (QKeyEvent *)e; 1605 QKeyEvent *ke = (QKeyEvent *)e;
1606 if ( ke->key() == Key_Enter ) { 1606 if ( ke->key() == Key_Enter ) {
1607 if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { 1607 if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) {
1608 postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', 1608 postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ',
1609 ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); 1609 ke->state(), " ", ke->isAutoRepeat(), ke->count() ) );
1610 return TRUE; 1610 return TRUE;
1611 } 1611 }
1612 } 1612 }
1613 } 1613 }
1614 return FALSE; 1614 return FALSE;
1615} 1615}
1616 1616
1617/*! 1617/*!
1618 \reimp 1618 \reimp
1619*/ 1619*/
1620void QPEApplication::timerEvent( QTimerEvent *e ) 1620void QPEApplication::timerEvent( QTimerEvent *e )
1621{ 1621{
1622 if ( e->timerId() == d->presstimer && d->presswidget ) { 1622 if ( e->timerId() == d->presstimer && d->presswidget ) {
1623 // Right pressed 1623 // Right pressed
1624 postEvent( d->presswidget, 1624 postEvent( d->presswidget,
1625 new QMouseEvent( QEvent::MouseButtonPress, d->presspos, 1625 new QMouseEvent( QEvent::MouseButtonPress, d->presspos,
1626 RightButton, LeftButton ) ); 1626 RightButton, LeftButton ) );
1627 killTimer( d->presstimer ); 1627 killTimer( d->presstimer );
1628 d->presstimer = 0; 1628 d->presstimer = 0;
1629 d->rightpressed = TRUE; 1629 d->rightpressed = TRUE;
1630 } 1630 }
1631} 1631}
1632 1632
1633void QPEApplication::removeSenderFromStylusDict() 1633void QPEApplication::removeSenderFromStylusDict()
1634{ 1634{
1635 stylusDict->remove 1635 stylusDict->remove
1636 ( ( void* ) sender() ); 1636 ( ( void* ) sender() );
1637 if ( d->presswidget == sender() ) 1637 if ( d->presswidget == sender() )
1638 d->presswidget = 0; 1638 d->presswidget = 0;
1639} 1639}
1640 1640
1641/*! 1641/*!
1642 \internal 1642 \internal
1643*/ 1643*/
1644bool QPEApplication::keyboardGrabbed() const 1644bool QPEApplication::keyboardGrabbed() const
1645{ 1645{
1646 return d->kbgrabbed; 1646 return d->kbgrabbed;
1647} 1647}
1648 1648
1649 1649
1650/*! 1650/*!
1651 Reverses the effect of grabKeyboard(). This is called automatically 1651 Reverses the effect of grabKeyboard(). This is called automatically
1652 on program exit. 1652 on program exit.
1653*/ 1653*/
1654void QPEApplication::ungrabKeyboard() 1654void QPEApplication::ungrabKeyboard()
1655{ 1655{
1656 ((QPEApplication *) qApp )-> d-> kbgrabbed = false; 1656 ((QPEApplication *) qApp )-> d-> kbgrabbed = false;
1657} 1657}
1658 1658
1659/*! 1659/*!
1660 Grabs the physical keyboard keys, e.g. the application's launching 1660 Grabs the physical keyboard keys, e.g. the application's launching
1661 keys. Instead of launching applications when these keys are pressed 1661 keys. Instead of launching applications when these keys are pressed
1662 the signals emitted are sent to this application instead. Some games 1662 the signals emitted are sent to this application instead. Some games
1663 programs take over the launch keys in this way to make interaction 1663 programs take over the launch keys in this way to make interaction
1664 easier. 1664 easier.
1665 1665
1666 \sa ungrabKeyboard() 1666 \sa ungrabKeyboard()
1667*/ 1667*/
1668void QPEApplication::grabKeyboard() 1668void QPEApplication::grabKeyboard()
1669{ 1669{
1670 ((QPEApplication *) qApp )-> d-> kbgrabbed = true; 1670 ((QPEApplication *) qApp )-> d-> kbgrabbed = true;
1671} 1671}
1672 1672
1673/*! 1673/*!
1674 \reimp 1674 \reimp
1675*/ 1675*/
1676int QPEApplication::exec() 1676int QPEApplication::exec()
1677{ 1677{
1678#ifndef QT_NO_COP 1678#ifndef QT_NO_COP
1679 d->sendQCopQ(); 1679 d->sendQCopQ();
1680#endif 1680#endif
1681 1681
1682 if ( d->keep_running ) 1682 if ( d->keep_running )
1683 //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) 1683 //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() )
1684 return QApplication::exec(); 1684 return QApplication::exec();
1685 1685
1686#ifndef QT_NO_COP 1686#ifndef QT_NO_COP
1687 1687
1688 { 1688 {
1689 QCopEnvelope e( "QPE/System", "closing(QString)" ); 1689 QCopEnvelope e( "QPE/System", "closing(QString)" );
1690 e << d->appName; 1690 e << d->appName;
1691 } 1691 }
1692#endif 1692#endif
1693 processEvents(); 1693 processEvents();
1694 return 0; 1694 return 0;
1695} 1695}
1696 1696
1697/*! 1697/*!
1698 \internal 1698 \internal
1699 External request for application to quit. Quits if possible without 1699 External request for application to quit. Quits if possible without
1700 loosing state. 1700 loosing state.
1701*/ 1701*/
1702void QPEApplication::tryQuit() 1702void QPEApplication::tryQuit()
1703{ 1703{
1704 if ( activeModalWidget() || strcmp( argv() [ 0 ], "embeddedkonsole" ) == 0 ) 1704 if ( activeModalWidget() || strcmp( argv() [ 0 ], "embeddedkonsole" ) == 0 )
1705 return ; // Inside modal loop or konsole. Too hard to save state. 1705 return ; // Inside modal loop or konsole. Too hard to save state.
1706#ifndef QT_NO_COP 1706#ifndef QT_NO_COP
1707 1707
1708 { 1708 {
1709 QCopEnvelope e( "QPE/System", "closing(QString)" ); 1709 QCopEnvelope e( "QPE/System", "closing(QString)" );
1710 e << d->appName; 1710 e << d->appName;
1711 } 1711 }
1712#endif 1712#endif
1713 processEvents(); 1713 processEvents();
1714 1714
1715 quit(); 1715 quit();
1716} 1716}
1717 1717
1718/*! 1718/*!
1719 \internal 1719 \internal
1720 User initiated quit. Makes the window 'Go Away'. If preloaded this means 1720 User initiated quit. Makes the window 'Go Away'. If preloaded this means
1721 hiding the window. If not it means quitting the application. 1721 hiding the window. If not it means quitting the application.
1722 As this is user initiated we don't need to check state. 1722 As this is user initiated we don't need to check state.
1723*/ 1723*/
1724void QPEApplication::hideOrQuit() 1724void QPEApplication::hideOrQuit()
1725{ 1725{
1726 processEvents(); 1726 processEvents();
1727 1727
1728 // If we are a preloaded application we don't actually quit, so emit 1728 // If we are a preloaded application we don't actually quit, so emit
1729 // a System message indicating we're quasi-closing. 1729 // a System message indicating we're quasi-closing.
1730 if ( d->preloaded && d->qpe_main_widget ) 1730 if ( d->preloaded && d->qpe_main_widget )
1731#ifndef QT_NO_COP 1731#ifndef QT_NO_COP
1732 1732
1733 { 1733 {
1734 QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); 1734 QCopEnvelope e("QPE/System", "fastAppHiding(QString)" );
1735 e << d->appName; 1735 e << d->appName;
1736 d->qpe_main_widget->hide(); 1736 d->qpe_main_widget->hide();
1737 } 1737 }
1738#endif 1738#endif
1739 else 1739 else
1740 quit(); 1740 quit();
1741} 1741}
1742 1742
1743 1743
1744#if defined(QT_QWS_IPAQ) || defined(QT_QWS_SHARP) 1744#if defined(QT_QWS_IPAQ) || defined(QT_QWS_SL5XXX)
1745 1745
1746// The libraries with the skiff package (and possibly others) have 1746// The libraries with the skiff package (and possibly others) have
1747// completely useless implementations of builtin new and delete that 1747// completely useless implementations of builtin new and delete that
1748// use about 50% of your CPU. Here we revert to the simple libc 1748// use about 50% of your CPU. Here we revert to the simple libc
1749// functions. 1749// functions.
1750 1750
1751void* operator new[]( size_t size ) 1751void* operator new[]( size_t size )
1752{ 1752{
1753 return malloc( size ); 1753 return malloc( size );
1754} 1754}
1755 1755
1756void* operator new( size_t size ) 1756void* operator new( size_t size )
1757{ 1757{
1758 return malloc( size ); 1758 return malloc( size );
1759} 1759}
1760 1760
1761void operator delete[]( void* p ) 1761void operator delete[]( void* p )
1762{ 1762{
1763 free( p ); 1763 free( p );
1764} 1764}
1765 1765
1766void operator delete[]( void* p, size_t /*size*/ ) 1766void operator delete[]( void* p, size_t /*size*/ )
1767{ 1767{
1768 free( p ); 1768 free( p );
1769} 1769}
1770 1770
1771void operator delete( void* p ) 1771void operator delete( void* p )
1772{ 1772{
1773 free( p ); 1773 free( p );
1774} 1774}
1775 1775
1776void operator delete( void* p, size_t /*size*/ ) 1776void operator delete( void* p, size_t /*size*/ )
1777{ 1777{
1778 free( p ); 1778 free( p );
1779} 1779}
1780 1780
1781#endif 1781#endif
1782 1782
1783#if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP) 1783#if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP)
1784#include <qwidgetlist.h> 1784#include <qwidgetlist.h>
1785#ifdef QWS 1785#ifdef QWS
1786#include <qgfx_qws.h> 1786#include <qgfx_qws.h>
1787extern QRect qt_maxWindowRect; 1787extern QRect qt_maxWindowRect;
1788void qt_setMaxWindowRect(const QRect& r ) 1788void qt_setMaxWindowRect(const QRect& r )
1789{ 1789{
1790 qt_maxWindowRect = qt_screen->mapFromDevice( r, 1790 qt_maxWindowRect = qt_screen->mapFromDevice( r,
1791 qt_screen->mapToDevice( QSize( qt_screen->width(), qt_screen->height() ) ) ); 1791 qt_screen->mapToDevice( QSize( qt_screen->width(), qt_screen->height() ) ) );
1792 // Re-resize any maximized windows 1792 // Re-resize any maximized windows
1793 QWidgetList* l = QApplication::topLevelWidgets(); 1793 QWidgetList* l = QApplication::topLevelWidgets();
1794 if ( l ) { 1794 if ( l ) {
1795 QWidget * w = l->first(); 1795 QWidget * w = l->first();
1796 while ( w ) { 1796 while ( w ) {
1797 if ( w->isVisible() && w->isMaximized() ) { 1797 if ( w->isVisible() && w->isMaximized() ) {
1798 w->showMaximized(); 1798 w->showMaximized();
1799 } 1799 }
1800 w = l->next(); 1800 w = l->next();
1801 } 1801 }
1802 delete l; 1802 delete l;
1803 } 1803 }
1804} 1804}
1805#endif 1805#endif
1806#endif 1806#endif
diff --git a/library/storage.cpp b/library/storage.cpp
index 3668d29..a7c466d 100644
--- a/library/storage.cpp
+++ b/library/storage.cpp
@@ -1,200 +1,200 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) Holger 'zecke' Freyther <freyther@kde.org> 2** Copyright (C) Holger 'zecke' Freyther <freyther@kde.org>
3** Copyright (C) 2000 Trolltech AS. All rights reserved. 3** Copyright (C) 2000 Trolltech AS. All rights reserved.
4** 4**
5** This file is part of Qtopia Environment. 5** This file is part of Qtopia Environment.
6** 6**
7** This file may be distributed and/or modified under the terms of the 7** This file may be distributed and/or modified under the terms of the
8** GNU General Public License version 2 as published by the Free Software 8** GNU General Public License version 2 as published by the Free Software
9** Foundation and appearing in the file LICENSE.GPL included in the 9** Foundation and appearing in the file LICENSE.GPL included in the
10** packaging of this file. 10** packaging of this file.
11** 11**
12** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 12** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
13** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 13** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
14** 14**
15** See http://www.trolltech.com/gpl/ for GPL licensing information. 15** See http://www.trolltech.com/gpl/ for GPL licensing information.
16** 16**
17** Contact info@trolltech.com if any conditions of this licensing are 17** Contact info@trolltech.com if any conditions of this licensing are
18** not clear to you. 18** not clear to you.
19** 19**
20**********************************************************************/ 20**********************************************************************/
21 21
22#include <qpe/storage.h> 22#include <qpe/storage.h>
23#ifdef QT_QWS_SHARP 23#ifdef QT_QWS_SL5XXX
24#include <qpe/custom.h> 24#include <qpe/custom.h>
25#endif 25#endif
26 26
27#include <qfile.h> 27#include <qfile.h>
28#include <qtimer.h> 28#include <qtimer.h>
29#include <qcopchannel_qws.h> 29#include <qcopchannel_qws.h>
30 30
31#include <stdio.h> 31#include <stdio.h>
32 32
33#if defined(_OS_LINUX_) || defined(Q_OS_LINUX) 33#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
34#include <sys/vfs.h> 34#include <sys/vfs.h>
35#include <mntent.h> 35#include <mntent.h>
36#endif 36#endif
37 37
38#include <qstringlist.h> 38#include <qstringlist.h>
39 39
40static bool isCF(const QString& m) 40static bool isCF(const QString& m)
41{ 41{
42 FILE* f = fopen("/var/run/stab", "r"); 42 FILE* f = fopen("/var/run/stab", "r");
43 if (!f) f = fopen("/var/state/pcmcia/stab", "r"); 43 if (!f) f = fopen("/var/state/pcmcia/stab", "r");
44 if (!f) f = fopen("/var/lib/pcmcia/stab", "r"); 44 if (!f) f = fopen("/var/lib/pcmcia/stab", "r");
45 if ( f ) { 45 if ( f ) {
46 char line[1024]; 46 char line[1024];
47 char devtype[80]; 47 char devtype[80];
48 char devname[80]; 48 char devname[80];
49 while ( fgets( line, 1024, f ) ) { 49 while ( fgets( line, 1024, f ) ) {
50 // 0 ide ide-cs 0 hda 3 0 50 // 0 ide ide-cs 0 hda 3 0
51 if ( sscanf(line,"%*d %s %*s %*s %s", devtype, devname )==2 ) 51 if ( sscanf(line,"%*d %s %*s %*s %s", devtype, devname )==2 )
52 { 52 {
53 if ( QString(devtype) == "ide" && m.find(devname)>0 ) { 53 if ( QString(devtype) == "ide" && m.find(devname)>0 ) {
54 fclose(f); 54 fclose(f);
55 return TRUE; 55 return TRUE;
56 } 56 }
57 } 57 }
58 } 58 }
59 fclose(f); 59 fclose(f);
60 } 60 }
61 return FALSE; 61 return FALSE;
62} 62}
63 63
64StorageInfo::StorageInfo( QObject *parent ) 64StorageInfo::StorageInfo( QObject *parent )
65 : QObject( parent ) 65 : QObject( parent )
66{ 66{
67 mFileSystems.setAutoDelete( TRUE ); 67 mFileSystems.setAutoDelete( TRUE );
68 channel = new QCopChannel( "QPE/Card", this ); 68 channel = new QCopChannel( "QPE/Card", this );
69 connect( channel, SIGNAL(received(const QCString &, const QByteArray &)), 69 connect( channel, SIGNAL(received(const QCString &, const QByteArray &)),
70 this, SLOT(cardMessage( const QCString &, const QByteArray &)) ); 70 this, SLOT(cardMessage( const QCString &, const QByteArray &)) );
71 update(); 71 update();
72} 72}
73 73
74const FileSystem *StorageInfo::fileSystemOf( const QString &filename ) 74const FileSystem *StorageInfo::fileSystemOf( const QString &filename )
75{ 75{
76 for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i) { 76 for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i) {
77 if ( filename.startsWith( (*i)->path() ) ) 77 if ( filename.startsWith( (*i)->path() ) )
78 return (*i); 78 return (*i);
79 } 79 }
80 return 0; 80 return 0;
81} 81}
82 82
83 83
84void StorageInfo::cardMessage( const QCString& msg, const QByteArray& ) 84void StorageInfo::cardMessage( const QCString& msg, const QByteArray& )
85{ 85{
86 if ( msg == "mtabChanged()" ) 86 if ( msg == "mtabChanged()" )
87 update(); 87 update();
88} 88}
89// cause of the lack of a d pointer we need 89// cause of the lack of a d pointer we need
90// to store informations in a config file :( 90// to store informations in a config file :(
91void StorageInfo::update() 91void StorageInfo::update()
92{ 92{
93 //qDebug("StorageInfo::updating"); 93 //qDebug("StorageInfo::updating");
94#if defined(_OS_LINUX_) || defined(Q_OS_LINUX) 94#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
95 struct mntent *me; 95 struct mntent *me;
96 FILE *mntfp = setmntent( "/etc/mtab", "r" ); 96 FILE *mntfp = setmntent( "/etc/mtab", "r" );
97 97
98 QStringList curdisks; 98 QStringList curdisks;
99 QStringList curopts; 99 QStringList curopts;
100 QStringList curfs; 100 QStringList curfs;
101 bool rebuild = FALSE; 101 bool rebuild = FALSE;
102 int n=0; 102 int n=0;
103 if ( mntfp ) { 103 if ( mntfp ) {
104 while ( (me = getmntent( mntfp )) != 0 ) { 104 while ( (me = getmntent( mntfp )) != 0 ) {
105 QString fs = me->mnt_fsname; 105 QString fs = me->mnt_fsname;
106 if ( fs.left(7)=="/dev/hd" || fs.left(7)=="/dev/sd" 106 if ( fs.left(7)=="/dev/hd" || fs.left(7)=="/dev/sd"
107 || fs.left(8)=="/dev/mtd" || fs.left(9) == "/dev/mmcd" 107 || fs.left(8)=="/dev/mtd" || fs.left(9) == "/dev/mmcd"
108 || fs.left( 14 ) == "/dev/mmc/part1" 108 || fs.left( 14 ) == "/dev/mmc/part1"
109 || fs.left(5)=="tmpfs" ) 109 || fs.left(5)=="tmpfs" )
110 { 110 {
111 n++; 111 n++;
112 curdisks.append(fs); 112 curdisks.append(fs);
113 curopts.append( me->mnt_opts ); 113 curopts.append( me->mnt_opts );
114 //qDebug("-->fs %s opts %s", fs.latin1(), me->mnt_opts ); 114 //qDebug("-->fs %s opts %s", fs.latin1(), me->mnt_opts );
115 curfs.append( me->mnt_dir ); 115 curfs.append( me->mnt_dir );
116 bool found = FALSE; 116 bool found = FALSE;
117 for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i) { 117 for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i) {
118 if ( (*i)->disk() == fs ) { 118 if ( (*i)->disk() == fs ) {
119 found = TRUE; 119 found = TRUE;
120 break; 120 break;
121 } 121 }
122 } 122 }
123 if ( !found ) 123 if ( !found )
124 rebuild = TRUE; 124 rebuild = TRUE;
125 } 125 }
126 } 126 }
127 endmntent( mntfp ); 127 endmntent( mntfp );
128 } 128 }
129 if ( rebuild || n != (int)mFileSystems.count() ) { 129 if ( rebuild || n != (int)mFileSystems.count() ) {
130 mFileSystems.clear(); 130 mFileSystems.clear();
131 QStringList::ConstIterator it=curdisks.begin(); 131 QStringList::ConstIterator it=curdisks.begin();
132 QStringList::ConstIterator fsit=curfs.begin(); 132 QStringList::ConstIterator fsit=curfs.begin();
133 QStringList::ConstIterator optsIt=curopts.begin(); 133 QStringList::ConstIterator optsIt=curopts.begin();
134 for (; it!=curdisks.end(); ++it, ++fsit, ++optsIt) { 134 for (; it!=curdisks.end(); ++it, ++fsit, ++optsIt) {
135 QString opts = *optsIt; 135 QString opts = *optsIt;
136 136
137 QString disk = *it; 137 QString disk = *it;
138 QString humanname; 138 QString humanname;
139 bool removable = FALSE; 139 bool removable = FALSE;
140 if ( isCF(disk) ) { 140 if ( isCF(disk) ) {
141 humanname = tr("CF Card"); 141 humanname = tr("CF Card");
142 removable = TRUE; 142 removable = TRUE;
143 } else if ( disk == "/dev/hda1" ) { 143 } else if ( disk == "/dev/hda1" ) {
144 humanname = tr("Hard Disk"); 144 humanname = tr("Hard Disk");
145 } else if ( disk.left(9) == "/dev/mmcd" ) { 145 } else if ( disk.left(9) == "/dev/mmcd" ) {
146 humanname = tr("SD Card"); 146 humanname = tr("SD Card");
147 removable = TRUE; 147 removable = TRUE;
148 } else if ( disk.left( 14 ) == "/dev/mmc/part1" ) { 148 } else if ( disk.left( 14 ) == "/dev/mmc/part1" ) {
149 humanname = tr("MMC Card"); 149 humanname = tr("MMC Card");
150 removable = TRUE; 150 removable = TRUE;
151 } else if ( disk.left(7) == "/dev/hd" ) 151 } else if ( disk.left(7) == "/dev/hd" )
152 humanname = tr("Hard Disk") + " " + disk; 152 humanname = tr("Hard Disk") + " " + disk;
153 else if ( disk.left(7) == "/dev/sd" ) 153 else if ( disk.left(7) == "/dev/sd" )
154 humanname = tr("SCSI Hard Disk") + " " + disk; 154 humanname = tr("SCSI Hard Disk") + " " + disk;
155 else if ( disk.left(14) == "/dev/mtdblock6" ) //openzaurus ramfs 155 else if ( disk.left(14) == "/dev/mtdblock6" ) //openzaurus ramfs
156 humanname = tr("Internal Memory"); 156 humanname = tr("Internal Memory");
157 else if ( disk == "/dev/mtdblock1" || humanname == "/dev/mtdblock/1" ) 157 else if ( disk == "/dev/mtdblock1" || humanname == "/dev/mtdblock/1" )
158 humanname = tr("Internal Storage"); 158 humanname = tr("Internal Storage");
159 else if ( disk.left(14) == "/dev/mtdblock/" ) 159 else if ( disk.left(14) == "/dev/mtdblock/" )
160 humanname = tr("Internal Storage") + " " + disk; 160 humanname = tr("Internal Storage") + " " + disk;
161 else if ( disk.left(13) == "/dev/mtdblock" ) 161 else if ( disk.left(13) == "/dev/mtdblock" )
162 humanname = tr("Internal Storage") + " " + disk; 162 humanname = tr("Internal Storage") + " " + disk;
163 else if ( disk.left(5) == "tmpfs" ) //ipaqs /mnt/ramfs 163 else if ( disk.left(5) == "tmpfs" ) //ipaqs /mnt/ramfs
164 humanname = tr("Internal Memory"); 164 humanname = tr("Internal Memory");
165 FileSystem *fs = new FileSystem( disk, *fsit, humanname, removable, opts ); 165 FileSystem *fs = new FileSystem( disk, *fsit, humanname, removable, opts );
166 mFileSystems.append( fs ); 166 mFileSystems.append( fs );
167 } 167 }
168 emit disksChanged(); 168 emit disksChanged();
169 } else { 169 } else {
170 // just update them 170 // just update them
171 for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i) 171 for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i)
172 i.current()->update(); 172 i.current()->update();
173 } 173 }
174#endif 174#endif
175} 175}
176 176
177//--------------------------------------------------------------------------- 177//---------------------------------------------------------------------------
178 178
179FileSystem::FileSystem( const QString &disk, const QString &path, const QString &name, bool rem, const QString &o ) 179FileSystem::FileSystem( const QString &disk, const QString &path, const QString &name, bool rem, const QString &o )
180 : fsdisk( disk ), fspath( path ), humanname( name ), blkSize(512), totalBlks(0), availBlks(0), removable( rem ), opts( o ) 180 : fsdisk( disk ), fspath( path ), humanname( name ), blkSize(512), totalBlks(0), availBlks(0), removable( rem ), opts( o )
181{ 181{
182 update(); 182 update();
183} 183}
184 184
185void FileSystem::update() 185void FileSystem::update()
186{ 186{
187#if defined(_OS_LINUX_) || defined(Q_OS_LINUX) 187#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
188 struct statfs fs; 188 struct statfs fs;
189 if ( !statfs( fspath.latin1(), &fs ) ) { 189 if ( !statfs( fspath.latin1(), &fs ) ) {
190 blkSize = fs.f_bsize; 190 blkSize = fs.f_bsize;
191 totalBlks = fs.f_blocks; 191 totalBlks = fs.f_blocks;
192 availBlks = fs.f_bavail; 192 availBlks = fs.f_bavail;
193 } else { 193 } else {
194 blkSize = 0; 194 blkSize = 0;
195 totalBlks = 0; 195 totalBlks = 0;
196 availBlks = 0; 196 availBlks = 0;
197 } 197 }
198#endif 198#endif
199} 199}
200 200
diff --git a/mkspecs/qws/linux-sharp-g++/qmake.conf b/mkspecs/qws/linux-sharp-g++/qmake.conf
index 06bf445..814b4fc 100644
--- a/mkspecs/qws/linux-sharp-g++/qmake.conf
+++ b/mkspecs/qws/linux-sharp-g++/qmake.conf
@@ -1,76 +1,76 @@
1# 1#
2# $Id$ 2# $Id$
3# 3#
4# qmake configuration for linux-g++ using the arm-linux-g++ crosscompiler 4# qmake configuration for linux-g++ using the arm-linux-g++ crosscompiler
5# 5#
6 6
7 MAKEFILE_GENERATOR= UNIX 7 MAKEFILE_GENERATOR= UNIX
8 TEMPLATE = app 8 TEMPLATE = app
9 CONFIG += qt warn_on release 9 CONFIG += qt warn_on release
10 10
11 QMAKE_CC = arm-linux-gcc 11 QMAKE_CC = arm-linux-gcc
12 QMAKE_LEX = flex 12 QMAKE_LEX = flex
13 QMAKE_LEXFLAGS = 13 QMAKE_LEXFLAGS =
14 QMAKE_YACC = yacc 14 QMAKE_YACC = yacc
15 QMAKE_YACCFLAGS = -d 15 QMAKE_YACCFLAGS = -d
16 QMAKE_CFLAGS = -pipe $(CFLAGS_EXTRA) 16 QMAKE_CFLAGS = -pipe $(CFLAGS_EXTRA)
17 QMAKE_CFLAGS_WARN_ON= -Wall -W 17 QMAKE_CFLAGS_WARN_ON= -Wall -W
18 QMAKE_CFLAGS_WARN_OFF= 18 QMAKE_CFLAGS_WARN_OFF=
19 QMAKE_CFLAGS_RELEASE= $(if $(CFLAGS_RELEASE),$(CFLAGS_RELEASE), -O2) 19 QMAKE_CFLAGS_RELEASE= $(if $(CFLAGS_RELEASE),$(CFLAGS_RELEASE), -O2)
20 QMAKE_CFLAGS_DEBUG= -g 20 QMAKE_CFLAGS_DEBUG= -g
21 QMAKE_CFLAGS_SHLIB= -fPIC 21 QMAKE_CFLAGS_SHLIB= -fPIC
22 QMAKE_CFLAGS_YACC= -Wno-unused -Wno-parentheses 22 QMAKE_CFLAGS_YACC= -Wno-unused -Wno-parentheses
23 QMAKE_CFLAGS_THREAD= -D_REENTRANT 23 QMAKE_CFLAGS_THREAD= -D_REENTRANT
24 24
25 QMAKE_CXX = arm-linux-g++ -DQT_QWS_SHARP -DQT_QWS_EBX 25 QMAKE_CXX = arm-linux-g++ -DQT_QWS_SL5XXX -DQT_QWS_SHARP -DQT_QWS_EBX -DQT_QWS_CUSTOM
26 QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -DQWS -fno-exceptions -fno-rtti $(CXXFLAGS_EXTRA) 26 QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -DQWS -fno-exceptions -fno-rtti $(CXXFLAGS_EXTRA)
27 QMAKE_CXXFLAGS_WARN_ON= $$QMAKE_CFLAGS_WARN_ON 27 QMAKE_CXXFLAGS_WARN_ON= $$QMAKE_CFLAGS_WARN_ON
28 QMAKE_CXXFLAGS_WARN_OFF= $$QMAKE_CFLAGS_WARN_OFF 28 QMAKE_CXXFLAGS_WARN_OFF= $$QMAKE_CFLAGS_WARN_OFF
29 QMAKE_CXXFLAGS_RELEASE= $$QMAKE_CFLAGS_RELEASE 29 QMAKE_CXXFLAGS_RELEASE= $$QMAKE_CFLAGS_RELEASE
30 QMAKE_CXXFLAGS_DEBUG= $$QMAKE_CFLAGS_DEBUG 30 QMAKE_CXXFLAGS_DEBUG= $$QMAKE_CFLAGS_DEBUG
31 QMAKE_CXXFLAGS_SHLIB= $$QMAKE_CFLAGS_SHLIB 31 QMAKE_CXXFLAGS_SHLIB= $$QMAKE_CFLAGS_SHLIB
32 QMAKE_CXXFLAGS_YACC= $$QMAKE_CFLAGS_YACC 32 QMAKE_CXXFLAGS_YACC= $$QMAKE_CFLAGS_YACC
33 QMAKE_CXXFLAGS_THREAD= $$QMAKE_CFLAGS_THREAD 33 QMAKE_CXXFLAGS_THREAD= $$QMAKE_CFLAGS_THREAD
34 34
35 QMAKE_INCDIR = 35 QMAKE_INCDIR =
36 QMAKE_LIBDIR = 36 QMAKE_LIBDIR =
37 QMAKE_INCDIR_X11= 37 QMAKE_INCDIR_X11=
38 QMAKE_LIBDIR_X11= 38 QMAKE_LIBDIR_X11=
39 QMAKE_INCDIR_QT = $(QTDIR)/include 39 QMAKE_INCDIR_QT = $(QTDIR)/include
40 QMAKE_LIBDIR_QT = $(QTDIR)/lib 40 QMAKE_LIBDIR_QT = $(QTDIR)/lib
41 QMAKE_INCDIR_OPENGL= /usr/X11R6/include 41 QMAKE_INCDIR_OPENGL= /usr/X11R6/include
42 QMAKE_LIBDIR_OPENGL= /usr/X11R6/lib 42 QMAKE_LIBDIR_OPENGL= /usr/X11R6/lib
43 43
44 QMAKE_LINK = arm-linux-gcc 44 QMAKE_LINK = arm-linux-gcc
45 QMAKE_LINK_SHLIB= arm-linux-gcc 45 QMAKE_LINK_SHLIB= arm-linux-gcc
46 QMAKE_LFLAGS = $(LFLAGS_EXTRA) 46 QMAKE_LFLAGS = $(LFLAGS_EXTRA)
47 QMAKE_LFLAGS_RELEASE= 47 QMAKE_LFLAGS_RELEASE=
48 QMAKE_LFLAGS_DEBUG= 48 QMAKE_LFLAGS_DEBUG=
49QMAKE_LFLAGS_SHLIB = -shared 49QMAKE_LFLAGS_SHLIB = -shared
50QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB 50QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB
51QMAKE_LFLAGS_SONAME = -Wl,-soname, 51QMAKE_LFLAGS_SONAME = -Wl,-soname,
52QMAKE_LFLAGS_THREAD = 52QMAKE_LFLAGS_THREAD =
53QMAKE_RPATH = -Wl,-rpath, 53QMAKE_RPATH = -Wl,-rpath,
54 54
55 QMAKE_LIBS = $(LIBS_EXTRA) 55 QMAKE_LIBS = $(LIBS_EXTRA)
56QMAKE_LIBS_DYNLOAD = -ldl 56QMAKE_LIBS_DYNLOAD = -ldl
57 QMAKE_LIBS_X11 = 57 QMAKE_LIBS_X11 =
58 QMAKE_LIBS_X11SM= 58 QMAKE_LIBS_X11SM=
59 QMAKE_LIBS_QT = -lqte 59 QMAKE_LIBS_QT = -lqte
60QMAKE_LIBS_QT_THREAD = -lqte-mt 60QMAKE_LIBS_QT_THREAD = -lqte-mt
61 QMAKE_LIBS_QT_OPENGL= -lqgl 61 QMAKE_LIBS_QT_OPENGL= -lqgl
62QMAKE_LIBS_THREAD = -lpthread 62QMAKE_LIBS_THREAD = -lpthread
63 63
64 QMAKE_MOC = $(QTDIR)/bin/moc 64 QMAKE_MOC = $(QTDIR)/bin/moc
65 QMAKE_UIC = $(QTDIR)/bin/uic 65 QMAKE_UIC = $(QTDIR)/bin/uic
66 66
67 QMAKE_AR = ar cqs 67 QMAKE_AR = ar cqs
68 QMAKE_RANLIB = 68 QMAKE_RANLIB =
69 69
70 QMAKE_TAR = tar -cf 70 QMAKE_TAR = tar -cf
71 QMAKE_GZIP = gzip -9f 71 QMAKE_GZIP = gzip -9f
72 72
73 QMAKE_COPY = cp -f 73 QMAKE_COPY = cp -f
74 QMAKE_MOVE = mv -f 74 QMAKE_MOVE = mv -f
75 QMAKE_DEL_FILE = rm -f 75 QMAKE_DEL_FILE = rm -f
76 QMAKE_DEL_DIR = rmdir 76 QMAKE_DEL_DIR = rmdir
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp
index 0ec6fad..d4396d2 100644
--- a/noncore/multimedia/opieplayer2/mediaplayer.cpp
+++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp
@@ -1,414 +1,414 @@
1#include <qpe/qpeapplication.h> 1#include <qpe/qpeapplication.h>
2#include <qpe/qlibrary.h> 2#include <qpe/qlibrary.h>
3#include <qpe/resource.h> 3#include <qpe/resource.h>
4#include <qpe/config.h> 4#include <qpe/config.h>
5#include <qpe/qcopenvelope_qws.h> 5#include <qpe/qcopenvelope_qws.h>
6#include <qfileinfo.h> 6#include <qfileinfo.h>
7 7
8#include <qmainwindow.h> 8#include <qmainwindow.h>
9#include <qmessagebox.h> 9#include <qmessagebox.h>
10#include <qwidgetstack.h> 10#include <qwidgetstack.h>
11#include <qfile.h> 11#include <qfile.h>
12 12
13#include "mediaplayer.h" 13#include "mediaplayer.h"
14#include "playlistwidget.h" 14#include "playlistwidget.h"
15#include "audiowidget.h" 15#include "audiowidget.h"
16#include "videowidget.h" 16#include "videowidget.h"
17#include "volumecontrol.h" 17#include "volumecontrol.h"
18#include "lib.h" 18#include "lib.h"
19 19
20#include "mediaplayerstate.h" 20#include "mediaplayerstate.h"
21 21
22// for setBacklight() 22// for setBacklight()
23#include <linux/fb.h> 23#include <linux/fb.h>
24#include <sys/file.h> 24#include <sys/file.h>
25#include <sys/ioctl.h> 25#include <sys/ioctl.h>
26 26
27 27
28 28
29 29
30#define FBIOBLANK 0x4611 30#define FBIOBLANK 0x4611
31 31
32MediaPlayer::MediaPlayer( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name ) 32MediaPlayer::MediaPlayer( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name )
33 : QObject( parent, name ), volumeDirection( 0 ), mediaPlayerState( _mediaPlayerState ), playList( _playList ) { 33 : QObject( parent, name ), volumeDirection( 0 ), mediaPlayerState( _mediaPlayerState ), playList( _playList ) {
34 34
35 m_audioUI = 0; 35 m_audioUI = 0;
36 m_videoUI = 0; 36 m_videoUI = 0;
37 m_xineControl = 0; 37 m_xineControl = 0;
38 xine = new XINE::Lib( XINE::Lib::InitializeInThread ); 38 xine = new XINE::Lib( XINE::Lib::InitializeInThread );
39 39
40 fd=-1;fl=-1; 40 fd=-1;fl=-1;
41 playList.setCaption( tr( "OpiePlayer: Initializating" ) ); 41 playList.setCaption( tr( "OpiePlayer: Initializating" ) );
42 42
43 qApp->processEvents(); 43 qApp->processEvents();
44 // QPEApplication::grabKeyboard(); // EVIL 44 // QPEApplication::grabKeyboard(); // EVIL
45 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 45 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
46 46
47 connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); 47 connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) );
48 48
49// What is pauseCheck good for? (Simon) 49// What is pauseCheck good for? (Simon)
50// connect( &mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); 50// connect( &mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) );
51 51
52 connect( &mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); 52 connect( &mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) );
53 connect( &mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); 53 connect( &mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) );
54 connect( &mediaPlayerState, SIGNAL( blankToggled( bool ) ), this, SLOT ( blank( bool ) ) ); 54 connect( &mediaPlayerState, SIGNAL( blankToggled( bool ) ), this, SLOT ( blank( bool ) ) );
55 55
56 volControl = new VolumeControl; 56 volControl = new VolumeControl;
57 Config cfg( "OpiePlayer" ); 57 Config cfg( "OpiePlayer" );
58 cfg.setGroup("PlayList"); 58 cfg.setGroup("PlayList");
59 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); 59 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default");
60 playList.setCaption( tr( "OpiePlayer: " ) + QFileInfo(currentPlaylist).baseName() ); 60 playList.setCaption( tr( "OpiePlayer: " ) + QFileInfo(currentPlaylist).baseName() );
61 61
62 m_skinLoader = new SkinLoader; 62 m_skinLoader = new SkinLoader;
63 m_skinLoader->schedule( AudioWidget::guiInfo() ); 63 m_skinLoader->schedule( AudioWidget::guiInfo() );
64 m_skinLoader->schedule( VideoWidget::guiInfo() ); 64 m_skinLoader->schedule( VideoWidget::guiInfo() );
65 m_skinLoader->start(); 65 m_skinLoader->start();
66} 66}
67 67
68MediaPlayer::~MediaPlayer() { 68MediaPlayer::~MediaPlayer() {
69 // this shold never happen, but one never knows... 69 // this shold never happen, but one never knows...
70 if ( xine ) { 70 if ( xine ) {
71 xine->ensureInitialized(); 71 xine->ensureInitialized();
72 delete xine; 72 delete xine;
73 } 73 }
74 delete m_xineControl; 74 delete m_xineControl;
75 delete m_audioUI; 75 delete m_audioUI;
76 delete m_videoUI; 76 delete m_videoUI;
77 delete volControl; 77 delete volControl;
78} 78}
79 79
80void MediaPlayer::pauseCheck( bool b ) { 80void MediaPlayer::pauseCheck( bool b ) {
81 if ( b && !mediaPlayerState.isPlaying() ) { 81 if ( b && !mediaPlayerState.isPlaying() ) {
82 mediaPlayerState.setPaused( FALSE ); 82 mediaPlayerState.setPaused( FALSE );
83 } 83 }
84} 84}
85 85
86void MediaPlayer::play() { 86void MediaPlayer::play() {
87 mediaPlayerState.setPlaying( FALSE ); 87 mediaPlayerState.setPlaying( FALSE );
88 mediaPlayerState.setPlaying( TRUE ); 88 mediaPlayerState.setPlaying( TRUE );
89} 89}
90 90
91void MediaPlayer::setPlaying( bool play ) { 91void MediaPlayer::setPlaying( bool play ) {
92 if ( !play ) { 92 if ( !play ) {
93 return; 93 return;
94 } 94 }
95 95
96 if ( mediaPlayerState.isPaused() ) { 96 if ( mediaPlayerState.isPaused() ) {
97 mediaPlayerState.setPaused( FALSE ); 97 mediaPlayerState.setPaused( FALSE );
98 return; 98 return;
99 } 99 }
100 100
101 QString tickerText, time, fileName; 101 QString tickerText, time, fileName;
102 if ( playList.currentTab() != PlayListWidget::CurrentPlayList ) { 102 if ( playList.currentTab() != PlayListWidget::CurrentPlayList ) {
103 //if playing in file list.. play in a different way 103 //if playing in file list.. play in a different way
104 // random and looping settings enabled causes problems here, 104 // random and looping settings enabled causes problems here,
105 // since there is no selected file in the playlist, but a selected file in the file list, 105 // since there is no selected file in the playlist, but a selected file in the file list,
106 // so we remember and shutoff 106 // so we remember and shutoff
107 l = mediaPlayerState.isLooping(); 107 l = mediaPlayerState.isLooping();
108 if(l) { 108 if(l) {
109 mediaPlayerState.setLooping( false ); 109 mediaPlayerState.setLooping( false );
110 } 110 }
111 r = mediaPlayerState.isShuffled(); 111 r = mediaPlayerState.isShuffled();
112 mediaPlayerState.setShuffled( false ); 112 mediaPlayerState.setShuffled( false );
113 } 113 }
114 114
115 PlayListWidget::Entry playListEntry = playList.currentEntry(); 115 PlayListWidget::Entry playListEntry = playList.currentEntry();
116 fileName = playListEntry.name; 116 fileName = playListEntry.name;
117 xineControl()->play( playListEntry.file ); 117 xineControl()->play( playListEntry.file );
118 118
119 long seconds = mediaPlayerState.length(); 119 long seconds = mediaPlayerState.length();
120 time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); 120 time.sprintf("%li:%02i", seconds/60, (int)seconds%60 );
121 121
122 if( fileName.left(4) == "http" ) { 122 if( fileName.left(4) == "http" ) {
123 fileName = QFileInfo( fileName ).baseName(); 123 fileName = QFileInfo( fileName ).baseName();
124 if ( xineControl()->getMetaInfo().isEmpty() ) { 124 if ( xineControl()->getMetaInfo().isEmpty() ) {
125 tickerText = tr( " File: " ) + fileName; 125 tickerText = tr( " File: " ) + fileName;
126 } else { 126 } else {
127 tickerText = xineControl()->getMetaInfo(); 127 tickerText = xineControl()->getMetaInfo();
128 } 128 }
129 } else { 129 } else {
130 if ( xineControl()->getMetaInfo().isEmpty() ) { 130 if ( xineControl()->getMetaInfo().isEmpty() ) {
131 tickerText = tr( " File: " ) + fileName + tr( ", Length: " ) + time + " "; 131 tickerText = tr( " File: " ) + fileName + tr( ", Length: " ) + time + " ";
132 } else { 132 } else {
133 tickerText = xineControl()->getMetaInfo() + " Length: " + time + " "; 133 tickerText = xineControl()->getMetaInfo() + " Length: " + time + " ";
134 } 134 }
135 } 135 }
136 audioUI()->setTickerText( tickerText ); 136 audioUI()->setTickerText( tickerText );
137} 137}
138 138
139 139
140void MediaPlayer::prev() { 140void MediaPlayer::prev() {
141 if( playList.currentTab() == PlayListWidget::CurrentPlayList ) { //if using the playlist 141 if( playList.currentTab() == PlayListWidget::CurrentPlayList ) { //if using the playlist
142 if ( playList.prev() ) { 142 if ( playList.prev() ) {
143 play(); 143 play();
144 } else if ( mediaPlayerState.isLooping() ) { 144 } else if ( mediaPlayerState.isLooping() ) {
145 if ( playList.last() ) { 145 if ( playList.last() ) {
146 play(); 146 play();
147 } 147 }
148 } else { 148 } else {
149 mediaPlayerState.setList(); 149 mediaPlayerState.setList();
150 } 150 }
151 } 151 }
152} 152}
153 153
154 154
155void MediaPlayer::next() { 155void MediaPlayer::next() {
156 156
157 if(playList.currentTab() == PlayListWidget::CurrentPlayList) { //if using the playlist 157 if(playList.currentTab() == PlayListWidget::CurrentPlayList) { //if using the playlist
158 if ( playList.next() ) { 158 if ( playList.next() ) {
159 play(); 159 play();
160 } else if ( mediaPlayerState.isLooping() ) { 160 } else if ( mediaPlayerState.isLooping() ) {
161 if ( playList.first() ) { 161 if ( playList.first() ) {
162 play(); 162 play();
163 } 163 }
164 } else { 164 } else {
165 mediaPlayerState.setList(); 165 mediaPlayerState.setList();
166 } 166 }
167 } else { //if playing from file list, let's just stop 167 } else { //if playing from file list, let's just stop
168 qDebug("<<<<<<<<<<<<<<<<<stop for filelists"); 168 qDebug("<<<<<<<<<<<<<<<<<stop for filelists");
169 mediaPlayerState.setPlaying(false); 169 mediaPlayerState.setPlaying(false);
170 mediaPlayerState.setDisplayType( MediaPlayerState::MediaSelection ); 170 mediaPlayerState.setDisplayType( MediaPlayerState::MediaSelection );
171 if(l) mediaPlayerState.setLooping(l); 171 if(l) mediaPlayerState.setLooping(l);
172 if(r) mediaPlayerState.setShuffled(r); 172 if(r) mediaPlayerState.setShuffled(r);
173 } 173 }
174 qApp->processEvents(); 174 qApp->processEvents();
175} 175}
176 176
177 177
178void MediaPlayer::startDecreasingVolume() { 178void MediaPlayer::startDecreasingVolume() {
179 volumeDirection = -1; 179 volumeDirection = -1;
180 startTimer( 100 ); 180 startTimer( 100 );
181 volControl->decVol(2); 181 volControl->decVol(2);
182} 182}
183 183
184 184
185void MediaPlayer::startIncreasingVolume() { 185void MediaPlayer::startIncreasingVolume() {
186 volumeDirection = +1; 186 volumeDirection = +1;
187 startTimer( 100 ); 187 startTimer( 100 );
188 volControl->incVol(2); 188 volControl->incVol(2);
189} 189}
190 190
191 191
192bool drawnOnScreenDisplay = FALSE; 192bool drawnOnScreenDisplay = FALSE;
193unsigned int onScreenDisplayVolume = 0; 193unsigned int onScreenDisplayVolume = 0;
194const int yoff = 110; 194const int yoff = 110;
195 195
196void MediaPlayer::stopChangingVolume() { 196void MediaPlayer::stopChangingVolume() {
197 killTimers(); 197 killTimers();
198 // Get rid of the on-screen display stuff 198 // Get rid of the on-screen display stuff
199 drawnOnScreenDisplay = FALSE; 199 drawnOnScreenDisplay = FALSE;
200 onScreenDisplayVolume = 0; 200 onScreenDisplayVolume = 0;
201 int w=0; 201 int w=0;
202 int h=0; 202 int h=0;
203 if( !xineControl()->hasVideo() ) { 203 if( !xineControl()->hasVideo() ) {
204 w = audioUI()->width(); 204 w = audioUI()->width();
205 h = audioUI()->height(); 205 h = audioUI()->height();
206 audioUI()->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); 206 audioUI()->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE );
207 } else { 207 } else {
208 w = videoUI()->width(); 208 w = videoUI()->width();
209 h = videoUI()->height(); 209 h = videoUI()->height();
210 videoUI()->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); 210 videoUI()->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE );
211 } 211 }
212} 212}
213 213
214 214
215void MediaPlayer::timerEvent( QTimerEvent * ) { 215void MediaPlayer::timerEvent( QTimerEvent * ) {
216 if ( volumeDirection == +1 ) { 216 if ( volumeDirection == +1 ) {
217 volControl->incVol( 2 ); 217 volControl->incVol( 2 );
218 } else if ( volumeDirection == -1 ) { 218 } else if ( volumeDirection == -1 ) {
219 volControl->decVol( 2 ); 219 volControl->decVol( 2 );
220 } 220 }
221 221
222 222
223 // TODO FIXME 223 // TODO FIXME
224 // huh?? 224 // huh??
225 unsigned int v= 0; 225 unsigned int v= 0;
226 v = volControl->volume(); 226 v = volControl->volume();
227 v = v / 10; 227 v = v / 10;
228 228
229 if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) { 229 if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) {
230 return; 230 return;
231 } 231 }
232 232
233 int w=0; int h=0; 233 int w=0; int h=0;
234 if( !xineControl()->hasVideo() ) { 234 if( !xineControl()->hasVideo() ) {
235 w = audioUI()->width(); 235 w = audioUI()->width();
236 h = audioUI()->height(); 236 h = audioUI()->height();
237 237
238 if ( drawnOnScreenDisplay ) { 238 if ( drawnOnScreenDisplay ) {
239 if ( onScreenDisplayVolume > v ) { 239 if ( onScreenDisplayVolume > v ) {
240 audioUI()->repaint( ( w - 200 ) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); 240 audioUI()->repaint( ( w - 200 ) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE );
241 } 241 }
242 } 242 }
243 drawnOnScreenDisplay = TRUE; 243 drawnOnScreenDisplay = TRUE;
244 onScreenDisplayVolume = v; 244 onScreenDisplayVolume = v;
245 QPainter p( audioUI() ); 245 QPainter p( audioUI() );
246 p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); 246 p.setPen( QColor( 0x10, 0xD0, 0x10 ) );
247 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); 247 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) );
248 248
249 QFont f; 249 QFont f;
250 f.setPixelSize( 20 ); 250 f.setPixelSize( 20 );
251 f.setBold( TRUE ); 251 f.setBold( TRUE );
252 p.setFont( f ); 252 p.setFont( f );
253 p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); 253 p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") );
254 254
255 for ( unsigned int i = 0; i < 10; i++ ) { 255 for ( unsigned int i = 0; i < 10; i++ ) {
256 if ( v > i ) { 256 if ( v > i ) {
257 p.drawRect( ( w - 200 ) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); 257 p.drawRect( ( w - 200 ) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 );
258 } else { 258 } else {
259 p.drawRect( ( w - 200 ) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); 259 p.drawRect( ( w - 200 ) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 );
260 } 260 }
261 } 261 }
262 } else { 262 } else {
263 w = videoUI()->width(); 263 w = videoUI()->width();
264 h = videoUI()->height(); 264 h = videoUI()->height();
265 265
266 if ( drawnOnScreenDisplay ) { 266 if ( drawnOnScreenDisplay ) {
267 if ( onScreenDisplayVolume > v ) { 267 if ( onScreenDisplayVolume > v ) {
268 videoUI()->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); 268 videoUI()->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE );
269 } 269 }
270 } 270 }
271 drawnOnScreenDisplay = TRUE; 271 drawnOnScreenDisplay = TRUE;
272 onScreenDisplayVolume = v; 272 onScreenDisplayVolume = v;
273 QPainter p( videoUI() ); 273 QPainter p( videoUI() );
274 p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); 274 p.setPen( QColor( 0x10, 0xD0, 0x10 ) );
275 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); 275 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) );
276 276
277 QFont f; 277 QFont f;
278 f.setPixelSize( 20 ); 278 f.setPixelSize( 20 );
279 f.setBold( TRUE ); 279 f.setBold( TRUE );
280 p.setFont( f ); 280 p.setFont( f );
281 p.drawText( (w - 200) / 2, h - yoff + 20, tr( "Volume" ) ); 281 p.drawText( (w - 200) / 2, h - yoff + 20, tr( "Volume" ) );
282 282
283 for ( unsigned int i = 0; i < 10; i++ ) { 283 for ( unsigned int i = 0; i < 10; i++ ) {
284 if ( v > i ) { 284 if ( v > i ) {
285 p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); 285 p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 );
286 } else { 286 } else {
287 p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); 287 p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 );
288 } 288 }
289 } 289 }
290 } 290 }
291} 291}
292 292
293 293
294void MediaPlayer::blank( bool b ) { 294void MediaPlayer::blank( bool b ) {
295 fd=open("/dev/fb0",O_RDWR); 295 fd=open("/dev/fb0",O_RDWR);
296#ifdef QT_QWS_EBX 296#ifdef QT_QWS_SL5XXX
297 fl= open( "/dev/fl", O_RDWR ); 297 fl= open( "/dev/fl", O_RDWR );
298#endif 298#endif
299 if (fd != -1) { 299 if (fd != -1) {
300 if ( b ) { 300 if ( b ) {
301 qDebug("do blanking"); 301 qDebug("do blanking");
302#ifdef QT_QWS_EBX 302#ifdef QT_QWS_SL5XXX
303 ioctl( fd, FBIOBLANK, 1 ); 303 ioctl( fd, FBIOBLANK, 1 );
304 if(fl !=-1) { 304 if(fl !=-1) {
305 ioctl( fl, 2 ); 305 ioctl( fl, 2 );
306 ::close(fl); 306 ::close(fl);
307 } 307 }
308#else 308#else
309 ioctl( fd, FBIOBLANK, 3 ); 309 ioctl( fd, FBIOBLANK, 3 );
310#endif 310#endif
311 isBlanked = TRUE; 311 isBlanked = TRUE;
312 } else { 312 } else {
313 qDebug("do unblanking"); 313 qDebug("do unblanking");
314 ioctl( fd, FBIOBLANK, 0); 314 ioctl( fd, FBIOBLANK, 0);
315#ifdef QT_QWS_EBX 315#ifdef QT_QWS_SL5XXX
316 if(fl != -1) { 316 if(fl != -1) {
317 ioctl( fl, 1); 317 ioctl( fl, 1);
318 ::close(fl); 318 ::close(fl);
319 } 319 }
320#endif 320#endif
321 isBlanked = FALSE; 321 isBlanked = FALSE;
322 } 322 }
323 close( fd ); 323 close( fd );
324 } else { 324 } else {
325 qDebug("<< /dev/fb0 could not be opened >>"); 325 qDebug("<< /dev/fb0 could not be opened >>");
326 } 326 }
327} 327}
328 328
329void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { 329void MediaPlayer::keyReleaseEvent( QKeyEvent *e) {
330 switch ( e->key() ) { 330 switch ( e->key() ) {
331////////////////////////////// Zaurus keys 331////////////////////////////// Zaurus keys
332 case Key_Home: 332 case Key_Home:
333 break; 333 break;
334 case Key_F9: //activity 334 case Key_F9: //activity
335 break; 335 break;
336 case Key_F10: //contacts 336 case Key_F10: //contacts
337 break; 337 break;
338 case Key_F11: //menu 338 case Key_F11: //menu
339 break; 339 break;
340 case Key_F12: //home 340 case Key_F12: //home
341 qDebug("Blank here"); 341 qDebug("Blank here");
342// mediaPlayerState->toggleBlank(); 342// mediaPlayerState->toggleBlank();
343 break; 343 break;
344 case Key_F13: //mail 344 case Key_F13: //mail
345 qDebug("Blank here"); 345 qDebug("Blank here");
346 // mediaPlayerState->toggleBlank(); 346 // mediaPlayerState->toggleBlank();
347 break; 347 break;
348 } 348 }
349} 349}
350 350
351void MediaPlayer::cleanUp() {// this happens on closing 351void MediaPlayer::cleanUp() {// this happens on closing
352 Config cfg( "OpiePlayer" ); 352 Config cfg( "OpiePlayer" );
353 mediaPlayerState.writeConfig( cfg ); 353 mediaPlayerState.writeConfig( cfg );
354 playList.writeDefaultPlaylist( ); 354 playList.writeDefaultPlaylist( );
355 355
356// QPEApplication::grabKeyboard(); 356// QPEApplication::grabKeyboard();
357// QPEApplication::ungrabKeyboard(); 357// QPEApplication::ungrabKeyboard();
358} 358}
359 359
360void MediaPlayer::recreateAudioAndVideoWidgets() const 360void MediaPlayer::recreateAudioAndVideoWidgets() const
361{ 361{
362 delete m_skinLoader; 362 delete m_skinLoader;
363 363
364 delete m_xineControl; 364 delete m_xineControl;
365 delete m_audioUI; 365 delete m_audioUI;
366 delete m_videoUI; 366 delete m_videoUI;
367 m_audioUI = new AudioWidget( playList, mediaPlayerState, 0, "audioUI" ); 367 m_audioUI = new AudioWidget( playList, mediaPlayerState, 0, "audioUI" );
368 m_videoUI = new VideoWidget( playList, mediaPlayerState, 0, "videoUI" ); 368 m_videoUI = new VideoWidget( playList, mediaPlayerState, 0, "videoUI" );
369 369
370 connect( m_audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); 370 connect( m_audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) );
371 connect( m_audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); 371 connect( m_audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) );
372 connect( m_audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); 372 connect( m_audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) );
373 connect( m_audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); 373 connect( m_audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) );
374 374
375 connect( m_videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); 375 connect( m_videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) );
376 connect( m_videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); 376 connect( m_videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) );
377 connect( m_videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); 377 connect( m_videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) );
378 connect( m_videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); 378 connect( m_videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) );
379 379
380 if ( !xine ) 380 if ( !xine )
381 xine = new XINE::Lib( XINE::Lib::InitializeImmediately ); 381 xine = new XINE::Lib( XINE::Lib::InitializeImmediately );
382 382
383 m_xineControl = new XineControl( xine, m_videoUI->vidWidget(), mediaPlayerState ); 383 m_xineControl = new XineControl( xine, m_videoUI->vidWidget(), mediaPlayerState );
384 384
385 xine = 0; 385 xine = 0;
386} 386}
387 387
388AudioWidget *MediaPlayer::audioUI() const 388AudioWidget *MediaPlayer::audioUI() const
389{ 389{
390 if ( !m_audioUI ) 390 if ( !m_audioUI )
391 recreateAudioAndVideoWidgets(); 391 recreateAudioAndVideoWidgets();
392 return m_audioUI; 392 return m_audioUI;
393} 393}
394 394
395VideoWidget *MediaPlayer::videoUI() const 395VideoWidget *MediaPlayer::videoUI() const
396{ 396{
397 if ( !m_videoUI ) 397 if ( !m_videoUI )
398 recreateAudioAndVideoWidgets(); 398 recreateAudioAndVideoWidgets();
399 return m_videoUI; 399 return m_videoUI;
400} 400}
401 401
402XineControl *MediaPlayer::xineControl() const 402XineControl *MediaPlayer::xineControl() const
403{ 403{
404 if ( !m_xineControl ) 404 if ( !m_xineControl )
405 recreateAudioAndVideoWidgets(); 405 recreateAudioAndVideoWidgets();
406 return m_xineControl; 406 return m_xineControl;
407} 407}
408 408
409void MediaPlayer::reloadSkins() 409void MediaPlayer::reloadSkins()
410{ 410{
411 audioUI()->loadSkin(); 411 audioUI()->loadSkin();
412 videoUI()->loadSkin(); 412 videoUI()->loadSkin();
413} 413}
414 414
diff --git a/noncore/settings/sound/soundsettings.cpp b/noncore/settings/sound/soundsettings.cpp
index dd341c0..afcdd49 100644
--- a/noncore/settings/sound/soundsettings.cpp
+++ b/noncore/settings/sound/soundsettings.cpp
@@ -1,211 +1,211 @@
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// parts copyright 2002 L.J. Potter 20// parts copyright 2002 L.J. Potter
21 21
22#include "soundsettings.h" 22#include "soundsettings.h"
23 23
24#include <qpe/qpeapplication.h> 24#include <qpe/qpeapplication.h>
25#include <qpe/config.h> 25#include <qpe/config.h>
26#include <qpe/qcopenvelope_qws.h> 26#include <qpe/qcopenvelope_qws.h>
27#include <qpe/storage.h> 27#include <qpe/storage.h>
28 28
29#include <qmessagebox.h> 29#include <qmessagebox.h>
30#include <qapplication.h> 30#include <qapplication.h>
31#include <qslider.h> 31#include <qslider.h>
32#include <qcheckbox.h> 32#include <qcheckbox.h>
33#include <qlineedit.h> 33#include <qlineedit.h>
34#include <qcombobox.h> 34#include <qcombobox.h>
35#include <qlabel.h> 35#include <qlabel.h>
36 36
37#include <sys/utsname.h> 37#include <sys/utsname.h>
38#include <sys/time.h> 38#include <sys/time.h>
39#include <sys/types.h> 39#include <sys/types.h>
40#include <unistd.h> 40#include <unistd.h>
41#include <stdio.h> 41#include <stdio.h>
42#include <sys/stat.h> 42#include <sys/stat.h>
43 43
44 44
45SoundSettings::SoundSettings( QWidget* parent, const char* objname, WFlags fl ) 45SoundSettings::SoundSettings( QWidget* parent, const char* objname, WFlags fl )
46 : SoundSettingsBase( parent, objname, TRUE, fl ) 46 : SoundSettingsBase( parent, objname, TRUE, fl )
47{ 47{
48 keyReset=FALSE; 48 keyReset=FALSE;
49 noWarning=false; 49 noWarning=false;
50 Config config( "qpe"); 50 Config config( "qpe");
51 config.setGroup( "Volume" ); 51 config.setGroup( "Volume" );
52 Config cfg("Vmemo"); 52 Config cfg("Vmemo");
53 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 53 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
54 AlertCheckBox->setChecked(cfg.readBoolEntry("Alert")); 54 AlertCheckBox->setChecked(cfg.readBoolEntry("Alert"));
55 55
56 cfg.setGroup("Record"); 56 cfg.setGroup("Record");
57 int rate=config.readNumEntry("SampleRate", 22050); 57 int rate=config.readNumEntry("SampleRate", 22050);
58 if(rate == 8000) 58 if(rate == 8000)
59 sampleRate->setCurrentItem(0); 59 sampleRate->setCurrentItem(0);
60 else if(rate == 11025) 60 else if(rate == 11025)
61 sampleRate->setCurrentItem(1); 61 sampleRate->setCurrentItem(1);
62 else if(rate == 22050) 62 else if(rate == 22050)
63 sampleRate->setCurrentItem(2); 63 sampleRate->setCurrentItem(2);
64 else if(rate == 33075) 64 else if(rate == 33075)
65 sampleRate->setCurrentItem(3); 65 sampleRate->setCurrentItem(3);
66 else if(rate==44100) 66 else if(rate==44100)
67 sampleRate->setCurrentItem(4); 67 sampleRate->setCurrentItem(4);
68 68
69 stereoCheckBox->setChecked(cfg.readNumEntry("Stereo", 0)); 69 stereoCheckBox->setChecked(cfg.readNumEntry("Stereo", 0));
70//TODO hide if zaurus- mono only 70//TODO hide if zaurus- mono only
71 71
72#if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) 72#if defined(QT_QWS_IPAQ) || defined(QT_QWS_SL5XXX)
73//since ipaq and zaurus have particular 73//since ipaq and zaurus have particular
74//devices 74//devices
75 bool systemZaurus=FALSE; 75 bool systemZaurus=FALSE;
76 struct utsname name; /* check for embedix kernel running on the zaurus*/ 76 struct utsname name; /* check for embedix kernel running on the zaurus*/
77 if (uname(&name) != -1) {// TODO change this here,... 77 if (uname(&name) != -1) {// TODO change this here,...
78 QString release=name.release; 78 QString release=name.release;
79 if( release.find("embedix",0,TRUE) != -1) { 79 if( release.find("embedix",0,TRUE) != -1) {
80 qDebug("IS System Zaurus"); 80 qDebug("IS System Zaurus");
81 systemZaurus=TRUE; 81 systemZaurus=TRUE;
82 } 82 }
83 } 83 }
84 if(!systemZaurus) { 84 if(!systemZaurus) {
85 stereoCheckBox->setChecked(TRUE); 85 stereoCheckBox->setChecked(TRUE);
86 } 86 }
87 stereoCheckBox->setEnabled(FALSE); 87 stereoCheckBox->setEnabled(FALSE);
88 sixteenBitCheckBox->setEnabled(FALSE); 88 sixteenBitCheckBox->setEnabled(FALSE);
89#else 89#else
90#endif 90#endif
91 int sRate=cfg.readNumEntry("SizeLimit", 30); 91 int sRate=cfg.readNumEntry("SizeLimit", 30);
92 qDebug("%d",sRate); 92 qDebug("%d",sRate);
93 93
94 if(sRate ==30) 94 if(sRate ==30)
95 timeLimitComboBox->setCurrentItem(0); 95 timeLimitComboBox->setCurrentItem(0);
96 else if(sRate==20) 96 else if(sRate==20)
97 timeLimitComboBox->setCurrentItem(1); 97 timeLimitComboBox->setCurrentItem(1);
98 else if(sRate == 15) 98 else if(sRate == 15)
99 timeLimitComboBox->setCurrentItem(2); 99 timeLimitComboBox->setCurrentItem(2);
100 else if(sRate == 10) 100 else if(sRate == 10)
101 timeLimitComboBox->setCurrentItem(3); 101 timeLimitComboBox->setCurrentItem(3);
102 else if(sRate == 5) 102 else if(sRate == 5)
103 timeLimitComboBox->setCurrentItem(4); 103 timeLimitComboBox->setCurrentItem(4);
104 else 104 else
105 timeLimitComboBox->setCurrentItem(5); 105 timeLimitComboBox->setCurrentItem(5);
106 106
107 sixteenBitCheckBox->setChecked(cfg.readNumEntry("SixteenBit", 1)); 107 sixteenBitCheckBox->setChecked(cfg.readNumEntry("SixteenBit", 1));
108 108
109 cfg.setGroup("Defaults"); 109 cfg.setGroup("Defaults");
110 keyComboBox->setCurrentItem(cfg.readNumEntry("toggleKey") ); 110 keyComboBox->setCurrentItem(cfg.readNumEntry("toggleKey") );
111 111
112 updateStorageCombo(); 112 updateStorageCombo();
113 connect( LocationComboBox,SIGNAL(activated(const QString &)), this, 113 connect( LocationComboBox,SIGNAL(activated(const QString &)), this,
114 SLOT( setLocation(const QString &))); 114 SLOT( setLocation(const QString &)));
115 connect( keyComboBox,SIGNAL(activated( int)), this, 115 connect( keyComboBox,SIGNAL(activated( int)), this,
116 SLOT( setKeyButton( int))); 116 SLOT( setKeyButton( int)));
117 connect( timeLimitComboBox,SIGNAL(activated( const QString &)), this, 117 connect( timeLimitComboBox,SIGNAL(activated( const QString &)), this,
118 SLOT( setSizeLimitButton(const QString &))); 118 SLOT( setSizeLimitButton(const QString &)));
119 connect( restartCheckBox,SIGNAL( toggled( bool)), this, 119 connect( restartCheckBox,SIGNAL( toggled( bool)), this,
120 SLOT( restartOpie( bool))); 120 SLOT( restartOpie( bool)));
121// connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 121// connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
122} 122}
123 123
124void SoundSettings::updateStorageCombo() { 124void SoundSettings::updateStorageCombo() {
125 125
126 Config config( "Vmemo" ); 126 Config config( "Vmemo" );
127 config.setGroup( "System" ); 127 config.setGroup( "System" );
128 QString loc = config.readEntry("RecLocation","/"); 128 QString loc = config.readEntry("RecLocation","/");
129 int i=0; 129 int i=0;
130 int set=0; 130 int set=0;
131 StorageInfo storageInfo; 131 StorageInfo storageInfo;
132 QString sName, sPath; 132 QString sName, sPath;
133 QStringList list; 133 QStringList list;
134 list << "Documents : "+QPEApplication::documentDir(); 134 list << "Documents : "+QPEApplication::documentDir();
135 list << "tmp : /tmp"; 135 list << "tmp : /tmp";
136 136
137 const QList<FileSystem> &fs = storageInfo.fileSystems(); 137 const QList<FileSystem> &fs = storageInfo.fileSystems();
138 QListIterator<FileSystem> it ( fs ); 138 QListIterator<FileSystem> it ( fs );
139 for( ; it.current(); ++it ){ 139 for( ; it.current(); ++it ){
140 const QString name = (*it)->name(); 140 const QString name = (*it)->name();
141 const QString path = (*it)->path(); 141 const QString path = (*it)->path();
142 qDebug("storage name "+name +" storage path is "+path); 142 qDebug("storage name "+name +" storage path is "+path);
143 list << name + ": " +path; 143 list << name + ": " +path;
144 if( loc.find( path,0,TRUE) != -1) 144 if( loc.find( path,0,TRUE) != -1)
145 set = i; 145 set = i;
146// if(dit.current()->file().find(path) != -1 ) storage=name; 146// if(dit.current()->file().find(path) != -1 ) storage=name;
147 i++; 147 i++;
148 } 148 }
149 149
150 LocationComboBox->insertStringList(list); 150 LocationComboBox->insertStringList(list);
151 qDebug("set item %d", set); 151 qDebug("set item %d", set);
152 LocationComboBox->setCurrentItem(set); 152 LocationComboBox->setCurrentItem(set);
153} 153}
154 154
155void SoundSettings::setLocation(const QString & string) { 155void SoundSettings::setLocation(const QString & string) {
156 Config config( "Vmemo" ); 156 Config config( "Vmemo" );
157 config.setGroup( "System" ); 157 config.setGroup( "System" );
158 config.writeEntry("RecLocation",string); 158 config.writeEntry("RecLocation",string);
159 qDebug("set location "+string); 159 qDebug("set location "+string);
160 config.write(); 160 config.write();
161} 161}
162 162
163void SoundSettings::cleanUp() { 163void SoundSettings::cleanUp() {
164 Config cfg("Vmemo"); 164 Config cfg("Vmemo");
165 cfg.writeEntry("Alert",AlertCheckBox->isChecked()); 165 cfg.writeEntry("Alert",AlertCheckBox->isChecked());
166 166
167 cfg.setGroup("Record"); 167 cfg.setGroup("Record");
168 cfg.writeEntry("SampleRate",sampleRate->currentText()); 168 cfg.writeEntry("SampleRate",sampleRate->currentText());
169 cfg.writeEntry("Stereo",stereoCheckBox->isChecked()); 169 cfg.writeEntry("Stereo",stereoCheckBox->isChecked());
170 cfg.writeEntry("SixteenBit",sixteenBitCheckBox->isChecked()); 170 cfg.writeEntry("SixteenBit",sixteenBitCheckBox->isChecked());
171 171
172 if(keyReset && noWarning) { 172 if(keyReset && noWarning) {
173 QCopEnvelope ("QPE/System", "restart()"); 173 QCopEnvelope ("QPE/System", "restart()");
174 } 174 }
175} 175}
176 176
177void SoundSettings::setKeyButton( int index) { 177void SoundSettings::setKeyButton( int index) {
178 Config cfg("Vmemo"); 178 Config cfg("Vmemo");
179 cfg.setGroup("Defaults"); 179 cfg.setGroup("Defaults");
180 cfg.writeEntry( "toggleKey", index ); 180 cfg.writeEntry( "toggleKey", index );
181 keyReset = TRUE; 181 keyReset = TRUE;
182 if( index == 1) { 182 if( index == 1) {
183 cfg.writeEntry( "hideIcon", 0 ); 183 cfg.writeEntry( "hideIcon", 0 );
184 keyLabel->setText(tr("Shows icon")); 184 keyLabel->setText(tr("Shows icon"));
185 } 185 }
186 else { 186 else {
187 cfg.writeEntry( "hideIcon", 1); 187 cfg.writeEntry( "hideIcon", 1);
188 keyLabel->setText(tr("Hides icon")); 188 keyLabel->setText(tr("Hides icon"));
189 } 189 }
190 cfg.write(); 190 cfg.write();
191} 191}
192 192
193void SoundSettings::updateLocationCombo() { 193void SoundSettings::updateLocationCombo() {
194 194
195} 195}
196 196
197void SoundSettings::setSizeLimitButton(const QString &index) { 197void SoundSettings::setSizeLimitButton(const QString &index) {
198 198
199 Config cfg("Vmemo"); 199 Config cfg("Vmemo");
200 cfg.setGroup("Record"); 200 cfg.setGroup("Record");
201 if(index.find("Unlimited",0,TRUE) != -1) 201 if(index.find("Unlimited",0,TRUE) != -1)
202 cfg.writeEntry("SizeLimit", -1); 202 cfg.writeEntry("SizeLimit", -1);
203 else 203 else
204 cfg.writeEntry("SizeLimit", index); 204 cfg.writeEntry("SizeLimit", index);
205 cfg.write(); 205 cfg.write();
206} 206}
207 207
208void SoundSettings::restartOpie(bool b) { 208void SoundSettings::restartOpie(bool b) {
209 noWarning=b; 209 noWarning=b;
210} 210}
211 211
diff --git a/noncore/tools/formatter/formatter.cpp b/noncore/tools/formatter/formatter.cpp
index f275fbe..79a7f9e 100644
--- a/noncore/tools/formatter/formatter.cpp
+++ b/noncore/tools/formatter/formatter.cpp
@@ -1,575 +1,575 @@
1/**************************************************************************** 1/****************************************************************************
2 ** formatter.cpp 2 ** formatter.cpp
3 ** 3 **
4 ** Copyright: Thu Apr 11 11:01:13 2002 4 ** Copyright: Thu Apr 11 11:01:13 2002
5 ** by: L. J. Potter 5 ** by: L. J. Potter
6 ** 6 **
7 ****************************************************************************/ 7 ****************************************************************************/
8 8
9#include "formatter.h" 9#include "formatter.h"
10#include "inputDialog.h" 10#include "inputDialog.h"
11#include "output.h" 11#include "output.h"
12 12
13#include <qpe/qpemenubar.h> 13#include <qpe/qpemenubar.h>
14#include <qpe/qpetoolbar.h> 14#include <qpe/qpetoolbar.h>
15#include <qpe/qpeapplication.h> 15#include <qpe/qpeapplication.h>
16#include <qpe/resource.h> 16#include <qpe/resource.h>
17#include <qpe/config.h> 17#include <qpe/config.h>
18#include <qpe/mimetype.h> 18#include <qpe/mimetype.h>
19#include <qpe/qcopenvelope_qws.h> 19#include <qpe/qcopenvelope_qws.h>
20#include <qpe/storage.h> 20#include <qpe/storage.h>
21 21
22#include <qmultilineedit.h> 22#include <qmultilineedit.h>
23#include <qstring.h> 23#include <qstring.h>
24#include <qlist.h> 24#include <qlist.h>
25#include <qstringlist.h> 25#include <qstringlist.h>
26#include <qdir.h> 26#include <qdir.h>
27#include <qfile.h> 27#include <qfile.h>
28 28
29#include <qtstream.h> 29#include <qtstream.h>
30 30
31#include <qcombobox.h> 31#include <qcombobox.h>
32#include <qpopupmenu.h> 32#include <qpopupmenu.h>
33#include <qmessagebox.h> 33#include <qmessagebox.h>
34#include <qregexp.h> 34#include <qregexp.h>
35 35
36#include <qlabel.h> 36#include <qlabel.h>
37#include <qlineedit.h> 37#include <qlineedit.h>
38#include <qpushbutton.h> 38#include <qpushbutton.h>
39#include <qtabwidget.h> 39#include <qtabwidget.h>
40#include <qwidget.h> 40#include <qwidget.h>
41#include <qlayout.h> 41#include <qlayout.h>
42#include <qvariant.h> 42#include <qvariant.h>
43 43
44#include <unistd.h> 44#include <unistd.h>
45#include <stdio.h> 45#include <stdio.h>
46#include <stdlib.h> 46#include <stdlib.h>
47#include <sys/vfs.h> 47#include <sys/vfs.h>
48#include <mntent.h> 48#include <mntent.h>
49#include <string.h> 49#include <string.h>
50#include <errno.h> 50#include <errno.h>
51 51
52#define BLANK ' ' 52#define BLANK ' '
53#define DELIMITER '#' 53#define DELIMITER '#'
54 54
55/* 55/*
56 Blah blah blah blah */ 56 Blah blah blah blah */
57FormatterApp::FormatterApp( QWidget* parent, const char* name, bool modal, WFlags fl ) 57FormatterApp::FormatterApp( QWidget* parent, const char* name, bool modal, WFlags fl )
58 : QMainWindow( parent, name, fl ) 58 : QMainWindow( parent, name, fl )
59// : QDialog( parent, name, modal, fl ) 59// : QDialog( parent, name, modal, fl )
60{ 60{
61 if ( !name ) 61 if ( !name )
62 setName( "FormatterApp" ); 62 setName( "FormatterApp" );
63 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 63 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
64 64
65 setCaption( tr( "Formatter" ) ); 65 setCaption( tr( "Formatter" ) );
66 FormatterAppLayout = new QGridLayout( this ); 66 FormatterAppLayout = new QGridLayout( this );
67 FormatterAppLayout->setSpacing( 2); 67 FormatterAppLayout->setSpacing( 2);
68 FormatterAppLayout->setMargin( 2 ); 68 FormatterAppLayout->setMargin( 2 );
69 69
70 TabWidget = new QTabWidget( this, "TabWidget" ); 70 TabWidget = new QTabWidget( this, "TabWidget" );
71 71
72 tab = new QWidget( TabWidget, "tab" ); 72 tab = new QWidget( TabWidget, "tab" );
73 tabLayout = new QGridLayout( tab ); 73 tabLayout = new QGridLayout( tab );
74 tabLayout->setSpacing( 3); 74 tabLayout->setSpacing( 3);
75 tabLayout->setMargin( 2); 75 tabLayout->setMargin( 2);
76 76
77 storageComboBox = new QComboBox( FALSE, tab, "storageComboBox" ); 77 storageComboBox = new QComboBox( FALSE, tab, "storageComboBox" );
78 storageComboBox->setMaximumWidth(220); 78 storageComboBox->setMaximumWidth(220);
79 79
80 tabLayout->addMultiCellWidget( storageComboBox, 0, 0, 0, 1); 80 tabLayout->addMultiCellWidget( storageComboBox, 0, 0, 0, 1);
81 81
82 TextLabel4 = new QLabel( tab, "TextLabel4" ); 82 TextLabel4 = new QLabel( tab, "TextLabel4" );
83 TextLabel4->setText( tr( "Storage Type" ) ); 83 TextLabel4->setText( tr( "Storage Type" ) );
84 84
85 tabLayout->addMultiCellWidget( TextLabel4, 1, 1, 0, 1); 85 tabLayout->addMultiCellWidget( TextLabel4, 1, 1, 0, 1);
86 86
87 TextLabel2 = new QLabel( tab, "TextLabel2" ); 87 TextLabel2 = new QLabel( tab, "TextLabel2" );
88 TextLabel2->setText( tr( "File Systems" ) ); 88 TextLabel2->setText( tr( "File Systems" ) );
89 89
90 tabLayout->addMultiCellWidget( TextLabel2, 4, 4, 0, 1); 90 tabLayout->addMultiCellWidget( TextLabel2, 4, 4, 0, 1);
91 91
92 fileSystemsCombo = new QComboBox( FALSE, tab, "fileSystemsCombo" ); 92 fileSystemsCombo = new QComboBox( FALSE, tab, "fileSystemsCombo" );
93 fileSystemsCombo->setMaximumWidth(220); 93 fileSystemsCombo->setMaximumWidth(220);
94 94
95 tabLayout->addMultiCellWidget( fileSystemsCombo, 3, 3, 0, 1); 95 tabLayout->addMultiCellWidget( fileSystemsCombo, 3, 3, 0, 1);
96 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Minimum ); 96 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Minimum );
97 tabLayout->addItem( spacer, 2, 0 ); 97 tabLayout->addItem( spacer, 2, 0 );
98 98
99 formatPushButton = new QPushButton( tab, "formatPushButton" ); 99 formatPushButton = new QPushButton( tab, "formatPushButton" );
100 formatPushButton->setText( tr( "Format" ) ); 100 formatPushButton->setText( tr( "Format" ) );
101 formatPushButton->setMaximumWidth(170); 101 formatPushButton->setMaximumWidth(170);
102 102
103 tabLayout->addMultiCellWidget( formatPushButton, 6, 6, 0, 1); 103 tabLayout->addMultiCellWidget( formatPushButton, 6, 6, 0, 1);
104 QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Minimum ); 104 QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Minimum );
105 tabLayout->addItem( spacer_2, 5, 0 ); 105 tabLayout->addItem( spacer_2, 5, 0 );
106 106
107 TabWidget->insertTab( tab, tr( "Main" ) ); 107 TabWidget->insertTab( tab, tr( "Main" ) );
108 108
109 tab_2 = new QWidget( TabWidget, "tab_2" ); 109 tab_2 = new QWidget( TabWidget, "tab_2" );
110 tabLayout_2 = new QGridLayout( tab_2 ); 110 tabLayout_2 = new QGridLayout( tab_2 );
111 tabLayout_2->setSpacing(3); 111 tabLayout_2->setSpacing(3);
112 tabLayout_2->setMargin(2); 112 tabLayout_2->setMargin(2);
113 113
114 mountPointLineEdit = new QLineEdit( tab_2, "mountPointLineEdit" ); 114 mountPointLineEdit = new QLineEdit( tab_2, "mountPointLineEdit" );
115 115
116 tabLayout_2->addMultiCellWidget( mountPointLineEdit, 0, 0, 0, 1); 116 tabLayout_2->addMultiCellWidget( mountPointLineEdit, 0, 0, 0, 1);
117 117
118 deviceComboBox = new QComboBox( FALSE, tab_2, "deviceComboBox" ); 118 deviceComboBox = new QComboBox( FALSE, tab_2, "deviceComboBox" );
119 119
120 tabLayout_2->addMultiCellWidget( deviceComboBox, 3, 3, 0, 1); 120 tabLayout_2->addMultiCellWidget( deviceComboBox, 3, 3, 0, 1);
121 121
122 TextLabel5 = new QLabel( tab_2, "TextLabel5" ); 122 TextLabel5 = new QLabel( tab_2, "TextLabel5" );
123 TextLabel5->setText( tr( "CAUTION:\n" 123 TextLabel5->setText( tr( "CAUTION:\n"
124 "Changing parameters on this \n" 124 "Changing parameters on this \n"
125 "page may cause your system \n" 125 "page may cause your system \n"
126 "to stop functioning properly!!" ) );//idiot message 126 "to stop functioning properly!!" ) );//idiot message
127 127
128 tabLayout_2->addMultiCellWidget( TextLabel5, 6, 6, 0, 1); 128 tabLayout_2->addMultiCellWidget( TextLabel5, 6, 6, 0, 1);
129 129
130 editPushButton = new QPushButton( tab_2, "editPushButton" ); 130 editPushButton = new QPushButton( tab_2, "editPushButton" );
131 editPushButton->setText( tr( "Edit fstab" ) ); 131 editPushButton->setText( tr( "Edit fstab" ) );
132 editPushButton->setMaximumWidth(100); 132 editPushButton->setMaximumWidth(100);
133 133
134 tabLayout_2->addMultiCellWidget( editPushButton, 7, 7, 0, 0 ); 134 tabLayout_2->addMultiCellWidget( editPushButton, 7, 7, 0, 0 );
135 135
136 fsckButton = new QPushButton( tab_2, "fsckPushButton" ); 136 fsckButton = new QPushButton( tab_2, "fsckPushButton" );
137 fsckButton->setText( tr( "Check Disk" ) ); 137 fsckButton->setText( tr( "Check Disk" ) );
138 fsckButton->setMaximumWidth(100); 138 fsckButton->setMaximumWidth(100);
139 139
140 tabLayout_2->addMultiCellWidget( fsckButton, 7, 7, 1, 1); 140 tabLayout_2->addMultiCellWidget( fsckButton, 7, 7, 1, 1);
141 141
142 TextLabel3 = new QLabel( tab_2, "TextLabel3" ); 142 TextLabel3 = new QLabel( tab_2, "TextLabel3" );
143 TextLabel3->setText( tr( "Device" ) ); 143 TextLabel3->setText( tr( "Device" ) );
144 144
145 tabLayout_2->addMultiCellWidget( TextLabel3, 4, 4, 0, 1 ); 145 tabLayout_2->addMultiCellWidget( TextLabel3, 4, 4, 0, 1 );
146 QSpacerItem* spacer_3 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); 146 QSpacerItem* spacer_3 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
147 tabLayout_2->addItem( spacer_3, 5, 0 ); 147 tabLayout_2->addItem( spacer_3, 5, 0 );
148 148
149 TextLabel1 = new QLabel( tab_2, "TextLabel1" ); 149 TextLabel1 = new QLabel( tab_2, "TextLabel1" );
150 TextLabel1->setText( tr( "Mount Point" ) ); 150 TextLabel1->setText( tr( "Mount Point" ) );
151 151
152 tabLayout_2->addMultiCellWidget( TextLabel1, 1, 1, 0, 1 ); 152 tabLayout_2->addMultiCellWidget( TextLabel1, 1, 1, 0, 1 );
153 QSpacerItem* spacer_4 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); 153 QSpacerItem* spacer_4 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
154 tabLayout_2->addItem( spacer_4, 2, 1 ); 154 tabLayout_2->addItem( spacer_4, 2, 1 );
155 TabWidget->insertTab( tab_2, tr( "Advanced" ) ); 155 TabWidget->insertTab( tab_2, tr( "Advanced" ) );
156 156
157 FormatterAppLayout->addWidget( TabWidget, 0, 1 ); 157 FormatterAppLayout->addWidget( TabWidget, 0, 1 );
158 158
159 connect( formatPushButton ,SIGNAL(released()),this,SLOT( doFormat()) ); 159 connect( formatPushButton ,SIGNAL(released()),this,SLOT( doFormat()) );
160 connect( editPushButton ,SIGNAL(released()),this,SLOT( editFstab()) ); 160 connect( editPushButton ,SIGNAL(released()),this,SLOT( editFstab()) );
161 connect( fsckButton ,SIGNAL(released()),this,SLOT( doFsck()) ); 161 connect( fsckButton ,SIGNAL(released()),this,SLOT( doFsck()) );
162 162
163 connect( fileSystemsCombo,SIGNAL(activated(int)),this,SLOT( fsComboSelected(int ) )); 163 connect( fileSystemsCombo,SIGNAL(activated(int)),this,SLOT( fsComboSelected(int ) ));
164 connect( storageComboBox,SIGNAL(activated(int)),this,SLOT( storageComboSelected(int ) )); 164 connect( storageComboBox,SIGNAL(activated(int)),this,SLOT( storageComboSelected(int ) ));
165 connect( deviceComboBox,SIGNAL(activated(int)),this,SLOT( deviceComboSelected(int ) )); 165 connect( deviceComboBox,SIGNAL(activated(int)),this,SLOT( deviceComboSelected(int ) ));
166 166
167 167
168 fillCombos(); 168 fillCombos();
169} 169}
170 170
171FormatterApp::~FormatterApp() { 171FormatterApp::~FormatterApp() {
172 172
173} 173}
174 174
175void FormatterApp::doFormat() { 175void FormatterApp::doFormat() {
176 int err=0; 176 int err=0;
177 Output *outDlg; 177 Output *outDlg;
178 QString umountS, remountS; 178 QString umountS, remountS;
179 QString text = storageComboBox->currentText(); 179 QString text = storageComboBox->currentText();
180 QString currentText = storageComboBox->currentText(); 180 QString currentText = storageComboBox->currentText();
181 QString cmd; 181 QString cmd;
182 QString diskDevice = currentText.right( currentText.length() - currentText.find(" -> ",0,TRUE) - 4); 182 QString diskDevice = currentText.right( currentText.length() - currentText.find(" -> ",0,TRUE) - 4);
183 QString diskName = currentText.left(currentText.find(" -> ",0,TRUE)); 183 QString diskName = currentText.left(currentText.find(" -> ",0,TRUE));
184 QString fs = fileSystemsCombo->currentText(); 184 QString fs = fileSystemsCombo->currentText();
185 185
186#if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) // lets test on something cheap 186#if defined(QT_QWS_IPAQ) || defined(QT_QWS_SL5XXX) // lets test on something cheap
187#else 187#else
188 currentText = diskDevice = "/dev/fd0"; 188 currentText = diskDevice = "/dev/fd0";
189 umountS = "umount -v /floppy 2>&1"; 189 umountS = "umount -v /floppy 2>&1";
190 remountS = "mount -v /floppy 2>&1"; 190 remountS = "mount -v /floppy 2>&1";
191#endif 191#endif
192 192
193 if( currentText.find("CF",0,TRUE) != -1) { 193 if( currentText.find("CF",0,TRUE) != -1) {
194 umountS = "umount "; 194 umountS = "umount ";
195 remountS = "mount "; 195 remountS = "mount ";
196 196
197// umountS = "/sbin/cardctl eject"; 197// umountS = "/sbin/cardctl eject";
198// remountS = "/sbin/cardctl insert"; 198// remountS = "/sbin/cardctl insert";
199 } 199 }
200 if( currentText.find("SD",0,TRUE) != -1) { 200 if( currentText.find("SD",0,TRUE) != -1) {
201 umountS = "umount "; 201 umountS = "umount ";
202 remountS = "mount "; 202 remountS = "mount ";
203// umountS = "/etc/sdcontrol compeject"; 203// umountS = "/etc/sdcontrol compeject";
204// remountS = "/etc/sdcontrol insert"; 204// remountS = "/etc/sdcontrol insert";
205 } 205 }
206 206
207 switch ( QMessageBox::warning(this,tr("Format?!?"),tr("Really format\n") +diskName+" "+ currentText + 207 switch ( QMessageBox::warning(this,tr("Format?!?"),tr("Really format\n") +diskName+" "+ currentText +
208 tr("\nwith ") + fs + tr(" filesystem?!?\nYou will loose all data!!"),tr("Yes"),tr("No"),0,1,1) ) { 208 tr("\nwith ") + fs + tr(" filesystem?!?\nYou will loose all data!!"),tr("Yes"),tr("No"),0,1,1) ) {
209 case 0: { 209 case 0: {
210 if(fs == "vfat") 210 if(fs == "vfat")
211 cmd = "mkdosfs -v " + diskDevice+" 2>&1"; 211 cmd = "mkdosfs -v " + diskDevice+" 2>&1";
212 else if(fs == "ext2") 212 else if(fs == "ext2")
213 cmd = "mke2fs -v " + diskDevice+" 2>&1"; 213 cmd = "mke2fs -v " + diskDevice+" 2>&1";
214 else { 214 else {
215 QMessageBox::warning(this, tr("Formatter"),tr("Could not format.\nUnknown type"), tr("Ok")); 215 QMessageBox::warning(this, tr("Formatter"),tr("Could not format.\nUnknown type"), tr("Ok"));
216 break; 216 break;
217 } 217 }
218// cmd = "ls -l"; 218// cmd = "ls -l";
219 outDlg = new Output(this, tr("Formatter Output"),FALSE); 219 outDlg = new Output(this, tr("Formatter Output"),FALSE);
220 outDlg->showMaximized(); 220 outDlg->showMaximized();
221 outDlg->show(); 221 outDlg->show();
222 qApp->processEvents(); 222 qApp->processEvents();
223 FILE *fp; 223 FILE *fp;
224 char line[130]; 224 char line[130];
225 outDlg->OutputEdit->append( tr("Trying to umount.") + currentText ); 225 outDlg->OutputEdit->append( tr("Trying to umount.") + currentText );
226 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 226 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
227 227
228 sleep(1); 228 sleep(1);
229 qDebug("Command is "+umountS); 229 qDebug("Command is "+umountS);
230 fp = popen( (const char *) umountS, "r"); 230 fp = popen( (const char *) umountS, "r");
231 qDebug("%d", fp); 231 qDebug("%d", fp);
232 if ( !fp ) { 232 if ( !fp ) {
233 qDebug("Could not execute '" + umountS + "'! err=%d\n" +(QString)strerror(errno), err); 233 qDebug("Could not execute '" + umountS + "'! err=%d\n" +(QString)strerror(errno), err);
234 QMessageBox::warning( this, tr("Formatter"), tr("umount failed!"), tr("&OK") ); 234 QMessageBox::warning( this, tr("Formatter"), tr("umount failed!"), tr("&OK") );
235 pclose(fp); 235 pclose(fp);
236 return; 236 return;
237 } else { 237 } else {
238// outDlg->OutputEdit->append( currentText + tr("\nhas been successfully umounted.")); 238// outDlg->OutputEdit->append( currentText + tr("\nhas been successfully umounted."));
239// outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 239// outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
240 while ( fgets( line, sizeof line, fp)) { 240 while ( fgets( line, sizeof line, fp)) {
241 if( ((QString)line).find("busy",0,TRUE) != -1) { 241 if( ((QString)line).find("busy",0,TRUE) != -1) {
242 qDebug("Could not find '" + umountS); 242 qDebug("Could not find '" + umountS);
243 QMessageBox::warning( this, tr("Formatter"), tr("Could not umount.\nDevice is busy!"), tr("&OK") ); 243 QMessageBox::warning( this, tr("Formatter"), tr("Could not umount.\nDevice is busy!"), tr("&OK") );
244 pclose(fp); 244 pclose(fp);
245 return; 245 return;
246 } else { 246 } else {
247 QString lineStr = line; 247 QString lineStr = line;
248 lineStr=lineStr.left(lineStr.length()-1); 248 lineStr=lineStr.left(lineStr.length()-1);
249 outDlg->OutputEdit->append(lineStr); 249 outDlg->OutputEdit->append(lineStr);
250 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 250 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
251 } 251 }
252 } 252 }
253 } 253 }
254 pclose(fp); 254 pclose(fp);
255 255
256 qDebug("Command would be: "+cmd); 256 qDebug("Command would be: "+cmd);
257 outDlg->OutputEdit->append( tr("Trying to format.") ); 257 outDlg->OutputEdit->append( tr("Trying to format.") );
258 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 258 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
259 259
260 fp = popen( (const char *) cmd, "r"); 260 fp = popen( (const char *) cmd, "r");
261 while ( fgets( line, sizeof line, fp)) { 261 while ( fgets( line, sizeof line, fp)) {
262 if( ((QString)line).find("No such device",0,TRUE) != -1) { 262 if( ((QString)line).find("No such device",0,TRUE) != -1) {
263 qDebug("No such device '" + umountS); 263 qDebug("No such device '" + umountS);
264 QMessageBox::warning( this, tr("Formatter"), tr("No such device!"), tr("&OK") ); 264 QMessageBox::warning( this, tr("Formatter"), tr("No such device!"), tr("&OK") );
265 pclose(fp); 265 pclose(fp);
266// outDlg->OutputEdit->append("No such device"); 266// outDlg->OutputEdit->append("No such device");
267// outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 267// outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
268 return; 268 return;
269 } else { 269 } else {
270 QString lineStr = line; 270 QString lineStr = line;
271 lineStr=lineStr.left(lineStr.length()-1); 271 lineStr=lineStr.left(lineStr.length()-1);
272 outDlg->OutputEdit->append(lineStr); 272 outDlg->OutputEdit->append(lineStr);
273 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 273 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
274 } 274 }
275 } 275 }
276 outDlg->OutputEdit->append( currentText + tr("\nhas been successfully formatted.")); 276 outDlg->OutputEdit->append( currentText + tr("\nhas been successfully formatted."));
277 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 277 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
278 pclose(fp); 278 pclose(fp);
279 279
280 outDlg->OutputEdit->append( tr("Trying to mount.") + currentText ); 280 outDlg->OutputEdit->append( tr("Trying to mount.") + currentText );
281 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 281 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
282 fp = popen( (const char *) remountS, "r"); 282 fp = popen( (const char *) remountS, "r");
283 if ( !fp) { 283 if ( !fp) {
284 qDebug("Could not execute '" + remountS + "'! err=%d\n" +(QString)strerror(errno), err); 284 qDebug("Could not execute '" + remountS + "'! err=%d\n" +(QString)strerror(errno), err);
285 QMessageBox::warning( this, tr("Formatter"), tr("Card mount failed!"), tr("&OK") ); 285 QMessageBox::warning( this, tr("Formatter"), tr("Card mount failed!"), tr("&OK") );
286 286
287 } else { 287 } else {
288 outDlg->OutputEdit->append( currentText + tr("\nhas been successfully mounted.")); 288 outDlg->OutputEdit->append( currentText + tr("\nhas been successfully mounted."));
289 while ( fgets( line, sizeof line, fp)) { 289 while ( fgets( line, sizeof line, fp)) {
290 QString lineStr = line; 290 QString lineStr = line;
291 lineStr=lineStr.left(lineStr.length()-1); 291 lineStr=lineStr.left(lineStr.length()-1);
292 outDlg->OutputEdit->append(lineStr); 292 outDlg->OutputEdit->append(lineStr);
293 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 293 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
294 } 294 }
295 } 295 }
296 pclose(fp); 296 pclose(fp);
297 sleep(1); 297 sleep(1);
298 298
299 outDlg->OutputEdit->append(tr("You can now close the output window.")); 299 outDlg->OutputEdit->append(tr("You can now close the output window."));
300 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 300 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
301// outDlg->close(); 301// outDlg->close();
302// if(outDlg) 302// if(outDlg)
303// delete outDlg; 303// delete outDlg;
304 } 304 }
305 break; 305 break;
306 }; 306 };
307} 307}
308 308
309bool FormatterApp::doFdisk() { 309bool FormatterApp::doFdisk() {
310 return FALSE; 310 return FALSE;
311 311
312} 312}
313 313
314void FormatterApp::fillCombos() { 314void FormatterApp::fillCombos() {
315 315
316 StorageInfo storageInfo; 316 StorageInfo storageInfo;
317 const QList<FileSystem> &fs = storageInfo.fileSystems(); 317 const QList<FileSystem> &fs = storageInfo.fileSystems();
318 QListIterator<FileSystem> it ( fs ); 318 QListIterator<FileSystem> it ( fs );
319 QString storage; 319 QString storage;
320 for( ; it.current(); ++it ){ 320 for( ; it.current(); ++it ){
321 const QString name = (*it)->name(); 321 const QString name = (*it)->name();
322 const QString path = (*it)->path(); 322 const QString path = (*it)->path();
323 const QString disk = (*it)->disk(); 323 const QString disk = (*it)->disk();
324 const QString options = (*it)->options(); 324 const QString options = (*it)->options();
325 if( name.find( tr("Internal"),0,TRUE) == -1) { 325 if( name.find( tr("Internal"),0,TRUE) == -1) {
326 storageComboBox->insertItem(name +" -> "+disk); 326 storageComboBox->insertItem(name +" -> "+disk);
327 } 327 }
328// deviceComboBox->insertItem(disk); 328// deviceComboBox->insertItem(disk);
329 } 329 }
330 parsetab("/etc/mtab"); 330 parsetab("/etc/mtab");
331// parsetab("/etc/fstab"); 331// parsetab("/etc/fstab");
332 fileSystemsCombo->insertStringList( fsList,-1); 332 fileSystemsCombo->insertStringList( fsList,-1);
333 deviceComboBox->insertStringList( deviceList,-1); 333 deviceComboBox->insertStringList( deviceList,-1);
334 storageComboSelected(0); 334 storageComboSelected(0);
335 deviceComboSelected(0); 335 deviceComboSelected(0);
336} 336}
337 337
338 338
339void FormatterApp::fsComboSelected(int index) { 339void FormatterApp::fsComboSelected(int index) {
340 340
341} 341}
342 342
343void FormatterApp::storageComboSelected(int index ) { 343void FormatterApp::storageComboSelected(int index ) {
344 344
345 QString currentText = storageComboBox->text(index); 345 QString currentText = storageComboBox->text(index);
346 QString nameS = currentText.left( currentText.find("->",0,TRUE)); 346 QString nameS = currentText.left( currentText.find("->",0,TRUE));
347 347
348 TextLabel4->setText( tr( "Storage Type : ") + nameS ); 348 TextLabel4->setText( tr( "Storage Type : ") + nameS );
349 currentText = currentText.right( currentText.length() - currentText.find(" -> ",0,TRUE) - 4); 349 currentText = currentText.right( currentText.length() - currentText.find(" -> ",0,TRUE) - 4);
350 350
351 QString fsType = getFileSystemType((const QString &) currentText); 351 QString fsType = getFileSystemType((const QString &) currentText);
352// qDebug(fsType); 352// qDebug(fsType);
353 for(int i = 0; i < fileSystemsCombo->count(); i++) { 353 for(int i = 0; i < fileSystemsCombo->count(); i++) {
354 if( fsType == fileSystemsCombo->text(i)) 354 if( fsType == fileSystemsCombo->text(i))
355 fileSystemsCombo->setCurrentItem(i); 355 fileSystemsCombo->setCurrentItem(i);
356 } 356 }
357// deviceComboSelected(index); 357// deviceComboSelected(index);
358} 358}
359 359
360void FormatterApp::deviceComboSelected(int index) { 360void FormatterApp::deviceComboSelected(int index) {
361 361
362 StorageInfo storageInfo; 362 StorageInfo storageInfo;
363 QString totalS, usedS, avS, diskS, nameS, fsType, selectedText; 363 QString totalS, usedS, avS, diskS, nameS, fsType, selectedText;
364 364
365 selectedText = deviceComboBox->text(index); 365 selectedText = deviceComboBox->text(index);
366 366
367 const QList<FileSystem> &fs = storageInfo.fileSystems(); 367 const QList<FileSystem> &fs = storageInfo.fileSystems();
368 QListIterator<FileSystem> it ( fs ); 368 QListIterator<FileSystem> it ( fs );
369 QString storage; 369 QString storage;
370 for( ; it.current(); ++it ){ 370 for( ; it.current(); ++it ){
371 const QString name = (*it)->name(); 371 const QString name = (*it)->name();
372 const QString path = (*it)->path(); 372 const QString path = (*it)->path();
373 const QString disk = (*it)->disk(); 373 const QString disk = (*it)->disk();
374// const QString options = (*it)->options(); 374// const QString options = (*it)->options();
375 if( selectedText == disk) { 375 if( selectedText == disk) {
376 diskS = disk; nameS= name; 376 diskS = disk; nameS= name;
377 mountPointLineEdit->setText(path); 377 mountPointLineEdit->setText(path);
378 long mult = (*it)->blockSize() / 1024; 378 long mult = (*it)->blockSize() / 1024;
379 long div = 1024 / (*it)->blockSize(); 379 long div = 1024 / (*it)->blockSize();
380 if ( !mult ) mult = 1; 380 if ( !mult ) mult = 1;
381 if ( !div ) div = 1; 381 if ( !div ) div = 1;
382 long total = (*it)->totalBlocks() * mult / div; 382 long total = (*it)->totalBlocks() * mult / div;
383 long totalMb = total/1024; 383 long totalMb = total/1024;
384 long avail = (*it)->availBlocks() * mult / div; 384 long avail = (*it)->availBlocks() * mult / div;
385 long availMb = avail/1024; 385 long availMb = avail/1024;
386 long used = total - avail; 386 long used = total - avail;
387 long usedMb = used/1024; 387 long usedMb = used/1024;
388 totalS.sprintf(tr("Total: %1 kB ( %d mB)\n").arg( total ), totalMb ); 388 totalS.sprintf(tr("Total: %1 kB ( %d mB)\n").arg( total ), totalMb );
389 usedS.sprintf(tr("Used: %1 kB ( %d mB)\n").arg(used) ,usedMb); 389 usedS.sprintf(tr("Used: %1 kB ( %d mB)\n").arg(used) ,usedMb);
390 avS.sprintf( tr("Available: %1 kB ( %d mB)").arg(avail), availMb ); 390 avS.sprintf( tr("Available: %1 kB ( %d mB)").arg(avail), availMb );
391 } 391 }
392 } 392 }
393 fsType = getFileSystemType((const QString &)selectedText); 393 fsType = getFileSystemType((const QString &)selectedText);
394 394
395 TextLabel5->setText("Type: "+ nameS+"\nFormatted with "+ fsType + " \n" + totalS + usedS + avS); 395 TextLabel5->setText("Type: "+ nameS+"\nFormatted with "+ fsType + " \n" + totalS + usedS + avS);
396// storageComboSelected(0); 396// storageComboSelected(0);
397} 397}
398 398
399void FormatterApp::cleanUp() { 399void FormatterApp::cleanUp() {
400 400
401} 401}
402 402
403 403
404void FormatterApp::editFstab() { 404void FormatterApp::editFstab() {
405 QCopEnvelope e("QPE/Application/textedit","setDocument(QString)"); 405 QCopEnvelope e("QPE/Application/textedit","setDocument(QString)");
406 e << (const QString &)"/etc/fstab"; 406 e << (const QString &)"/etc/fstab";
407} 407}
408 408
409void FormatterApp::parsetab(const QString &fileName) { 409void FormatterApp::parsetab(const QString &fileName) {
410 410
411 fileSystemTypeList.clear(); 411 fileSystemTypeList.clear();
412 fsList.clear(); 412 fsList.clear();
413 struct mntent *me; 413 struct mntent *me;
414// if(fileName == "/etc/mtab") { 414// if(fileName == "/etc/mtab") {
415 FILE *mntfp = setmntent( fileName.latin1(), "r" ); 415 FILE *mntfp = setmntent( fileName.latin1(), "r" );
416 if ( mntfp ) { 416 if ( mntfp ) {
417 while ( (me = getmntent( mntfp )) != 0 ) { 417 while ( (me = getmntent( mntfp )) != 0 ) {
418 QString deviceName = me->mnt_fsname; 418 QString deviceName = me->mnt_fsname;
419 QString filesystemType = me->mnt_type; 419 QString filesystemType = me->mnt_type;
420 if(deviceName != "none") { 420 if(deviceName != "none") {
421 if( fsList.contains(filesystemType) == 0 421 if( fsList.contains(filesystemType) == 0
422 & filesystemType.find("proc",0,TRUE) == -1 422 & filesystemType.find("proc",0,TRUE) == -1
423 & filesystemType.find("cramfs",0,TRUE) == -1 423 & filesystemType.find("cramfs",0,TRUE) == -1
424 & filesystemType.find("auto",0,TRUE) == -1) 424 & filesystemType.find("auto",0,TRUE) == -1)
425 fsList << filesystemType; 425 fsList << filesystemType;
426 deviceList << deviceName; 426 deviceList << deviceName;
427 qDebug(deviceName+"::"+filesystemType); 427 qDebug(deviceName+"::"+filesystemType);
428 fileSystemTypeList << deviceName+"::"+filesystemType; 428 fileSystemTypeList << deviceName+"::"+filesystemType;
429 } 429 }
430 } 430 }
431 } 431 }
432 endmntent( mntfp ); 432 endmntent( mntfp );
433// } else if(fileName == "/etc/fstab") { 433// } else if(fileName == "/etc/fstab") {
434// QFile f("/etc/fstab"); 434// QFile f("/etc/fstab");
435// if ( f.open(IO_ReadOnly) ) { 435// if ( f.open(IO_ReadOnly) ) {
436// QTextStream t (&f); 436// QTextStream t (&f);
437// QString s; 437// QString s;
438// while (! t.eof()) { 438// while (! t.eof()) {
439// s=t.readLine(); 439// s=t.readLine();
440// s=s.simplifyWhiteSpace(); 440// s=s.simplifyWhiteSpace();
441// if ( (!s.isEmpty() ) && (s.find(" ")!=0) ) { 441// if ( (!s.isEmpty() ) && (s.find(" ")!=0) ) {
442// // = me->mnt_fsname; 442// // = me->mnt_fsname;
443// QString filesystemType = me->mnt_type; 443// QString filesystemType = me->mnt_type;
444// QString deviceName = s.left(0,s.find(BLANK) ); 444// QString deviceName = s.left(0,s.find(BLANK) );
445// s=s.remove(0,s.find(BLANK)+1 ); // devicename 445// s=s.remove(0,s.find(BLANK)+1 ); // devicename
446 446
447// s=s.remove(0,s.find(BLANK)+1 ); // mountpoint 447// s=s.remove(0,s.find(BLANK)+1 ); // mountpoint
448// QStringt mountPoint= s.left(0,s.find(BLANK) ); 448// QStringt mountPoint= s.left(0,s.find(BLANK) );
449// s=s.remove(0,s.find(BLANK)+1 ); // fs 449// s=s.remove(0,s.find(BLANK)+1 ); // fs
450// QString filesystemType= s.left(0,s.find(BLANK) ); 450// QString filesystemType= s.left(0,s.find(BLANK) );
451// } 451// }
452// } 452// }
453// } 453// }
454// f.close(); 454// f.close();
455// } 455// }
456} 456}
457 457
458QString FormatterApp::getFileSystemType(const QString &currentText) { 458QString FormatterApp::getFileSystemType(const QString &currentText) {
459 459
460 parsetab("/etc/mtab"); //why did TT forget filesystem type? 460 parsetab("/etc/mtab"); //why did TT forget filesystem type?
461 461
462 for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { 462 for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) {
463 QString temp = (*it); 463 QString temp = (*it);
464 if( temp.find( currentText,0,TRUE) != -1) { 464 if( temp.find( currentText,0,TRUE) != -1) {
465 return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); 465 return temp.right( temp.length() - temp.find("::",0,TRUE) - 2);
466// qDebug(fsType); 466// qDebug(fsType);
467 } 467 }
468 } 468 }
469 return ""; 469 return "";
470} 470}
471 471
472bool FormatterApp::doFsck() { 472bool FormatterApp::doFsck() {
473 473
474 Output *outDlg; 474 Output *outDlg;
475 QString selectedDevice; 475 QString selectedDevice;
476// #if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) 476// #if defined(QT_QWS_IPAQ) || defined(QT_QWS_SL5XXX)
477 selectedDevice = deviceComboBox->currentText(); 477 selectedDevice = deviceComboBox->currentText();
478 QString mountPoint = mountPointLineEdit->text(); 478 QString mountPoint = mountPointLineEdit->text();
479 QString umountS = "umount -v "+mountPoint+" 2>&1"; 479 QString umountS = "umount -v "+mountPoint+" 2>&1";
480 QString remountS = "mount -v "+mountPoint+" 2>&1"; 480 QString remountS = "mount -v "+mountPoint+" 2>&1";
481// #else 481// #else
482// // for testing 482// // for testing
483// // currentText = diskDevice = "/dev/fd0"; 483// // currentText = diskDevice = "/dev/fd0";
484// QString umountS = "umount -v /floppy 2>&1"; 484// QString umountS = "umount -v /floppy 2>&1";
485// QString remountS = "mount -v /floppy 2>&1"; 485// QString remountS = "mount -v /floppy 2>&1";
486// selectedDevice ="/dev/fd0"; 486// selectedDevice ="/dev/fd0";
487 487
488// #endif 488// #endif
489 489
490 QString fsType = getFileSystemType((const QString &)selectedDevice); 490 QString fsType = getFileSystemType((const QString &)selectedDevice);
491 QString cmd; 491 QString cmd;
492 qDebug( selectedDevice +" "+ fsType); 492 qDebug( selectedDevice +" "+ fsType);
493 if(fsType == "vfat") cmd = "dosfsck -vy "; 493 if(fsType == "vfat") cmd = "dosfsck -vy ";
494 if(fsType == "ext2") cmd = "e2fsck -cpvy "; 494 if(fsType == "ext2") cmd = "e2fsck -cpvy ";
495 cmd += selectedDevice + " 2>&1"; 495 cmd += selectedDevice + " 2>&1";
496 496
497 outDlg = new Output(this, tr("Formatter Output"),FALSE); 497 outDlg = new Output(this, tr("Formatter Output"),FALSE);
498 outDlg->showMaximized(); 498 outDlg->showMaximized();
499 outDlg->show(); 499 outDlg->show();
500 qApp->processEvents(); 500 qApp->processEvents();
501 FILE *fp; 501 FILE *fp;
502 char line[130]; 502 char line[130];
503 outDlg->OutputEdit->append( tr("Trying to umount.")); 503 outDlg->OutputEdit->append( tr("Trying to umount."));
504 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 504 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
505 505
506 sleep(1); 506 sleep(1);
507// qDebug("Command is "+umountS); 507// qDebug("Command is "+umountS);
508 fp = popen( (const char *) umountS, "r"); 508 fp = popen( (const char *) umountS, "r");
509// qDebug("%d", fp); 509// qDebug("%d", fp);
510 if ( !fp ) { 510 if ( !fp ) {
511 qDebug("Could not execute '" + umountS + "'!\n" +(QString)strerror(errno)); 511 qDebug("Could not execute '" + umountS + "'!\n" +(QString)strerror(errno));
512 QMessageBox::warning( this, tr("Formatter"), tr("umount failed!"), tr("&OK") ); 512 QMessageBox::warning( this, tr("Formatter"), tr("umount failed!"), tr("&OK") );
513 pclose(fp); 513 pclose(fp);
514 return false; 514 return false;
515 } else { 515 } else {
516// outDlg->OutputEdit->append( currentText + tr("\nhas been successfully umounted.")); 516// outDlg->OutputEdit->append( currentText + tr("\nhas been successfully umounted."));
517// outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 517// outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
518 while ( fgets( line, sizeof line, fp)) { 518 while ( fgets( line, sizeof line, fp)) {
519 if( ((QString)line).find("busy",0,TRUE) != -1) { 519 if( ((QString)line).find("busy",0,TRUE) != -1) {
520 qDebug("Could not find '" + umountS); 520 qDebug("Could not find '" + umountS);
521 QMessageBox::warning( this, tr("Formatter"), 521 QMessageBox::warning( this, tr("Formatter"),
522 tr("Could not umount.\nDevice is busy!"), tr("&OK") ); 522 tr("Could not umount.\nDevice is busy!"), tr("&OK") );
523 pclose(fp); 523 pclose(fp);
524 return false; 524 return false;
525 } else { 525 } else {
526 QString lineStr = line; 526 QString lineStr = line;
527 lineStr=lineStr.left(lineStr.length()-1); 527 lineStr=lineStr.left(lineStr.length()-1);
528 outDlg->OutputEdit->append(lineStr); 528 outDlg->OutputEdit->append(lineStr);
529 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 529 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
530 } 530 }
531 } 531 }
532 } 532 }
533 pclose(fp); 533 pclose(fp);
534///////////////////////////////////// 534/////////////////////////////////////
535 fp = popen( (const char *) cmd, "r"); 535 fp = popen( (const char *) cmd, "r");
536 while ( fgets( line, sizeof line, fp)) { 536 while ( fgets( line, sizeof line, fp)) {
537 if( ((QString)line).find("No such device",0,TRUE) != -1) { 537 if( ((QString)line).find("No such device",0,TRUE) != -1) {
538 qDebug("No such device '" + umountS); 538 qDebug("No such device '" + umountS);
539 QMessageBox::warning( this, tr("Formatter"), tr("No such device!"), tr("&OK") ); 539 QMessageBox::warning( this, tr("Formatter"), tr("No such device!"), tr("&OK") );
540 pclose(fp); 540 pclose(fp);
541// outDlg->OutputEdit->append("No such device"); 541// outDlg->OutputEdit->append("No such device");
542// outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 542// outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
543 return false; 543 return false;
544 } else { 544 } else {
545 QString lineStr = line; 545 QString lineStr = line;
546 lineStr=lineStr.left(lineStr.length()-1); 546 lineStr=lineStr.left(lineStr.length()-1);
547 outDlg->OutputEdit->append(lineStr); 547 outDlg->OutputEdit->append(lineStr);
548 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 548 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
549 } 549 }
550 } 550 }
551 outDlg->OutputEdit->append(tr("You can now close the output window.")); 551 outDlg->OutputEdit->append(tr("You can now close the output window."));
552 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 552 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
553// outDlg->OutputEdit->append( currentText + tr("\nhas been successfully formatted.")); 553// outDlg->OutputEdit->append( currentText + tr("\nhas been successfully formatted."));
554// outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 554// outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
555 pclose(fp); 555 pclose(fp);
556 556
557///////////////////////////////////////// 557/////////////////////////////////////////
558 558
559 return true; 559 return true;
560} 560}
561 561
562bool FormatterApp::doFsckCheck() { 562bool FormatterApp::doFsckCheck() {
563 563
564 return FALSE; 564 return FALSE;
565} 565}
566 566
567int FormatterApp::formatCheck(const QString &deviceStr) { 567int FormatterApp::formatCheck(const QString &deviceStr) {
568 568
569 return -1; 569 return -1;
570} 570}
571 571
572int FormatterApp::runCommand(const QString &command) { 572int FormatterApp::runCommand(const QString &command) {
573 573
574 return -1; 574 return -1;
575} 575}
diff --git a/qt/qconfig-qpe.h b/qt/qconfig-qpe.h
index 2b05f90..30d8190 100644
--- a/qt/qconfig-qpe.h
+++ b/qt/qconfig-qpe.h
@@ -1,99 +1,99 @@
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#ifndef QT_H 20#ifndef QT_H
21#endif // QT_H 21#endif // QT_H
22 22
23// Empty leaves all features enabled. See doc/html/features.html for choices. 23// Empty leaves all features enabled. See doc/html/features.html for choices.
24 24
25// Note that disabling some features will produce a libqt that is not 25// Note that disabling some features will produce a libqt that is not
26// compatible with other libqt builds. Such modifications are only 26// compatible with other libqt builds. Such modifications are only
27// supported on Qt/Embedded where reducing the library size is important 27// supported on Qt/Embedded where reducing the library size is important
28// and where the application-suite is often a fixed set. 28// and where the application-suite is often a fixed set.
29 29
30#ifndef QT_DLL 30#ifndef QT_DLL
31#define QT_DLL // Internal 31#define QT_DLL // Internal
32#endif 32#endif
33 33
34#if defined(QT_QWS_IPAQ) || defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_EBX) 34#if defined(QT_QWS_IPAQ) || defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_SL5XXX)
35# define QT_NO_QWS_CURSOR 35# define QT_NO_QWS_CURSOR
36# define QT_NO_QWS_MOUSE_AUTO 36# define QT_NO_QWS_MOUSE_AUTO
37#endif 37#endif
38#ifndef QT_NO_CODECS 38#ifndef QT_NO_CODECS
39#define QT_NO_CODECS 39#define QT_NO_CODECS
40#endif 40#endif
41#define QT_NO_UNICODETABLES 41#define QT_NO_UNICODETABLES
42//#define QT_NO_IMAGEIO_BMP 42//#define QT_NO_IMAGEIO_BMP
43#define QT_NO_IMAGEIO_PPM 43#define QT_NO_IMAGEIO_PPM
44//#define QT_NO_ASYNC_IO 44//#define QT_NO_ASYNC_IO
45//#define QT_NO_ASYNC_IMAGE_IO 45//#define QT_NO_ASYNC_IMAGE_IO
46#define QT_NO_FREETYPE 46#define QT_NO_FREETYPE
47#define QT_NO_BDF 47#define QT_NO_BDF
48//#define QT_NO_FONTDATABASE 48//#define QT_NO_FONTDATABASE
49#define QT_NO_DRAGANDDROP 49#define QT_NO_DRAGANDDROP
50//#define QT_NO_CLIPBOARD 50//#define QT_NO_CLIPBOARD
51#define QT_NO_PROPERTIES 51#define QT_NO_PROPERTIES
52#define QT_NO_NETWORKPROTOCOL 52#define QT_NO_NETWORKPROTOCOL
53 53
54#define QT_NO_IMAGE_TEXT 54#define QT_NO_IMAGE_TEXT
55 55
56//#define QT_NO_TOOLTIP 56//#define QT_NO_TOOLTIP
57#define QT_NO_COLORNAMES 57#define QT_NO_COLORNAMES
58#define QT_NO_TRANSFORMATIONS 58#define QT_NO_TRANSFORMATIONS
59#define QT_NO_TRANSLATION_BUILDER 59#define QT_NO_TRANSLATION_BUILDER
60#define QT_NO_COMPLEXTEXT 60#define QT_NO_COMPLEXTEXT
61#define QT_NO_PRINTER 61#define QT_NO_PRINTER
62#define QT_NO_PICTURE 62#define QT_NO_PICTURE
63//#define QT_NO_ICONVIEW 63//#define QT_NO_ICONVIEW
64#define QT_NO_DIAL 64#define QT_NO_DIAL
65#define QT_NO_SIZEGRIP 65#define QT_NO_SIZEGRIP
66#define QT_NO_WORKSPACE 66#define QT_NO_WORKSPACE
67//#define QT_NO_TABLE 67//#define QT_NO_TABLE
68//#define QT_NO_ACTION 68//#define QT_NO_ACTION
69//#define QT_NO_SETTINGS 69//#define QT_NO_SETTINGS
70#define QT_NO_STYLE_POCKETPC 70#define QT_NO_STYLE_POCKETPC
71#ifndef QT_NO_STYLE_AQUA 71#ifndef QT_NO_STYLE_AQUA
72# define QT_NO_STYLE_AQUA 72# define QT_NO_STYLE_AQUA
73#endif 73#endif
74#define QT_NO_STYLE_MOTIF 74#define QT_NO_STYLE_MOTIF
75#define QT_NO_STYLE_PLATINUM 75#define QT_NO_STYLE_PLATINUM
76#define QT_NO_FILEDIALOG 76#define QT_NO_FILEDIALOG
77#define QT_NO_FONTDIALOG 77#define QT_NO_FONTDIALOG
78#define QT_NO_PRINTDIALOG 78#define QT_NO_PRINTDIALOG
79#define QT_NO_COLORDIALOG 79#define QT_NO_COLORDIALOG
80#define QT_NO_INPUTDIALOG 80#define QT_NO_INPUTDIALOG
81//#define QT_NO_MESSAGEBOX 81//#define QT_NO_MESSAGEBOX
82#define QT_NO_PROGRESSDIALOG 82#define QT_NO_PROGRESSDIALOG
83//#define QT_NO_TABDIALOG 83//#define QT_NO_TABDIALOG
84#define QT_NO_WIZARD 84#define QT_NO_WIZARD
85#define QT_NO_EFFECTS 85#define QT_NO_EFFECTS
86//#define QT_NO_COMPONENT 86//#define QT_NO_COMPONENT
87#define QT_NO_DOM 87#define QT_NO_DOM
88#define QT_NO_SEMIMODAL 88#define QT_NO_SEMIMODAL
89//#define QT_NO_PROGRESSBAR 89//#define QT_NO_PROGRESSBAR
90#define QT_NO_SPLITTER 90#define QT_NO_SPLITTER
91 91
92//#define QT_NO_QWS_SAVEFONTS 92//#define QT_NO_QWS_SAVEFONTS
93//#define QT_NO_QWS_PROPERTIES 93//#define QT_NO_QWS_PROPERTIES
94 94
95#define QT_NO_QWS_BEOS_WM_STYLE 95#define QT_NO_QWS_BEOS_WM_STYLE
96#define QT_NO_QWS_KDE2_WM_STYLE 96#define QT_NO_QWS_KDE2_WM_STYLE
97#define QT_NO_QWS_KDE_WM_STYLE 97#define QT_NO_QWS_KDE_WM_STYLE
98#define QT_NO_QWS_WINDOWS_WM_STYLE 98#define QT_NO_QWS_WINDOWS_WM_STYLE
99 99
diff --git a/x11/libqpe-x11/qpe/qpeapplication.cpp b/x11/libqpe-x11/qpe/qpeapplication.cpp
index ed815f8..eb01e50 100644
--- a/x11/libqpe-x11/qpe/qpeapplication.cpp
+++ b/x11/libqpe-x11/qpe/qpeapplication.cpp
@@ -1,795 +1,795 @@
1#define QTOPIA_INTERNAL_LANGLIST 1#define QTOPIA_INTERNAL_LANGLIST
2 2
3#include <stdio.h> 3#include <stdio.h>
4#include <stdlib.h> 4#include <stdlib.h>
5#include <unistd.h> 5#include <unistd.h>
6#include <sys/file.h> 6#include <sys/file.h>
7 7
8 8
9#include <qdir.h> 9#include <qdir.h>
10#include <qdialog.h> 10#include <qdialog.h>
11#include <qdragobject.h> 11#include <qdragobject.h>
12#include <qevent.h> 12#include <qevent.h>
13#include <qlabel.h> 13#include <qlabel.h>
14#include <qlist.h> 14#include <qlist.h>
15#include <qtextstream.h> 15#include <qtextstream.h>
16#include <qtextcodec.h> 16#include <qtextcodec.h>
17#include <qpalette.h> 17#include <qpalette.h>
18#include <qptrdict.h> 18#include <qptrdict.h>
19#include <qregexp.h> 19#include <qregexp.h>
20#include <qtimer.h> 20#include <qtimer.h>
21 21
22#include <qpe/alarmserver.h> 22#include <qpe/alarmserver.h>
23#include <qpe/applnk.h> 23#include <qpe/applnk.h>
24#include <qpe/qpemenubar.h> 24#include <qpe/qpemenubar.h>
25#include <qpe/textcodecinterface.h> 25#include <qpe/textcodecinterface.h>
26#include <qpe/imagecodecinterface.h> 26#include <qpe/imagecodecinterface.h>
27#include <qpe/qlibrary.h> 27#include <qpe/qlibrary.h>
28#include <qpe/qpestyle.h> 28#include <qpe/qpestyle.h>
29#include <qpe/styleinterface.h> 29#include <qpe/styleinterface.h>
30#include <qpe/global.h> 30#include <qpe/global.h>
31#include <qpe/resource.h> 31#include <qpe/resource.h>
32#include <qpe/config.h> 32#include <qpe/config.h>
33#include <qpe/network.h> 33#include <qpe/network.h>
34 34
35#include <qpe/qpeapplication.h> 35#include <qpe/qpeapplication.h>
36#include <qpe/timestring.h> 36#include <qpe/timestring.h>
37#include <qpe/qcopenvelope_qws.h> 37#include <qpe/qcopenvelope_qws.h>
38 38
39 39
40#include <X11/Xlib.h> 40#include <X11/Xlib.h>
41#include <X11/Xutil.h> 41#include <X11/Xutil.h>
42 42
43const int XKeyPress = KeyPress; 43const int XKeyPress = KeyPress;
44const int XKeyRelease = KeyRelease; 44const int XKeyRelease = KeyRelease;
45#undef KeyPress 45#undef KeyPress
46#undef KeyRelease 46#undef KeyRelease
47 47
48namespace { 48namespace {
49 struct QCopRec{ 49 struct QCopRec{
50 QCopRec( const QCString& ch, const QCString& msg, const QByteArray& ar ) 50 QCopRec( const QCString& ch, const QCString& msg, const QByteArray& ar )
51 : channel(ch), message(msg), data(ar) { 51 : channel(ch), message(msg), data(ar) {
52 52
53 } 53 }
54 QCString channel; 54 QCString channel;
55 QCString message; 55 QCString message;
56 QByteArray data; 56 QByteArray data;
57 }; 57 };
58}; 58};
59 59
60 60
61class QPEApplication::Private { 61class QPEApplication::Private {
62public: 62public:
63 Private(); 63 Private();
64 ~Private(); 64 ~Private();
65 void enqueueQCop( const QCString& ch, const QCString& msg, 65 void enqueueQCop( const QCString& ch, const QCString& msg,
66 const QByteArray& ); 66 const QByteArray& );
67 void sendQCopQ(); 67 void sendQCopQ();
68 static void show_mx(QWidget* mw, bool nomaximize ); 68 static void show_mx(QWidget* mw, bool nomaximize );
69 void show( QWidget* mw, bool nomax ); 69 void show( QWidget* mw, bool nomax );
70 void loadTextCodecs(); 70 void loadTextCodecs();
71 void loadImageCodecs(); 71 void loadImageCodecs();
72 72
73 int kbgrabber; 73 int kbgrabber;
74 int presstimer; 74 int presstimer;
75 75
76 bool rightpressed : 1; 76 bool rightpressed : 1;
77 bool kbregrab : 1; 77 bool kbregrab : 1;
78 bool notbusysent : 1; 78 bool notbusysent : 1;
79 bool preloaded : 1; 79 bool preloaded : 1;
80 bool forceshow : 1; 80 bool forceshow : 1;
81 bool nomaximize : 1; 81 bool nomaximize : 1;
82 bool keep_running : 1; 82 bool keep_running : 1;
83 83
84 QWidget* presswidget; 84 QWidget* presswidget;
85 QPoint presspos; 85 QPoint presspos;
86 QWidget* qpe_main_widget; 86 QWidget* qpe_main_widget;
87 QString appName; 87 QString appName;
88 QString styleName; 88 QString styleName;
89 QString decorationName; 89 QString decorationName;
90 Atom wm_delete_window; 90 Atom wm_delete_window;
91 Atom wm_take_focus; 91 Atom wm_take_focus;
92 Atom wm_context_help; 92 Atom wm_context_help;
93 Atom wm_context_accept; 93 Atom wm_context_accept;
94 Atom wm_protocols; 94 Atom wm_protocols;
95 95
96private: 96private:
97 QList<QCopRec> qcopq; 97 QList<QCopRec> qcopq;
98}; 98};
99QPEApplication::Private::~Private() { 99QPEApplication::Private::~Private() {
100} 100}
101QPEApplication::Private::Private() 101QPEApplication::Private::Private()
102 : kbgrabber(0 ), presstimer(0 ), rightpressed( FALSE ), kbregrab( FALSE ), notbusysent( FALSE ), 102 : kbgrabber(0 ), presstimer(0 ), rightpressed( FALSE ), kbregrab( FALSE ), notbusysent( FALSE ),
103 preloaded( FALSE ), forceshow( FALSE ), nomaximize( FALSE ), keep_running( TRUE ), 103 preloaded( FALSE ), forceshow( FALSE ), nomaximize( FALSE ), keep_running( TRUE ),
104 presswidget( 0 ), qpe_main_widget(0 ) { 104 presswidget( 0 ), qpe_main_widget(0 ) {
105 105
106 qcopq.setAutoDelete( TRUE ); 106 qcopq.setAutoDelete( TRUE );
107} 107}
108void QPEApplication::Private::enqueueQCop( const QCString& chan, const QCString& msg, 108void QPEApplication::Private::enqueueQCop( const QCString& chan, const QCString& msg,
109 const QByteArray& ar ) { 109 const QByteArray& ar ) {
110 qcopq.append( new QCopRec(chan, msg, ar ) ); 110 qcopq.append( new QCopRec(chan, msg, ar ) );
111} 111}
112void QPEApplication::Private::sendQCopQ() { 112void QPEApplication::Private::sendQCopQ() {
113 QCopRec* r; 113 QCopRec* r;
114 for ( r = qcopq.first(); r; r = qcopq.next() ) { 114 for ( r = qcopq.first(); r; r = qcopq.next() ) {
115 QCopChannel::sendLocally( r->channel, r->message, r->data ); 115 QCopChannel::sendLocally( r->channel, r->message, r->data );
116 } 116 }
117 qcopq.clear(); 117 qcopq.clear();
118} 118}
119void QPEApplication::Private::show_mx(QWidget* mw, bool nomaximize ) { 119void QPEApplication::Private::show_mx(QWidget* mw, bool nomaximize ) {
120 if (mw->layout() && mw->inherits("QDialog") ) { 120 if (mw->layout() && mw->inherits("QDialog") ) {
121 QPEApplication::showDialog( (QDialog*)mw, nomaximize ); 121 QPEApplication::showDialog( (QDialog*)mw, nomaximize );
122 }else { 122 }else {
123 if (!nomaximize ) 123 if (!nomaximize )
124 mw->showMaximized(); 124 mw->showMaximized();
125 else 125 else
126 mw->show(); 126 mw->show();
127 } 127 }
128} 128}
129void QPEApplication::Private::show( QWidget* mw, bool nomax ) { 129void QPEApplication::Private::show( QWidget* mw, bool nomax ) {
130 nomaximize = nomax; 130 nomaximize = nomax;
131 qpe_main_widget = mw; 131 qpe_main_widget = mw;
132 132
133 sendQCopQ(); 133 sendQCopQ();
134 134
135 if ( preloaded ) { 135 if ( preloaded ) {
136 if (forceshow ) 136 if (forceshow )
137 show_mx(mw, nomax ); 137 show_mx(mw, nomax );
138 }else if ( keep_running ) 138 }else if ( keep_running )
139 show_mx( mw, nomax ); 139 show_mx( mw, nomax );
140} 140}
141void QPEApplication::Private::loadTextCodecs() { 141void QPEApplication::Private::loadTextCodecs() {
142 QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; 142 QString path = QPEApplication::qpeDir() + "/plugins/textcodecs";
143 QDir dir( path, "lib*.so" ); 143 QDir dir( path, "lib*.so" );
144 QStringList list = dir.entryList(); 144 QStringList list = dir.entryList();
145 QStringList::Iterator it; 145 QStringList::Iterator it;
146 for ( it = list.begin(); it != list.end(); ++it ) { 146 for ( it = list.begin(); it != list.end(); ++it ) {
147 TextCodecInterface *iface = 0; 147 TextCodecInterface *iface = 0;
148 QLibrary *lib = new QLibrary( path + "/" + *it ); 148 QLibrary *lib = new QLibrary( path + "/" + *it );
149 if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { 149 if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) {
150 QValueList<int> mibs = iface->mibEnums(); 150 QValueList<int> mibs = iface->mibEnums();
151 for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { 151 for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) {
152 (void)iface->createForMib(*i); 152 (void)iface->createForMib(*i);
153 // ### it exists now; need to remember if we can delete it 153 // ### it exists now; need to remember if we can delete it
154 } 154 }
155 } 155 }
156 else { 156 else {
157 lib->unload(); 157 lib->unload();
158 delete lib; 158 delete lib;
159 } 159 }
160 } 160 }
161} 161}
162void QPEApplication::Private::loadImageCodecs() { 162void QPEApplication::Private::loadImageCodecs() {
163 QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; 163 QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs";
164 QDir dir( path, "lib*.so" ); 164 QDir dir( path, "lib*.so" );
165 QStringList list = dir.entryList(); 165 QStringList list = dir.entryList();
166 QStringList::Iterator it; 166 QStringList::Iterator it;
167 for ( it = list.begin(); it != list.end(); ++it ) { 167 for ( it = list.begin(); it != list.end(); ++it ) {
168 ImageCodecInterface *iface = 0; 168 ImageCodecInterface *iface = 0;
169 QLibrary *lib = new QLibrary( path + "/" + *it ); 169 QLibrary *lib = new QLibrary( path + "/" + *it );
170 if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { 170 if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) {
171 QStringList formats = iface->keys(); 171 QStringList formats = iface->keys();
172 for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { 172 for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) {
173 (void)iface->installIOHandler(*i); 173 (void)iface->installIOHandler(*i);
174 // ### it exists now; need to remember if we can delete it 174 // ### it exists now; need to remember if we can delete it
175 } 175 }
176 } 176 }
177 else { 177 else {
178 lib->unload(); 178 lib->unload();
179 delete lib; 179 delete lib;
180 } 180 }
181 } 181 }
182} 182}
183 183
184// The Help System hook 184// The Help System hook
185namespace { 185namespace {
186 class ResourceMimeFactory : public QMimeSourceFactory 186 class ResourceMimeFactory : public QMimeSourceFactory
187 { 187 {
188 public: 188 public:
189 ResourceMimeFactory(); 189 ResourceMimeFactory();
190 ~ResourceMimeFactory(); 190 ~ResourceMimeFactory();
191 const QMimeSource* data( const QString& abs_name )const; 191 const QMimeSource* data( const QString& abs_name )const;
192 }; 192 };
193 ResourceMimeFactory::ResourceMimeFactory() 193 ResourceMimeFactory::ResourceMimeFactory()
194 { 194 {
195 setFilePath( Global::helpPath() ); 195 setFilePath( Global::helpPath() );
196 setExtensionType( "html", "text/html;charset=UTF-8" ); 196 setExtensionType( "html", "text/html;charset=UTF-8" );
197 } 197 }
198 ResourceMimeFactory::~ResourceMimeFactory() { 198 ResourceMimeFactory::~ResourceMimeFactory() {
199 } 199 }
200 200
201 const QMimeSource* ResourceMimeFactory::data( const QString& abs_name ) const 201 const QMimeSource* ResourceMimeFactory::data( const QString& abs_name ) const
202 { 202 {
203 const QMimeSource * r = QMimeSourceFactory::data( abs_name ); 203 const QMimeSource * r = QMimeSourceFactory::data( abs_name );
204 if ( !r ) { 204 if ( !r ) {
205 int sl = abs_name.length(); 205 int sl = abs_name.length();
206 do { 206 do {
207 sl = abs_name.findRev( '/', sl - 1 ); 207 sl = abs_name.findRev( '/', sl - 1 );
208 QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; 208 QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name;
209 int dot = name.findRev( '.' ); 209 int dot = name.findRev( '.' );
210 if ( dot >= 0 ) 210 if ( dot >= 0 )
211 name = name.left( dot ); 211 name = name.left( dot );
212 QImage img = Resource::loadImage( name ); 212 QImage img = Resource::loadImage( name );
213 if ( !img.isNull() ) 213 if ( !img.isNull() )
214 r = new QImageDrag( img ); 214 r = new QImageDrag( img );
215 } 215 }
216 while ( !r && sl > 0 ); 216 while ( !r && sl > 0 );
217 } 217 }
218 return r; 218 return r;
219 }; 219 };
220}; 220};
221// QPEApplication 221// QPEApplication
222QPEApplication::~QPEApplication() { 222QPEApplication::~QPEApplication() {
223 qWarning("~QPEApplication"); 223 qWarning("~QPEApplication");
224 ungrabKeyboard(); 224 ungrabKeyboard();
225 qWarning("UngrabKeyboard"); 225 qWarning("UngrabKeyboard");
226 226
227// delete m_sys; 227// delete m_sys;
228// delete m_pid; 228// delete m_pid;
229 229
230 delete d; 230 delete d;
231} 231}
232QPEApplication::QPEApplication(int &arg, char** argv, Type t) 232QPEApplication::QPEApplication(int &arg, char** argv, Type t)
233 : QApplication( arg, argv, t ) { 233 : QApplication( arg, argv, t ) {
234 d = new Private; 234 d = new Private;
235 d->loadTextCodecs(); 235 d->loadTextCodecs();
236 d->loadImageCodecs(); 236 d->loadImageCodecs();
237 237
238 // Init X-Atom 238 // Init X-Atom
239 Atom *atoms[5]; 239 Atom *atoms[5];
240 Atom atoms_re[5]; 240 Atom atoms_re[5];
241 char* names[5]; 241 char* names[5];
242 int n = 0; 242 int n = 0;
243 atoms[n] = &d->wm_delete_window; 243 atoms[n] = &d->wm_delete_window;
244 names[n++] = "WM_DELETE_WINDOW"; 244 names[n++] = "WM_DELETE_WINDOW";
245 245
246 atoms[n] = &d->wm_take_focus; 246 atoms[n] = &d->wm_take_focus;
247 names[n++] = "WM_TAKE_FOCUS"; 247 names[n++] = "WM_TAKE_FOCUS";
248 248
249 atoms[n] = &d->wm_context_help; 249 atoms[n] = &d->wm_context_help;
250 names[n++] = "_NET_WM_CONTEXT_HELP"; 250 names[n++] = "_NET_WM_CONTEXT_HELP";
251 251
252 atoms[n] = &d->wm_context_accept; 252 atoms[n] = &d->wm_context_accept;
253 names[n++] = "_NET_WM_CONTEXT_ACCEPT"; 253 names[n++] = "_NET_WM_CONTEXT_ACCEPT";
254 254
255 atoms[n] = &d->wm_protocols; 255 atoms[n] = &d->wm_protocols;
256 names[n++] = "WM_PROTOCOLS"; 256 names[n++] = "WM_PROTOCOLS";
257 257
258 XInternAtoms( qt_xdisplay(), names, n, FALSE, atoms_re); 258 XInternAtoms( qt_xdisplay(), names, n, FALSE, atoms_re);
259 // now copy the values over to the properties 259 // now copy the values over to the properties
260 for (int i = 0; i < n; i++ ) 260 for (int i = 0; i < n; i++ )
261 *atoms[i] = atoms_re[i]; 261 *atoms[i] = atoms_re[i];
262 // done with X11 Stuff 262 // done with X11 Stuff
263 263
264 int dw = desktop()->width(); 264 int dw = desktop()->width();
265 if ( dw < 200 ) { 265 if ( dw < 200 ) {
266 setFont( QFont( "helvetica", 8 ) ); 266 setFont( QFont( "helvetica", 8 ) );
267 AppLnk::setSmallIconSize( 10 ); 267 AppLnk::setSmallIconSize( 10 );
268 AppLnk::setBigIconSize( 28 ); 268 AppLnk::setBigIconSize( 28 );
269 }else if ( dw > 600 ) { 269 }else if ( dw > 600 ) {
270 setFont( QFont( "helvetica", 12 ) ); 270 setFont( QFont( "helvetica", 12 ) );
271 AppLnk::setSmallIconSize( 24 ); 271 AppLnk::setSmallIconSize( 24 );
272 AppLnk::setBigIconSize( 48 ); 272 AppLnk::setBigIconSize( 48 );
273 }else if ( dw > 200 ) { 273 }else if ( dw > 200 ) {
274 setFont( QFont( "helvetica", 10 ) ); 274 setFont( QFont( "helvetica", 10 ) );
275 AppLnk::setSmallIconSize( 16 ); 275 AppLnk::setSmallIconSize( 16 );
276 AppLnk::setBigIconSize( 32 ); 276 AppLnk::setBigIconSize( 32 );
277 } 277 }
278 QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); 278 QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory );
279 279
280 connect( this, SIGNAL( lastWindowClosed() ), this, SLOT(hideOrQuit() ) ); 280 connect( this, SIGNAL( lastWindowClosed() ), this, SLOT(hideOrQuit() ) );
281 281
282 QString qcopfn( "/tmp/qcop-msg-" ); 282 QString qcopfn( "/tmp/qcop-msg-" );
283 qcopfn += QString( argv[0] ); // append command name to the QCOP name 283 qcopfn += QString( argv[0] ); // append command name to the QCOP name
284 QFile file( qcopfn ); 284 QFile file( qcopfn );
285 if (file.open(IO_ReadOnly ) ) { 285 if (file.open(IO_ReadOnly ) ) {
286 flock( file.handle(), LOCK_EX ); 286 flock( file.handle(), LOCK_EX );
287 } 287 }
288 288
289 /* Hmmm damn we need to make the parent 0l otherwise it get's deleted 289 /* Hmmm damn we need to make the parent 0l otherwise it get's deleted
290 * past the QApplication 290 * past the QApplication
291 */ 291 */
292 m_sys = new QCopChannel( "QPE/System", 0l); 292 m_sys = new QCopChannel( "QPE/System", 0l);
293 connect(m_sys, SIGNAL( received( const QCString&, const QByteArray& ) ), 293 connect(m_sys, SIGNAL( received( const QCString&, const QByteArray& ) ),
294 this, SLOT(systemMessage( const QCString&, const QByteArray& ) ) ); 294 this, SLOT(systemMessage( const QCString&, const QByteArray& ) ) );
295 295
296 // private channel QPE/Application/appname 296 // private channel QPE/Application/appname
297 QCString channel = QCString( argv[0] ); 297 QCString channel = QCString( argv[0] );
298 channel.replace( QRegExp( ".*/"), "" ); 298 channel.replace( QRegExp( ".*/"), "" );
299 d->appName = channel; 299 d->appName = channel;
300 channel = "QPE/Application/"+ channel; 300 channel = "QPE/Application/"+ channel;
301 m_pid = new QCopChannel( channel, 0l ); 301 m_pid = new QCopChannel( channel, 0l );
302 connect(m_pid, SIGNAL( received( const QCString&, const QByteArray& ) ), 302 connect(m_pid, SIGNAL( received( const QCString&, const QByteArray& ) ),
303 this, SLOT( pidMessage( const QCString&, const QByteArray& ) ) ); 303 this, SLOT( pidMessage( const QCString&, const QByteArray& ) ) );
304 304
305 // read the Pre QCOP Stuff from the file 305 // read the Pre QCOP Stuff from the file
306 if ( file.isOpen() ) { 306 if ( file.isOpen() ) {
307 d->keep_running = FALSE; 307 d->keep_running = FALSE;
308 QDataStream ds( &file ); 308 QDataStream ds( &file );
309 QCString chanel, message; 309 QCString chanel, message;
310 QByteArray data; 310 QByteArray data;
311 while (!ds.atEnd() ) { 311 while (!ds.atEnd() ) {
312 ds >> chanel >> message >> data; 312 ds >> chanel >> message >> data;
313 d->enqueueQCop( chanel, message, data ); 313 d->enqueueQCop( chanel, message, data );
314 } 314 }
315 flock( file.handle(), LOCK_UN ); 315 flock( file.handle(), LOCK_UN );
316 file.close(); 316 file.close();
317 file.remove(); 317 file.remove();
318 } 318 }
319 319
320 // read in some stuff from the command line 320 // read in some stuff from the command line
321 // we do not have setArgs so we need to take 321 // we do not have setArgs so we need to take
322 // care of that 322 // care of that
323 for ( int a = 0; a < arg; a++ ) { 323 for ( int a = 0; a < arg; a++ ) {
324 if ( qstrcmp( argv[a], "-preload" ) == 0 ) { 324 if ( qstrcmp( argv[a], "-preload" ) == 0 ) {
325 d->preloaded = TRUE; 325 d->preloaded = TRUE;
326 }else if ( qstrcmp( argv[a ] , "-preload-show" ) == 0 ) { 326 }else if ( qstrcmp( argv[a ] , "-preload-show" ) == 0 ) {
327 d->preloaded = TRUE; 327 d->preloaded = TRUE;
328 d->forceshow = TRUE; 328 d->forceshow = TRUE;
329 } 329 }
330 } 330 }
331 initTranslations(); 331 initTranslations();
332 applyStyle(); 332 applyStyle();
333 333
334 if ( type() == GuiServer ) 334 if ( type() == GuiServer )
335 ; 335 ;
336 336
337 installEventFilter( this ); 337 installEventFilter( this );
338 QPEMenuToolFocusManager::initialize(); 338 QPEMenuToolFocusManager::initialize();
339} 339}
340void QPEApplication::initTranslations() { 340void QPEApplication::initTranslations() {
341 // Translations add it 341 // Translations add it
342 QStringList langs = Global::languageList(); 342 QStringList langs = Global::languageList();
343 for ( QStringList::ConstIterator it = langs.begin(); it != langs.end(); ++it ) { 343 for ( QStringList::ConstIterator it = langs.begin(); it != langs.end(); ++it ) {
344 QString lang = *it; 344 QString lang = *it;
345 345
346 QTranslator * trans; 346 QTranslator * trans;
347 QString tfn; 347 QString tfn;
348 348
349 trans = new QTranslator( this ); 349 trans = new QTranslator( this );
350 tfn = qpeDir() + "/i18n/" + lang + "/libqpe.qm"; 350 tfn = qpeDir() + "/i18n/" + lang + "/libqpe.qm";
351 if ( trans->load( tfn ) ) 351 if ( trans->load( tfn ) )
352 installTranslator( trans ); 352 installTranslator( trans );
353 else 353 else
354 delete trans; 354 delete trans;
355 355
356 trans = new QTranslator( this ); 356 trans = new QTranslator( this );
357 tfn = qpeDir() + "/i18n/" + lang + "/" + d->appName + ".qm"; 357 tfn = qpeDir() + "/i18n/" + lang + "/" + d->appName + ".qm";
358 if ( trans->load( tfn ) ) 358 if ( trans->load( tfn ) )
359 installTranslator( trans ); 359 installTranslator( trans );
360 else 360 else
361 delete trans; 361 delete trans;
362 } 362 }
363} 363}
364QString QPEApplication::qpeDir() { 364QString QPEApplication::qpeDir() {
365 const char * base = getenv( "OPIEDIR" ); 365 const char * base = getenv( "OPIEDIR" );
366 if ( base ) 366 if ( base )
367 return QString( base ) + "/"; 367 return QString( base ) + "/";
368 368
369 return QString( "../" ); 369 return QString( "../" );
370} 370}
371QString QPEApplication::documentDir() { 371QString QPEApplication::documentDir() {
372 const char* base = getenv( "HOME"); 372 const char* base = getenv( "HOME");
373 if ( base ) 373 if ( base )
374 return QString( base ) + "/Documents"; 374 return QString( base ) + "/Documents";
375 375
376 return QString( "../Documents" ); 376 return QString( "../Documents" );
377} 377}
378void QPEApplication::applyStyle() { 378void QPEApplication::applyStyle() {
379 Config config( "qpe" ); 379 Config config( "qpe" );
380 380
381 config.setGroup( "Appearance" ); 381 config.setGroup( "Appearance" );
382 382
383 // Widget style 383 // Widget style
384 QString style = config.readEntry( "Style", "Light" ); 384 QString style = config.readEntry( "Style", "Light" );
385 internalSetStyle( style ); 385 internalSetStyle( style );
386 386
387 // Colors 387 // Colors
388 QColor bgcolor( config.readEntry( "Background", "#E5E1D5" ) ); 388 QColor bgcolor( config.readEntry( "Background", "#E5E1D5" ) );
389 QColor btncolor( config.readEntry( "Button", "#D6CDBB" ) ); 389 QColor btncolor( config.readEntry( "Button", "#D6CDBB" ) );
390 QPalette pal( btncolor, bgcolor ); 390 QPalette pal( btncolor, bgcolor );
391 QString color = config.readEntry( "Highlight", "#800000" ); 391 QString color = config.readEntry( "Highlight", "#800000" );
392 pal.setColor( QColorGroup::Highlight, QColor( color ) ); 392 pal.setColor( QColorGroup::Highlight, QColor( color ) );
393 color = config.readEntry( "HighlightedText", "#FFFFFF" ); 393 color = config.readEntry( "HighlightedText", "#FFFFFF" );
394 pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); 394 pal.setColor( QColorGroup::HighlightedText, QColor( color ) );
395 color = config.readEntry( "Text", "#000000" ); 395 color = config.readEntry( "Text", "#000000" );
396 pal.setColor( QColorGroup::Text, QColor( color ) ); 396 pal.setColor( QColorGroup::Text, QColor( color ) );
397 color = config.readEntry( "ButtonText", "#000000" ); 397 color = config.readEntry( "ButtonText", "#000000" );
398 pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); 398 pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) );
399 color = config.readEntry( "Base", "#FFFFFF" ); 399 color = config.readEntry( "Base", "#FFFFFF" );
400 pal.setColor( QColorGroup::Base, QColor( color ) ); 400 pal.setColor( QColorGroup::Base, QColor( color ) );
401 401
402 pal.setColor( QPalette::Disabled, QColorGroup::Text, 402 pal.setColor( QPalette::Disabled, QColorGroup::Text,
403 pal.color( QPalette::Active, QColorGroup::Background ).dark() ); 403 pal.color( QPalette::Active, QColorGroup::Background ).dark() );
404 404
405 setPalette( pal, TRUE ); 405 setPalette( pal, TRUE );
406 406
407 407
408 408
409 // Font 409 // Font
410 QString ff = config.readEntry( "FontFamily", font().family() ); 410 QString ff = config.readEntry( "FontFamily", font().family() );
411 int fs = config.readNumEntry( "FontSize", font().pointSize() ); 411 int fs = config.readNumEntry( "FontSize", font().pointSize() );
412 setFont( QFont(ff, fs) ); 412 setFont( QFont(ff, fs) );
413} 413}
414int QPEApplication::defaultRotation() { 414int QPEApplication::defaultRotation() {
415 return 0; 415 return 0;
416} 416}
417void QPEApplication::setDefaultRotation(int r ) { 417void QPEApplication::setDefaultRotation(int r ) {
418 418
419} 419}
420void QPEApplication::grabKeyboard() { 420void QPEApplication::grabKeyboard() {
421 QPEApplication::Private * d = ( ( QPEApplication* ) qApp ) ->d; 421 QPEApplication::Private * d = ( ( QPEApplication* ) qApp ) ->d;
422 if ( qApp->type() == QApplication::GuiServer ) 422 if ( qApp->type() == QApplication::GuiServer )
423 d->kbgrabber = 0; 423 d->kbgrabber = 0;
424 else { 424 else {
425 QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" ); 425 QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" );
426 e << d->appName; 426 e << d->appName;
427 427
428 d->kbgrabber = 2; // me 428 d->kbgrabber = 2; // me
429 } 429 }
430} 430}
431void QPEApplication::ungrabKeyboard() { 431void QPEApplication::ungrabKeyboard() {
432 QPEApplication::Private * d = ( ( QPEApplication* ) qApp ) ->d; 432 QPEApplication::Private * d = ( ( QPEApplication* ) qApp ) ->d;
433 if ( d->kbgrabber == 2 ) { 433 if ( d->kbgrabber == 2 ) {
434 QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" ); 434 QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" );
435 e << QString::null; 435 e << QString::null;
436 436
437 d->kbregrab = FALSE; 437 d->kbregrab = FALSE;
438 d->kbgrabber = 0; 438 d->kbgrabber = 0;
439 } 439 }
440} 440}
441void QPEApplication::showMainWidget( QWidget* wid, bool b) { 441void QPEApplication::showMainWidget( QWidget* wid, bool b) {
442 d->show(wid, b ); 442 d->show(wid, b );
443} 443}
444void QPEApplication::showMainDocumentWidget( QWidget* mw, bool m) { 444void QPEApplication::showMainDocumentWidget( QWidget* mw, bool m) {
445 if ( mw && argc() == 2 ) 445 if ( mw && argc() == 2 )
446 Global::setDocument( mw, QString::fromUtf8(argv()[1] ) ); 446 Global::setDocument( mw, QString::fromUtf8(argv()[1] ) );
447 447
448 d->show(mw, m ); 448 d->show(mw, m );
449} 449}
450void QPEApplication::showDialog( QDialog* d, bool nomax ) { 450void QPEApplication::showDialog( QDialog* d, bool nomax ) {
451 QSize sh = d->sizeHint(); 451 QSize sh = d->sizeHint();
452 int w = QMAX(sh.width(),d->width()); 452 int w = QMAX(sh.width(),d->width());
453 int h = QMAX(sh.height(),d->height()); 453 int h = QMAX(sh.height(),d->height());
454 if ( !nomax 454 if ( !nomax
455 && ( w > qApp->desktop()->width()*3/4 455 && ( w > qApp->desktop()->width()*3/4
456 || h > qApp->desktop()->height()*3/4 ) ) 456 || h > qApp->desktop()->height()*3/4 ) )
457 { 457 {
458 d->showMaximized(); 458 d->showMaximized();
459 } else { 459 } else {
460 d->resize(w,h); 460 d->resize(w,h);
461 d->show(); 461 d->show();
462 } 462 }
463} 463}
464int QPEApplication::execDialog( QDialog* d, bool nomax) { 464int QPEApplication::execDialog( QDialog* d, bool nomax) {
465 showDialog(d,nomax); 465 showDialog(d,nomax);
466 return d->exec(); 466 return d->exec();
467} 467}
468void QPEApplication::setKeepRunning() { 468void QPEApplication::setKeepRunning() {
469 if ( qApp && qApp->inherits( "QPEApplication" ) ) { 469 if ( qApp && qApp->inherits( "QPEApplication" ) ) {
470 QPEApplication * qpeApp = ( QPEApplication* ) qApp; 470 QPEApplication * qpeApp = ( QPEApplication* ) qApp;
471 qpeApp->d->keep_running = TRUE; 471 qpeApp->d->keep_running = TRUE;
472 } 472 }
473} 473}
474bool QPEApplication::keepRunning()const { 474bool QPEApplication::keepRunning()const {
475 return d->keep_running; 475 return d->keep_running;
476} 476}
477bool QPEApplication::keyboardGrabbed()const { 477bool QPEApplication::keyboardGrabbed()const {
478 return d->kbgrabber; 478 return d->kbgrabber;
479} 479}
480int QPEApplication::exec() { 480int QPEApplication::exec() {
481 /* now send the QCOP stuff gotten from the file */ 481 /* now send the QCOP stuff gotten from the file */
482 d->sendQCopQ(); 482 d->sendQCopQ();
483 483
484 if ( d->keep_running ) { 484 if ( d->keep_running ) {
485 qWarning("going to exec"); 485 qWarning("going to exec");
486 int a = QApplication::exec(); 486 int a = QApplication::exec();
487 qWarning("left"); 487 qWarning("left");
488 return a; 488 return a;
489 } 489 }
490 490
491 { 491 {
492 QCopEnvelope e( "QPE/System", "closing(QString)" ); 492 QCopEnvelope e( "QPE/System", "closing(QString)" );
493 e << d->appName; 493 e << d->appName;
494 } 494 }
495 qWarning("processing events!"); 495 qWarning("processing events!");
496 processEvents(); 496 processEvents();
497 return 0; 497 return 0;
498} 498}
499void QPEApplication::internalSetStyle( const QString& ) { 499void QPEApplication::internalSetStyle( const QString& ) {
500 500
501} 501}
502void QPEApplication::systemMessage( const QCString& chan, const QByteArray& ) { 502void QPEApplication::systemMessage( const QCString& chan, const QByteArray& ) {
503 qWarning("QPEApplication::systemMessage( %s )", chan.data() ); 503 qWarning("QPEApplication::systemMessage( %s )", chan.data() );
504} 504}
505void QPEApplication::pidMessage( const QCString& msg, const QByteArray& ) { 505void QPEApplication::pidMessage( const QCString& msg, const QByteArray& ) {
506 if ( msg == "flush()" ) { 506 if ( msg == "flush()" ) {
507 emit flush(); 507 emit flush();
508 QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); 508 QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" );
509 e << d->appName; 509 e << d->appName;
510 }else if ( msg == "reload()" ) { 510 }else if ( msg == "reload()" ) {
511 emit reload(); 511 emit reload();
512 } 512 }
513 513
514} 514}
515void QPEApplication::timerEvent( QTimerEvent* e ) { 515void QPEApplication::timerEvent( QTimerEvent* e ) {
516 if ( e->timerId() == d->presstimer && d->presswidget ) { 516 if ( e->timerId() == d->presstimer && d->presswidget ) {
517 // Right pressed 517 // Right pressed
518 postEvent( d->presswidget, 518 postEvent( d->presswidget,
519 new QMouseEvent( QEvent::MouseButtonPress, d->presspos, 519 new QMouseEvent( QEvent::MouseButtonPress, d->presspos,
520 RightButton, LeftButton ) ); 520 RightButton, LeftButton ) );
521 killTimer( d->presstimer ); 521 killTimer( d->presstimer );
522 d->presstimer = 0; 522 d->presstimer = 0;
523 } 523 }
524} 524}
525 525
526// InputMethods Hints 526// InputMethods Hints
527namespace { 527namespace {
528 static QPtrDict<void>* inputMethodDict = 0; 528 static QPtrDict<void>* inputMethodDict = 0;
529 static void createInputMethodDict(){ 529 static void createInputMethodDict(){
530 if ( !inputMethodDict ) 530 if ( !inputMethodDict )
531 inputMethodDict = new QPtrDict<void>; 531 inputMethodDict = new QPtrDict<void>;
532 } 532 }
533 533
534 static QPtrDict<void>* stylusDict = 0; 534 static QPtrDict<void>* stylusDict = 0;
535 static void createDict() { 535 static void createDict() {
536 if ( !stylusDict ) 536 if ( !stylusDict )
537 stylusDict = new QPtrDict<void>; 537 stylusDict = new QPtrDict<void>;
538 } 538 }
539}; 539};
540 540
541void QPEApplication::setInputMethodHint( QWidget* w, InputMethodHint mode ) { 541void QPEApplication::setInputMethodHint( QWidget* w, InputMethodHint mode ) {
542 createInputMethodDict(); 542 createInputMethodDict();
543 if ( mode == Normal ) { 543 if ( mode == Normal ) {
544 inputMethodDict->remove 544 inputMethodDict->remove
545 ( w ); 545 ( w );
546 }else { 546 }else {
547 inputMethodDict->insert( w, ( void* ) mode ); 547 inputMethodDict->insert( w, ( void* ) mode );
548 } 548 }
549} 549}
550QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget* w) { 550QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget* w) {
551 if ( inputMethodDict && w ) 551 if ( inputMethodDict && w )
552 return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); 552 return ( InputMethodHint ) ( int ) inputMethodDict->find( w );
553 return Normal; 553 return Normal;
554} 554}
555 555
556 556
557void QPEApplication::removeSenderFromStylusDict() { 557void QPEApplication::removeSenderFromStylusDict() {
558 stylusDict->remove( ( void* ) sender() ); 558 stylusDict->remove( ( void* ) sender() );
559 if ( d->presswidget == sender() ) 559 if ( d->presswidget == sender() )
560 d->presswidget = 0; 560 d->presswidget = 0;
561} 561}
562void QPEApplication::setStylusOperation( QWidget* w, StylusMode mode) { 562void QPEApplication::setStylusOperation( QWidget* w, StylusMode mode) {
563 createDict(); 563 createDict();
564 if ( mode == LeftOnly ) { 564 if ( mode == LeftOnly ) {
565 stylusDict->remove 565 stylusDict->remove
566 ( w ); 566 ( w );
567 w->removeEventFilter( qApp ); 567 w->removeEventFilter( qApp );
568 }else { 568 }else {
569 stylusDict->insert( w, ( void* ) mode ); 569 stylusDict->insert( w, ( void* ) mode );
570 connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) ); 570 connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) );
571 w->installEventFilter( qApp ); 571 w->installEventFilter( qApp );
572 } 572 }
573} 573}
574QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w) { 574QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w) {
575 if ( stylusDict ) 575 if ( stylusDict )
576 return ( StylusMode ) ( int ) stylusDict->find( w ); 576 return ( StylusMode ) ( int ) stylusDict->find( w );
577 return LeftOnly; 577 return LeftOnly;
578} 578}
579 579
580// eventFilter...... 580// eventFilter......
581bool QPEApplication::eventFilter( QObject* o, QEvent* e ) { 581bool QPEApplication::eventFilter( QObject* o, QEvent* e ) {
582 /* 582 /*
583 * We want our WM to show Ok and a X button 583 * We want our WM to show Ok and a X button
584 * on dialogs 584 * on dialogs
585 * our part is to set the _NET_WM_CONTEXT_ACCEPT 585 * our part is to set the _NET_WM_CONTEXT_ACCEPT
586 * propery 586 * propery
587 * and then wait for a client message -zecke 587 * and then wait for a client message -zecke
588 * on show we will add the prop 588 * on show we will add the prop
589 */ 589 */
590 if (o->inherits("QDialog") && e->type() == QEvent::Show ) { 590 if (o->inherits("QDialog") && e->type() == QEvent::Show ) {
591 QDialog* dialog = (QDialog*)o; 591 QDialog* dialog = (QDialog*)o;
592 Atom wm_prot[45]; 592 Atom wm_prot[45];
593 int n = 0; 593 int n = 0;
594 wm_prot[n++] = d->wm_delete_window; 594 wm_prot[n++] = d->wm_delete_window;
595 wm_prot[n++] = d->wm_take_focus; 595 wm_prot[n++] = d->wm_take_focus;
596 wm_prot[n++] = d->wm_context_accept; 596 wm_prot[n++] = d->wm_context_accept;
597 if ( dialog->testWFlags( WStyle_ContextHelp ) ) 597 if ( dialog->testWFlags( WStyle_ContextHelp ) )
598 wm_prot[n++] = d->wm_context_help; 598 wm_prot[n++] = d->wm_context_help;
599 XSetWMProtocols( qt_xdisplay(), dialog->winId(), wm_prot, n ); 599 XSetWMProtocols( qt_xdisplay(), dialog->winId(), wm_prot, n );
600 return TRUE; // should be save 600 return TRUE; // should be save
601 } 601 }
602 if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { 602 if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) {
603 QMouseEvent * me = ( QMouseEvent* ) e; 603 QMouseEvent * me = ( QMouseEvent* ) e;
604 StylusMode mode = (StylusMode)(int)stylusDict->find(o); 604 StylusMode mode = (StylusMode)(int)stylusDict->find(o);
605 switch (mode) { 605 switch (mode) {
606 case RightOnHold: 606 case RightOnHold:
607 switch ( me->type() ) { 607 switch ( me->type() ) {
608 case QEvent::MouseButtonPress: 608 case QEvent::MouseButtonPress:
609 if ( me->button() == LeftButton ) { 609 if ( me->button() == LeftButton ) {
610 d->presstimer = startTimer(500); // #### pref. 610 d->presstimer = startTimer(500); // #### pref.
611 d->presswidget = (QWidget*)o; 611 d->presswidget = (QWidget*)o;
612 d->presspos = me->pos(); 612 d->presspos = me->pos();
613 d->rightpressed = FALSE; 613 d->rightpressed = FALSE;
614 } 614 }
615 break; 615 break;
616 case QEvent::MouseMove: 616 case QEvent::MouseMove:
617 if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) { 617 if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) {
618 killTimer(d->presstimer); 618 killTimer(d->presstimer);
619 d->presstimer = 0; 619 d->presstimer = 0;
620 } 620 }
621 break; 621 break;
622 case QEvent::MouseButtonRelease: 622 case QEvent::MouseButtonRelease:
623 if ( me->button() == LeftButton ) { 623 if ( me->button() == LeftButton ) {
624 if ( d->presstimer ) { 624 if ( d->presstimer ) {
625 killTimer(d->presstimer); 625 killTimer(d->presstimer);
626 d->presstimer = 0; 626 d->presstimer = 0;
627 } 627 }
628 if ( d->rightpressed && d->presswidget ) { 628 if ( d->rightpressed && d->presswidget ) {
629 // Right released 629 // Right released
630 postEvent( d->presswidget, 630 postEvent( d->presswidget,
631 new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), 631 new QMouseEvent( QEvent::MouseButtonRelease, me->pos(),
632 RightButton, LeftButton + RightButton ) ); 632 RightButton, LeftButton + RightButton ) );
633 // Left released, off-widget 633 // Left released, off-widget
634 postEvent( d->presswidget, 634 postEvent( d->presswidget,
635 new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1), 635 new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1),
636 LeftButton, LeftButton ) ); 636 LeftButton, LeftButton ) );
637 postEvent( d->presswidget, 637 postEvent( d->presswidget,
638 new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1), 638 new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1),
639 LeftButton, LeftButton ) ); 639 LeftButton, LeftButton ) );
640 d->rightpressed = FALSE; 640 d->rightpressed = FALSE;
641 return TRUE; // don't send the real Left release 641 return TRUE; // don't send the real Left release
642 } 642 }
643 } 643 }
644 break; 644 break;
645 default: 645 default:
646 break; 646 break;
647 } 647 }
648 break; 648 break;
649 default: 649 default:
650 ; 650 ;
651 } 651 }
652 } 652 }
653 else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { 653 else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) {
654 QKeyEvent *ke = (QKeyEvent *)e; 654 QKeyEvent *ke = (QKeyEvent *)e;
655 if ( ke->key() == Key_Enter ) { 655 if ( ke->key() == Key_Enter ) {
656 if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { 656 if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) {
657 postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', 657 postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ',
658 ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); 658 ke->state(), " ", ke->isAutoRepeat(), ke->count() ) );
659 return TRUE; 659 return TRUE;
660 } 660 }
661 } 661 }
662 } 662 }
663 return FALSE; 663 return FALSE;
664} 664}
665 665
666// Quit stuff 666// Quit stuff
667void QPEApplication::restart() { 667void QPEApplication::restart() {
668 668
669} 669}
670void QPEApplication::shutdown() { 670void QPEApplication::shutdown() {
671 671
672} 672}
673void QPEApplication::tryQuit() { 673void QPEApplication::tryQuit() {
674 qWarning("TryQuit!!"); 674 qWarning("TryQuit!!");
675 if ( activeModalWidget() || strcmp( argv() [ 0 ], "embeddedkonsole" ) == 0 ) 675 if ( activeModalWidget() || strcmp( argv() [ 0 ], "embeddedkonsole" ) == 0 )
676 return ; // Inside modal loop or konsole. Too hard to save state. 676 return ; // Inside modal loop or konsole. Too hard to save state.
677 { 677 {
678 QCopEnvelope e( "QPE/System", "closing(QString)" ); 678 QCopEnvelope e( "QPE/System", "closing(QString)" );
679 e << d->appName; 679 e << d->appName;
680 } 680 }
681 processEvents(); 681 processEvents();
682 682
683 quit(); 683 quit();
684} 684}
685void QPEApplication::hideOrQuit() { 685void QPEApplication::hideOrQuit() {
686 qWarning("hide or close"); 686 qWarning("hide or close");
687 processEvents(); 687 processEvents();
688 qWarning("past processing"); 688 qWarning("past processing");
689 689
690 // If we are a preloaded application we don't actually quit, so emit 690 // If we are a preloaded application we don't actually quit, so emit
691 // a System message indicating we're quasi-closing. 691 // a System message indicating we're quasi-closing.
692 if ( d->preloaded && d->qpe_main_widget ) 692 if ( d->preloaded && d->qpe_main_widget )
693 693
694 { 694 {
695 qWarning("hiding"); 695 qWarning("hiding");
696 QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); 696 QCopEnvelope e("QPE/System", "fastAppHiding(QString)" );
697 e << d->appName; 697 e << d->appName;
698 d->qpe_main_widget->hide(); 698 d->qpe_main_widget->hide();
699 } 699 }
700 else 700 else
701 quit(); 701 quit();
702} 702}
703 703
704/*! 704/*!
705 \internal 705 \internal
706*/ 706*/
707void QPEApplication::prepareForTermination( bool willrestart ) 707void QPEApplication::prepareForTermination( bool willrestart )
708{ 708{
709 if ( willrestart ) { 709 if ( willrestart ) {
710 // Draw a big wait icon, the image can be altered in later revisions 710 // Draw a big wait icon, the image can be altered in later revisions
711 // QWidget *d = QApplication::desktop(); 711 // QWidget *d = QApplication::desktop();
712 QImage img = Resource::loadImage( "launcher/new_wait" ); 712 QImage img = Resource::loadImage( "launcher/new_wait" );
713 QPixmap pix; 713 QPixmap pix;
714 pix.convertFromImage( img.smoothScale( 1 * img.width(), 1 * img.height() ) ); 714 pix.convertFromImage( img.smoothScale( 1 * img.width(), 1 * img.height() ) );
715 QLabel *lblWait = new QLabel( 0, "wait hack!", QWidget::WStyle_Customize | 715 QLabel *lblWait = new QLabel( 0, "wait hack!", QWidget::WStyle_Customize |
716 QWidget::WStyle_NoBorder | QWidget::WStyle_Tool ); 716 QWidget::WStyle_NoBorder | QWidget::WStyle_Tool );
717 lblWait->setPixmap( pix ); 717 lblWait->setPixmap( pix );
718 lblWait->setAlignment( QWidget::AlignCenter ); 718 lblWait->setAlignment( QWidget::AlignCenter );
719 lblWait->show(); 719 lblWait->show();
720 lblWait->showMaximized(); 720 lblWait->showMaximized();
721 } 721 }
722#ifndef SINGLE_APP 722#ifndef SINGLE_APP
723 { QCopEnvelope envelope( "QPE/System", "forceQuit()" ); 723 { QCopEnvelope envelope( "QPE/System", "forceQuit()" );
724 } 724 }
725 processEvents(); // ensure the message goes out. 725 processEvents(); // ensure the message goes out.
726 sleep( 1 ); // You have 1 second to comply. 726 sleep( 1 ); // You have 1 second to comply.
727#endif 727#endif
728} 728}
729int QPEApplication::x11ClientMessage(QWidget* w, XEvent* event, bool b ) { 729int QPEApplication::x11ClientMessage(QWidget* w, XEvent* event, bool b ) {
730 qWarning("X11 ClientMessage %d %d", event->type, ClientMessage); 730 qWarning("X11 ClientMessage %d %d", event->type, ClientMessage);
731 if ( event->type == ClientMessage ) { 731 if ( event->type == ClientMessage ) {
732 if ( (event->xclient.message_type == d->wm_protocols) && 732 if ( (event->xclient.message_type == d->wm_protocols) &&
733 (event->xclient.data.l[0] == d->wm_context_accept ) ) { 733 (event->xclient.data.l[0] == d->wm_context_accept ) ) {
734 qWarning("accepted!!!"); 734 qWarning("accepted!!!");
735 /* 735 /*
736 * I'm not sure if we should use activeWidget 736 * I'm not sure if we should use activeWidget
737 * or activeModalWidget 737 * or activeModalWidget
738 * a QDialog could be not modal too 738 * a QDialog could be not modal too
739 */ 739 */
740 if ( w->inherits("QDialog" ) ) { 740 if ( w->inherits("QDialog" ) ) {
741 qWarning("inherits QDialog!!!"); 741 qWarning("inherits QDialog!!!");
742 QDialog* dia = (QDialog*)w; 742 QDialog* dia = (QDialog*)w;
743 /* 743 /*
744 * call it directly or via QTimer::singleShot? 744 * call it directly or via QTimer::singleShot?
745 */ 745 */
746 QTimer::singleShot(0, dia, SLOT(accept() ) ); 746 QTimer::singleShot(0, dia, SLOT(accept() ) );
747 return 0; 747 return 0;
748 } 748 }
749 749
750 } 750 }
751 } 751 }
752 return QApplication::x11ClientMessage(w, event, b ); 752 return QApplication::x11ClientMessage(w, event, b );
753} 753}
754 754
755#define KeyPress XKeyPress 755#define KeyPress XKeyPress
756#define KeyRelease XKeyRelease 756#define KeyRelease XKeyRelease
757 757
758#if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) 758#if defined(QT_QWS_IPAQ) || defined(QT_QWS_SL5XXX)
759 759
760// The libraries with the skiff package (and possibly others) have 760// The libraries with the skiff package (and possibly others) have
761// completely useless implementations of builtin new and delete that 761// completely useless implementations of builtin new and delete that
762// use about 50% of your CPU. Here we revert to the simple libc 762// use about 50% of your CPU. Here we revert to the simple libc
763// functions. 763// functions.
764 764
765void* operator new[]( size_t size ) 765void* operator new[]( size_t size )
766{ 766{
767 return malloc( size ); 767 return malloc( size );
768} 768}
769 769
770void* operator new( size_t size ) 770void* operator new( size_t size )
771{ 771{
772 return malloc( size ); 772 return malloc( size );
773} 773}
774 774
775void operator delete[]( void* p ) 775void operator delete[]( void* p )
776{ 776{
777 free( p ); 777 free( p );
778} 778}
779 779
780void operator delete[]( void* p, size_t /*size*/ ) 780void operator delete[]( void* p, size_t /*size*/ )
781{ 781{
782 free( p ); 782 free( p );
783} 783}
784 784
785void operator delete( void* p ) 785void operator delete( void* p )
786{ 786{
787 free( p ); 787 free( p );
788} 788}
789 789
790void operator delete( void* p, size_t /*size*/ ) 790void operator delete( void* p, size_t /*size*/ )
791{ 791{
792 free( p ); 792 free( p );
793} 793}
794 794
795#endif 795#endif