author | zecke <zecke> | 2004-08-24 13:38:23 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-08-24 13:38:23 (UTC) |
commit | 0a141c4a9719aa273867ad45c4293208545489b1 (patch) (unidiff) | |
tree | 4059ae180d00d33cc31dd9083d38a14b946253a2 /library | |
parent | 102bb2b65c71da12c4f9f1ce7a5d1b37b6eb50ee (diff) | |
download | opie-0a141c4a9719aa273867ad45c4293208545489b1.zip opie-0a141c4a9719aa273867ad45c4293208545489b1.tar.gz opie-0a141c4a9719aa273867ad45c4293208545489b1.tar.bz2 |
Add RightOn Hold Visual Feedback and integrate it
into QPEApplication
Icons and Config Option will be comitted by WIMPIE
-rw-r--r-- | library/backend/rohfeedback.cpp | 125 | ||||
-rw-r--r-- | library/backend/rohfeedback.h | 62 | ||||
-rw-r--r-- | library/qpeapplication.cpp | 32 |
3 files changed, 216 insertions, 3 deletions
diff --git a/library/backend/rohfeedback.cpp b/library/backend/rohfeedback.cpp new file mode 100644 index 0000000..ff76a36 --- a/dev/null +++ b/library/backend/rohfeedback.cpp | |||
@@ -0,0 +1,125 @@ | |||
1 | #include <rohfeedback.h> | ||
2 | |||
3 | |||
4 | #include <stdio.h> | ||
5 | #include <qpeapplication.h> | ||
6 | #include <qevent.h> | ||
7 | #include <resource.h> | ||
8 | #include <qpixmap.h> | ||
9 | #include <qbitmap.h> | ||
10 | |||
11 | #define SPEED 600 | ||
12 | #define DELAY 500 | ||
13 | |||
14 | namespace Opie { | ||
15 | namespace Internal { | ||
16 | /* | ||
17 | |||
18 | RightOnHold feedback | ||
19 | |||
20 | */ | ||
21 | |||
22 | QPixmap * RoHFeedback::Imgs[NOOFICONS] = { 0, 0, 0, 0, 0 }; | ||
23 | QBitmap * RoHFeedback::Masks[NOOFICONS]; | ||
24 | int RoHFeedback::IconWidth; | ||
25 | int RoHFeedback::IconHeight; | ||
26 | |||
27 | RoHFeedback::RoHFeedback() : | ||
28 | QLabel( 0, 0, Qt::WType_Popup ), Timer() { | ||
29 | |||
30 | Receiver = 0l; | ||
31 | connect( &Timer, SIGNAL( timeout() ), this, SLOT( iconShow() ) ); | ||
32 | |||
33 | if( Imgs[0] == 0 ) { | ||
34 | QString S; | ||
35 | |||
36 | |||
37 | for( int i = 0; i < NOOFICONS ; i ++ ) { | ||
38 | Imgs[i] = new QPixmap( Resource::loadPixmap("RoH/star/"+ | ||
39 | QString::number(i+1) + | ||
40 | ".png" )); | ||
41 | Masks[i] = new QBitmap(); | ||
42 | (*Masks[i]) = Resource::loadPixmap("RoH/star/"+QString::number(i+1) + | ||
43 | ".png" ); | ||
44 | } | ||
45 | } | ||
46 | |||
47 | IconWidth = Imgs[0]->size().width(); | ||
48 | IconHeight = Imgs[0]->size().height(); | ||
49 | |||
50 | resize( IconWidth, IconHeight ); | ||
51 | } | ||
52 | |||
53 | int RoHFeedback::delay( void ) { | ||
54 | return DELAY+SPEED+50; | ||
55 | } | ||
56 | |||
57 | RoHFeedback::~RoHFeedback() { | ||
58 | for ( int i = 0; i < NOOFICONS; ++i ) { | ||
59 | delete Imgs [i]; | ||
60 | delete Masks[i]; | ||
61 | } | ||
62 | } | ||
63 | |||
64 | void RoHFeedback::init( const QPoint & P, QWidget* wid ) { | ||
65 | if( ! IconWidth ) | ||
66 | return; | ||
67 | |||
68 | Receiver = wid; | ||
69 | IconNr = -1; | ||
70 | move( P.x()-IconWidth/2, P.y() - IconHeight/2 ); | ||
71 | // to initialize | ||
72 | Timer.start( DELAY - SPEED/NOOFICONS ); | ||
73 | } | ||
74 | |||
75 | void RoHFeedback::stop( void ) { | ||
76 | IconNr = -2; // stop | ||
77 | hide(); | ||
78 | Timer.stop(); | ||
79 | } | ||
80 | |||
81 | bool RoHFeedback::event( QEvent * E ) { | ||
82 | |||
83 | if( E->type() >= QEvent::MouseButtonPress && | ||
84 | E->type() <= QEvent::MouseMove ) { | ||
85 | // pass the event to the receiver with translated coord | ||
86 | QMouseEvent QME( ((QMouseEvent *)E)->type(), | ||
87 | Receiver->mapFromGlobal( | ||
88 | ((QMouseEvent *)E)->globalPos() ), | ||
89 | ((QMouseEvent *)E)->globalPos(), | ||
90 | ((QMouseEvent *)E)->button(), | ||
91 | ((QMouseEvent *)E)->state() | ||
92 | ); | ||
93 | return QPEApplication::sendEvent( Receiver, &QME ); | ||
94 | } | ||
95 | |||
96 | // first let the label treat the event | ||
97 | return QLabel::event( E ); | ||
98 | } | ||
99 | |||
100 | void RoHFeedback::iconShow( void ) { | ||
101 | switch( IconNr ) { | ||
102 | case FeedbackTimerStart: | ||
103 | IconNr = 0; | ||
104 | Timer.start( SPEED/NOOFICONS ); | ||
105 | break; | ||
106 | case FeedbackStopped: | ||
107 | // stopped | ||
108 | IconNr = FeedbackTimerStart; | ||
109 | hide(); | ||
110 | break; | ||
111 | case FeedbackShow: // first | ||
112 | show(); | ||
113 | // FT | ||
114 | default : | ||
115 | // show | ||
116 | |||
117 | setPixmap( *(Imgs[IconNr]) ); | ||
118 | setMask( *(Masks[IconNr]) ); | ||
119 | IconNr = (IconNr+1)%NOOFICONS; // rotate | ||
120 | break; | ||
121 | } | ||
122 | } | ||
123 | |||
124 | } | ||
125 | } \ No newline at end of file | ||
diff --git a/library/backend/rohfeedback.h b/library/backend/rohfeedback.h new file mode 100644 index 0000000..f38a095 --- a/dev/null +++ b/library/backend/rohfeedback.h | |||
@@ -0,0 +1,62 @@ | |||
1 | #ifndef ROHFEEDBACK_H | ||
2 | #define ROHFEEDBACK_H | ||
3 | |||
4 | /* | ||
5 | |||
6 | RightOnHold feedback show | ||
7 | |||
8 | */ | ||
9 | |||
10 | #define NOOFICONS 5 | ||
11 | |||
12 | #include <qlabel.h> | ||
13 | #include <qtimer.h> | ||
14 | |||
15 | class QEvent; | ||
16 | class QPixmap; | ||
17 | class QBitmap; | ||
18 | class QMouseEvent; | ||
19 | |||
20 | namespace Opie { | ||
21 | namespace Internal { | ||
22 | |||
23 | class RoHFeedback : public QLabel { | ||
24 | |||
25 | Q_OBJECT | ||
26 | |||
27 | enum Actions { | ||
28 | FeedbackStopped = -2, | ||
29 | FeedbackTimerStart = -1, | ||
30 | FeedbackShow = 0 | ||
31 | }; | ||
32 | public : | ||
33 | |||
34 | RoHFeedback(); | ||
35 | ~RoHFeedback(); | ||
36 | |||
37 | |||
38 | void init( const QPoint & P, QWidget* wid ); | ||
39 | void stop( void ); | ||
40 | int delay( void ); | ||
41 | |||
42 | public slots : | ||
43 | |||
44 | void iconShow( void ); | ||
45 | |||
46 | protected : | ||
47 | |||
48 | bool event( QEvent * E ); | ||
49 | |||
50 | QTimer Timer; | ||
51 | int IconNr; | ||
52 | QWidget * Receiver; | ||
53 | |||
54 | static int IconWidth; | ||
55 | static int IconHeight; | ||
56 | static QPixmap * Imgs[NOOFICONS]; | ||
57 | static QBitmap * Masks[NOOFICONS]; | ||
58 | }; | ||
59 | } | ||
60 | } | ||
61 | |||
62 | #endif | ||
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index 59ca61b..acad81d 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -1,686 +1,693 @@ | |||
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 | #define QTOPIA_INTERNAL_LANGLIST | 20 | #define QTOPIA_INTERNAL_LANGLIST |
21 | #include <stdlib.h> | 21 | #include <stdlib.h> |
22 | #include <unistd.h> | 22 | #include <unistd.h> |
23 | #ifndef Q_OS_MACX | 23 | #ifndef Q_OS_MACX |
24 | #include <linux/limits.h> // needed for some toolchains (PATH_MAX) | 24 | #include <linux/limits.h> // needed for some toolchains (PATH_MAX) |
25 | #endif | 25 | #endif |
26 | #include <qfile.h> | 26 | #include <qfile.h> |
27 | #include <qqueue.h> | 27 | #include <qqueue.h> |
28 | #ifdef Q_WS_QWS | 28 | #ifdef Q_WS_QWS |
29 | #ifndef QT_NO_COP | 29 | #ifndef QT_NO_COP |
30 | #if QT_VERSION <= 231 | 30 | #if QT_VERSION <= 231 |
31 | #define private public | 31 | #define private public |
32 | #define sendLocally processEvent | 32 | #define sendLocally processEvent |
33 | #include "qcopenvelope_qws.h" | 33 | #include "qcopenvelope_qws.h" |
34 | #undef private | 34 | #undef private |
35 | #else | 35 | #else |
36 | #include "qcopenvelope_qws.h" | 36 | #include "qcopenvelope_qws.h" |
37 | #endif | 37 | #endif |
38 | #endif | 38 | #endif |
39 | #include <qwindowsystem_qws.h> | 39 | #include <qwindowsystem_qws.h> |
40 | #endif | 40 | #endif |
41 | #include <qtextstream.h> | 41 | #include <qtextstream.h> |
42 | #include <qpalette.h> | 42 | #include <qpalette.h> |
43 | #include <qbuffer.h> | 43 | #include <qbuffer.h> |
44 | #include <qptrdict.h> | 44 | #include <qptrdict.h> |
45 | #include <qregexp.h> | 45 | #include <qregexp.h> |
46 | #include <qdir.h> | 46 | #include <qdir.h> |
47 | #include <qlabel.h> | 47 | #include <qlabel.h> |
48 | #include <qdialog.h> | 48 | #include <qdialog.h> |
49 | #include <qdragobject.h> | 49 | #include <qdragobject.h> |
50 | #include <qtextcodec.h> | 50 | #include <qtextcodec.h> |
51 | #include <qevent.h> | 51 | #include <qevent.h> |
52 | #include <qtooltip.h> | 52 | #include <qtooltip.h> |
53 | #include <qsignal.h> | 53 | #include <qsignal.h> |
54 | #include <qmainwindow.h> | 54 | #include <qmainwindow.h> |
55 | #include <qwidgetlist.h> | 55 | #include <qwidgetlist.h> |
56 | #include <qpixmapcache.h> | 56 | #include <qpixmapcache.h> |
57 | 57 | ||
58 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 58 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
59 | #define QTOPIA_INTERNAL_INITAPP | 59 | #define QTOPIA_INTERNAL_INITAPP |
60 | #include "qpeapplication.h" | 60 | #include "qpeapplication.h" |
61 | #include "qpestyle.h" | 61 | #include "qpestyle.h" |
62 | #include "styleinterface.h" | 62 | #include "styleinterface.h" |
63 | #if QT_VERSION >= 300 | 63 | #if QT_VERSION >= 300 |
64 | #include <qstylefactory.h> | 64 | #include <qstylefactory.h> |
65 | #else | 65 | #else |
66 | #include <qplatinumstyle.h> | 66 | #include <qplatinumstyle.h> |
67 | #include <qwindowsstyle.h> | 67 | #include <qwindowsstyle.h> |
68 | #include <qmotifstyle.h> | 68 | #include <qmotifstyle.h> |
69 | #include <qmotifplusstyle.h> | 69 | #include <qmotifplusstyle.h> |
70 | #include "lightstyle.h" | 70 | #include "lightstyle.h" |
71 | 71 | ||
72 | #include <qpe/qlibrary.h> | 72 | #include <qpe/qlibrary.h> |
73 | #endif | 73 | #endif |
74 | #include "global.h" | 74 | #include "global.h" |
75 | #include "resource.h" | 75 | #include "resource.h" |
76 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) | 76 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) |
77 | #include "qutfcodec.h" | 77 | #include "qutfcodec.h" |
78 | #endif | 78 | #endif |
79 | #include "config.h" | 79 | #include "config.h" |
80 | #include "network.h" | 80 | #include "network.h" |
81 | #ifdef QWS | 81 | #ifdef QWS |
82 | #include "fontmanager.h" | 82 | #include "fontmanager.h" |
83 | #include "fontdatabase.h" | 83 | #include "fontdatabase.h" |
84 | #endif | 84 | #endif |
85 | 85 | ||
86 | #include "alarmserver.h" | 86 | #include "alarmserver.h" |
87 | #include "applnk.h" | 87 | #include "applnk.h" |
88 | #include "qpemenubar.h" | 88 | #include "qpemenubar.h" |
89 | #include "textcodecinterface.h" | 89 | #include "textcodecinterface.h" |
90 | #include "imagecodecinterface.h" | 90 | #include "imagecodecinterface.h" |
91 | 91 | ||
92 | #include <unistd.h> | 92 | #include <unistd.h> |
93 | #include <sys/file.h> | 93 | #include <sys/file.h> |
94 | #include <sys/ioctl.h> | 94 | #include <sys/ioctl.h> |
95 | #ifndef QT_NO_SOUND | 95 | #ifndef QT_NO_SOUND |
96 | #include <sys/soundcard.h> | 96 | #include <sys/soundcard.h> |
97 | #endif | 97 | #endif |
98 | #include "qt_override_p.h" | 98 | #include "qt_override_p.h" |
99 | 99 | ||
100 | #include <qpe/rohfeedback.h> | ||
101 | |||
102 | |||
100 | static bool useBigPixmaps = 0; | 103 | static bool useBigPixmaps = 0; |
101 | 104 | ||
105 | |||
102 | class HackWidget : public QWidget | 106 | class HackWidget : public QWidget |
103 | { | 107 | { |
104 | public: | 108 | public: |
105 | bool needsOk() | 109 | bool needsOk() |
106 | { return (getWState() & WState_Reserved1 ); } | 110 | { return (getWState() & WState_Reserved1 ); } |
107 | 111 | ||
108 | QRect normalGeometry() | 112 | QRect normalGeometry() |
109 | { return topData()->normalGeometry; }; | 113 | { return topData()->normalGeometry; }; |
110 | }; | 114 | }; |
111 | 115 | ||
112 | class QPEApplicationData | 116 | class QPEApplicationData |
113 | { | 117 | { |
114 | public: | 118 | public: |
115 | QPEApplicationData ( ) | 119 | QPEApplicationData ( ) |
116 | : presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ), | 120 | : presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ), |
117 | notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ), | 121 | notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ), |
118 | keep_running( true ), qcopQok( false ), | 122 | keep_running( true ), qcopQok( false ), |
119 | fontFamily( "Vera" ), fontSize( 10 ), smallIconSize( 14 ), | 123 | fontFamily( "Vera" ), fontSize( 10 ), smallIconSize( 14 ), |
120 | bigIconSize( 32 ), qpe_main_widget( 0 ) | 124 | bigIconSize( 32 ), qpe_main_widget( 0 ) |
121 | { | 125 | { |
122 | Config cfg( "qpe" ); | 126 | Config cfg( "qpe" ); |
123 | cfg.setGroup( "Appearance" ); | 127 | cfg.setGroup( "Appearance" ); |
124 | useBigPixmaps = cfg.readBoolEntry( "useBigPixmaps", false ); | 128 | useBigPixmaps = cfg.readBoolEntry( "useBigPixmaps", false ); |
125 | fontFamily = cfg.readEntry( "FontFamily", "Vera" ); | 129 | fontFamily = cfg.readEntry( "FontFamily", "Vera" ); |
126 | fontSize = cfg.readNumEntry( "FontSize", 10 ); | 130 | fontSize = cfg.readNumEntry( "FontSize", 10 ); |
127 | smallIconSize = cfg.readNumEntry( "SmallIconSize", 14 ); | 131 | smallIconSize = cfg.readNumEntry( "SmallIconSize", 14 ); |
128 | bigIconSize = cfg.readNumEntry( "BigIconSize", 32 ); | 132 | bigIconSize = cfg.readNumEntry( "BigIconSize", 32 ); |
133 | RoH = 0; | ||
129 | } | 134 | } |
130 | 135 | ||
131 | int presstimer; | 136 | int presstimer; |
132 | QWidget* presswidget; | 137 | QWidget* presswidget; |
133 | QPoint presspos; | 138 | QPoint presspos; |
134 | 139 | ||
135 | bool rightpressed : 1; | 140 | bool rightpressed : 1; |
136 | bool kbgrabbed : 1; | 141 | bool kbgrabbed : 1; |
137 | bool notbusysent : 1; | 142 | bool notbusysent : 1; |
138 | bool preloaded : 1; | 143 | bool preloaded : 1; |
139 | bool forceshow : 1; | 144 | bool forceshow : 1; |
140 | bool nomaximize : 1; | 145 | bool nomaximize : 1; |
141 | bool keep_running : 1; | 146 | bool keep_running : 1; |
142 | bool qcopQok : 1; | 147 | bool qcopQok : 1; |
143 | 148 | ||
144 | QCString fontFamily; | 149 | QCString fontFamily; |
145 | int fontSize; | 150 | int fontSize; |
146 | int smallIconSize; | 151 | int smallIconSize; |
147 | int bigIconSize; | 152 | int bigIconSize; |
148 | 153 | ||
149 | QStringList langs; | 154 | QStringList langs; |
150 | QString appName; | 155 | QString appName; |
151 | struct QCopRec | 156 | struct QCopRec |
152 | { | 157 | { |
153 | QCopRec( const QCString &ch, const QCString &msg, | 158 | QCopRec( const QCString &ch, const QCString &msg, |
154 | const QByteArray &d ) : | 159 | const QByteArray &d ) : |
155 | channel( ch ), message( msg ), data( d ) | 160 | channel( ch ), message( msg ), data( d ) |
156 | { } | 161 | { } |
157 | 162 | ||
158 | QCString channel; | 163 | QCString channel; |
159 | QCString message; | 164 | QCString message; |
160 | QByteArray data; | 165 | QByteArray data; |
161 | }; | 166 | }; |
162 | QWidget* qpe_main_widget; | 167 | QWidget* qpe_main_widget; |
163 | QGuardedPtr<QWidget> lastraised; | 168 | QGuardedPtr<QWidget> lastraised; |
164 | QQueue<QCopRec> qcopq; | 169 | QQueue<QCopRec> qcopq; |
165 | QString styleName; | 170 | QString styleName; |
166 | QString decorationName; | 171 | QString decorationName; |
167 | 172 | ||
168 | void enqueueQCop( const QCString &ch, const QCString &msg, | 173 | void enqueueQCop( const QCString &ch, const QCString &msg, |
169 | const QByteArray &data ) | 174 | const QByteArray &data ) |
170 | { | 175 | { |
171 | qcopq.enqueue( new QCopRec( ch, msg, data ) ); | 176 | qcopq.enqueue( new QCopRec( ch, msg, data ) ); |
172 | } | 177 | } |
173 | void sendQCopQ() | 178 | void sendQCopQ() |
174 | { | 179 | { |
175 | if (!qcopQok ) | 180 | if (!qcopQok ) |
176 | return; | 181 | return; |
177 | 182 | ||
178 | QCopRec * r; | 183 | QCopRec * r; |
179 | 184 | ||
180 | while((r=qcopq.dequeue())) { | 185 | while((r=qcopq.dequeue())) { |
181 | // remove from queue before sending... | 186 | // remove from queue before sending... |
182 | // event loop can come around again before getting | 187 | // event loop can come around again before getting |
183 | // back from sendLocally | 188 | // back from sendLocally |
184 | #ifndef QT_NO_COP | 189 | #ifndef QT_NO_COP |
185 | QCopChannel::sendLocally( r->channel, r->message, r->data ); | 190 | QCopChannel::sendLocally( r->channel, r->message, r->data ); |
186 | #endif | 191 | #endif |
187 | 192 | ||
188 | delete r; | 193 | delete r; |
189 | } | 194 | } |
190 | } | 195 | } |
191 | 196 | ||
192 | static void show_mx(QWidget* mw, bool nomaximize, QString &strName) | 197 | static void show_mx(QWidget* mw, bool nomaximize, QString &strName) |
193 | { | 198 | { |
194 | if ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) | 199 | if ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) |
195 | { | 200 | { |
196 | ( ( QMainWindow* ) mw )->setUsesBigPixmaps( useBigPixmaps ); | 201 | ( ( QMainWindow* ) mw )->setUsesBigPixmaps( useBigPixmaps ); |
197 | } | 202 | } |
198 | QPoint p; | 203 | QPoint p; |
199 | QSize s; | 204 | QSize s; |
200 | bool max; | 205 | bool max; |
201 | if ( mw->isVisible() ) { | 206 | if ( mw->isVisible() ) { |
202 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { | 207 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { |
203 | mw->resize(s); | 208 | mw->resize(s); |
204 | mw->move(p); | 209 | mw->move(p); |
205 | } | 210 | } |
206 | mw->raise(); | 211 | mw->raise(); |
207 | } else { | 212 | } else { |
208 | 213 | ||
209 | if ( mw->layout() && mw->inherits("QDialog") ) { | 214 | if ( mw->layout() && mw->inherits("QDialog") ) { |
210 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { | 215 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { |
211 | mw->resize(s); | 216 | mw->resize(s); |
212 | mw->move(p); | 217 | mw->move(p); |
213 | 218 | ||
214 | if ( max && !nomaximize ) { | 219 | if ( max && !nomaximize ) { |
215 | mw->showMaximized(); | 220 | mw->showMaximized(); |
216 | } else { | 221 | } else { |
217 | mw->show(); | 222 | mw->show(); |
218 | } | 223 | } |
219 | } else { | 224 | } else { |
220 | qpe_show_dialog((QDialog*)mw,nomaximize); | 225 | qpe_show_dialog((QDialog*)mw,nomaximize); |
221 | } | 226 | } |
222 | } else { | 227 | } else { |
223 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { | 228 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { |
224 | mw->resize(s); | 229 | mw->resize(s); |
225 | mw->move(p); | 230 | mw->move(p); |
226 | } else { //no stored rectangle, make an estimation | 231 | } else { //no stored rectangle, make an estimation |
227 | int x = (qApp->desktop()->width()-mw->frameGeometry().width())/2; | 232 | int x = (qApp->desktop()->width()-mw->frameGeometry().width())/2; |
228 | int y = (qApp->desktop()->height()-mw->frameGeometry().height())/2; | 233 | int y = (qApp->desktop()->height()-mw->frameGeometry().height())/2; |
229 | mw->move( QMAX(x,0), QMAX(y,0) ); | 234 | mw->move( QMAX(x,0), QMAX(y,0) ); |
230 | #ifdef Q_WS_QWS | 235 | #ifdef Q_WS_QWS |
231 | if ( !nomaximize ) | 236 | if ( !nomaximize ) |
232 | mw->showMaximized(); | 237 | mw->showMaximized(); |
233 | #endif | 238 | #endif |
234 | } | 239 | } |
235 | if ( max && !nomaximize ) | 240 | if ( max && !nomaximize ) |
236 | mw->showMaximized(); | 241 | mw->showMaximized(); |
237 | else | 242 | else |
238 | mw->show(); | 243 | mw->show(); |
239 | } | 244 | } |
240 | } | 245 | } |
241 | } | 246 | } |
242 | 247 | ||
243 | static void qpe_show_dialog( QDialog* d, bool nomax ) | 248 | static void qpe_show_dialog( QDialog* d, bool nomax ) |
244 | { | 249 | { |
245 | QSize sh = d->sizeHint(); | 250 | QSize sh = d->sizeHint(); |
246 | int w = QMAX(sh.width(),d->width()); | 251 | int w = QMAX(sh.width(),d->width()); |
247 | int h = QMAX(sh.height(),d->height()); | 252 | int h = QMAX(sh.height(),d->height()); |
248 | 253 | ||
249 | if ( d->parentWidget() && !d->parentWidget()->topLevelWidget()->isMaximized() ) | 254 | if ( d->parentWidget() && !d->parentWidget()->topLevelWidget()->isMaximized() ) |
250 | nomax = TRUE; | 255 | nomax = TRUE; |
251 | 256 | ||
252 | #ifndef Q_WS_QWS | 257 | #ifndef Q_WS_QWS |
253 | QSize s(qApp->desktop()->width(), qApp->desktop()->height() ); | 258 | QSize s(qApp->desktop()->width(), qApp->desktop()->height() ); |
254 | #else | 259 | #else |
255 | QSize s(qt_maxWindowRect.width(), qt_maxWindowRect.height() ); | 260 | QSize s(qt_maxWindowRect.width(), qt_maxWindowRect.height() ); |
256 | #endif | 261 | #endif |
257 | 262 | ||
258 | int maxX = s.width() - (d->frameGeometry().width() - d->geometry().width()); | 263 | int maxX = s.width() - (d->frameGeometry().width() - d->geometry().width()); |
259 | int maxY = s.height() - (d->frameGeometry().height() - d->geometry().height()); | 264 | int maxY = s.height() - (d->frameGeometry().height() - d->geometry().height()); |
260 | 265 | ||
261 | if ( (w >= maxX && h >= maxY) || ( (!nomax) && ( w > s.width()*3/4 || h > s.height()*3/4 ) ) ) { | 266 | if ( (w >= maxX && h >= maxY) || ( (!nomax) && ( w > s.width()*3/4 || h > s.height()*3/4 ) ) ) { |
262 | d->showMaximized(); | 267 | d->showMaximized(); |
263 | } else { | 268 | } else { |
264 | // try centering the dialog around its parent | 269 | // try centering the dialog around its parent |
265 | QPoint p(0,0); | 270 | QPoint p(0,0); |
266 | if ( d->parentWidget() ) { | 271 | if ( d->parentWidget() ) { |
267 | QPoint pp = d->parentWidget()->mapToGlobal( QPoint(0,0) ); | 272 | QPoint pp = d->parentWidget()->mapToGlobal( QPoint(0,0) ); |
268 | p = QPoint( pp.x() + d->parentWidget()->width()/2, | 273 | p = QPoint( pp.x() + d->parentWidget()->width()/2, |
269 | pp.y() + d->parentWidget()->height()/ 2 ); | 274 | pp.y() + d->parentWidget()->height()/ 2 ); |
270 | } else { | 275 | } else { |
271 | p = QPoint( maxX/2, maxY/2 ); | 276 | p = QPoint( maxX/2, maxY/2 ); |
272 | } | 277 | } |
273 | 278 | ||
274 | p = QPoint( p.x() - w/2, p.y() - h/2 ); | 279 | p = QPoint( p.x() - w/2, p.y() - h/2 ); |
275 | // qDebug("p(x,y) is %d %d", p.x(), p.y() ); | 280 | // qDebug("p(x,y) is %d %d", p.x(), p.y() ); |
276 | 281 | ||
277 | if ( w >= maxX ) { | 282 | if ( w >= maxX ) { |
278 | if ( p.y() < 0 ) | 283 | if ( p.y() < 0 ) |
279 | p.setY(0); | 284 | p.setY(0); |
280 | if ( p.y() + h > maxY ) | 285 | if ( p.y() + h > maxY ) |
281 | p.setY( maxY - h); | 286 | p.setY( maxY - h); |
282 | 287 | ||
283 | d->resize(maxX, h); | 288 | d->resize(maxX, h); |
284 | d->move(0, p.y() ); | 289 | d->move(0, p.y() ); |
285 | } else if ( h >= maxY ) { | 290 | } else if ( h >= maxY ) { |
286 | if ( p.x() < 0 ) | 291 | if ( p.x() < 0 ) |
287 | p.setX(0); | 292 | p.setX(0); |
288 | if ( p.x() + w > maxX ) | 293 | if ( p.x() + w > maxX ) |
289 | p.setX( maxX - w); | 294 | p.setX( maxX - w); |
290 | 295 | ||
291 | d->resize(w, maxY); | 296 | d->resize(w, maxY); |
292 | d->move(p.x(),0); | 297 | d->move(p.x(),0); |
293 | } else { | 298 | } else { |
294 | d->resize(w, h); | 299 | d->resize(w, h); |
295 | } | 300 | } |
296 | 301 | ||
297 | d->show(); | 302 | d->show(); |
298 | } | 303 | } |
299 | } | 304 | } |
300 | 305 | ||
301 | static bool read_widget_rect(const QString &app, bool &maximized, QPoint &p, QSize &s) | 306 | static bool read_widget_rect(const QString &app, bool &maximized, QPoint &p, QSize &s) |
302 | { | 307 | { |
303 | maximized = TRUE; | 308 | maximized = TRUE; |
304 | // 350 is the trigger in qwsdefaultdecoration for providing a resize button | 309 | // 350 is the trigger in qwsdefaultdecoration for providing a resize button |
305 | if ( qApp->desktop()->width() <= 350 ) | 310 | if ( qApp->desktop()->width() <= 350 ) |
306 | return FALSE; | 311 | return FALSE; |
307 | 312 | ||
308 | Config cfg( "qpe" ); | 313 | Config cfg( "qpe" ); |
309 | cfg.setGroup("ApplicationPositions"); | 314 | cfg.setGroup("ApplicationPositions"); |
310 | QString str = cfg.readEntry( app, QString::null ); | 315 | QString str = cfg.readEntry( app, QString::null ); |
311 | QStringList l = QStringList::split(",", str); | 316 | QStringList l = QStringList::split(",", str); |
312 | 317 | ||
313 | if ( l.count() == 5) { | 318 | if ( l.count() == 5) { |
314 | p.setX( l[0].toInt() ); | 319 | p.setX( l[0].toInt() ); |
315 | p.setY( l[1].toInt() ); | 320 | p.setY( l[1].toInt() ); |
316 | 321 | ||
317 | s.setWidth( l[2].toInt() ); | 322 | s.setWidth( l[2].toInt() ); |
318 | s.setHeight( l[3].toInt() ); | 323 | s.setHeight( l[3].toInt() ); |
319 | 324 | ||
320 | maximized = l[4].toInt(); | 325 | maximized = l[4].toInt(); |
321 | 326 | ||
322 | return TRUE; | 327 | return TRUE; |
323 | } | 328 | } |
324 | 329 | ||
325 | return FALSE; | 330 | return FALSE; |
326 | } | 331 | } |
327 | 332 | ||
328 | 333 | ||
329 | static bool validate_widget_size(const QWidget *w, QPoint &p, QSize &s) | 334 | static bool validate_widget_size(const QWidget *w, QPoint &p, QSize &s) |
330 | { | 335 | { |
331 | #ifndef Q_WS_QWS | 336 | #ifndef Q_WS_QWS |
332 | QRect qt_maxWindowRect = qApp->desktop()->geometry(); | 337 | QRect qt_maxWindowRect = qApp->desktop()->geometry(); |
333 | #endif | 338 | #endif |
334 | int maxX = qt_maxWindowRect.width(); | 339 | int maxX = qt_maxWindowRect.width(); |
335 | int maxY = qt_maxWindowRect.height(); | 340 | int maxY = qt_maxWindowRect.height(); |
336 | int wWidth = s.width() + ( w->frameGeometry().width() - w->geometry().width() ); | 341 | int wWidth = s.width() + ( w->frameGeometry().width() - w->geometry().width() ); |
337 | int wHeight = s.height() + ( w->frameGeometry().height() - w->geometry().height() ); | 342 | int wHeight = s.height() + ( w->frameGeometry().height() - w->geometry().height() ); |
338 | 343 | ||
339 | // total window size is not allowed to be larger than desktop window size | 344 | // total window size is not allowed to be larger than desktop window size |
340 | if ( ( wWidth >= maxX ) && ( wHeight >= maxY ) ) | 345 | if ( ( wWidth >= maxX ) && ( wHeight >= maxY ) ) |
341 | return FALSE; | 346 | return FALSE; |
342 | 347 | ||
343 | if ( wWidth > maxX ) { | 348 | if ( wWidth > maxX ) { |
344 | s.setWidth( maxX - (w->frameGeometry().width() - w->geometry().width() ) ); | 349 | s.setWidth( maxX - (w->frameGeometry().width() - w->geometry().width() ) ); |
345 | wWidth = maxX; | 350 | wWidth = maxX; |
346 | } | 351 | } |
347 | 352 | ||
348 | if ( wHeight > maxY ) { | 353 | if ( wHeight > maxY ) { |
349 | s.setHeight( maxY - (w->frameGeometry().height() - w->geometry().height() ) ); | 354 | s.setHeight( maxY - (w->frameGeometry().height() - w->geometry().height() ) ); |
350 | wHeight = maxY; | 355 | wHeight = maxY; |
351 | } | 356 | } |
352 | 357 | ||
353 | // any smaller than this and the maximize/close/help buttons will be overlapping | 358 | // any smaller than this and the maximize/close/help buttons will be overlapping |
354 | if ( wWidth < 80 || wHeight < 60 ) | 359 | if ( wWidth < 80 || wHeight < 60 ) |
355 | return FALSE; | 360 | return FALSE; |
356 | 361 | ||
357 | if ( p.x() < 0 ) | 362 | if ( p.x() < 0 ) |
358 | p.setX(0); | 363 | p.setX(0); |
359 | if ( p.y() < 0 ) | 364 | if ( p.y() < 0 ) |
360 | p.setY(0); | 365 | p.setY(0); |
361 | 366 | ||
362 | if ( p.x() + wWidth > maxX ) | 367 | if ( p.x() + wWidth > maxX ) |
363 | p.setX( maxX - wWidth ); | 368 | p.setX( maxX - wWidth ); |
364 | if ( p.y() + wHeight > maxY ) | 369 | if ( p.y() + wHeight > maxY ) |
365 | p.setY( maxY - wHeight ); | 370 | p.setY( maxY - wHeight ); |
366 | 371 | ||
367 | return TRUE; | 372 | return TRUE; |
368 | } | 373 | } |
369 | 374 | ||
370 | static void store_widget_rect(QWidget *w, QString &app) | 375 | static void store_widget_rect(QWidget *w, QString &app) |
371 | { | 376 | { |
372 | // 350 is the trigger in qwsdefaultdecoration for providing a resize button | 377 | // 350 is the trigger in qwsdefaultdecoration for providing a resize button |
373 | if ( qApp->desktop()->width() <= 350 ) | 378 | if ( qApp->desktop()->width() <= 350 ) |
374 | return; | 379 | return; |
375 | // we use these to map the offset of geometry and pos. ( we can only use normalGeometry to | 380 | // we use these to map the offset of geometry and pos. ( we can only use normalGeometry to |
376 | // get the non-maximized version, so we have to do it the hard way ) | 381 | // get the non-maximized version, so we have to do it the hard way ) |
377 | int offsetX = w->x() - w->geometry().left(); | 382 | int offsetX = w->x() - w->geometry().left(); |
378 | int offsetY = w->y() - w->geometry().top(); | 383 | int offsetY = w->y() - w->geometry().top(); |
379 | 384 | ||
380 | QRect r; | 385 | QRect r; |
381 | if ( w->isMaximized() ) | 386 | if ( w->isMaximized() ) |
382 | r = ( (HackWidget *) w)->normalGeometry(); | 387 | r = ( (HackWidget *) w)->normalGeometry(); |
383 | else | 388 | else |
384 | r = w->geometry(); | 389 | r = w->geometry(); |
385 | 390 | ||
386 | // Stores the window placement as pos(), size() (due to the offset mapping) | 391 | // Stores the window placement as pos(), size() (due to the offset mapping) |
387 | Config cfg( "qpe" ); | 392 | Config cfg( "qpe" ); |
388 | cfg.setGroup("ApplicationPositions"); | 393 | cfg.setGroup("ApplicationPositions"); |
389 | QString s; | 394 | QString s; |
390 | s.sprintf("%d,%d,%d,%d,%d", r.left() + offsetX, r.top() + offsetY, r.width(), r.height(), w->isMaximized() ); | 395 | s.sprintf("%d,%d,%d,%d,%d", r.left() + offsetX, r.top() + offsetY, r.width(), r.height(), w->isMaximized() ); |
391 | cfg.writeEntry( app, s ); | 396 | cfg.writeEntry( app, s ); |
392 | } | 397 | } |
393 | 398 | ||
394 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) | 399 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) |
395 | { | 400 | { |
396 | /* | 401 | /* |
397 | // This works but disable it for now until it is safe to apply | 402 | // This works but disable it for now until it is safe to apply |
398 | // What is does is scan the .desktop files of all the apps for | 403 | // What is does is scan the .desktop files of all the apps for |
399 | // the applnk that has the corresponding argv[0] as this program | 404 | // the applnk that has the corresponding argv[0] as this program |
400 | // then it uses the name stored in the .desktop file as the caption | 405 | // then it uses the name stored in the .desktop file as the caption |
401 | // for the main widget. This saves duplicating translations for | 406 | // for the main widget. This saves duplicating translations for |
402 | // the app name in the program and in the .desktop files. | 407 | // the app name in the program and in the .desktop files. |
403 | 408 | ||
404 | AppLnkSet apps( appsPath ); | 409 | AppLnkSet apps( appsPath ); |
405 | 410 | ||
406 | QList<AppLnk> appsList = apps.children(); | 411 | QList<AppLnk> appsList = apps.children(); |
407 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { | 412 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { |
408 | if ( (*it)->exec() == appName ) { | 413 | if ( (*it)->exec() == appName ) { |
409 | mw->setCaption( (*it)->name() ); | 414 | mw->setCaption( (*it)->name() ); |
410 | return TRUE; | 415 | return TRUE; |
411 | } | 416 | } |
412 | } | 417 | } |
413 | */ | 418 | */ |
414 | return FALSE; | 419 | return FALSE; |
415 | } | 420 | } |
416 | 421 | ||
417 | 422 | ||
418 | void show(QWidget* mw, bool nomax) | 423 | void show(QWidget* mw, bool nomax) |
419 | { | 424 | { |
420 | setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); | 425 | setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); |
421 | nomaximize = nomax; | 426 | nomaximize = nomax; |
422 | qpe_main_widget = mw; | 427 | qpe_main_widget = mw; |
423 | qcopQok = TRUE; | 428 | qcopQok = TRUE; |
424 | #ifndef QT_NO_COP | 429 | #ifndef QT_NO_COP |
425 | 430 | ||
426 | sendQCopQ(); | 431 | sendQCopQ(); |
427 | #endif | 432 | #endif |
428 | 433 | ||
429 | if ( preloaded ) { | 434 | if ( preloaded ) { |
430 | if (forceshow) | 435 | if (forceshow) |
431 | show_mx(mw, nomax, appName); | 436 | show_mx(mw, nomax, appName); |
432 | } | 437 | } |
433 | else if ( keep_running ) { | 438 | else if ( keep_running ) { |
434 | show_mx(mw, nomax, appName); | 439 | show_mx(mw, nomax, appName); |
435 | } | 440 | } |
436 | } | 441 | } |
437 | 442 | ||
438 | void loadTextCodecs() | 443 | void loadTextCodecs() |
439 | { | 444 | { |
440 | QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; | 445 | QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; |
441 | #ifdef Q_OS_MACX | 446 | #ifdef Q_OS_MACX |
442 | QDir dir( path, "lib*.dylib" ); | 447 | QDir dir( path, "lib*.dylib" ); |
443 | #else | 448 | #else |
444 | QDir dir( path, "lib*.so" ); | 449 | QDir dir( path, "lib*.so" ); |
445 | #endif | 450 | #endif |
446 | QStringList list; | 451 | QStringList list; |
447 | if ( dir. exists ( )) | 452 | if ( dir. exists ( )) |
448 | list = dir.entryList(); | 453 | list = dir.entryList(); |
449 | QStringList::Iterator it; | 454 | QStringList::Iterator it; |
450 | for ( it = list.begin(); it != list.end(); ++it ) { | 455 | for ( it = list.begin(); it != list.end(); ++it ) { |
451 | TextCodecInterface *iface = 0; | 456 | TextCodecInterface *iface = 0; |
452 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 457 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
453 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 458 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
454 | QValueList<int> mibs = iface->mibEnums(); | 459 | QValueList<int> mibs = iface->mibEnums(); |
455 | for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { | 460 | for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { |
456 | (void)iface->createForMib(*i); | 461 | (void)iface->createForMib(*i); |
457 | // ### it exists now; need to remember if we can delete it | 462 | // ### it exists now; need to remember if we can delete it |
458 | } | 463 | } |
459 | } | 464 | } |
460 | else { | 465 | else { |
461 | lib->unload(); | 466 | lib->unload(); |
462 | delete lib; | 467 | delete lib; |
463 | } | 468 | } |
464 | } | 469 | } |
465 | } | 470 | } |
466 | 471 | ||
467 | void loadImageCodecs() | 472 | void loadImageCodecs() |
468 | { | 473 | { |
469 | QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; | 474 | QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; |
470 | #ifdef Q_OS_MACX | 475 | #ifdef Q_OS_MACX |
471 | QDir dir( path, "lib*.dylib" ); | 476 | QDir dir( path, "lib*.dylib" ); |
472 | #else | 477 | #else |
473 | QDir dir( path, "lib*.so" ); | 478 | QDir dir( path, "lib*.so" ); |
474 | #endif | 479 | #endif |
475 | QStringList list; | 480 | QStringList list; |
476 | if ( dir. exists ( )) | 481 | if ( dir. exists ( )) |
477 | list = dir.entryList(); | 482 | list = dir.entryList(); |
478 | QStringList::Iterator it; | 483 | QStringList::Iterator it; |
479 | for ( it = list.begin(); it != list.end(); ++it ) { | 484 | for ( it = list.begin(); it != list.end(); ++it ) { |
480 | ImageCodecInterface *iface = 0; | 485 | ImageCodecInterface *iface = 0; |
481 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 486 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
482 | if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 487 | if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
483 | QStringList formats = iface->keys(); | 488 | QStringList formats = iface->keys(); |
484 | for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { | 489 | for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { |
485 | (void)iface->installIOHandler(*i); | 490 | (void)iface->installIOHandler(*i); |
486 | // ### it exists now; need to remember if we can delete it | 491 | // ### it exists now; need to remember if we can delete it |
487 | } | 492 | } |
488 | } | 493 | } |
489 | else { | 494 | else { |
490 | lib->unload(); | 495 | lib->unload(); |
491 | delete lib; | 496 | delete lib; |
492 | } | 497 | } |
493 | } | 498 | } |
494 | } | 499 | } |
500 | |||
501 | Opie::Internal::RoHFeedback * RoH; | ||
495 | }; | 502 | }; |
496 | 503 | ||
497 | class ResourceMimeFactory : public QMimeSourceFactory | 504 | class ResourceMimeFactory : public QMimeSourceFactory |
498 | { | 505 | { |
499 | public: | 506 | public: |
500 | ResourceMimeFactory() : resImage( 0 ) | 507 | ResourceMimeFactory() : resImage( 0 ) |
501 | { | 508 | { |
502 | setFilePath( Global::helpPath() ); | 509 | setFilePath( Global::helpPath() ); |
503 | setExtensionType( "html", "text/html;charset=UTF-8" ); | 510 | setExtensionType( "html", "text/html;charset=UTF-8" ); |
504 | } | 511 | } |
505 | ~ResourceMimeFactory() { | 512 | ~ResourceMimeFactory() { |
506 | delete resImage; | 513 | delete resImage; |
507 | } | 514 | } |
508 | 515 | ||
509 | const QMimeSource* data( const QString& abs_name ) const | 516 | const QMimeSource* data( const QString& abs_name ) const |
510 | { | 517 | { |
511 | const QMimeSource * r = QMimeSourceFactory::data( abs_name ); | 518 | const QMimeSource * r = QMimeSourceFactory::data( abs_name ); |
512 | if ( !r ) { | 519 | if ( !r ) { |
513 | int sl = abs_name.length(); | 520 | int sl = abs_name.length(); |
514 | do { | 521 | do { |
515 | sl = abs_name.findRev( '/', sl - 1 ); | 522 | sl = abs_name.findRev( '/', sl - 1 ); |
516 | QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; | 523 | QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; |
517 | int dot = name.findRev( '.' ); | 524 | int dot = name.findRev( '.' ); |
518 | if ( dot >= 0 ) | 525 | if ( dot >= 0 ) |
519 | name = name.left( dot ); | 526 | name = name.left( dot ); |
520 | QImage img = Resource::loadImage( name ); | 527 | QImage img = Resource::loadImage( name ); |
521 | if ( !img.isNull() ) { | 528 | if ( !img.isNull() ) { |
522 | delete resImage; | 529 | delete resImage; |
523 | resImage = new QImageDrag( img ); | 530 | resImage = new QImageDrag( img ); |
524 | r = resImage; | 531 | r = resImage; |
525 | } | 532 | } |
526 | } | 533 | } |
527 | while ( !r && sl > 0 ); | 534 | while ( !r && sl > 0 ); |
528 | } | 535 | } |
529 | return r; | 536 | return r; |
530 | } | 537 | } |
531 | private: | 538 | private: |
532 | mutable QImageDrag *resImage; | 539 | mutable QImageDrag *resImage; |
533 | }; | 540 | }; |
534 | 541 | ||
535 | static int& hack(int& i) | 542 | static int& hack(int& i) |
536 | { | 543 | { |
537 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) | 544 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) |
538 | // These should be created, but aren't in Qt 2.3.0 | 545 | // These should be created, but aren't in Qt 2.3.0 |
539 | (void)new QUtf8Codec; | 546 | (void)new QUtf8Codec; |
540 | (void)new QUtf16Codec; | 547 | (void)new QUtf16Codec; |
541 | #endif | 548 | #endif |
542 | return i; | 549 | return i; |
543 | } | 550 | } |
544 | 551 | ||
545 | static int muted = 0; | 552 | static int muted = 0; |
546 | static int micMuted = 0; | 553 | static int micMuted = 0; |
547 | 554 | ||
548 | static void setVolume( int t = 0, int percent = -1 ) | 555 | static void setVolume( int t = 0, int percent = -1 ) |
549 | { | 556 | { |
550 | switch ( t ) { | 557 | switch ( t ) { |
551 | case 0: { | 558 | case 0: { |
552 | Config cfg( "qpe" ); | 559 | Config cfg( "qpe" ); |
553 | cfg.setGroup( "Volume" ); | 560 | cfg.setGroup( "Volume" ); |
554 | if ( percent < 0 ) | 561 | if ( percent < 0 ) |
555 | percent = cfg.readNumEntry( "VolumePercent", 50 ); | 562 | percent = cfg.readNumEntry( "VolumePercent", 50 ); |
556 | #ifndef QT_NO_SOUND | 563 | #ifndef QT_NO_SOUND |
557 | int fd = 0; | 564 | int fd = 0; |
558 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 565 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
559 | int vol = muted ? 0 : percent; | 566 | int vol = muted ? 0 : percent; |
560 | // set both channels to same volume | 567 | // set both channels to same volume |
561 | vol |= vol << 8; | 568 | vol |= vol << 8; |
562 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_VOLUME ), &vol ); | 569 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_VOLUME ), &vol ); |
563 | ::close( fd ); | 570 | ::close( fd ); |
564 | } | 571 | } |
565 | #endif | 572 | #endif |
566 | } | 573 | } |
567 | break; | 574 | break; |
568 | } | 575 | } |
569 | } | 576 | } |
570 | 577 | ||
571 | static void setMic( int t = 0, int percent = -1 ) | 578 | static void setMic( int t = 0, int percent = -1 ) |
572 | { | 579 | { |
573 | switch ( t ) { | 580 | switch ( t ) { |
574 | case 0: { | 581 | case 0: { |
575 | Config cfg( "qpe" ); | 582 | Config cfg( "qpe" ); |
576 | cfg.setGroup( "Volume" ); | 583 | cfg.setGroup( "Volume" ); |
577 | if ( percent < 0 ) | 584 | if ( percent < 0 ) |
578 | percent = cfg.readNumEntry( "Mic", 50 ); | 585 | percent = cfg.readNumEntry( "Mic", 50 ); |
579 | 586 | ||
580 | #ifndef QT_NO_SOUND | 587 | #ifndef QT_NO_SOUND |
581 | int fd = 0; | 588 | int fd = 0; |
582 | int mic = micMuted ? 0 : percent; | 589 | int mic = micMuted ? 0 : percent; |
583 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 590 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
584 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); | 591 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); |
585 | ::close( fd ); | 592 | ::close( fd ); |
586 | } | 593 | } |
587 | #endif | 594 | #endif |
588 | } | 595 | } |
589 | break; | 596 | break; |
590 | } | 597 | } |
591 | } | 598 | } |
592 | 599 | ||
593 | 600 | ||
594 | static void setBass( int t = 0, int percent = -1 ) | 601 | static void setBass( int t = 0, int percent = -1 ) |
595 | { | 602 | { |
596 | switch ( t ) { | 603 | switch ( t ) { |
597 | case 0: { | 604 | case 0: { |
598 | Config cfg( "qpe" ); | 605 | Config cfg( "qpe" ); |
599 | cfg.setGroup( "Volume" ); | 606 | cfg.setGroup( "Volume" ); |
600 | if ( percent < 0 ) | 607 | if ( percent < 0 ) |
601 | percent = cfg.readNumEntry( "BassPercent", 50 ); | 608 | percent = cfg.readNumEntry( "BassPercent", 50 ); |
602 | 609 | ||
603 | #ifndef QT_NO_SOUND | 610 | #ifndef QT_NO_SOUND |
604 | int fd = 0; | 611 | int fd = 0; |
605 | int bass = percent; | 612 | int bass = percent; |
606 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 613 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
607 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass ); | 614 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass ); |
608 | ::close( fd ); | 615 | ::close( fd ); |
609 | } | 616 | } |
610 | #endif | 617 | #endif |
611 | } | 618 | } |
612 | break; | 619 | break; |
613 | } | 620 | } |
614 | } | 621 | } |
615 | 622 | ||
616 | 623 | ||
617 | static void setTreble( int t = 0, int percent = -1 ) | 624 | static void setTreble( int t = 0, int percent = -1 ) |
618 | { | 625 | { |
619 | switch ( t ) { | 626 | switch ( t ) { |
620 | case 0: { | 627 | case 0: { |
621 | Config cfg( "qpe" ); | 628 | Config cfg( "qpe" ); |
622 | cfg.setGroup( "Volume" ); | 629 | cfg.setGroup( "Volume" ); |
623 | if ( percent < 0 ) | 630 | if ( percent < 0 ) |
624 | percent = cfg.readNumEntry( "TreblePercent", 50 ); | 631 | percent = cfg.readNumEntry( "TreblePercent", 50 ); |
625 | 632 | ||
626 | #ifndef QT_NO_SOUND | 633 | #ifndef QT_NO_SOUND |
627 | int fd = 0; | 634 | int fd = 0; |
628 | int treble = percent; | 635 | int treble = percent; |
629 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 636 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
630 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble ); | 637 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble ); |
631 | ::close( fd ); | 638 | ::close( fd ); |
632 | } | 639 | } |
633 | #endif | 640 | #endif |
634 | } | 641 | } |
635 | break; | 642 | break; |
636 | } | 643 | } |
637 | } | 644 | } |
638 | 645 | ||
639 | 646 | ||
640 | /** | 647 | /** |
641 | \class QPEApplication | 648 | \class QPEApplication |
642 | \brief The QPEApplication class implements various system services | 649 | \brief The QPEApplication class implements various system services |
643 | that are available to all Qtopia applications. | 650 | that are available to all Qtopia applications. |
644 | 651 | ||
645 | Simply by using QPEApplication instead of QApplication, a standard Qt | 652 | Simply by using QPEApplication instead of QApplication, a standard Qt |
646 | application becomes a Qtopia application. It automatically follows | 653 | application becomes a Qtopia application. It automatically follows |
647 | style changes, quits and raises, and in the | 654 | style changes, quits and raises, and in the |
648 | case of \link docwidget.html document-oriented\endlink applications, | 655 | case of \link docwidget.html document-oriented\endlink applications, |
649 | changes the currently displayed document in response to the environment. | 656 | changes the currently displayed document in response to the environment. |
650 | 657 | ||
651 | To create a \link docwidget.html document-oriented\endlink | 658 | To create a \link docwidget.html document-oriented\endlink |
652 | application use showMainDocumentWidget(); to create a | 659 | application use showMainDocumentWidget(); to create a |
653 | non-document-oriented application use showMainWidget(). The | 660 | non-document-oriented application use showMainWidget(). The |
654 | keepRunning() function indicates whether the application will | 661 | keepRunning() function indicates whether the application will |
655 | continue running after it's processed the last \link qcop.html | 662 | continue running after it's processed the last \link qcop.html |
656 | QCop\endlink message. This can be changed using setKeepRunning(). | 663 | QCop\endlink message. This can be changed using setKeepRunning(). |
657 | 664 | ||
658 | A variety of signals are emitted when certain events occur, for | 665 | A variety of signals are emitted when certain events occur, for |
659 | example, timeChanged(), clockChanged(), weekChanged(), | 666 | example, timeChanged(), clockChanged(), weekChanged(), |
660 | dateFormatChanged() and volumeChanged(). If the application receives | 667 | dateFormatChanged() and volumeChanged(). If the application receives |
661 | a \link qcop.html QCop\endlink message on the application's | 668 | a \link qcop.html QCop\endlink message on the application's |
662 | QPE/Application/\e{appname} channel, the appMessage() signal is | 669 | QPE/Application/\e{appname} channel, the appMessage() signal is |
663 | emitted. There are also flush() and reload() signals, which | 670 | emitted. There are also flush() and reload() signals, which |
664 | are emitted when synching begins and ends respectively - upon these | 671 | are emitted when synching begins and ends respectively - upon these |
665 | signals, the application should save and reload any data | 672 | signals, the application should save and reload any data |
666 | files that are involved in synching. Most of these signals will initially | 673 | files that are involved in synching. Most of these signals will initially |
667 | be received and unfiltered through the appMessage() signal. | 674 | be received and unfiltered through the appMessage() signal. |
668 | 675 | ||
669 | This class also provides a set of useful static functions. The | 676 | This class also provides a set of useful static functions. The |
670 | qpeDir() and documentDir() functions return the respective paths. | 677 | qpeDir() and documentDir() functions return the respective paths. |
671 | The grabKeyboard() and ungrabKeyboard() functions are used to | 678 | The grabKeyboard() and ungrabKeyboard() functions are used to |
672 | control whether the application takes control of the device's | 679 | control whether the application takes control of the device's |
673 | physical buttons (e.g. application launch keys). The stylus' mode of | 680 | physical buttons (e.g. application launch keys). The stylus' mode of |
674 | operation is set with setStylusOperation() and retrieved with | 681 | operation is set with setStylusOperation() and retrieved with |
675 | stylusOperation(). There are also setInputMethodHint() and | 682 | stylusOperation(). There are also setInputMethodHint() and |
676 | inputMethodHint() functions. | 683 | inputMethodHint() functions. |
677 | 684 | ||
678 | \ingroup qtopiaemb | 685 | \ingroup qtopiaemb |
679 | */ | 686 | */ |
680 | 687 | ||
681 | /*! | 688 | /*! |
682 | \fn void QPEApplication::clientMoused() | 689 | \fn void QPEApplication::clientMoused() |
683 | 690 | ||
684 | \internal | 691 | \internal |
685 | */ | 692 | */ |
686 | 693 | ||
@@ -1016,385 +1023,385 @@ void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) | |||
1016 | ( w ); | 1023 | ( w ); |
1017 | } | 1024 | } |
1018 | else { | 1025 | else { |
1019 | inputMethodDict->insert( w, ( void* ) mode ); | 1026 | inputMethodDict->insert( w, ( void* ) mode ); |
1020 | } | 1027 | } |
1021 | } | 1028 | } |
1022 | 1029 | ||
1023 | class HackDialog : public QDialog | 1030 | class HackDialog : public QDialog |
1024 | { | 1031 | { |
1025 | public: | 1032 | public: |
1026 | void acceptIt() | 1033 | void acceptIt() |
1027 | { | 1034 | { |
1028 | accept(); | 1035 | accept(); |
1029 | } | 1036 | } |
1030 | void rejectIt() | 1037 | void rejectIt() |
1031 | { | 1038 | { |
1032 | reject(); | 1039 | reject(); |
1033 | } | 1040 | } |
1034 | }; | 1041 | }; |
1035 | 1042 | ||
1036 | 1043 | ||
1037 | void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) | 1044 | void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) |
1038 | { | 1045 | { |
1039 | // specialised actions for certain widgets. May want to | 1046 | // specialised actions for certain widgets. May want to |
1040 | // add more stuff here. | 1047 | // add more stuff here. |
1041 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" ) | 1048 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" ) |
1042 | && activePopupWidget() ->parentWidget() | 1049 | && activePopupWidget() ->parentWidget() |
1043 | && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) ) | 1050 | && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) ) |
1044 | key = Qt::Key_Return; | 1051 | key = Qt::Key_Return; |
1045 | 1052 | ||
1046 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) ) | 1053 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) ) |
1047 | key = Qt::Key_Return; | 1054 | key = Qt::Key_Return; |
1048 | 1055 | ||
1049 | #ifdef QWS | 1056 | #ifdef QWS |
1050 | 1057 | ||
1051 | ke->simpleData.keycode = key; | 1058 | ke->simpleData.keycode = key; |
1052 | #endif | 1059 | #endif |
1053 | } | 1060 | } |
1054 | 1061 | ||
1055 | 1062 | ||
1056 | /*! | 1063 | /*! |
1057 | \internal | 1064 | \internal |
1058 | */ | 1065 | */ |
1059 | 1066 | ||
1060 | #ifdef QWS | 1067 | #ifdef QWS |
1061 | bool QPEApplication::qwsEventFilter( QWSEvent * e ) | 1068 | bool QPEApplication::qwsEventFilter( QWSEvent * e ) |
1062 | { | 1069 | { |
1063 | if ( !d->notbusysent && e->type == QWSEvent::Focus ) { | 1070 | if ( !d->notbusysent && e->type == QWSEvent::Focus ) { |
1064 | if ( qApp->type() != QApplication::GuiServer ) { | 1071 | if ( qApp->type() != QApplication::GuiServer ) { |
1065 | QCopEnvelope e( "QPE/System", "notBusy(QString)" ); | 1072 | QCopEnvelope e( "QPE/System", "notBusy(QString)" ); |
1066 | e << d->appName; | 1073 | e << d->appName; |
1067 | } | 1074 | } |
1068 | d->notbusysent = TRUE; | 1075 | d->notbusysent = TRUE; |
1069 | } | 1076 | } |
1070 | if ( type() == GuiServer ) { | 1077 | if ( type() == GuiServer ) { |
1071 | switch ( e->type ) { | 1078 | switch ( e->type ) { |
1072 | case QWSEvent::Mouse: | 1079 | case QWSEvent::Mouse: |
1073 | if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) ) | 1080 | if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) ) |
1074 | emit clientMoused(); | 1081 | emit clientMoused(); |
1075 | break; | 1082 | break; |
1076 | default: | 1083 | default: |
1077 | break; | 1084 | break; |
1078 | } | 1085 | } |
1079 | } | 1086 | } |
1080 | if ( e->type == QWSEvent::Key ) { | 1087 | if ( e->type == QWSEvent::Key ) { |
1081 | QWSKeyEvent *ke = ( QWSKeyEvent * ) e; | 1088 | QWSKeyEvent *ke = ( QWSKeyEvent * ) e; |
1082 | if ( ke->simpleData.keycode == Qt::Key_F33 ) { | 1089 | if ( ke->simpleData.keycode == Qt::Key_F33 ) { |
1083 | // Use special "OK" key to press "OK" on top level widgets | 1090 | // Use special "OK" key to press "OK" on top level widgets |
1084 | QWidget * active = activeWindow(); | 1091 | QWidget * active = activeWindow(); |
1085 | QWidget *popup = 0; | 1092 | QWidget *popup = 0; |
1086 | if ( active && active->isPopup() ) { | 1093 | if ( active && active->isPopup() ) { |
1087 | popup = active; | 1094 | popup = active; |
1088 | active = active->parentWidget(); | 1095 | active = active->parentWidget(); |
1089 | } | 1096 | } |
1090 | if ( active && ( int ) active->winId() == ke->simpleData.window && | 1097 | if ( active && ( int ) active->winId() == ke->simpleData.window && |
1091 | !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) { | 1098 | !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) { |
1092 | if ( ke->simpleData.is_press ) { | 1099 | if ( ke->simpleData.is_press ) { |
1093 | if ( popup ) | 1100 | if ( popup ) |
1094 | popup->close(); | 1101 | popup->close(); |
1095 | if ( active->inherits( "QDialog" ) ) { | 1102 | if ( active->inherits( "QDialog" ) ) { |
1096 | HackDialog * d = ( HackDialog * ) active; | 1103 | HackDialog * d = ( HackDialog * ) active; |
1097 | d->acceptIt(); | 1104 | d->acceptIt(); |
1098 | return TRUE; | 1105 | return TRUE; |
1099 | } | 1106 | } |
1100 | else if ( ( ( HackWidget * ) active ) ->needsOk() ) { | 1107 | else if ( ( ( HackWidget * ) active ) ->needsOk() ) { |
1101 | QSignal s; | 1108 | QSignal s; |
1102 | s.connect( active, SLOT( accept() ) ); | 1109 | s.connect( active, SLOT( accept() ) ); |
1103 | s.activate(); | 1110 | s.activate(); |
1104 | } | 1111 | } |
1105 | else { | 1112 | else { |
1106 | // do the same as with the select key: Map to the default action of the widget: | 1113 | // do the same as with the select key: Map to the default action of the widget: |
1107 | mapToDefaultAction( ke, Qt::Key_Return ); | 1114 | mapToDefaultAction( ke, Qt::Key_Return ); |
1108 | } | 1115 | } |
1109 | } | 1116 | } |
1110 | } | 1117 | } |
1111 | } | 1118 | } |
1112 | else if ( ke->simpleData.keycode == Qt::Key_F30 ) { | 1119 | else if ( ke->simpleData.keycode == Qt::Key_F30 ) { |
1113 | // Use special "select" key to do whatever default action a widget has | 1120 | // Use special "select" key to do whatever default action a widget has |
1114 | mapToDefaultAction( ke, Qt::Key_Space ); | 1121 | mapToDefaultAction( ke, Qt::Key_Space ); |
1115 | } | 1122 | } |
1116 | else if ( ke->simpleData.keycode == Qt::Key_Escape && | 1123 | else if ( ke->simpleData.keycode == Qt::Key_Escape && |
1117 | ke->simpleData.is_press ) { | 1124 | ke->simpleData.is_press ) { |
1118 | // Escape key closes app if focus on toplevel | 1125 | // Escape key closes app if focus on toplevel |
1119 | QWidget * active = activeWindow(); | 1126 | QWidget * active = activeWindow(); |
1120 | if ( active && active->testWFlags( WType_TopLevel ) && | 1127 | if ( active && active->testWFlags( WType_TopLevel ) && |
1121 | ( int ) active->winId() == ke->simpleData.window && | 1128 | ( int ) active->winId() == ke->simpleData.window && |
1122 | !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) { | 1129 | !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) { |
1123 | if ( active->inherits( "QDialog" ) ) { | 1130 | if ( active->inherits( "QDialog" ) ) { |
1124 | HackDialog * d = ( HackDialog * ) active; | 1131 | HackDialog * d = ( HackDialog * ) active; |
1125 | d->rejectIt(); | 1132 | d->rejectIt(); |
1126 | return TRUE; | 1133 | return TRUE; |
1127 | } else /*if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 )*/ { | 1134 | } else /*if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 )*/ { |
1128 | active->close(); | 1135 | active->close(); |
1129 | } | 1136 | } |
1130 | } | 1137 | } |
1131 | 1138 | ||
1132 | } | 1139 | } |
1133 | else if ( ke->simpleData.keycode >= Qt::Key_F1 && ke->simpleData.keycode <= Qt::Key_F29 ) { | 1140 | else if ( ke->simpleData.keycode >= Qt::Key_F1 && ke->simpleData.keycode <= Qt::Key_F29 ) { |
1134 | // this should be if ( ODevice::inst ( )-> buttonForKeycode ( ... )) | 1141 | // this should be if ( ODevice::inst ( )-> buttonForKeycode ( ... )) |
1135 | // but we cannot access libopie function within libqpe :( | 1142 | // but we cannot access libopie function within libqpe :( |
1136 | 1143 | ||
1137 | QWidget * active = activeWindow ( ); | 1144 | QWidget * active = activeWindow ( ); |
1138 | if ( active && ((int) active-> winId ( ) == ke-> simpleData.window )) { | 1145 | if ( active && ((int) active-> winId ( ) == ke-> simpleData.window )) { |
1139 | if ( d-> kbgrabbed ) { // we grabbed the keyboard | 1146 | if ( d-> kbgrabbed ) { // we grabbed the keyboard |
1140 | QChar ch ( ke-> simpleData.unicode ); | 1147 | QChar ch ( ke-> simpleData.unicode ); |
1141 | QKeyEvent qke ( ke-> simpleData. is_press ? QEvent::KeyPress : QEvent::KeyRelease, | 1148 | QKeyEvent qke ( ke-> simpleData. is_press ? QEvent::KeyPress : QEvent::KeyRelease, |
1142 | ke-> simpleData.keycode, | 1149 | ke-> simpleData.keycode, |
1143 | ch. latin1 ( ), | 1150 | ch. latin1 ( ), |
1144 | ke-> simpleData.modifiers, | 1151 | ke-> simpleData.modifiers, |
1145 | QString ( ch ), | 1152 | QString ( ch ), |
1146 | ke-> simpleData.is_auto_repeat, 1 ); | 1153 | ke-> simpleData.is_auto_repeat, 1 ); |
1147 | 1154 | ||
1148 | QObject *which = QWidget::keyboardGrabber ( ); | 1155 | QObject *which = QWidget::keyboardGrabber ( ); |
1149 | if ( !which ) | 1156 | if ( !which ) |
1150 | which = QApplication::focusWidget ( ); | 1157 | which = QApplication::focusWidget ( ); |
1151 | if ( !which ) | 1158 | if ( !which ) |
1152 | which = QApplication::activeWindow ( ); | 1159 | which = QApplication::activeWindow ( ); |
1153 | if ( !which ) | 1160 | if ( !which ) |
1154 | which = qApp; | 1161 | which = qApp; |
1155 | 1162 | ||
1156 | QApplication::sendEvent ( which, &qke ); | 1163 | QApplication::sendEvent ( which, &qke ); |
1157 | } | 1164 | } |
1158 | else { // we didn't grab the keyboard, so send the event to the launcher | 1165 | else { // we didn't grab the keyboard, so send the event to the launcher |
1159 | QCopEnvelope e ( "QPE/Launcher", "deviceButton(int,int,int)" ); | 1166 | QCopEnvelope e ( "QPE/Launcher", "deviceButton(int,int,int)" ); |
1160 | e << int( ke-> simpleData.keycode ) << int( ke-> simpleData. is_press ) << int( ke-> simpleData.is_auto_repeat ); | 1167 | e << int( ke-> simpleData.keycode ) << int( ke-> simpleData. is_press ) << int( ke-> simpleData.is_auto_repeat ); |
1161 | } | 1168 | } |
1162 | } | 1169 | } |
1163 | return true; | 1170 | return true; |
1164 | } | 1171 | } |
1165 | } | 1172 | } |
1166 | if ( e->type == QWSEvent::Focus ) { | 1173 | if ( e->type == QWSEvent::Focus ) { |
1167 | QWSFocusEvent * fe = ( QWSFocusEvent* ) e; | 1174 | QWSFocusEvent * fe = ( QWSFocusEvent* ) e; |
1168 | if ( !fe->simpleData.get_focus ) { | 1175 | if ( !fe->simpleData.get_focus ) { |
1169 | QWidget * active = activeWindow(); | 1176 | QWidget * active = activeWindow(); |
1170 | while ( active && active->isPopup() ) { | 1177 | while ( active && active->isPopup() ) { |
1171 | active->close(); | 1178 | active->close(); |
1172 | active = activeWindow(); | 1179 | active = activeWindow(); |
1173 | } | 1180 | } |
1174 | } | 1181 | } |
1175 | else { | 1182 | else { |
1176 | // make sure our modal widget is ALWAYS on top | 1183 | // make sure our modal widget is ALWAYS on top |
1177 | QWidget *topm = activeModalWidget(); | 1184 | QWidget *topm = activeModalWidget(); |
1178 | if ( topm && static_cast<int>( topm->winId() ) != fe->simpleData.window) { | 1185 | if ( topm && static_cast<int>( topm->winId() ) != fe->simpleData.window) { |
1179 | topm->raise(); | 1186 | topm->raise(); |
1180 | } | 1187 | } |
1181 | } | 1188 | } |
1182 | if ( fe->simpleData.get_focus && inputMethodDict ) { | 1189 | if ( fe->simpleData.get_focus && inputMethodDict ) { |
1183 | InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) ); | 1190 | InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) ); |
1184 | if ( m == AlwaysOff ) | 1191 | if ( m == AlwaysOff ) |
1185 | Global::hideInputMethod(); | 1192 | Global::hideInputMethod(); |
1186 | if ( m == AlwaysOn ) | 1193 | if ( m == AlwaysOn ) |
1187 | Global::showInputMethod(); | 1194 | Global::showInputMethod(); |
1188 | } | 1195 | } |
1189 | } | 1196 | } |
1190 | 1197 | ||
1191 | 1198 | ||
1192 | return QApplication::qwsEventFilter( e ); | 1199 | return QApplication::qwsEventFilter( e ); |
1193 | } | 1200 | } |
1194 | #endif | 1201 | #endif |
1195 | 1202 | ||
1196 | /*! | 1203 | /*! |
1197 | Destroys the QPEApplication. | 1204 | Destroys the QPEApplication. |
1198 | */ | 1205 | */ |
1199 | QPEApplication::~QPEApplication() | 1206 | QPEApplication::~QPEApplication() |
1200 | { | 1207 | { |
1201 | ungrabKeyboard(); | 1208 | ungrabKeyboard(); |
1202 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 1209 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
1203 | // Need to delete QCopChannels early, since the display will | 1210 | // Need to delete QCopChannels early, since the display will |
1204 | // be gone by the time we get to ~QObject(). | 1211 | // be gone by the time we get to ~QObject(). |
1205 | delete sysChannel; | 1212 | delete sysChannel; |
1206 | delete pidChannel; | 1213 | delete pidChannel; |
1207 | #endif | 1214 | #endif |
1208 | 1215 | delete d->RoH; | |
1209 | delete d; | 1216 | delete d; |
1210 | } | 1217 | } |
1211 | 1218 | ||
1212 | /*! | 1219 | /*! |
1213 | Returns <tt>$OPIEDIR/</tt>. | 1220 | Returns <tt>$OPIEDIR/</tt>. |
1214 | */ | 1221 | */ |
1215 | QString QPEApplication::qpeDir() | 1222 | QString QPEApplication::qpeDir() |
1216 | { | 1223 | { |
1217 | const char * base = getenv( "OPIEDIR" ); | 1224 | const char * base = getenv( "OPIEDIR" ); |
1218 | if ( base ) | 1225 | if ( base ) |
1219 | return QString( base ) + "/"; | 1226 | return QString( base ) + "/"; |
1220 | 1227 | ||
1221 | return QString( "../" ); | 1228 | return QString( "../" ); |
1222 | } | 1229 | } |
1223 | 1230 | ||
1224 | /*! | 1231 | /*! |
1225 | Returns the user's current Document directory. There is a trailing "/". | 1232 | Returns the user's current Document directory. There is a trailing "/". |
1226 | .. well, it does now,, and there's no trailing '/' | 1233 | .. well, it does now,, and there's no trailing '/' |
1227 | */ | 1234 | */ |
1228 | QString QPEApplication::documentDir() | 1235 | QString QPEApplication::documentDir() |
1229 | { | 1236 | { |
1230 | const char* base = getenv( "HOME"); | 1237 | const char* base = getenv( "HOME"); |
1231 | if ( base ) | 1238 | if ( base ) |
1232 | return QString( base ) + "/Documents"; | 1239 | return QString( base ) + "/Documents"; |
1233 | 1240 | ||
1234 | return QString( "../Documents" ); | 1241 | return QString( "../Documents" ); |
1235 | } | 1242 | } |
1236 | 1243 | ||
1237 | static int deforient = -1; | 1244 | static int deforient = -1; |
1238 | 1245 | ||
1239 | /*! | 1246 | /*! |
1240 | \internal | 1247 | \internal |
1241 | */ | 1248 | */ |
1242 | int QPEApplication::defaultRotation() | 1249 | int QPEApplication::defaultRotation() |
1243 | { | 1250 | { |
1244 | if ( deforient < 0 ) { | 1251 | if ( deforient < 0 ) { |
1245 | QString d = getenv( "QWS_DISPLAY" ); | 1252 | QString d = getenv( "QWS_DISPLAY" ); |
1246 | if ( d.contains( "Rot90" ) ) { | 1253 | if ( d.contains( "Rot90" ) ) { |
1247 | deforient = 90; | 1254 | deforient = 90; |
1248 | } | 1255 | } |
1249 | else if ( d.contains( "Rot180" ) ) { | 1256 | else if ( d.contains( "Rot180" ) ) { |
1250 | deforient = 180; | 1257 | deforient = 180; |
1251 | } | 1258 | } |
1252 | else if ( d.contains( "Rot270" ) ) { | 1259 | else if ( d.contains( "Rot270" ) ) { |
1253 | deforient = 270; | 1260 | deforient = 270; |
1254 | } | 1261 | } |
1255 | else { | 1262 | else { |
1256 | deforient = 0; | 1263 | deforient = 0; |
1257 | } | 1264 | } |
1258 | } | 1265 | } |
1259 | return deforient; | 1266 | return deforient; |
1260 | } | 1267 | } |
1261 | 1268 | ||
1262 | /*! | 1269 | /*! |
1263 | \internal | 1270 | \internal |
1264 | */ | 1271 | */ |
1265 | void QPEApplication::setDefaultRotation( int r ) | 1272 | void QPEApplication::setDefaultRotation( int r ) |
1266 | { | 1273 | { |
1267 | if ( qApp->type() == GuiServer ) { | 1274 | if ( qApp->type() == GuiServer ) { |
1268 | deforient = r; | 1275 | deforient = r; |
1269 | setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); | 1276 | setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); |
1270 | Config config("qpe"); | 1277 | Config config("qpe"); |
1271 | config.setGroup( "Rotation" ); | 1278 | config.setGroup( "Rotation" ); |
1272 | config.writeEntry( "Rot", r ); | 1279 | config.writeEntry( "Rot", r ); |
1273 | } | 1280 | } |
1274 | else { | 1281 | else { |
1275 | #ifndef QT_NO_COP | 1282 | #ifndef QT_NO_COP |
1276 | { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); | 1283 | { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); |
1277 | e << r; | 1284 | e << r; |
1278 | } | 1285 | } |
1279 | #endif | 1286 | #endif |
1280 | 1287 | ||
1281 | } | 1288 | } |
1282 | } | 1289 | } |
1283 | 1290 | ||
1284 | #include <qgfx_qws.h> | 1291 | #include <qgfx_qws.h> |
1285 | #include <qwindowsystem_qws.h> | 1292 | #include <qwindowsystem_qws.h> |
1286 | 1293 | ||
1287 | #if QT_VERSION > 236 | 1294 | #if QT_VERSION > 236 |
1288 | extern void qws_clearLoadedFonts(); | 1295 | extern void qws_clearLoadedFonts(); |
1289 | #endif | 1296 | #endif |
1290 | 1297 | ||
1291 | void QPEApplication::setCurrentMode( int x, int y, int depth ) | 1298 | void QPEApplication::setCurrentMode( int x, int y, int depth ) |
1292 | { | 1299 | { |
1293 | // Reset the caches | 1300 | // Reset the caches |
1294 | #if QT_VERSION > 236 | 1301 | #if QT_VERSION > 236 |
1295 | qws_clearLoadedFonts(); | 1302 | qws_clearLoadedFonts(); |
1296 | #endif | 1303 | #endif |
1297 | QPixmapCache::clear(); | 1304 | QPixmapCache::clear(); |
1298 | 1305 | ||
1299 | // Change the screen mode | 1306 | // Change the screen mode |
1300 | qt_screen->setMode(x, y, depth); | 1307 | qt_screen->setMode(x, y, depth); |
1301 | 1308 | ||
1302 | if ( qApp->type() == GuiServer ) { | 1309 | if ( qApp->type() == GuiServer ) { |
1303 | #if QT_VERSION > 236 | 1310 | #if QT_VERSION > 236 |
1304 | // Reconfigure the GuiServer | 1311 | // Reconfigure the GuiServer |
1305 | qwsServer->beginDisplayReconfigure(); | 1312 | qwsServer->beginDisplayReconfigure(); |
1306 | qwsServer->endDisplayReconfigure(); | 1313 | qwsServer->endDisplayReconfigure(); |
1307 | #endif | 1314 | #endif |
1308 | // Get all the running apps to reset | 1315 | // Get all the running apps to reset |
1309 | QCopEnvelope env( "QPE/System", "reset()" ); | 1316 | QCopEnvelope env( "QPE/System", "reset()" ); |
1310 | } | 1317 | } |
1311 | } | 1318 | } |
1312 | 1319 | ||
1313 | void QPEApplication::reset() { | 1320 | void QPEApplication::reset() { |
1314 | // Reconnect to the screen | 1321 | // Reconnect to the screen |
1315 | qt_screen->disconnect(); | 1322 | qt_screen->disconnect(); |
1316 | qt_screen->connect( QString::null ); | 1323 | qt_screen->connect( QString::null ); |
1317 | 1324 | ||
1318 | // Redraw everything | 1325 | // Redraw everything |
1319 | applyStyle(); | 1326 | applyStyle(); |
1320 | } | 1327 | } |
1321 | 1328 | ||
1322 | #if (QT_VERSION < 238) && defined Q_OS_MACX | 1329 | #if (QT_VERSION < 238) && defined Q_OS_MACX |
1323 | bool qt_left_hand_scrollbars = false; | 1330 | bool qt_left_hand_scrollbars = false; |
1324 | #else | 1331 | #else |
1325 | #ifdef Q_OS_MACX | 1332 | #ifdef Q_OS_MACX |
1326 | #define WEAK_SYMBOL __attribute__((weak_import)) | 1333 | #define WEAK_SYMBOL __attribute__((weak_import)) |
1327 | #else | 1334 | #else |
1328 | #define WEAK_SYMBOL __attribute__((weak)) | 1335 | #define WEAK_SYMBOL __attribute__((weak)) |
1329 | #endif | 1336 | #endif |
1330 | extern bool qt_left_hand_scrollbars WEAK_SYMBOL; | 1337 | extern bool qt_left_hand_scrollbars WEAK_SYMBOL; |
1331 | #endif | 1338 | #endif |
1332 | 1339 | ||
1333 | /*! | 1340 | /*! |
1334 | \internal | 1341 | \internal |
1335 | */ | 1342 | */ |
1336 | void QPEApplication::applyStyle() | 1343 | void QPEApplication::applyStyle() |
1337 | { | 1344 | { |
1338 | Config config( "qpe" ); | 1345 | Config config( "qpe" ); |
1339 | config.setGroup( "Appearance" ); | 1346 | config.setGroup( "Appearance" ); |
1340 | 1347 | ||
1341 | #if QT_VERSION > 233 | 1348 | #if QT_VERSION > 233 |
1342 | #if !defined(OPIE_NO_OVERRIDE_QT) | 1349 | #if !defined(OPIE_NO_OVERRIDE_QT) |
1343 | // don't block ourselves ... | 1350 | // don't block ourselves ... |
1344 | Opie::force_appearance = 0; | 1351 | Opie::force_appearance = 0; |
1345 | 1352 | ||
1346 | static QString appname = Opie::binaryName ( ); | 1353 | static QString appname = Opie::binaryName ( ); |
1347 | 1354 | ||
1348 | QStringList ex = config. readListEntry ( "NoStyle", ';' ); | 1355 | QStringList ex = config. readListEntry ( "NoStyle", ';' ); |
1349 | int nostyle = 0; | 1356 | int nostyle = 0; |
1350 | for ( QStringList::Iterator it = ex. begin ( ); it != ex. end ( ); ++it ) { | 1357 | for ( QStringList::Iterator it = ex. begin ( ); it != ex. end ( ); ++it ) { |
1351 | if ( QRegExp (( *it ). mid ( 1 ), false, true ). find ( appname, 0 ) >= 0 ) { | 1358 | if ( QRegExp (( *it ). mid ( 1 ), false, true ). find ( appname, 0 ) >= 0 ) { |
1352 | nostyle = ( *it ). left ( 1 ). toInt ( 0, 32 ); | 1359 | nostyle = ( *it ). left ( 1 ). toInt ( 0, 32 ); |
1353 | break; | 1360 | break; |
1354 | } | 1361 | } |
1355 | } | 1362 | } |
1356 | #else | 1363 | #else |
1357 | int nostyle = 0; | 1364 | int nostyle = 0; |
1358 | #endif | 1365 | #endif |
1359 | 1366 | ||
1360 | // Widget style | 1367 | // Widget style |
1361 | QString style = config.readEntry( "Style", "FlatStyle" ); | 1368 | QString style = config.readEntry( "Style", "FlatStyle" ); |
1362 | 1369 | ||
1363 | // don't set a custom style | 1370 | // don't set a custom style |
1364 | if ( nostyle & Opie::Force_Style ) | 1371 | if ( nostyle & Opie::Force_Style ) |
1365 | style = "FlatStyle"; | 1372 | style = "FlatStyle"; |
1366 | 1373 | ||
1367 | internalSetStyle ( style ); | 1374 | internalSetStyle ( style ); |
1368 | 1375 | ||
1369 | // Colors - from /etc/colors/Liquid.scheme | 1376 | // Colors - from /etc/colors/Liquid.scheme |
1370 | QColor bgcolor( config.readEntry( "Background", "#E0E0E0" ) ); | 1377 | QColor bgcolor( config.readEntry( "Background", "#E0E0E0" ) ); |
1371 | QColor btncolor( config.readEntry( "Button", "#96c8fa" ) ); | 1378 | QColor btncolor( config.readEntry( "Button", "#96c8fa" ) ); |
1372 | QPalette pal( btncolor, bgcolor ); | 1379 | QPalette pal( btncolor, bgcolor ); |
1373 | QString color = config.readEntry( "Highlight", "#73adef" ); | 1380 | QString color = config.readEntry( "Highlight", "#73adef" ); |
1374 | pal.setColor( QColorGroup::Highlight, QColor( color ) ); | 1381 | pal.setColor( QColorGroup::Highlight, QColor( color ) ); |
1375 | color = config.readEntry( "HighlightedText", "#FFFFFF" ); | 1382 | color = config.readEntry( "HighlightedText", "#FFFFFF" ); |
1376 | pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); | 1383 | pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); |
1377 | color = config.readEntry( "Text", "#000000" ); | 1384 | color = config.readEntry( "Text", "#000000" ); |
1378 | pal.setColor( QColorGroup::Text, QColor( color ) ); | 1385 | pal.setColor( QColorGroup::Text, QColor( color ) ); |
1379 | color = config.readEntry( "ButtonText", "#000000" ); | 1386 | color = config.readEntry( "ButtonText", "#000000" ); |
1380 | pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); | 1387 | pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); |
1381 | color = config.readEntry( "Base", "#FFFFFF" ); | 1388 | color = config.readEntry( "Base", "#FFFFFF" ); |
1382 | pal.setColor( QColorGroup::Base, QColor( color ) ); | 1389 | pal.setColor( QColorGroup::Base, QColor( color ) ); |
1383 | 1390 | ||
1384 | pal.setColor( QPalette::Disabled, QColorGroup::Text, | 1391 | pal.setColor( QPalette::Disabled, QColorGroup::Text, |
1385 | pal.color( QPalette::Active, QColorGroup::Background ).dark() ); | 1392 | pal.color( QPalette::Active, QColorGroup::Background ).dark() ); |
1386 | 1393 | ||
1387 | setPalette( pal, TRUE ); | 1394 | setPalette( pal, TRUE ); |
1388 | 1395 | ||
1389 | 1396 | ||
1390 | // Set the ScrollBar on the 'right' side but only if the weak symbol is present | 1397 | // Set the ScrollBar on the 'right' side but only if the weak symbol is present |
1391 | if (&qt_left_hand_scrollbars ) | 1398 | if (&qt_left_hand_scrollbars ) |
1392 | qt_left_hand_scrollbars = config.readBoolEntry( "LeftHand", false ); | 1399 | qt_left_hand_scrollbars = config.readBoolEntry( "LeftHand", false ); |
1393 | 1400 | ||
1394 | // Window Decoration | 1401 | // Window Decoration |
1395 | QString dec = config.readEntry( "Decoration", "Flat" ); | 1402 | QString dec = config.readEntry( "Decoration", "Flat" ); |
1396 | 1403 | ||
1397 | // don't set a custom deco | 1404 | // don't set a custom deco |
1398 | if ( nostyle & Opie::Force_Decoration ) | 1405 | if ( nostyle & Opie::Force_Decoration ) |
1399 | dec = ""; | 1406 | dec = ""; |
1400 | 1407 | ||
@@ -1834,454 +1841,473 @@ void QPEApplication::internalSetStyle( const QString &style ) | |||
1834 | if ( style == "QPE" ) { | 1841 | if ( style == "QPE" ) { |
1835 | setStyle( new QPEStyle ); | 1842 | setStyle( new QPEStyle ); |
1836 | } | 1843 | } |
1837 | else { | 1844 | else { |
1838 | QStyle *s = QStyleFactory::create( style ); | 1845 | QStyle *s = QStyleFactory::create( style ); |
1839 | if ( s ) | 1846 | if ( s ) |
1840 | setStyle( s ); | 1847 | setStyle( s ); |
1841 | } | 1848 | } |
1842 | #else | 1849 | #else |
1843 | if ( style == "Windows" ) { | 1850 | if ( style == "Windows" ) { |
1844 | setStyle( new QWindowsStyle ); | 1851 | setStyle( new QWindowsStyle ); |
1845 | } | 1852 | } |
1846 | else if ( style == "QPE" ) { | 1853 | else if ( style == "QPE" ) { |
1847 | setStyle( new QPEStyle ); | 1854 | setStyle( new QPEStyle ); |
1848 | } | 1855 | } |
1849 | else if ( style == "Light" ) { | 1856 | else if ( style == "Light" ) { |
1850 | setStyle( new LightStyle ); | 1857 | setStyle( new LightStyle ); |
1851 | } | 1858 | } |
1852 | #ifndef QT_NO_STYLE_PLATINUM | 1859 | #ifndef QT_NO_STYLE_PLATINUM |
1853 | else if ( style == "Platinum" ) { | 1860 | else if ( style == "Platinum" ) { |
1854 | setStyle( new QPlatinumStyle ); | 1861 | setStyle( new QPlatinumStyle ); |
1855 | } | 1862 | } |
1856 | #endif | 1863 | #endif |
1857 | #ifndef QT_NO_STYLE_MOTIF | 1864 | #ifndef QT_NO_STYLE_MOTIF |
1858 | else if ( style == "Motif" ) { | 1865 | else if ( style == "Motif" ) { |
1859 | setStyle( new QMotifStyle ); | 1866 | setStyle( new QMotifStyle ); |
1860 | } | 1867 | } |
1861 | #endif | 1868 | #endif |
1862 | #ifndef QT_NO_STYLE_MOTIFPLUS | 1869 | #ifndef QT_NO_STYLE_MOTIFPLUS |
1863 | else if ( style == "MotifPlus" ) { | 1870 | else if ( style == "MotifPlus" ) { |
1864 | setStyle( new QMotifPlusStyle ); | 1871 | setStyle( new QMotifPlusStyle ); |
1865 | } | 1872 | } |
1866 | #endif | 1873 | #endif |
1867 | 1874 | ||
1868 | else { | 1875 | else { |
1869 | QStyle *sty = 0; | 1876 | QStyle *sty = 0; |
1870 | QString path = QPEApplication::qpeDir ( ) + "/plugins/styles/"; | 1877 | QString path = QPEApplication::qpeDir ( ) + "/plugins/styles/"; |
1871 | 1878 | ||
1872 | #ifdef Q_OS_MACX | 1879 | #ifdef Q_OS_MACX |
1873 | if ( style. find ( ".dylib" ) > 0 ) | 1880 | if ( style. find ( ".dylib" ) > 0 ) |
1874 | path += style; | 1881 | path += style; |
1875 | else | 1882 | else |
1876 | path = path + "lib" + style. lower ( ) + ".dylib"; // compatibility | 1883 | path = path + "lib" + style. lower ( ) + ".dylib"; // compatibility |
1877 | #else | 1884 | #else |
1878 | if ( style. find ( ".so" ) > 0 ) | 1885 | if ( style. find ( ".so" ) > 0 ) |
1879 | path += style; | 1886 | path += style; |
1880 | else | 1887 | else |
1881 | path = path + "lib" + style. lower ( ) + ".so"; // compatibility | 1888 | path = path + "lib" + style. lower ( ) + ".so"; // compatibility |
1882 | #endif | 1889 | #endif |
1883 | static QLibrary *lastlib = 0; | 1890 | static QLibrary *lastlib = 0; |
1884 | static StyleInterface *lastiface = 0; | 1891 | static StyleInterface *lastiface = 0; |
1885 | 1892 | ||
1886 | QLibrary *lib = new QLibrary ( path ); | 1893 | QLibrary *lib = new QLibrary ( path ); |
1887 | StyleInterface *iface = 0; | 1894 | StyleInterface *iface = 0; |
1888 | 1895 | ||
1889 | if (( lib-> queryInterface ( IID_Style, ( QUnknownInterface ** ) &iface ) == QS_OK ) && iface ) | 1896 | if (( lib-> queryInterface ( IID_Style, ( QUnknownInterface ** ) &iface ) == QS_OK ) && iface ) |
1890 | sty = iface-> style ( ); | 1897 | sty = iface-> style ( ); |
1891 | 1898 | ||
1892 | if ( sty ) { | 1899 | if ( sty ) { |
1893 | setStyle ( sty ); | 1900 | setStyle ( sty ); |
1894 | 1901 | ||
1895 | if ( lastiface ) | 1902 | if ( lastiface ) |
1896 | lastiface-> release ( ); | 1903 | lastiface-> release ( ); |
1897 | lastiface = iface; | 1904 | lastiface = iface; |
1898 | 1905 | ||
1899 | if ( lastlib ) { | 1906 | if ( lastlib ) { |
1900 | lastlib-> unload ( ); | 1907 | lastlib-> unload ( ); |
1901 | delete lastlib; | 1908 | delete lastlib; |
1902 | } | 1909 | } |
1903 | lastlib = lib; | 1910 | lastlib = lib; |
1904 | } | 1911 | } |
1905 | else { | 1912 | else { |
1906 | if ( iface ) | 1913 | if ( iface ) |
1907 | iface-> release ( ); | 1914 | iface-> release ( ); |
1908 | delete lib; | 1915 | delete lib; |
1909 | 1916 | ||
1910 | setStyle ( new LightStyle ( )); | 1917 | setStyle ( new LightStyle ( )); |
1911 | } | 1918 | } |
1912 | } | 1919 | } |
1913 | #endif | 1920 | #endif |
1914 | } | 1921 | } |
1915 | 1922 | ||
1916 | /*! | 1923 | /*! |
1917 | \internal | 1924 | \internal |
1918 | */ | 1925 | */ |
1919 | void QPEApplication::prepareForTermination( bool willrestart ) | 1926 | void QPEApplication::prepareForTermination( bool willrestart ) |
1920 | { | 1927 | { |
1921 | if ( willrestart ) { | 1928 | if ( willrestart ) { |
1922 | // Draw a big wait icon, the image can be altered in later revisions | 1929 | // Draw a big wait icon, the image can be altered in later revisions |
1923 | // QWidget *d = QApplication::desktop(); | 1930 | // QWidget *d = QApplication::desktop(); |
1924 | QImage img = Resource::loadImage( "launcher/new_wait" ); | 1931 | QImage img = Resource::loadImage( "launcher/new_wait" ); |
1925 | QPixmap pix; | 1932 | QPixmap pix; |
1926 | pix.convertFromImage( img.smoothScale( 1 * img.width(), 1 * img.height() ) ); | 1933 | pix.convertFromImage( img.smoothScale( 1 * img.width(), 1 * img.height() ) ); |
1927 | QLabel *lblWait = new QLabel( 0, "wait hack!", QWidget::WStyle_Customize | | 1934 | QLabel *lblWait = new QLabel( 0, "wait hack!", QWidget::WStyle_Customize | |
1928 | QWidget::WStyle_NoBorder | QWidget::WStyle_Tool ); | 1935 | QWidget::WStyle_NoBorder | QWidget::WStyle_Tool ); |
1929 | lblWait->setPixmap( pix ); | 1936 | lblWait->setPixmap( pix ); |
1930 | lblWait->setAlignment( QWidget::AlignCenter ); | 1937 | lblWait->setAlignment( QWidget::AlignCenter ); |
1931 | lblWait->show(); | 1938 | lblWait->show(); |
1932 | lblWait->showMaximized(); | 1939 | lblWait->showMaximized(); |
1933 | } | 1940 | } |
1934 | #ifndef SINGLE_APP | 1941 | #ifndef SINGLE_APP |
1935 | { QCopEnvelope envelope( "QPE/System", "forceQuit()" ); | 1942 | { QCopEnvelope envelope( "QPE/System", "forceQuit()" ); |
1936 | } | 1943 | } |
1937 | processEvents(); // ensure the message goes out. | 1944 | processEvents(); // ensure the message goes out. |
1938 | sleep( 1 ); // You have 1 second to comply. | 1945 | sleep( 1 ); // You have 1 second to comply. |
1939 | #endif | 1946 | #endif |
1940 | } | 1947 | } |
1941 | 1948 | ||
1942 | /*! | 1949 | /*! |
1943 | \internal | 1950 | \internal |
1944 | */ | 1951 | */ |
1945 | void QPEApplication::shutdown() | 1952 | void QPEApplication::shutdown() |
1946 | { | 1953 | { |
1947 | // Implement in server's QPEApplication subclass | 1954 | // Implement in server's QPEApplication subclass |
1948 | } | 1955 | } |
1949 | 1956 | ||
1950 | /*! | 1957 | /*! |
1951 | \internal | 1958 | \internal |
1952 | */ | 1959 | */ |
1953 | void QPEApplication::restart() | 1960 | void QPEApplication::restart() |
1954 | { | 1961 | { |
1955 | // Implement in server's QPEApplication subclass | 1962 | // Implement in server's QPEApplication subclass |
1956 | } | 1963 | } |
1957 | 1964 | ||
1958 | static QPtrDict<void>* stylusDict = 0; | 1965 | static QPtrDict<void>* stylusDict = 0; |
1959 | static void createDict() | 1966 | static void createDict() |
1960 | { | 1967 | { |
1961 | if ( !stylusDict ) | 1968 | if ( !stylusDict ) |
1962 | stylusDict = new QPtrDict<void>; | 1969 | stylusDict = new QPtrDict<void>; |
1963 | } | 1970 | } |
1964 | 1971 | ||
1965 | /*! | 1972 | /*! |
1966 | Returns the current StylusMode for widget \a w. | 1973 | Returns the current StylusMode for widget \a w. |
1967 | 1974 | ||
1968 | \sa setStylusOperation() StylusMode | 1975 | \sa setStylusOperation() StylusMode |
1969 | */ | 1976 | */ |
1970 | QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w ) | 1977 | QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w ) |
1971 | { | 1978 | { |
1972 | if ( stylusDict ) | 1979 | if ( stylusDict ) |
1973 | return ( StylusMode ) ( int ) stylusDict->find( w ); | 1980 | return ( StylusMode ) ( int ) stylusDict->find( w ); |
1974 | return LeftOnly; | 1981 | return LeftOnly; |
1975 | } | 1982 | } |
1976 | 1983 | ||
1977 | /*! | 1984 | /*! |
1978 | \enum QPEApplication::StylusMode | 1985 | \enum QPEApplication::StylusMode |
1979 | 1986 | ||
1980 | \value LeftOnly the stylus only generates LeftButton | 1987 | \value LeftOnly the stylus only generates LeftButton |
1981 | events (the default). | 1988 | events (the default). |
1982 | \value RightOnHold the stylus generates RightButton events | 1989 | \value RightOnHold the stylus generates RightButton events |
1983 | if the user uses the press-and-hold gesture. | 1990 | if the user uses the press-and-hold gesture. |
1984 | 1991 | ||
1985 | \sa setStylusOperation() stylusOperation() | 1992 | \sa setStylusOperation() stylusOperation() |
1986 | */ | 1993 | */ |
1987 | 1994 | ||
1988 | /*! | 1995 | /*! |
1989 | Causes widget \a w to receive mouse events according to the stylus | 1996 | Causes widget \a w to receive mouse events according to the stylus |
1990 | \a mode. | 1997 | \a mode. |
1991 | 1998 | ||
1992 | \sa stylusOperation() StylusMode | 1999 | \sa stylusOperation() StylusMode |
1993 | */ | 2000 | */ |
1994 | void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode ) | 2001 | void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode ) |
1995 | { | 2002 | { |
1996 | createDict(); | 2003 | createDict(); |
1997 | if ( mode == LeftOnly ) { | 2004 | if ( mode == LeftOnly ) { |
1998 | stylusDict->remove | 2005 | stylusDict->remove |
1999 | ( w ); | 2006 | ( w ); |
2000 | w->removeEventFilter( qApp ); | 2007 | w->removeEventFilter( qApp ); |
2001 | } | 2008 | } |
2002 | else { | 2009 | else { |
2003 | stylusDict->insert( w, ( void* ) mode ); | 2010 | stylusDict->insert( w, ( void* ) mode ); |
2004 | connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) ); | 2011 | connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) ); |
2005 | w->installEventFilter( qApp ); | 2012 | w->installEventFilter( qApp ); |
2006 | } | 2013 | } |
2007 | } | 2014 | } |
2008 | 2015 | ||
2009 | 2016 | ||
2010 | /*! | 2017 | /*! |
2011 | \reimp | 2018 | \reimp |
2012 | */ | 2019 | */ |
2013 | bool QPEApplication::eventFilter( QObject *o, QEvent *e ) | 2020 | bool QPEApplication::eventFilter( QObject *o, QEvent *e ) |
2014 | { | 2021 | { |
2015 | if ( !o->isWidgetType() ) | 2022 | if ( !o->isWidgetType() ) |
2016 | return FALSE; | 2023 | return FALSE; |
2017 | 2024 | ||
2018 | if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { | 2025 | if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { |
2019 | QMouseEvent * me = ( QMouseEvent* ) e; | 2026 | QMouseEvent * me = ( QMouseEvent* ) e; |
2020 | StylusMode mode = (StylusMode)(int)stylusDict->find(o); | 2027 | StylusMode mode = (StylusMode)(int)stylusDict->find(o); |
2021 | switch (mode) { | 2028 | switch (mode) { |
2022 | case RightOnHold: | 2029 | case RightOnHold: |
2023 | switch ( me->type() ) { | 2030 | switch ( me->type() ) { |
2024 | case QEvent::MouseButtonPress: | 2031 | case QEvent::MouseButtonPress: |
2025 | if ( me->button() == LeftButton ) { | 2032 | if ( me->button() == LeftButton ) { |
2026 | if (!d->presstimer ) | ||
2027 | d->presstimer = startTimer(500); // #### pref. | ||
2028 | d->presswidget = (QWidget*)o; | 2033 | d->presswidget = (QWidget*)o; |
2029 | d->presspos = me->pos(); | 2034 | d->presspos = me->pos(); |
2030 | d->rightpressed = FALSE; | 2035 | d->rightpressed = FALSE; |
2036 | // just for the time being | ||
2037 | static int pref = 500; | ||
2038 | #ifdef WITHROHFEEDBACK | ||
2039 | if( ! d->RoH ) | ||
2040 | d->RoH = new Opie::Internal::RoHFeedback; | ||
2041 | |||
2042 | d->RoH->init( me->globalPos(), d->presswidget ); | ||
2043 | pref = d->RoH->delay(); | ||
2044 | #endif | ||
2045 | if (!d->presstimer ) | ||
2046 | d->presstimer = startTimer( pref ); // #### pref. | ||
2047 | |||
2031 | } | 2048 | } |
2032 | break; | 2049 | break; |
2033 | case QEvent::MouseMove: | 2050 | case QEvent::MouseMove: |
2034 | if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) { | 2051 | if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) { |
2035 | killTimer(d->presstimer); | 2052 | killTimer(d->presstimer); |
2053 | #ifdef WITHROHFEEDBACK | ||
2054 | if( d->RoH ) | ||
2055 | d->RoH->stop( ); | ||
2056 | #endif | ||
2036 | d->presstimer = 0; | 2057 | d->presstimer = 0; |
2037 | } | 2058 | } |
2038 | break; | 2059 | break; |
2039 | case QEvent::MouseButtonRelease: | 2060 | case QEvent::MouseButtonRelease: |
2040 | if ( me->button() == LeftButton ) { | 2061 | if ( me->button() == LeftButton ) { |
2041 | if ( d->presstimer ) { | 2062 | if ( d->presstimer ) { |
2042 | killTimer(d->presstimer); | 2063 | killTimer(d->presstimer); |
2064 | #ifdef WITHROHFEEDBACK | ||
2065 | if( d->RoH ) | ||
2066 | d->RoH->stop( ); | ||
2067 | #endif | ||
2043 | d->presstimer = 0; | 2068 | d->presstimer = 0; |
2044 | } | 2069 | } |
2045 | if ( d->rightpressed && d->presswidget ) { | 2070 | if ( d->rightpressed && d->presswidget ) { |
2046 | // Right released | 2071 | // Right released |
2047 | postEvent( d->presswidget, | 2072 | postEvent( d->presswidget, |
2048 | new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), | 2073 | new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), |
2049 | RightButton, LeftButton + RightButton ) ); | 2074 | RightButton, LeftButton + RightButton ) ); |
2050 | // Left released, off-widget | 2075 | // Left released, off-widget |
2051 | postEvent( d->presswidget, | 2076 | postEvent( d->presswidget, |
2052 | new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1), | 2077 | new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1), |
2053 | LeftButton, LeftButton ) ); | 2078 | LeftButton, LeftButton ) ); |
2054 | postEvent( d->presswidget, | 2079 | postEvent( d->presswidget, |
2055 | new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1), | 2080 | new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1), |
2056 | LeftButton, LeftButton ) ); | 2081 | LeftButton, LeftButton ) ); |
2057 | d->rightpressed = FALSE; | 2082 | d->rightpressed = FALSE; |
2058 | return TRUE; // don't send the real Left release | 2083 | return TRUE; // don't send the real Left release |
2059 | } | 2084 | } |
2060 | } | 2085 | } |
2061 | break; | 2086 | break; |
2062 | default: | 2087 | default: |
2063 | break; | 2088 | break; |
2064 | } | 2089 | } |
2065 | break; | 2090 | break; |
2066 | default: | 2091 | default: |
2067 | ; | 2092 | ; |
2068 | } | 2093 | } |
2069 | } | 2094 | } |
2070 | else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { | 2095 | else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { |
2071 | QKeyEvent *ke = (QKeyEvent *)e; | 2096 | QKeyEvent *ke = (QKeyEvent *)e; |
2072 | if ( ke->key() == Key_Enter ) { | 2097 | if ( ke->key() == Key_Enter ) { |
2073 | if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { | 2098 | if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { |
2074 | postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', | 2099 | postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', |
2075 | ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); | 2100 | ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); |
2076 | return TRUE; | 2101 | return TRUE; |
2077 | } | 2102 | } |
2078 | } | 2103 | } |
2079 | } | 2104 | } |
2080 | return FALSE; | 2105 | return FALSE; |
2081 | } | 2106 | } |
2082 | 2107 | ||
2083 | /*! | 2108 | /*! |
2084 | \reimp | 2109 | \reimp |
2085 | */ | 2110 | */ |
2086 | void QPEApplication::timerEvent( QTimerEvent *e ) | 2111 | void QPEApplication::timerEvent( QTimerEvent *e ) |
2087 | { | 2112 | { |
2088 | if ( e->timerId() == d->presstimer && d->presswidget ) { | 2113 | if ( e->timerId() == d->presstimer && d->presswidget ) { |
2089 | // Right pressed | 2114 | // Right pressed |
2090 | postEvent( d->presswidget, | 2115 | postEvent( d->presswidget, |
2091 | new QMouseEvent( QEvent::MouseButtonPress, d->presspos, | 2116 | new QMouseEvent( QEvent::MouseButtonPress, d->presspos, |
2092 | RightButton, LeftButton ) ); | 2117 | RightButton, LeftButton ) ); |
2093 | killTimer( d->presstimer ); | 2118 | killTimer( d->presstimer ); |
2094 | d->presstimer = 0; | 2119 | d->presstimer = 0; |
2095 | d->rightpressed = TRUE; | 2120 | d->rightpressed = TRUE; |
2121 | d->RoH->stop(); | ||
2096 | } | 2122 | } |
2097 | } | 2123 | } |
2098 | 2124 | ||
2099 | void QPEApplication::removeSenderFromStylusDict() | 2125 | void QPEApplication::removeSenderFromStylusDict() |
2100 | { | 2126 | { |
2101 | stylusDict->remove | 2127 | stylusDict->remove |
2102 | ( ( void* ) sender() ); | 2128 | ( ( void* ) sender() ); |
2103 | if ( d->presswidget == sender() ) | 2129 | if ( d->presswidget == sender() ) |
2104 | d->presswidget = 0; | 2130 | d->presswidget = 0; |
2105 | } | 2131 | } |
2106 | 2132 | ||
2107 | /*! | 2133 | /*! |
2108 | \internal | 2134 | \internal |
2109 | */ | 2135 | */ |
2110 | bool QPEApplication::keyboardGrabbed() const | 2136 | bool QPEApplication::keyboardGrabbed() const |
2111 | { | 2137 | { |
2112 | return d->kbgrabbed; | 2138 | return d->kbgrabbed; |
2113 | } | 2139 | } |
2114 | 2140 | ||
2115 | 2141 | ||
2116 | /*! | 2142 | /*! |
2117 | Reverses the effect of grabKeyboard(). This is called automatically | 2143 | Reverses the effect of grabKeyboard(). This is called automatically |
2118 | on program exit. | 2144 | on program exit. |
2119 | */ | 2145 | */ |
2120 | void QPEApplication::ungrabKeyboard() | 2146 | void QPEApplication::ungrabKeyboard() |
2121 | { | 2147 | { |
2122 | ((QPEApplication *) qApp )-> d-> kbgrabbed = false; | 2148 | ((QPEApplication *) qApp )-> d-> kbgrabbed = false; |
2123 | } | 2149 | } |
2124 | 2150 | ||
2125 | /*! | 2151 | /*! |
2126 | Grabs the physical keyboard keys, e.g. the application's launching | 2152 | Grabs the physical keyboard keys, e.g. the application's launching |
2127 | keys. Instead of launching applications when these keys are pressed | 2153 | keys. Instead of launching applications when these keys are pressed |
2128 | the signals emitted are sent to this application instead. Some games | 2154 | the signals emitted are sent to this application instead. Some games |
2129 | programs take over the launch keys in this way to make interaction | 2155 | programs take over the launch keys in this way to make interaction |
2130 | easier. | 2156 | easier. |
2131 | 2157 | ||
2132 | \sa ungrabKeyboard() | 2158 | \sa ungrabKeyboard() |
2133 | */ | 2159 | */ |
2134 | void QPEApplication::grabKeyboard() | 2160 | void QPEApplication::grabKeyboard() |
2135 | { | 2161 | { |
2136 | ((QPEApplication *) qApp )-> d-> kbgrabbed = true; | 2162 | ((QPEApplication *) qApp )-> d-> kbgrabbed = true; |
2137 | } | 2163 | } |
2138 | 2164 | ||
2139 | /*! | 2165 | /*! |
2140 | \reimp | 2166 | \reimp |
2141 | */ | 2167 | */ |
2142 | int QPEApplication::exec() | 2168 | int QPEApplication::exec() |
2143 | { | 2169 | { |
2144 | d->qcopQok = true; | 2170 | d->qcopQok = true; |
2145 | #ifndef QT_NO_COP | 2171 | #ifndef QT_NO_COP |
2146 | d->sendQCopQ(); | 2172 | d->sendQCopQ(); |
2147 | if ( !d->keep_running ) | 2173 | if ( !d->keep_running ) |
2148 | processEvents(); // we may have received QCop messages in the meantime. | 2174 | processEvents(); // we may have received QCop messages in the meantime. |
2149 | #endif | 2175 | #endif |
2150 | 2176 | ||
2151 | if ( d->keep_running ) | 2177 | if ( d->keep_running ) |
2152 | //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) | 2178 | //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) |
2153 | return QApplication::exec(); | 2179 | return QApplication::exec(); |
2154 | 2180 | ||
2155 | #ifndef QT_NO_COP | 2181 | #ifndef QT_NO_COP |
2156 | 2182 | ||
2157 | { | 2183 | { |
2158 | QCopEnvelope e( "QPE/System", "closing(QString)" ); | 2184 | QCopEnvelope e( "QPE/System", "closing(QString)" ); |
2159 | e << d->appName; | 2185 | e << d->appName; |
2160 | } | 2186 | } |
2161 | #endif | 2187 | #endif |
2162 | processEvents(); | 2188 | processEvents(); |
2163 | return 0; | 2189 | return 0; |
2164 | } | 2190 | } |
2165 | 2191 | ||
2166 | /*! | 2192 | /*! |
2167 | \internal | 2193 | \internal |
2168 | External request for application to quit. Quits if possible without | 2194 | External request for application to quit. Quits if possible without |
2169 | loosing state. | 2195 | loosing state. |
2170 | */ | 2196 | */ |
2171 | void QPEApplication::tryQuit() | 2197 | void QPEApplication::tryQuit() |
2172 | { | 2198 | { |
2173 | if ( activeModalWidget() ) | 2199 | if ( activeModalWidget() ) |
2174 | return ; // Inside modal loop or konsole. Too hard to save state. | 2200 | return ; // Inside modal loop or konsole. Too hard to save state. |
2175 | #ifndef QT_NO_COP | 2201 | #ifndef QT_NO_COP |
2176 | 2202 | ||
2177 | { | 2203 | { |
2178 | QCopEnvelope e( "QPE/System", "closing(QString)" ); | 2204 | QCopEnvelope e( "QPE/System", "closing(QString)" ); |
2179 | e << d->appName; | 2205 | e << d->appName; |
2180 | } | 2206 | } |
2181 | #endif | 2207 | #endif |
2182 | if ( d->keep_running ) | 2208 | if ( d->keep_running ) |
2183 | d->store_widget_rect(d->qpe_main_widget, d->appName); | 2209 | d->store_widget_rect(d->qpe_main_widget, d->appName); |
2184 | processEvents(); | 2210 | processEvents(); |
2185 | 2211 | ||
2186 | quit(); | 2212 | quit(); |
2187 | } | 2213 | } |
2188 | 2214 | ||
2189 | /*! | 2215 | /*! |
2190 | \internal | 2216 | \internal |
2191 | */ | 2217 | */ |
2192 | void QPEApplication::installTranslation( const QString& baseName ) { | 2218 | void QPEApplication::installTranslation( const QString& baseName ) { |
2193 | QTranslator* trans = new QTranslator(this); | 2219 | QTranslator* trans = new QTranslator(this); |
2194 | QString tfn = qpeDir() + "/i18n/"+baseName; | 2220 | QString tfn = qpeDir() + "/i18n/"+baseName; |
2195 | if ( trans->load( tfn ) ) | 2221 | if ( trans->load( tfn ) ) |
2196 | installTranslator( trans ); | 2222 | installTranslator( trans ); |
2197 | else | 2223 | else |
2198 | delete trans; | 2224 | delete trans; |
2199 | } | 2225 | } |
2200 | 2226 | ||
2201 | /*! | 2227 | /*! |
2202 | \internal | 2228 | \internal |
2203 | User initiated quit. Makes the window 'Go Away'. If preloaded this means | 2229 | User initiated quit. Makes the window 'Go Away'. If preloaded this means |
2204 | hiding the window. If not it means quitting the application. | 2230 | hiding the window. If not it means quitting the application. |
2205 | As this is user initiated we don't need to check state. | 2231 | As this is user initiated we don't need to check state. |
2206 | */ | 2232 | */ |
2207 | void QPEApplication::hideOrQuit() | 2233 | void QPEApplication::hideOrQuit() |
2208 | { | 2234 | { |
2209 | if ( d->keep_running ) | 2235 | if ( d->keep_running ) |
2210 | d->store_widget_rect(d->qpe_main_widget, d->appName); | 2236 | d->store_widget_rect(d->qpe_main_widget, d->appName); |
2211 | processEvents(); | 2237 | processEvents(); |
2212 | 2238 | ||
2213 | // If we are a preloaded application we don't actually quit, so emit | 2239 | // If we are a preloaded application we don't actually quit, so emit |
2214 | // a System message indicating we're quasi-closing. | 2240 | // a System message indicating we're quasi-closing. |
2215 | if ( d->preloaded && d->qpe_main_widget ) | 2241 | if ( d->preloaded && d->qpe_main_widget ) |
2216 | #ifndef QT_NO_COP | 2242 | #ifndef QT_NO_COP |
2217 | 2243 | ||
2218 | { | 2244 | { |
2219 | QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); | 2245 | QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); |
2220 | e << d->appName; | 2246 | e << d->appName; |
2221 | d->qpe_main_widget->hide(); | 2247 | d->qpe_main_widget->hide(); |
2222 | } | 2248 | } |
2223 | #endif | 2249 | #endif |
2224 | else | 2250 | else |
2225 | quit(); | 2251 | quit(); |
2226 | } | 2252 | } |
2227 | 2253 | ||
2228 | #if (__GNUC__ > 2 ) | 2254 | #if (__GNUC__ > 2 ) |
2229 | extern "C" void __cxa_pure_virtual(); | 2255 | extern "C" void __cxa_pure_virtual(); |
2230 | 2256 | ||
2231 | void __cxa_pure_virtual() | 2257 | void __cxa_pure_virtual() |
2232 | { | 2258 | { |
2233 | fprintf( stderr, "Pure virtual called\n"); | 2259 | fprintf( stderr, "Pure virtual called\n"); |
2234 | abort(); | 2260 | abort(); |
2235 | 2261 | ||
2236 | } | 2262 | } |
2237 | 2263 | ||
2238 | #endif | 2264 | #endif |
2239 | 2265 | ||
2240 | 2266 | ||
2241 | #if defined(OPIE_NEW_MALLOC) | 2267 | #if defined(OPIE_NEW_MALLOC) |
2242 | 2268 | ||
2243 | // The libraries with the skiff package (and possibly others) have | 2269 | // The libraries with the skiff package (and possibly others) have |
2244 | // completely useless implementations of builtin new and delete that | 2270 | // completely useless implementations of builtin new and delete that |
2245 | // use about 50% of your CPU. Here we revert to the simple libc | 2271 | // use about 50% of your CPU. Here we revert to the simple libc |
2246 | // functions. | 2272 | // functions. |
2247 | 2273 | ||
2248 | void* operator new[]( size_t size ) | 2274 | void* operator new[]( size_t size ) |
2249 | { | 2275 | { |
2250 | return malloc( size ); | 2276 | return malloc( size ); |
2251 | } | 2277 | } |
2252 | 2278 | ||
2253 | void* operator new( size_t size ) | 2279 | void* operator new( size_t size ) |
2254 | { | 2280 | { |
2255 | return malloc( size ); | 2281 | return malloc( size ); |
2256 | } | 2282 | } |
2257 | 2283 | ||
2258 | void operator delete[]( void* p ) | 2284 | void operator delete[]( void* p ) |
2259 | { | 2285 | { |
2260 | free( p ); | 2286 | free( p ); |
2261 | } | 2287 | } |
2262 | 2288 | ||
2263 | void operator delete[]( void* p, size_t /*size*/ ) | 2289 | void operator delete[]( void* p, size_t /*size*/ ) |
2264 | { | 2290 | { |
2265 | free( p ); | 2291 | free( p ); |
2266 | } | 2292 | } |
2267 | 2293 | ||
2268 | 2294 | ||
2269 | void operator delete( void* p ) | 2295 | void operator delete( void* p ) |
2270 | { | 2296 | { |
2271 | free( p ); | 2297 | free( p ); |
2272 | } | 2298 | } |
2273 | 2299 | ||
2274 | void operator delete( void* p, size_t /*size*/ ) | 2300 | void operator delete( void* p, size_t /*size*/ ) |
2275 | { | 2301 | { |
2276 | free( p ); | 2302 | free( p ); |
2277 | } | 2303 | } |
2278 | 2304 | ||
2279 | #endif | 2305 | #endif |
2280 | 2306 | ||
2281 | #if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP) | 2307 | #if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP) |
2282 | #include <qwidgetlist.h> | 2308 | #include <qwidgetlist.h> |
2283 | #ifdef QWS | 2309 | #ifdef QWS |
2284 | #include <qgfx_qws.h> | 2310 | #include <qgfx_qws.h> |
2285 | extern QRect qt_maxWindowRect; | 2311 | extern QRect qt_maxWindowRect; |
2286 | void qt_setMaxWindowRect(const QRect& r ) | 2312 | void qt_setMaxWindowRect(const QRect& r ) |
2287 | { | 2313 | { |