author | zecke <zecke> | 2005-02-22 23:25:19 (UTC) |
---|---|---|
committer | zecke <zecke> | 2005-02-22 23:25:19 (UTC) |
commit | 30857db6ca3f355aa3d50b59f03a13c82f265af2 (patch) (unidiff) | |
tree | 53431b5d7108c674fe99ea214d06a60a5e494588 | |
parent | ff2fdaf1a8e8a17ce756c0413102b37705e0c646 (diff) | |
download | opie-30857db6ca3f355aa3d50b59f03a13c82f265af2.zip opie-30857db6ca3f355aa3d50b59f03a13c82f265af2.tar.gz opie-30857db6ca3f355aa3d50b59f03a13c82f265af2.tar.bz2 |
Instead of having the same method four time with different name and image to load
we now have a define.
This makes it more easy to change the handling of builtin decoration image
-rw-r--r-- | library/qpedecoration_qws.cpp | 55 |
1 files changed, 15 insertions, 40 deletions
diff --git a/library/qpedecoration_qws.cpp b/library/qpedecoration_qws.cpp index fb47c14..1afae88 100644 --- a/library/qpedecoration_qws.cpp +++ b/library/qpedecoration_qws.cpp | |||
@@ -1,968 +1,943 @@ | |||
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 | #ifdef QWS | 20 | #ifdef QWS |
21 | #define QTOPIA_INTERNAL_LANGLIST | 21 | #define QTOPIA_INTERNAL_LANGLIST |
22 | #include <qapplication.h> | 22 | #include <qapplication.h> |
23 | #include <qstyle.h> | 23 | #include <qstyle.h> |
24 | #include <qwidget.h> | 24 | #include <qwidget.h> |
25 | #include <qpainter.h> | 25 | #include <qpainter.h> |
26 | #include <qtimer.h> | 26 | #include <qtimer.h> |
27 | #include <qwhatsthis.h> | 27 | #include <qwhatsthis.h> |
28 | #include <qpopupmenu.h> | 28 | #include <qpopupmenu.h> |
29 | #include "qcopenvelope_qws.h" | 29 | #include "qcopenvelope_qws.h" |
30 | #include "qpedecoration_qws.h" | 30 | #include "qpedecoration_qws.h" |
31 | #include <qdialog.h> | 31 | #include <qdialog.h> |
32 | #include <qdrawutil.h> | 32 | #include <qdrawutil.h> |
33 | #include <qgfx_qws.h> | 33 | #include <qgfx_qws.h> |
34 | #include "qpeapplication.h" | 34 | #include "qpeapplication.h" |
35 | #include "resource.h" | 35 | #include "resource.h" |
36 | #include "global.h" | 36 | #include "global.h" |
37 | #include "qlibrary.h" | 37 | #include "qlibrary.h" |
38 | #include "windowdecorationinterface.h" | 38 | #include "windowdecorationinterface.h" |
39 | #include <qpe/qlibrary.h> | 39 | #include <qpe/qlibrary.h> |
40 | #include <qfile.h> | 40 | #include <qfile.h> |
41 | #include <qsignal.h> | 41 | #include <qsignal.h> |
42 | 42 | ||
43 | #include <stdlib.h> | 43 | #include <stdlib.h> |
44 | 44 | ||
45 | extern Q_EXPORT QRect qt_maxWindowRect; | 45 | extern Q_EXPORT QRect qt_maxWindowRect; |
46 | 46 | ||
47 | #define WHATSTHIS_MODE | 47 | #define WHATSTHIS_MODE |
48 | 48 | ||
49 | #ifndef QT_NO_QWS_QPE_WM_STYLE | 49 | #ifndef QT_NO_QWS_QPE_WM_STYLE |
50 | 50 | ||
51 | #ifndef QT_NO_IMAGEIO_XPM | 51 | #ifndef QT_NO_IMAGEIO_XPM |
52 | 52 | ||
53 | /* XPM */ | 53 | /* XPM */ |
54 | static const char * const qpe_close_xpm[] = { | 54 | static const char * const qpe_close_xpm[] = { |
55 | "16 16 3 1", | 55 | "16 16 3 1", |
56 | " c None", | 56 | " c None", |
57 | ". c #FFFFFF", | 57 | ". c #FFFFFF", |
58 | "+ c #000000", | 58 | "+ c #000000", |
59 | " ", | 59 | " ", |
60 | " ", | 60 | " ", |
61 | " ..... ", | 61 | " ..... ", |
62 | " ..+++++.. ", | 62 | " ..+++++.. ", |
63 | " .+++++++++. ", | 63 | " .+++++++++. ", |
64 | " .+..+++..+. ", | 64 | " .+..+++..+. ", |
65 | " .++...+...++. ", | 65 | " .++...+...++. ", |
66 | " .+++.....+++. ", | 66 | " .+++.....+++. ", |
67 | " .++++...++++. ", | 67 | " .++++...++++. ", |
68 | " .+++.....+++. ", | 68 | " .+++.....+++. ", |
69 | " .++...+...++. ", | 69 | " .++...+...++. ", |
70 | " .+..+++..+. ", | 70 | " .+..+++..+. ", |
71 | " .+++++++++. ", | 71 | " .+++++++++. ", |
72 | " ..+++++.. ", | 72 | " ..+++++.. ", |
73 | " ..... ", | 73 | " ..... ", |
74 | " "}; | 74 | " "}; |
75 | 75 | ||
76 | /* XPM */ | 76 | /* XPM */ |
77 | static const char * const qpe_accept_xpm[] = { | 77 | static const char * const qpe_accept_xpm[] = { |
78 | "16 16 3 1", | 78 | "16 16 3 1", |
79 | " c None", | 79 | " c None", |
80 | ". c #FFFFFF", | 80 | ". c #FFFFFF", |
81 | "+ c #000000", | 81 | "+ c #000000", |
82 | " ", | 82 | " ", |
83 | " ", | 83 | " ", |
84 | " ..... ", | 84 | " ..... ", |
85 | " ..+++++.. ", | 85 | " ..+++++.. ", |
86 | " .+++++++++. ", | 86 | " .+++++++++. ", |
87 | " .+++++++++. ", | 87 | " .+++++++++. ", |
88 | " .+++++++..++. ", | 88 | " .+++++++..++. ", |
89 | " .++.+++...++. ", | 89 | " .++.+++...++. ", |
90 | " .+...+...+++. ", | 90 | " .+...+...+++. ", |
91 | " .+......++++. ", | 91 | " .+......++++. ", |
92 | " .++....+++++. ", | 92 | " .++....+++++. ", |
93 | " .++..+++++. ", | 93 | " .++..+++++. ", |
94 | " .+++++++++. ", | 94 | " .+++++++++. ", |
95 | " ..+++++.. ", | 95 | " ..+++++.. ", |
96 | " ..... ", | 96 | " ..... ", |
97 | " "}; | 97 | " "}; |
98 | 98 | ||
99 | #endif // QT_NO_IMAGEIO_XPM | 99 | #endif // QT_NO_IMAGEIO_XPM |
100 | 100 | ||
101 | class DecorHackWidget : public QWidget | 101 | class DecorHackWidget : public QWidget |
102 | { | 102 | { |
103 | public: | 103 | public: |
104 | bool needsOk() { | 104 | bool needsOk() { |
105 | return (getWState() & WState_Reserved1 ) || | 105 | return (getWState() & WState_Reserved1 ) || |
106 | (inherits("QDialog") && !inherits("QMessageBox") | 106 | (inherits("QDialog") && !inherits("QMessageBox") |
107 | && !inherits("QWizard") ); | 107 | && !inherits("QWizard") ); |
108 | } | 108 | } |
109 | }; | 109 | }; |
110 | 110 | ||
111 | static QImage scaleButton( const QImage &img, int height ) | 111 | static QImage scaleButton( const QImage &img, int height ) |
112 | { | 112 | { |
113 | //ML: We don't want to scale if the difference is less than 4 pixels to prevent blurring | 113 | //ML: We don't want to scale if the difference is less than 4 pixels to prevent blurring |
114 | if ( img.height() != 0 && ::abs( img.height()-height ) > 4 ) { | 114 | if ( img.height() != 0 && ::abs( img.height()-height ) > 4 ) { |
115 | return img.smoothScale( img.width()*height/img.height(), height ); | 115 | return img.smoothScale( img.width()*height/img.height(), height ); |
116 | } else { | 116 | } else { |
117 | return img; | 117 | return img; |
118 | } | 118 | } |
119 | } | 119 | } |
120 | 120 | ||
121 | class TLWidget : public QWidget | 121 | class TLWidget : public QWidget |
122 | { | 122 | { |
123 | public: | 123 | public: |
124 | QWSManager *manager() | 124 | QWSManager *manager() |
125 | { | 125 | { |
126 | return topData()->qwsManager; | 126 | return topData()->qwsManager; |
127 | } | 127 | } |
128 | 128 | ||
129 | QTLWExtra *topExtra() | 129 | QTLWExtra *topExtra() |
130 | { | 130 | { |
131 | return topData(); | 131 | return topData(); |
132 | } | 132 | } |
133 | 133 | ||
134 | void setWState( uint s ) { QWidget::setWState( s ); } | 134 | void setWState( uint s ) { QWidget::setWState( s ); } |
135 | void clearWState( uint s ) { QWidget::clearWState( s ); } | 135 | void clearWState( uint s ) { QWidget::clearWState( s ); } |
136 | }; | 136 | }; |
137 | 137 | ||
138 | 138 | ||
139 | QPEManager::QPEManager( QPEDecoration *d, QObject *parent ) | 139 | QPEManager::QPEManager( QPEDecoration *d, QObject *parent ) |
140 | : QObject( parent ), decoration( d ), helpState(0), inWhatsThis(FALSE) | 140 | : QObject( parent ), decoration( d ), helpState(0), inWhatsThis(FALSE) |
141 | { | 141 | { |
142 | wtTimer = new QTimer( this ); | 142 | wtTimer = new QTimer( this ); |
143 | connect( wtTimer, SIGNAL(timeout()), this, SLOT(whatsThisTimeout()) ); | 143 | connect( wtTimer, SIGNAL(timeout()), this, SLOT(whatsThisTimeout()) ); |
144 | } | 144 | } |
145 | 145 | ||
146 | 146 | ||
147 | void QPEManager::updateActive() | 147 | void QPEManager::updateActive() |
148 | { | 148 | { |
149 | QWidget *newActive = qApp->activeWindow(); | 149 | QWidget *newActive = qApp->activeWindow(); |
150 | if ( newActive && (QWidget*)active == newActive ) | 150 | if ( newActive && (QWidget*)active == newActive ) |
151 | return; | 151 | return; |
152 | 152 | ||
153 | if ( active && (!newActive || ((TLWidget *)newActive)->manager()) ) { | 153 | if ( active && (!newActive || ((TLWidget *)newActive)->manager()) ) { |
154 | ((TLWidget *)(QWidget*)active)->manager()->removeEventFilter( this ); | 154 | ((TLWidget *)(QWidget*)active)->manager()->removeEventFilter( this ); |
155 | } | 155 | } |
156 | 156 | ||
157 | if ( newActive && ((TLWidget *)newActive)->manager() ) { | 157 | if ( newActive && ((TLWidget *)newActive)->manager() ) { |
158 | active = newActive; | 158 | active = newActive; |
159 | ((TLWidget *)(QWidget*)active)->manager()->installEventFilter( this ); | 159 | ((TLWidget *)(QWidget*)active)->manager()->installEventFilter( this ); |
160 | } else if ( !newActive ) { | 160 | } else if ( !newActive ) { |
161 | active = 0; | 161 | active = 0; |
162 | } | 162 | } |
163 | } | 163 | } |
164 | 164 | ||
165 | int QPEManager::pointInQpeRegion( QWidget *w, const QPoint &p ) | 165 | int QPEManager::pointInQpeRegion( QWidget *w, const QPoint &p ) |
166 | { | 166 | { |
167 | QRect rect(w->geometry()); | 167 | QRect rect(w->geometry()); |
168 | 168 | ||
169 | if ( decoration->region( w, rect, | 169 | if ( decoration->region( w, rect, |
170 | (QWSDecoration::Region)QPEDecoration::Help ).contains(p) ) | 170 | (QWSDecoration::Region)QPEDecoration::Help ).contains(p) ) |
171 | return QPEDecoration::Help; | 171 | return QPEDecoration::Help; |
172 | 172 | ||
173 | for (int i = QWSDecoration::LastRegion; i >= QWSDecoration::Title; i--) { | 173 | for (int i = QWSDecoration::LastRegion; i >= QWSDecoration::Title; i--) { |
174 | if (decoration->region(w, rect, (QWSDecoration::Region)i).contains(p)) | 174 | if (decoration->region(w, rect, (QWSDecoration::Region)i).contains(p)) |
175 | return (QWSDecoration::Region)i; | 175 | return (QWSDecoration::Region)i; |
176 | } | 176 | } |
177 | 177 | ||
178 | return QWSDecoration::None; | 178 | return QWSDecoration::None; |
179 | } | 179 | } |
180 | 180 | ||
181 | bool QPEManager::eventFilter( QObject *o, QEvent *e ) | 181 | bool QPEManager::eventFilter( QObject *o, QEvent *e ) |
182 | { | 182 | { |
183 | QWSManager *mgr = (QWSManager *)o; | 183 | QWSManager *mgr = (QWSManager *)o; |
184 | QWidget *w = mgr->widget(); | 184 | QWidget *w = mgr->widget(); |
185 | switch ( e->type() ) { | 185 | switch ( e->type() ) { |
186 | case QEvent::MouseButtonPress: | 186 | case QEvent::MouseButtonPress: |
187 | { | 187 | { |
188 | pressTime = QTime::currentTime(); | 188 | pressTime = QTime::currentTime(); |
189 | QPoint p = ((QMouseEvent*)e)->globalPos(); | 189 | QPoint p = ((QMouseEvent*)e)->globalPos(); |
190 | int inRegion = pointInQpeRegion( w, p ); | 190 | int inRegion = pointInQpeRegion( w, p ); |
191 | #ifdef WHATSTHIS_MODE | 191 | #ifdef WHATSTHIS_MODE |
192 | if ( !w->geometry().contains(p) && QWhatsThis::inWhatsThisMode() ) { | 192 | if ( !w->geometry().contains(p) && QWhatsThis::inWhatsThisMode() ) { |
193 | QString text; | 193 | QString text; |
194 | switch ( inRegion ) { | 194 | switch ( inRegion ) { |
195 | case QWSDecoration::Close: | 195 | case QWSDecoration::Close: |
196 | if ( ((DecorHackWidget*)w)->needsOk() ) | 196 | if ( ((DecorHackWidget*)w)->needsOk() ) |
197 | text = tr("Click to close this window, discarding changes."); | 197 | text = tr("Click to close this window, discarding changes."); |
198 | else | 198 | else |
199 | text = tr("Click to close this window."); | 199 | text = tr("Click to close this window."); |
200 | break; | 200 | break; |
201 | case QWSDecoration::Minimize: | 201 | case QWSDecoration::Minimize: |
202 | text = tr("Click to close this window and apply changes."); | 202 | text = tr("Click to close this window and apply changes."); |
203 | break; | 203 | break; |
204 | case QWSDecoration::Maximize: | 204 | case QWSDecoration::Maximize: |
205 | if ( w->isMaximized() ) | 205 | if ( w->isMaximized() ) |
206 | text = tr("Click to make this window movable."); | 206 | text = tr("Click to make this window movable."); |
207 | else | 207 | else |
208 | text = tr("Click to make this window use all available screen area."); | 208 | text = tr("Click to make this window use all available screen area."); |
209 | break; | 209 | break; |
210 | default: | 210 | default: |
211 | break; | 211 | break; |
212 | } | 212 | } |
213 | QWhatsThis::leaveWhatsThisMode( text ); | 213 | QWhatsThis::leaveWhatsThisMode( text ); |
214 | whatsThisTimeout(); | 214 | whatsThisTimeout(); |
215 | helpState = 0; | 215 | helpState = 0; |
216 | return true; | 216 | return true; |
217 | } | 217 | } |
218 | #endif | 218 | #endif |
219 | if ( inRegion == QPEDecoration::Help ) { | 219 | if ( inRegion == QPEDecoration::Help ) { |
220 | #ifdef WHATSTHIS_MODE | 220 | #ifdef WHATSTHIS_MODE |
221 | wtTimer->start( 400, TRUE ); | 221 | wtTimer->start( 400, TRUE ); |
222 | #endif | 222 | #endif |
223 | helpState = QWSButton::Clicked|QWSButton::MouseOver; | 223 | helpState = QWSButton::Clicked|QWSButton::MouseOver; |
224 | drawButton( w, QPEDecoration::Help, helpState ); | 224 | drawButton( w, QPEDecoration::Help, helpState ); |
225 | return true; | 225 | return true; |
226 | } | 226 | } |
227 | } | 227 | } |
228 | break; | 228 | break; |
229 | case QEvent::MouseButtonRelease: | 229 | case QEvent::MouseButtonRelease: |
230 | if ( helpState & QWSButton::Clicked ) { | 230 | if ( helpState & QWSButton::Clicked ) { |
231 | wtTimer->stop(); | 231 | wtTimer->stop(); |
232 | helpState = 0; | 232 | helpState = 0; |
233 | drawButton( w, QPEDecoration::Help, helpState ); | 233 | drawButton( w, QPEDecoration::Help, helpState ); |
234 | QPoint p = ((QMouseEvent*)e)->globalPos(); | 234 | QPoint p = ((QMouseEvent*)e)->globalPos(); |
235 | if ( pointInQpeRegion( w, p ) == QPEDecoration::Help ) { | 235 | if ( pointInQpeRegion( w, p ) == QPEDecoration::Help ) { |
236 | decoration->help( w ); | 236 | decoration->help( w ); |
237 | } | 237 | } |
238 | return true; | 238 | return true; |
239 | } | 239 | } |
240 | break; | 240 | break; |
241 | case QEvent::MouseMove: | 241 | case QEvent::MouseMove: |
242 | if ( helpState & QWSButton::Clicked ) { | 242 | if ( helpState & QWSButton::Clicked ) { |
243 | int oldState = helpState; | 243 | int oldState = helpState; |
244 | QPoint p = ((QMouseEvent*)e)->globalPos(); | 244 | QPoint p = ((QMouseEvent*)e)->globalPos(); |
245 | if ( pointInQpeRegion( w, p ) == QPEDecoration::Help ) { | 245 | if ( pointInQpeRegion( w, p ) == QPEDecoration::Help ) { |
246 | helpState = QWSButton::Clicked|QWSButton::MouseOver; | 246 | helpState = QWSButton::Clicked|QWSButton::MouseOver; |
247 | } else { | 247 | } else { |
248 | helpState = 0; | 248 | helpState = 0; |
249 | } | 249 | } |
250 | if ( helpState != oldState ) | 250 | if ( helpState != oldState ) |
251 | drawButton( w, QPEDecoration::Help, helpState ); | 251 | drawButton( w, QPEDecoration::Help, helpState ); |
252 | } | 252 | } |
253 | break; | 253 | break; |
254 | default: | 254 | default: |
255 | break; | 255 | break; |
256 | } | 256 | } |
257 | return QObject::eventFilter( o, e ); | 257 | return QObject::eventFilter( o, e ); |
258 | } | 258 | } |
259 | 259 | ||
260 | void QPEManager::drawButton( QWidget *w, QPEDecoration::QPERegion r, int state ) | 260 | void QPEManager::drawButton( QWidget *w, QPEDecoration::QPERegion r, int state ) |
261 | { | 261 | { |
262 | QPainter painter(w); | 262 | QPainter painter(w); |
263 | QRegion rgn = ((TLWidget *)w)->topExtra()->decor_allocated_region; | 263 | QRegion rgn = ((TLWidget *)w)->topExtra()->decor_allocated_region; |
264 | painter.internalGfx()->setWidgetDeviceRegion( rgn ); | 264 | painter.internalGfx()->setWidgetDeviceRegion( rgn ); |
265 | painter.setClipRegion(decoration->region(w, w->rect(),QWSDecoration::All)); | 265 | painter.setClipRegion(decoration->region(w, w->rect(),QWSDecoration::All)); |
266 | decoration->paintButton( &painter, w, (QWSDecoration::Region)r, state ); | 266 | decoration->paintButton( &painter, w, (QWSDecoration::Region)r, state ); |
267 | } | 267 | } |
268 | 268 | ||
269 | void QPEManager::drawTitle( QWidget *w ) | 269 | void QPEManager::drawTitle( QWidget *w ) |
270 | { | 270 | { |
271 | QPainter painter(w); | 271 | QPainter painter(w); |
272 | QRegion rgn = ((TLWidget *)w)->topExtra()->decor_allocated_region; | 272 | QRegion rgn = ((TLWidget *)w)->topExtra()->decor_allocated_region; |
273 | painter.internalGfx()->setWidgetDeviceRegion( rgn ); | 273 | painter.internalGfx()->setWidgetDeviceRegion( rgn ); |
274 | painter.setClipRegion(decoration->region(w, w->rect(),QWSDecoration::All)); | 274 | painter.setClipRegion(decoration->region(w, w->rect(),QWSDecoration::All)); |
275 | decoration->paint( &painter, w ); | 275 | decoration->paint( &painter, w ); |
276 | decoration->paintButton(&painter, w, QWSDecoration::Menu, 0); | 276 | decoration->paintButton(&painter, w, QWSDecoration::Menu, 0); |
277 | decoration->paintButton(&painter, w, QWSDecoration::Close, 0); | 277 | decoration->paintButton(&painter, w, QWSDecoration::Close, 0); |
278 | decoration->paintButton(&painter, w, QWSDecoration::Minimize, 0); | 278 | decoration->paintButton(&painter, w, QWSDecoration::Minimize, 0); |
279 | decoration->paintButton(&painter, w, QWSDecoration::Maximize, 0); | 279 | decoration->paintButton(&painter, w, QWSDecoration::Maximize, 0); |
280 | } | 280 | } |
281 | 281 | ||
282 | void QPEManager::whatsThisTimeout() | 282 | void QPEManager::whatsThisTimeout() |
283 | { | 283 | { |
284 | if ( !QWhatsThis::inWhatsThisMode() ) { | 284 | if ( !QWhatsThis::inWhatsThisMode() ) { |
285 | if ( inWhatsThis ) { | 285 | if ( inWhatsThis ) { |
286 | if ( whatsThis ) { | 286 | if ( whatsThis ) { |
287 | QWidget *w = whatsThis; | 287 | QWidget *w = whatsThis; |
288 | whatsThis = 0; | 288 | whatsThis = 0; |
289 | drawTitle( w ); | 289 | drawTitle( w ); |
290 | } | 290 | } |
291 | wtTimer->stop(); | 291 | wtTimer->stop(); |
292 | } else { | 292 | } else { |
293 | QWhatsThis::enterWhatsThisMode(); | 293 | QWhatsThis::enterWhatsThisMode(); |
294 | helpState = 0; | 294 | helpState = 0; |
295 | updateActive(); | 295 | updateActive(); |
296 | if ( active ) { | 296 | if ( active ) { |
297 | whatsThis = active; | 297 | whatsThis = active; |
298 | drawTitle( active ); | 298 | drawTitle( active ); |
299 | // check periodically to see if we've left whats this mode | 299 | // check periodically to see if we've left whats this mode |
300 | wtTimer->start( 250 ); | 300 | wtTimer->start( 250 ); |
301 | } | 301 | } |
302 | } | 302 | } |
303 | inWhatsThis = !inWhatsThis; | 303 | inWhatsThis = !inWhatsThis; |
304 | } | 304 | } |
305 | } | 305 | } |
306 | 306 | ||
307 | //=========================================================================== | 307 | //=========================================================================== |
308 | 308 | #define IMAGE_METHOD( methodName, imageName ) \ | |
309 | static QImage *okImage( int th ) | 309 | static QImage* methodName( int th ) { \ |
310 | { | 310 | static QImage *i = 0; \ |
311 | static QImage *i = 0; | 311 | if ( !i || ::abs( i->height()-th ) > 4 ) { \ |
312 | if ( !i || ::abs( i->height()-th ) > 4 ) { | 312 | delete i; \ |
313 | delete i; | 313 | i = new QImage(scaleButton(Resource::loadImage(#imageName),th)); \ |
314 | i = new QImage(scaleButton(Resource::loadImage("OKButton"),th)); | 314 | } \ |
315 | } | 315 | \ |
316 | return i; | 316 | return i; \ |
317 | } | 317 | } |
318 | 318 | ||
319 | static QImage *closeImage( int th ) | 319 | IMAGE_METHOD(okImage, OKButton ); |
320 | { | 320 | IMAGE_METHOD(closeImage, CloseButton ); |
321 | static QImage *i = 0; | 321 | IMAGE_METHOD(helpImage, HelpButton ); |
322 | if ( !i || ::abs( i->height()-th ) > 4 ) { | 322 | IMAGE_METHOD(maximizeImage,MaximizeButton ); |
323 | delete i; | ||
324 | i = new QImage(scaleButton(Resource::loadImage("CloseButton"),th)); | ||
325 | } | ||
326 | return i; | ||
327 | } | ||
328 | |||
329 | static QImage *helpImage( int th ) | ||
330 | { | ||
331 | static QImage *i = 0; | ||
332 | if ( !i || ::abs( i->height()-th ) > 4 ) { | ||
333 | delete i; | ||
334 | i = new QImage(scaleButton(Resource::loadImage("HelpButton"),th)); | ||
335 | } | ||
336 | return i; | ||
337 | } | ||
338 | |||
339 | static QImage *maximizeImage( int th ) | ||
340 | { | ||
341 | static QImage *i = 0; | ||
342 | if ( !i || ::abs( i->height()-th ) > 4 ) { | ||
343 | delete i; | ||
344 | i = new QImage(scaleButton(Resource::loadImage("MaximizeButton"),th)); | ||
345 | } | ||
346 | return i; | ||
347 | } | ||
348 | 323 | ||
349 | int WindowDecorationInterface::metric( Metric m, const WindowData *wd ) const | 324 | int WindowDecorationInterface::metric( Metric m, const WindowData *wd ) const |
350 | { | 325 | { |
351 | switch ( m ) { | 326 | switch ( m ) { |
352 | case TitleHeight: | 327 | case TitleHeight: |
353 | if ( QApplication::desktop()->height() > 320 ) | 328 | if ( QApplication::desktop()->height() > 320 ) |
354 | return 19; | 329 | return 19; |
355 | else | 330 | else |
356 | return 15; | 331 | return 15; |
357 | case LeftBorder: | 332 | case LeftBorder: |
358 | case RightBorder: | 333 | case RightBorder: |
359 | case TopBorder: | 334 | case TopBorder: |
360 | case BottomBorder: | 335 | case BottomBorder: |
361 | return 4; | 336 | return 4; |
362 | case OKWidth: | 337 | case OKWidth: |
363 | return okImage(metric(TitleHeight,wd))->width(); | 338 | return okImage(metric(TitleHeight,wd))->width(); |
364 | case CloseWidth: | 339 | case CloseWidth: |
365 | return closeImage(metric(TitleHeight,wd))->width(); | 340 | return closeImage(metric(TitleHeight,wd))->width(); |
366 | case HelpWidth: | 341 | case HelpWidth: |
367 | return helpImage(metric(TitleHeight,wd))->width(); | 342 | return helpImage(metric(TitleHeight,wd))->width(); |
368 | case MaximizeWidth: | 343 | case MaximizeWidth: |
369 | return maximizeImage(metric(TitleHeight,wd))->width(); | 344 | return maximizeImage(metric(TitleHeight,wd))->width(); |
370 | case CornerGrabSize: | 345 | case CornerGrabSize: |
371 | return 16; | 346 | return 16; |
372 | } | 347 | } |
373 | 348 | ||
374 | return 0; | 349 | return 0; |
375 | } | 350 | } |
376 | 351 | ||
377 | void WindowDecorationInterface::drawArea( Area a, QPainter *p, const WindowData *wd ) const | 352 | void WindowDecorationInterface::drawArea( Area a, QPainter *p, const WindowData *wd ) const |
378 | { | 353 | { |
379 | int th = metric( TitleHeight, wd ); | 354 | int th = metric( TitleHeight, wd ); |
380 | QRect r = wd->rect; | 355 | QRect r = wd->rect; |
381 | 356 | ||
382 | switch ( a ) { | 357 | switch ( a ) { |
383 | case Border: | 358 | case Border: |
384 | { | 359 | { |
385 | const QColorGroup &cg = wd->palette.active(); | 360 | const QColorGroup &cg = wd->palette.active(); |
386 | qDrawWinPanel(p, r.x()-metric(LeftBorder,wd), | 361 | qDrawWinPanel(p, r.x()-metric(LeftBorder,wd), |
387 | r.y()-th-metric(TopBorder,wd), | 362 | r.y()-th-metric(TopBorder,wd), |
388 | r.width()+metric(LeftBorder,wd)+metric(RightBorder,wd), | 363 | r.width()+metric(LeftBorder,wd)+metric(RightBorder,wd), |
389 | r.height()+th+metric(TopBorder,wd)+metric(BottomBorder,wd), | 364 | r.height()+th+metric(TopBorder,wd)+metric(BottomBorder,wd), |
390 | cg, FALSE, &cg.brush(QColorGroup::Background)); | 365 | cg, FALSE, &cg.brush(QColorGroup::Background)); |
391 | } | 366 | } |
392 | break; | 367 | break; |
393 | case Title: | 368 | case Title: |
394 | { | 369 | { |
395 | const QColorGroup &cg = wd->palette.active(); | 370 | const QColorGroup &cg = wd->palette.active(); |
396 | QBrush titleBrush; | 371 | QBrush titleBrush; |
397 | QPen titleLines; | 372 | QPen titleLines; |
398 | 373 | ||
399 | if ( wd->flags & WindowData::Active ) { | 374 | if ( wd->flags & WindowData::Active ) { |
400 | titleBrush = cg.brush(QColorGroup::Highlight); | 375 | titleBrush = cg.brush(QColorGroup::Highlight); |
401 | titleLines = titleBrush.color().dark(); | 376 | titleLines = titleBrush.color().dark(); |
402 | } else { | 377 | } else { |
403 | titleBrush = cg.brush(QColorGroup::Background); | 378 | titleBrush = cg.brush(QColorGroup::Background); |
404 | titleLines = titleBrush.color(); | 379 | titleLines = titleBrush.color(); |
405 | } | 380 | } |
406 | 381 | ||
407 | p->fillRect( r.x(), r.y()-th, r.width(), th, titleBrush); | 382 | p->fillRect( r.x(), r.y()-th, r.width(), th, titleBrush); |
408 | 383 | ||
409 | p->setPen( titleLines ); | 384 | p->setPen( titleLines ); |
410 | for ( int i = r.y()-th; i < r.y(); i += 2 ) | 385 | for ( int i = r.y()-th; i < r.y(); i += 2 ) |
411 | p->drawLine( r.left(), i, r.right(), i ); | 386 | p->drawLine( r.left(), i, r.right(), i ); |
412 | } | 387 | } |
413 | break; | 388 | break; |
414 | case TitleText: | 389 | case TitleText: |
415 | p->drawText( r.x()+3+metric(HelpWidth,wd), r.top()-th, | 390 | p->drawText( r.x()+3+metric(HelpWidth,wd), r.top()-th, |
416 | r.width()-metric(OKWidth,wd)-metric(CloseWidth,wd), | 391 | r.width()-metric(OKWidth,wd)-metric(CloseWidth,wd), |
417 | th, QPainter::AlignVCenter, wd->caption); | 392 | th, QPainter::AlignVCenter, wd->caption); |
418 | break; | 393 | break; |
419 | } | 394 | } |
420 | } | 395 | } |
421 | 396 | ||
422 | void WindowDecorationInterface::drawButton( Button b, QPainter *p, const WindowData *wd, int x, int y, int, int, QWSButton::State state ) const | 397 | void WindowDecorationInterface::drawButton( Button b, QPainter *p, const WindowData *wd, int x, int y, int, int, QWSButton::State state ) const |
423 | { | 398 | { |
424 | QImage *img = 0; | 399 | QImage *img = 0; |
425 | switch ( b ) { | 400 | switch ( b ) { |
426 | case OK: | 401 | case OK: |
427 | img = okImage(metric(TitleHeight,wd)); | 402 | img = okImage(metric(TitleHeight,wd)); |
428 | break; | 403 | break; |
429 | case Close: | 404 | case Close: |
430 | img = closeImage(metric(TitleHeight,wd)); | 405 | img = closeImage(metric(TitleHeight,wd)); |
431 | break; | 406 | break; |
432 | case Help: | 407 | case Help: |
433 | img = helpImage(metric(TitleHeight,wd)); | 408 | img = helpImage(metric(TitleHeight,wd)); |
434 | break; | 409 | break; |
435 | case Maximize: | 410 | case Maximize: |
436 | img = maximizeImage(metric(TitleHeight,wd)); | 411 | img = maximizeImage(metric(TitleHeight,wd)); |
437 | break; | 412 | break; |
438 | } | 413 | } |
439 | 414 | ||
440 | if ( img ) { | 415 | if ( img ) { |
441 | if ((state & QWSButton::MouseOver) && (state & QWSButton::Clicked)) | 416 | if ((state & QWSButton::MouseOver) && (state & QWSButton::Clicked)) |
442 | p->drawImage(x+2, y+2, *img); | 417 | p->drawImage(x+2, y+2, *img); |
443 | else | 418 | else |
444 | p->drawImage(x+1, y+1, *img); | 419 | p->drawImage(x+1, y+1, *img); |
445 | } | 420 | } |
446 | } | 421 | } |
447 | 422 | ||
448 | QRegion WindowDecorationInterface::mask( const WindowData *wd ) const | 423 | QRegion WindowDecorationInterface::mask( const WindowData *wd ) const |
449 | { | 424 | { |
450 | int th = metric(TitleHeight,wd); | 425 | int th = metric(TitleHeight,wd); |
451 | QRect rect( wd->rect ); | 426 | QRect rect( wd->rect ); |
452 | QRect r(rect.left() - metric(LeftBorder,wd), | 427 | QRect r(rect.left() - metric(LeftBorder,wd), |
453 | rect.top() - th - metric(TopBorder,wd), | 428 | rect.top() - th - metric(TopBorder,wd), |
454 | rect.width() + metric(LeftBorder,wd) + metric(RightBorder,wd), | 429 | rect.width() + metric(LeftBorder,wd) + metric(RightBorder,wd), |
455 | rect.height() + th + metric(TopBorder,wd) + metric(BottomBorder,wd)); | 430 | rect.height() + th + metric(TopBorder,wd) + metric(BottomBorder,wd)); |
456 | return QRegion(r) - rect; | 431 | return QRegion(r) - rect; |
457 | } | 432 | } |
458 | 433 | ||
459 | class DefaultWindowDecoration : public WindowDecorationInterface | 434 | class DefaultWindowDecoration : public WindowDecorationInterface |
460 | { | 435 | { |
461 | public: | 436 | public: |
462 | DefaultWindowDecoration(){} | 437 | DefaultWindowDecoration(){} |
463 | QString name() const { | 438 | QString name() const { |
464 | return qApp->translate("WindowDecoration", "Default", | 439 | return qApp->translate("WindowDecoration", "Default", |
465 | "List box text for default window decoration"); | 440 | "List box text for default window decoration"); |
466 | } | 441 | } |
467 | QPixmap icon() const { | 442 | QPixmap icon() const { |
468 | return QPixmap(); | 443 | return QPixmap(); |
469 | } | 444 | } |
470 | QRESULT queryInterface( const QUuid &uuid, QUnknownInterface **iface ) { | 445 | QRESULT queryInterface( const QUuid &uuid, QUnknownInterface **iface ) { |
471 | *iface = 0; | 446 | *iface = 0; |
472 | if ( uuid == IID_QUnknown ) | 447 | if ( uuid == IID_QUnknown ) |
473 | *iface = this; | 448 | *iface = this; |
474 | else if ( uuid == IID_WindowDecoration ) | 449 | else if ( uuid == IID_WindowDecoration ) |
475 | *iface = this; | 450 | *iface = this; |
476 | else | 451 | else |
477 | return QS_FALSE; | 452 | return QS_FALSE; |
478 | 453 | ||
479 | if ( *iface ) | 454 | if ( *iface ) |
480 | (*iface)->addRef(); | 455 | (*iface)->addRef(); |
481 | return QS_OK; | 456 | return QS_OK; |
482 | } | 457 | } |
483 | Q_REFCOUNT | 458 | Q_REFCOUNT |
484 | 459 | ||
485 | }; | 460 | }; |
486 | 461 | ||
487 | static WindowDecorationInterface *wdiface = 0; | 462 | static WindowDecorationInterface *wdiface = 0; |
488 | static QLibrary* wdlib = 0; | 463 | static QLibrary* wdlib = 0; |
489 | static QString libname; | 464 | static QString libname; |
490 | 465 | ||
491 | //=========================================================================== | 466 | //=========================================================================== |
492 | bool QPEDecoration::helpExists() const | 467 | bool QPEDecoration::helpExists() const |
493 | { | 468 | { |
494 | if ( helpFile.isNull() ) { | 469 | if ( helpFile.isNull() ) { |
495 | QStringList helpPath = Global::helpPath(); | 470 | QStringList helpPath = Global::helpPath(); |
496 | QString hf = QString(qApp->argv()[0]) + ".html"; | 471 | QString hf = QString(qApp->argv()[0]) + ".html"; |
497 | bool he = FALSE; | 472 | bool he = FALSE; |
498 | for (QStringList::ConstIterator it=helpPath.begin(); it!=helpPath.end() && !he; ++it) | 473 | for (QStringList::ConstIterator it=helpPath.begin(); it!=helpPath.end() && !he; ++it) |
499 | he = QFile::exists( *it + "/" + hf ); | 474 | he = QFile::exists( *it + "/" + hf ); |
500 | ((QPEDecoration*)this)->helpFile = hf; | 475 | ((QPEDecoration*)this)->helpFile = hf; |
501 | ((QPEDecoration*)this)->helpexists = he; | 476 | ((QPEDecoration*)this)->helpexists = he; |
502 | return he; | 477 | return he; |
503 | } | 478 | } |
504 | return helpexists; | 479 | return helpexists; |
505 | } | 480 | } |
506 | 481 | ||
507 | QPEDecoration::QPEDecoration() | 482 | QPEDecoration::QPEDecoration() |
508 | : QWSDefaultDecoration() | 483 | : QWSDefaultDecoration() |
509 | { | 484 | { |
510 | if ( wdlib ) { | 485 | if ( wdlib ) { |
511 | delete wdlib; | 486 | delete wdlib; |
512 | wdlib = 0; | 487 | wdlib = 0; |
513 | } else { | 488 | } else { |
514 | delete wdiface; | 489 | delete wdiface; |
515 | } | 490 | } |
516 | wdiface = new DefaultWindowDecoration; | 491 | wdiface = new DefaultWindowDecoration; |
517 | 492 | ||
518 | helpexists = FALSE; // We don't know (flagged by helpFile being null) | 493 | helpexists = FALSE; // We don't know (flagged by helpFile being null) |
519 | qpeManager = new QPEManager( this ); | 494 | qpeManager = new QPEManager( this ); |
520 | imageOk = Resource::loadImage( "OKButton" ); | 495 | imageOk = Resource::loadImage( "OKButton" ); |
521 | imageClose = Resource::loadImage( "CloseButton" ); | 496 | imageClose = Resource::loadImage( "CloseButton" ); |
522 | imageHelp = Resource::loadImage( "HelpButton" ); | 497 | imageHelp = Resource::loadImage( "HelpButton" ); |
523 | } | 498 | } |
524 | 499 | ||
525 | QPEDecoration::QPEDecoration( const QString &plugin ) | 500 | QPEDecoration::QPEDecoration( const QString &plugin ) |
526 | : QWSDefaultDecoration() | 501 | : QWSDefaultDecoration() |
527 | { | 502 | { |
528 | libname = plugin; | 503 | libname = plugin; |
529 | 504 | ||
530 | if ( wdlib ) { | 505 | if ( wdlib ) { |
531 | wdiface->release(); | 506 | wdiface->release(); |
532 | wdlib->unload(); | 507 | wdlib->unload(); |
533 | delete wdlib; | 508 | delete wdlib; |
534 | wdlib = 0; | 509 | wdlib = 0; |
535 | } else { | 510 | } else { |
536 | delete wdiface; | 511 | delete wdiface; |
537 | } | 512 | } |
538 | 513 | ||
539 | WindowDecorationInterface *iface = 0; | 514 | WindowDecorationInterface *iface = 0; |
540 | QString path = QPEApplication::qpeDir() + "plugins/decorations/"; | 515 | QString path = QPEApplication::qpeDir() + "plugins/decorations/"; |
541 | 516 | ||
542 | #ifdef Q_OS_MACX | 517 | #ifdef Q_OS_MACX |
543 | if ( plugin.find( ".dylib" ) > 0 ) { | 518 | if ( plugin.find( ".dylib" ) > 0 ) { |
544 | #else | 519 | #else |
545 | if ( plugin.find( ".so" ) > 0 ) { | 520 | if ( plugin.find( ".so" ) > 0 ) { |
546 | #endif | 521 | #endif |
547 | // full library name supplied | 522 | // full library name supplied |
548 | path += plugin; | 523 | path += plugin; |
549 | } else { | 524 | } else { |
550 | #ifdef Q_OS_MACX | 525 | #ifdef Q_OS_MACX |
551 | path += "lib" + plugin.lower() + ".dylib"; // compatibility | 526 | path += "lib" + plugin.lower() + ".dylib"; // compatibility |
552 | #else | 527 | #else |
553 | path += "lib" + plugin.lower() + ".so"; // compatibility | 528 | path += "lib" + plugin.lower() + ".so"; // compatibility |
554 | #endif | 529 | #endif |
555 | } | 530 | } |
556 | 531 | ||
557 | QLibrary *lib = new QLibrary( path ); | 532 | QLibrary *lib = new QLibrary( path ); |
558 | if ( lib->queryInterface( IID_WindowDecoration, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 533 | if ( lib->queryInterface( IID_WindowDecoration, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
559 | wdiface = iface; | 534 | wdiface = iface; |
560 | wdlib = lib; | 535 | wdlib = lib; |
561 | } else { | 536 | } else { |
562 | delete lib; | 537 | delete lib; |
563 | wdiface = new DefaultWindowDecoration; | 538 | wdiface = new DefaultWindowDecoration; |
564 | } | 539 | } |
565 | 540 | ||
566 | 541 | ||
567 | 542 | ||
568 | helpexists = FALSE; // We don't know (flagged by helpFile being null) | 543 | helpexists = FALSE; // We don't know (flagged by helpFile being null) |
569 | qpeManager = new QPEManager( this ); | 544 | qpeManager = new QPEManager( this ); |
570 | } | 545 | } |
571 | 546 | ||
572 | QPEDecoration::~QPEDecoration() | 547 | QPEDecoration::~QPEDecoration() |
573 | { | 548 | { |
574 | delete qpeManager; | 549 | delete qpeManager; |
575 | } | 550 | } |
576 | 551 | ||
577 | const char **QPEDecoration::menuPixmap() | 552 | const char **QPEDecoration::menuPixmap() |
578 | { | 553 | { |
579 | return (const char **)0; | 554 | return (const char **)0; |
580 | } | 555 | } |
581 | 556 | ||
582 | const char **QPEDecoration::closePixmap() | 557 | const char **QPEDecoration::closePixmap() |
583 | { | 558 | { |
584 | return (const char **)qpe_close_xpm; | 559 | return (const char **)qpe_close_xpm; |
585 | } | 560 | } |
586 | 561 | ||
587 | const char **QPEDecoration::minimizePixmap() | 562 | const char **QPEDecoration::minimizePixmap() |
588 | { | 563 | { |
589 | return (const char **)qpe_accept_xpm; | 564 | return (const char **)qpe_accept_xpm; |
590 | } | 565 | } |
591 | 566 | ||
592 | const char **QPEDecoration::maximizePixmap() | 567 | const char **QPEDecoration::maximizePixmap() |
593 | { | 568 | { |
594 | return (const char **)0; | 569 | return (const char **)0; |
595 | } | 570 | } |
596 | 571 | ||
597 | const char **QPEDecoration::normalizePixmap() | 572 | const char **QPEDecoration::normalizePixmap() |
598 | { | 573 | { |
599 | return (const char **)0; | 574 | return (const char **)0; |
600 | } | 575 | } |
601 | 576 | ||
602 | int QPEDecoration::getTitleHeight( const QWidget *w ) | 577 | int QPEDecoration::getTitleHeight( const QWidget *w ) |
603 | { | 578 | { |
604 | WindowDecorationInterface::WindowData wd; | 579 | WindowDecorationInterface::WindowData wd; |
605 | windowData( w, wd ); | 580 | windowData( w, wd ); |
606 | return wdiface->metric(WindowDecorationInterface::TitleHeight,&wd); | 581 | return wdiface->metric(WindowDecorationInterface::TitleHeight,&wd); |
607 | } | 582 | } |
608 | 583 | ||
609 | /* | 584 | /* |
610 | If rect is empty, no frame is added. (a hack, really) | 585 | If rect is empty, no frame is added. (a hack, really) |
611 | */ | 586 | */ |
612 | QRegion QPEDecoration::region(const QWidget *widget, const QRect &rect, QWSDecoration::Region type) | 587 | QRegion QPEDecoration::region(const QWidget *widget, const QRect &rect, QWSDecoration::Region type) |
613 | { | 588 | { |
614 | qpeManager->updateActive(); | 589 | qpeManager->updateActive(); |
615 | 590 | ||
616 | WindowDecorationInterface::WindowData wd; | 591 | WindowDecorationInterface::WindowData wd; |
617 | windowData( widget, wd ); | 592 | windowData( widget, wd ); |
618 | wd.rect = rect; | 593 | wd.rect = rect; |
619 | 594 | ||
620 | int titleHeight = wdiface->metric(WindowDecorationInterface::TitleHeight,&wd); | 595 | int titleHeight = wdiface->metric(WindowDecorationInterface::TitleHeight,&wd); |
621 | int okWidth = wdiface->metric(WindowDecorationInterface::OKWidth,&wd); | 596 | int okWidth = wdiface->metric(WindowDecorationInterface::OKWidth,&wd); |
622 | int closeWidth = wdiface->metric(WindowDecorationInterface::CloseWidth,&wd); | 597 | int closeWidth = wdiface->metric(WindowDecorationInterface::CloseWidth,&wd); |
623 | int helpWidth = wdiface->metric(WindowDecorationInterface::HelpWidth,&wd); | 598 | int helpWidth = wdiface->metric(WindowDecorationInterface::HelpWidth,&wd); |
624 | int grab = wdiface->metric(WindowDecorationInterface::CornerGrabSize,&wd); | 599 | int grab = wdiface->metric(WindowDecorationInterface::CornerGrabSize,&wd); |
625 | 600 | ||
626 | QRegion region; | 601 | QRegion region; |
627 | 602 | ||
628 | switch ((int)type) { | 603 | switch ((int)type) { |
629 | case Menu: | 604 | case Menu: |
630 | break; | 605 | break; |
631 | case Maximize: | 606 | case Maximize: |
632 | if ( !widget->inherits( "QDialog" ) && qApp->desktop()->width() > 350 ) { | 607 | if ( !widget->inherits( "QDialog" ) && qApp->desktop()->width() > 350 ) { |
633 | int maximizeWidth = wdiface->metric(WindowDecorationInterface::MaximizeWidth,&wd); | 608 | int maximizeWidth = wdiface->metric(WindowDecorationInterface::MaximizeWidth,&wd); |
634 | int left = rect.right() - maximizeWidth - closeWidth; | 609 | int left = rect.right() - maximizeWidth - closeWidth; |
635 | if ( ((DecorHackWidget *)widget)->needsOk() ) | 610 | if ( ((DecorHackWidget *)widget)->needsOk() ) |
636 | left -= okWidth; | 611 | left -= okWidth; |
637 | QRect r(left, rect.top() - titleHeight, closeWidth, titleHeight); | 612 | QRect r(left, rect.top() - titleHeight, closeWidth, titleHeight); |
638 | region = r; | 613 | region = r; |
639 | } | 614 | } |
640 | break; | 615 | break; |
641 | case Minimize: | 616 | case Minimize: |
642 | if ( ((DecorHackWidget *)widget)->needsOk() ) { | 617 | if ( ((DecorHackWidget *)widget)->needsOk() ) { |
643 | QRect r(rect.right() - okWidth, | 618 | QRect r(rect.right() - okWidth, |
644 | rect.top() - titleHeight, okWidth, titleHeight); | 619 | rect.top() - titleHeight, okWidth, titleHeight); |
645 | if (r.left() > rect.left() + titleHeight) | 620 | if (r.left() > rect.left() + titleHeight) |
646 | region = r; | 621 | region = r; |
647 | } | 622 | } |
648 | break; | 623 | break; |
649 | case Close: | 624 | case Close: |
650 | { | 625 | { |
651 | int left = rect.right() - closeWidth; | 626 | int left = rect.right() - closeWidth; |
652 | if ( ((DecorHackWidget *)widget)->needsOk() ) | 627 | if ( ((DecorHackWidget *)widget)->needsOk() ) |
653 | left -= okWidth; | 628 | left -= okWidth; |
654 | QRect r(left, rect.top() - titleHeight, closeWidth, titleHeight); | 629 | QRect r(left, rect.top() - titleHeight, closeWidth, titleHeight); |
655 | region = r; | 630 | region = r; |
656 | } | 631 | } |
657 | break; | 632 | break; |
658 | case Title: | 633 | case Title: |
659 | if ( !widget->isMaximized() ) { | 634 | if ( !widget->isMaximized() ) { |
660 | int width = rect.width() - helpWidth - closeWidth; | 635 | int width = rect.width() - helpWidth - closeWidth; |
661 | if ( ((DecorHackWidget *)widget)->needsOk() ) | 636 | if ( ((DecorHackWidget *)widget)->needsOk() ) |
662 | width -= okWidth; | 637 | width -= okWidth; |
663 | QRect r(rect.left()+helpWidth, rect.top() - titleHeight, | 638 | QRect r(rect.left()+helpWidth, rect.top() - titleHeight, |
664 | width, titleHeight); | 639 | width, titleHeight); |
665 | if (r.width() > 0) | 640 | if (r.width() > 0) |
666 | region = r; | 641 | region = r; |
667 | } | 642 | } |
668 | break; | 643 | break; |
669 | case Help: | 644 | case Help: |
670 | if ( helpExists() || widget->testWFlags(Qt::WStyle_ContextHelp) ) { | 645 | if ( helpExists() || widget->testWFlags(Qt::WStyle_ContextHelp) ) { |
671 | QRect r(rect.left(), rect.top() - titleHeight, | 646 | QRect r(rect.left(), rect.top() - titleHeight, |
672 | helpWidth, titleHeight); | 647 | helpWidth, titleHeight); |
673 | region = r; | 648 | region = r; |
674 | } | 649 | } |
675 | break; | 650 | break; |
676 | case Top: | 651 | case Top: |
677 | if ( !widget->isMaximized() ) { | 652 | if ( !widget->isMaximized() ) { |
678 | QRegion m = wdiface->mask(&wd); | 653 | QRegion m = wdiface->mask(&wd); |
679 | QRect br = m.boundingRect(); | 654 | QRect br = m.boundingRect(); |
680 | int b = wdiface->metric(WindowDecorationInterface::TopBorder,&wd); | 655 | int b = wdiface->metric(WindowDecorationInterface::TopBorder,&wd); |
681 | region = m & QRect( br.left()+grab, br.top(), | 656 | region = m & QRect( br.left()+grab, br.top(), |
682 | br.width()-2*grab, b ); | 657 | br.width()-2*grab, b ); |
683 | } | 658 | } |
684 | break; | 659 | break; |
685 | case Left: | 660 | case Left: |
686 | if ( !widget->isMaximized() ) { | 661 | if ( !widget->isMaximized() ) { |
687 | QRegion m = wdiface->mask(&wd); | 662 | QRegion m = wdiface->mask(&wd); |
688 | QRect br = m.boundingRect(); | 663 | QRect br = m.boundingRect(); |
689 | int b = wdiface->metric(WindowDecorationInterface::LeftBorder,&wd); | 664 | int b = wdiface->metric(WindowDecorationInterface::LeftBorder,&wd); |
690 | region = m & QRect( br.left(), br.top()+grab, | 665 | region = m & QRect( br.left(), br.top()+grab, |
691 | b, br.height()-2*grab ); | 666 | b, br.height()-2*grab ); |
692 | } | 667 | } |
693 | break; | 668 | break; |
694 | case Right: | 669 | case Right: |
695 | if ( !widget->isMaximized() ) { | 670 | if ( !widget->isMaximized() ) { |
696 | QRegion m = wdiface->mask(&wd); | 671 | QRegion m = wdiface->mask(&wd); |
697 | QRect br = m.boundingRect(); | 672 | QRect br = m.boundingRect(); |
698 | int b = wdiface->metric(WindowDecorationInterface::RightBorder,&wd); | 673 | int b = wdiface->metric(WindowDecorationInterface::RightBorder,&wd); |
699 | region = m & QRect( rect.right(), br.top()+grab, | 674 | region = m & QRect( rect.right(), br.top()+grab, |
700 | b, br.height()-2*grab ); | 675 | b, br.height()-2*grab ); |
701 | } | 676 | } |
702 | break; | 677 | break; |
703 | case Bottom: | 678 | case Bottom: |
704 | if ( !widget->isMaximized() ) { | 679 | if ( !widget->isMaximized() ) { |
705 | QRegion m = wdiface->mask(&wd); | 680 | QRegion m = wdiface->mask(&wd); |
706 | QRect br = m.boundingRect(); | 681 | QRect br = m.boundingRect(); |
707 | int b = wdiface->metric(WindowDecorationInterface::BottomBorder,&wd); | 682 | int b = wdiface->metric(WindowDecorationInterface::BottomBorder,&wd); |
708 | region = m & QRect( br.left()+grab, rect.bottom(), | 683 | region = m & QRect( br.left()+grab, rect.bottom(), |
709 | br.width()-2*grab, b ); | 684 | br.width()-2*grab, b ); |
710 | } | 685 | } |
711 | break; | 686 | break; |
712 | case TopLeft: | 687 | case TopLeft: |
713 | if ( !widget->isMaximized() ) { | 688 | if ( !widget->isMaximized() ) { |
714 | QRegion m = wdiface->mask(&wd); | 689 | QRegion m = wdiface->mask(&wd); |
715 | QRect br = m.boundingRect(); | 690 | QRect br = m.boundingRect(); |
716 | int tb = wdiface->metric(WindowDecorationInterface::TopBorder,&wd); | 691 | int tb = wdiface->metric(WindowDecorationInterface::TopBorder,&wd); |
717 | int lb = wdiface->metric(WindowDecorationInterface::LeftBorder,&wd); | 692 | int lb = wdiface->metric(WindowDecorationInterface::LeftBorder,&wd); |
718 | QRegion crgn( br.left(), br.top(), grab, tb ); | 693 | QRegion crgn( br.left(), br.top(), grab, tb ); |
719 | crgn |= QRect( br.left(), br.top(), lb, grab ); | 694 | crgn |= QRect( br.left(), br.top(), lb, grab ); |
720 | region = m & crgn; | 695 | region = m & crgn; |
721 | } | 696 | } |
722 | break; | 697 | break; |
723 | case TopRight: | 698 | case TopRight: |
724 | if ( !widget->isMaximized() ) { | 699 | if ( !widget->isMaximized() ) { |
725 | QRegion m = wdiface->mask(&wd); | 700 | QRegion m = wdiface->mask(&wd); |
726 | QRect br = m.boundingRect(); | 701 | QRect br = m.boundingRect(); |
727 | int tb = wdiface->metric(WindowDecorationInterface::TopBorder,&wd); | 702 | int tb = wdiface->metric(WindowDecorationInterface::TopBorder,&wd); |
728 | int rb = wdiface->metric(WindowDecorationInterface::RightBorder,&wd); | 703 | int rb = wdiface->metric(WindowDecorationInterface::RightBorder,&wd); |
729 | QRegion crgn( br.right()-grab, br.top(), grab, tb ); | 704 | QRegion crgn( br.right()-grab, br.top(), grab, tb ); |
730 | crgn |= QRect( br.right()-rb, br.top(), rb, grab ); | 705 | crgn |= QRect( br.right()-rb, br.top(), rb, grab ); |
731 | region = m & crgn; | 706 | region = m & crgn; |
732 | } | 707 | } |
733 | break; | 708 | break; |
734 | case BottomLeft: | 709 | case BottomLeft: |
735 | if ( !widget->isMaximized() ) { | 710 | if ( !widget->isMaximized() ) { |
736 | QRegion m = wdiface->mask(&wd); | 711 | QRegion m = wdiface->mask(&wd); |
737 | QRect br = m.boundingRect(); | 712 | QRect br = m.boundingRect(); |
738 | region = m & QRect( br.left(), br.bottom()-grab, grab, grab ); | 713 | region = m & QRect( br.left(), br.bottom()-grab, grab, grab ); |
739 | } | 714 | } |
740 | break; | 715 | break; |
741 | case BottomRight: | 716 | case BottomRight: |
742 | if ( !widget->isMaximized() ) { | 717 | if ( !widget->isMaximized() ) { |
743 | QRegion m = wdiface->mask(&wd); | 718 | QRegion m = wdiface->mask(&wd); |
744 | QRect br = m.boundingRect(); | 719 | QRect br = m.boundingRect(); |
745 | region = m & QRect( br.right()-grab, br.bottom()-grab, grab, grab ); | 720 | region = m & QRect( br.right()-grab, br.bottom()-grab, grab, grab ); |
746 | } | 721 | } |
747 | break; | 722 | break; |
748 | case All: | 723 | case All: |
749 | if ( widget->isMaximized() ) | 724 | if ( widget->isMaximized() ) |
750 | region = QWSDefaultDecoration::region(widget, rect, type); | 725 | region = QWSDefaultDecoration::region(widget, rect, type); |
751 | else | 726 | else |
752 | region = wdiface->mask(&wd) - rect; | 727 | region = wdiface->mask(&wd) - rect; |
753 | break; | 728 | break; |
754 | default: | 729 | default: |
755 | region = QWSDefaultDecoration::region(widget, rect, type); | 730 | region = QWSDefaultDecoration::region(widget, rect, type); |
756 | break; | 731 | break; |
757 | } | 732 | } |
758 | 733 | ||
759 | return region; | 734 | return region; |
760 | } | 735 | } |
761 | 736 | ||
762 | void QPEDecoration::paint(QPainter *painter, const QWidget *widget) | 737 | void QPEDecoration::paint(QPainter *painter, const QWidget *widget) |
763 | { | 738 | { |
764 | WindowDecorationInterface::WindowData wd; | 739 | WindowDecorationInterface::WindowData wd; |
765 | windowData( widget, wd ); | 740 | windowData( widget, wd ); |
766 | 741 | ||
767 | int titleWidth = getTitleWidth(widget); | 742 | int titleWidth = getTitleWidth(widget); |
768 | int titleHeight = wdiface->metric(WindowDecorationInterface::TitleHeight,&wd); | 743 | int titleHeight = wdiface->metric(WindowDecorationInterface::TitleHeight,&wd); |
769 | 744 | ||
770 | QRect rect(widget->rect()); | 745 | QRect rect(widget->rect()); |
771 | 746 | ||
772 | // title bar rect | 747 | // title bar rect |
773 | QRect tbr( rect.left(), rect.top() - titleHeight, rect.width(), titleHeight ); | 748 | QRect tbr( rect.left(), rect.top() - titleHeight, rect.width(), titleHeight ); |
774 | 749 | ||
775 | #ifndef QT_NO_PALETTE | 750 | #ifndef QT_NO_PALETTE |
776 | QRegion oldClip = painter->clipRegion(); | 751 | QRegion oldClip = painter->clipRegion(); |
777 | painter->setClipRegion( oldClip - QRegion( tbr ) );// reduce flicker | 752 | painter->setClipRegion( oldClip - QRegion( tbr ) );// reduce flicker |
778 | wdiface->drawArea( WindowDecorationInterface::Border, painter, &wd ); | 753 | wdiface->drawArea( WindowDecorationInterface::Border, painter, &wd ); |
779 | painter->setClipRegion( oldClip ); | 754 | painter->setClipRegion( oldClip ); |
780 | 755 | ||
781 | if (titleWidth > 0) { | 756 | if (titleWidth > 0) { |
782 | const QColorGroup &cg = widget->palette().active(); | 757 | const QColorGroup &cg = widget->palette().active(); |
783 | QBrush titleBrush; | 758 | QBrush titleBrush; |
784 | QPen titlePen; | 759 | QPen titlePen; |
785 | 760 | ||
786 | if ( wd.flags & WindowDecorationInterface::WindowData::Active ) { | 761 | if ( wd.flags & WindowDecorationInterface::WindowData::Active ) { |
787 | titleBrush = cg.brush(QColorGroup::Highlight); | 762 | titleBrush = cg.brush(QColorGroup::Highlight); |
788 | titlePen = cg.color(QColorGroup::HighlightedText); | 763 | titlePen = cg.color(QColorGroup::HighlightedText); |
789 | } else { | 764 | } else { |
790 | titleBrush = cg.brush(QColorGroup::Background); | 765 | titleBrush = cg.brush(QColorGroup::Background); |
791 | titlePen = cg.color(QColorGroup::Text); | 766 | titlePen = cg.color(QColorGroup::Text); |
792 | } | 767 | } |
793 | 768 | ||
794 | wdiface->drawArea( WindowDecorationInterface::Title, painter, &wd ); | 769 | wdiface->drawArea( WindowDecorationInterface::Title, painter, &wd ); |
795 | 770 | ||
796 | // Draw caption | 771 | // Draw caption |
797 | painter->setPen(titlePen); | 772 | painter->setPen(titlePen); |
798 | QFont f( QApplication::font() ); | 773 | QFont f( QApplication::font() ); |
799 | f.setWeight( QFont::Bold ); | 774 | f.setWeight( QFont::Bold ); |
800 | painter->setFont(f); | 775 | painter->setFont(f); |
801 | wdiface->drawArea( WindowDecorationInterface::TitleText, painter, &wd ); | 776 | wdiface->drawArea( WindowDecorationInterface::TitleText, painter, &wd ); |
802 | } | 777 | } |
803 | #endif //QT_NO_PALETTE | 778 | #endif //QT_NO_PALETTE |
804 | 779 | ||
805 | paintButton( painter, widget, (QWSDecoration::Region)Help, 0 ); | 780 | paintButton( painter, widget, (QWSDecoration::Region)Help, 0 ); |
806 | } | 781 | } |
807 | 782 | ||
808 | void QPEDecoration::paintButton(QPainter *painter, const QWidget *w, | 783 | void QPEDecoration::paintButton(QPainter *painter, const QWidget *w, |
809 | QWSDecoration::Region type, int state) | 784 | QWSDecoration::Region type, int state) |
810 | { | 785 | { |
811 | WindowDecorationInterface::Button b; | 786 | WindowDecorationInterface::Button b; |
812 | switch ((int)type) { | 787 | switch ((int)type) { |
813 | case Close: | 788 | case Close: |
814 | b = WindowDecorationInterface::Close; | 789 | b = WindowDecorationInterface::Close; |
815 | break; | 790 | break; |
816 | case Minimize: | 791 | case Minimize: |
817 | if ( ((DecorHackWidget *)w)->needsOk() ) | 792 | if ( ((DecorHackWidget *)w)->needsOk() ) |
818 | b = WindowDecorationInterface::OK; | 793 | b = WindowDecorationInterface::OK; |
819 | else if ( helpExists() ) | 794 | else if ( helpExists() ) |
820 | b = WindowDecorationInterface::Help; | 795 | b = WindowDecorationInterface::Help; |
821 | else | 796 | else |
822 | return; | 797 | return; |
823 | break; | 798 | break; |
824 | case Help: | 799 | case Help: |
825 | b = WindowDecorationInterface::Help; | 800 | b = WindowDecorationInterface::Help; |
826 | break; | 801 | break; |
827 | case Maximize: | 802 | case Maximize: |
828 | b = WindowDecorationInterface::Maximize; | 803 | b = WindowDecorationInterface::Maximize; |
829 | break; | 804 | break; |
830 | default: | 805 | default: |
831 | return; | 806 | return; |
832 | } | 807 | } |
833 | 808 | ||
834 | WindowDecorationInterface::WindowData wd; | 809 | WindowDecorationInterface::WindowData wd; |
835 | windowData( w, wd ); | 810 | windowData( w, wd ); |
836 | 811 | ||
837 | int titleHeight = wdiface->metric(WindowDecorationInterface::TitleHeight,&wd); | 812 | int titleHeight = wdiface->metric(WindowDecorationInterface::TitleHeight,&wd); |
838 | QRect rect(w->rect()); | 813 | QRect rect(w->rect()); |
839 | QRect tbr( rect.left(), rect.top() - titleHeight, rect.width(), titleHeight ); | 814 | QRect tbr( rect.left(), rect.top() - titleHeight, rect.width(), titleHeight ); |
840 | QRect brect(region(w, w->rect(), type).boundingRect()); | 815 | QRect brect(region(w, w->rect(), type).boundingRect()); |
841 | 816 | ||
842 | const QColorGroup &cg = w->palette().active(); | 817 | const QColorGroup &cg = w->palette().active(); |
843 | if ( wd.flags & WindowDecorationInterface::WindowData::Active ) | 818 | if ( wd.flags & WindowDecorationInterface::WindowData::Active ) |
844 | painter->setPen( cg.color(QColorGroup::HighlightedText) ); | 819 | painter->setPen( cg.color(QColorGroup::HighlightedText) ); |
845 | else | 820 | else |
846 | painter->setPen( cg.color(QColorGroup::Text) ); | 821 | painter->setPen( cg.color(QColorGroup::Text) ); |
847 | 822 | ||
848 | QRegion oldClip = painter->clipRegion(); | 823 | QRegion oldClip = painter->clipRegion(); |
849 | painter->setClipRegion( QRect(brect.x(), tbr.y(), brect.width(), tbr.height()) ); // reduce flicker | 824 | painter->setClipRegion( QRect(brect.x(), tbr.y(), brect.width(), tbr.height()) ); // reduce flicker |
850 | wdiface->drawArea( WindowDecorationInterface::Title, painter, &wd ); | 825 | wdiface->drawArea( WindowDecorationInterface::Title, painter, &wd ); |
851 | wdiface->drawButton( b, painter, &wd, brect.x(), brect.y(), brect.width(), brect.height(), (QWSButton::State)state ); | 826 | wdiface->drawButton( b, painter, &wd, brect.x(), brect.y(), brect.width(), brect.height(), (QWSButton::State)state ); |
852 | painter->setClipRegion( oldClip ); | 827 | painter->setClipRegion( oldClip ); |
853 | } | 828 | } |
854 | 829 | ||
855 | //#define QPE_DONT_SHOW_TITLEBAR | 830 | //#define QPE_DONT_SHOW_TITLEBAR |
856 | 831 | ||
857 | void QPEDecoration::maximize( QWidget *widget ) | 832 | void QPEDecoration::maximize( QWidget *widget ) |
858 | { | 833 | { |
859 | #ifdef QPE_DONT_SHOW_TITLEBAR | 834 | #ifdef QPE_DONT_SHOW_TITLEBAR |
860 | if ( !widget->inherits( "QDialog" ) ) { | 835 | if ( !widget->inherits( "QDialog" ) ) { |
861 | widget->setGeometry( qt_maxWindowRect ); | 836 | widget->setGeometry( qt_maxWindowRect ); |
862 | } else | 837 | } else |
863 | #endif | 838 | #endif |
864 | { | 839 | { |
865 | QWSDecoration::maximize( widget ); | 840 | QWSDecoration::maximize( widget ); |
866 | } | 841 | } |
867 | } | 842 | } |
868 | 843 | ||
869 | QPopupMenu *QPEDecoration::menu( const QWidget *, const QPoint & ) | 844 | QPopupMenu *QPEDecoration::menu( const QWidget *, const QPoint & ) |
870 | { | 845 | { |
871 | QPopupMenu *m = new QPopupMenu(); | 846 | QPopupMenu *m = new QPopupMenu(); |
872 | 847 | ||
873 | m->insertItem(QPEManager::tr("Restore"), (int)Normalize); | 848 | m->insertItem(QPEManager::tr("Restore"), (int)Normalize); |
874 | m->insertItem(QPEManager::tr("Move"), (int)Title); | 849 | m->insertItem(QPEManager::tr("Move"), (int)Title); |
875 | m->insertItem(QPEManager::tr("Size"), (int)BottomRight); | 850 | m->insertItem(QPEManager::tr("Size"), (int)BottomRight); |
876 | m->insertItem(QPEManager::tr("Maximize"), (int)Maximize); | 851 | m->insertItem(QPEManager::tr("Maximize"), (int)Maximize); |
877 | m->insertSeparator(); | 852 | m->insertSeparator(); |
878 | m->insertItem(QPEManager::tr("Close"), (int)Close); | 853 | m->insertItem(QPEManager::tr("Close"), (int)Close); |
879 | 854 | ||
880 | return m; | 855 | return m; |
881 | } | 856 | } |
882 | 857 | ||
883 | #ifndef QT_NO_DIALOG | 858 | #ifndef QT_NO_DIALOG |
884 | class HackDialog : public QDialog | 859 | class HackDialog : public QDialog |
885 | { | 860 | { |
886 | public: | 861 | public: |
887 | void acceptIt() { | 862 | void acceptIt() { |
888 | if ( isA( "QMessageBox" ) ) | 863 | if ( isA( "QMessageBox" ) ) |
889 | qApp->postEvent( this, new QKeyEvent( QEvent::KeyPress, Key_Enter, '\n', 0, "\n" ) ); | 864 | qApp->postEvent( this, new QKeyEvent( QEvent::KeyPress, Key_Enter, '\n', 0, "\n" ) ); |
890 | else | 865 | else |
891 | accept(); | 866 | accept(); |
892 | } | 867 | } |
893 | }; | 868 | }; |
894 | #endif | 869 | #endif |
895 | 870 | ||
896 | 871 | ||
897 | void QPEDecoration::minimize( QWidget *widget ) | 872 | void QPEDecoration::minimize( QWidget *widget ) |
898 | { | 873 | { |
899 | #ifndef QT_NO_DIALOG | 874 | #ifndef QT_NO_DIALOG |
900 | // We use the minimize button as an "accept" button. | 875 | // We use the minimize button as an "accept" button. |
901 | if ( widget->inherits( "QDialog" ) ) { | 876 | if ( widget->inherits( "QDialog" ) ) { |
902 | HackDialog *d = (HackDialog *)widget; | 877 | HackDialog *d = (HackDialog *)widget; |
903 | d->acceptIt(); | 878 | d->acceptIt(); |
904 | } | 879 | } |
905 | #endif | 880 | #endif |
906 | else if ( ((DecorHackWidget *)widget)->needsOk() ) { | 881 | else if ( ((DecorHackWidget *)widget)->needsOk() ) { |
907 | QSignal s; | 882 | QSignal s; |
908 | s.connect( widget, SLOT( accept() ) ); | 883 | s.connect( widget, SLOT( accept() ) ); |
909 | s.activate(); | 884 | s.activate(); |
910 | } else { | 885 | } else { |
911 | help( widget ); | 886 | help( widget ); |
912 | } | 887 | } |
913 | } | 888 | } |
914 | 889 | ||
915 | void QPEDecoration::help( QWidget *w ) | 890 | void QPEDecoration::help( QWidget *w ) |
916 | { | 891 | { |
917 | if ( helpExists() ) { | 892 | if ( helpExists() ) { |
918 | QString hf = helpFile; | 893 | QString hf = helpFile; |
919 | QString localHelpFile = QString(qApp->argv()[0]) + "-" + w->name() + ".html"; | 894 | QString localHelpFile = QString(qApp->argv()[0]) + "-" + w->name() + ".html"; |
920 | QStringList helpPath = Global::helpPath(); | 895 | QStringList helpPath = Global::helpPath(); |
921 | for (QStringList::ConstIterator it=helpPath.begin(); it!=helpPath.end(); ++it) { | 896 | for (QStringList::ConstIterator it=helpPath.begin(); it!=helpPath.end(); ++it) { |
922 | if ( QFile::exists( *it + "/" + localHelpFile ) ) { | 897 | if ( QFile::exists( *it + "/" + localHelpFile ) ) { |
923 | hf = localHelpFile; | 898 | hf = localHelpFile; |
924 | break; | 899 | break; |
925 | } | 900 | } |
926 | } | 901 | } |
927 | Global::execute( "helpbrowser", hf ); | 902 | Global::execute( "helpbrowser", hf ); |
928 | } else if ( w && w->testWFlags(Qt::WStyle_ContextHelp) ) { | 903 | } else if ( w && w->testWFlags(Qt::WStyle_ContextHelp) ) { |
929 | QWhatsThis::enterWhatsThisMode(); | 904 | QWhatsThis::enterWhatsThisMode(); |
930 | QWhatsThis::leaveWhatsThisMode( QObject::tr( | 905 | QWhatsThis::leaveWhatsThisMode( QObject::tr( |
931 | "<Qt>Comprehensive help is not available for this application, " | 906 | "<Qt>Comprehensive help is not available for this application, " |
932 | "however there is context-sensitive help.<p>To use context-sensitive help:<p>" | 907 | "however there is context-sensitive help.<p>To use context-sensitive help:<p>" |
933 | "<ol><li>click and hold the help button." | 908 | "<ol><li>click and hold the help button." |
934 | "<li>when the title bar shows <b>What's this...</b>, " | 909 | "<li>when the title bar shows <b>What's this...</b>, " |
935 | "click on any control.</ol></Qt>" ) ); | 910 | "click on any control.</ol></Qt>" ) ); |
936 | } | 911 | } |
937 | } | 912 | } |
938 | 913 | ||
939 | void QPEDecoration::windowData( const QWidget *w, WindowDecorationInterface::WindowData &wd ) const | 914 | void QPEDecoration::windowData( const QWidget *w, WindowDecorationInterface::WindowData &wd ) const |
940 | { | 915 | { |
941 | wd.rect = w->rect(); | 916 | wd.rect = w->rect(); |
942 | if ( qpeManager->whatsThisWidget() == w ) | 917 | if ( qpeManager->whatsThisWidget() == w ) |
943 | wd.caption = QObject::tr( "What's this..." ); | 918 | wd.caption = QObject::tr( "What's this..." ); |
944 | else | 919 | else |
945 | wd.caption = w->caption(); | 920 | wd.caption = w->caption(); |
946 | wd.palette = qApp->palette(); | 921 | wd.palette = qApp->palette(); |
947 | wd.flags = 0; | 922 | wd.flags = 0; |
948 | wd.flags |= w->isMaximized() ? WindowDecorationInterface::WindowData::Maximized : 0; | 923 | wd.flags |= w->isMaximized() ? WindowDecorationInterface::WindowData::Maximized : 0; |
949 | wd.flags |= w->testWFlags(Qt::WStyle_Dialog) ? WindowDecorationInterface::WindowData::Dialog : 0; | 924 | wd.flags |= w->testWFlags(Qt::WStyle_Dialog) ? WindowDecorationInterface::WindowData::Dialog : 0; |
950 | const QWidget *active = qpeManager->activeWidget(); | 925 | const QWidget *active = qpeManager->activeWidget(); |
951 | wd.flags |= w == active ? WindowDecorationInterface::WindowData::Active : 0; | 926 | wd.flags |= w == active ? WindowDecorationInterface::WindowData::Active : 0; |
952 | wd.reserved = 1; | 927 | wd.reserved = 1; |
953 | } | 928 | } |
954 | 929 | ||
955 | /* | 930 | /* |
956 | #ifndef QT_NO_POPUPMENU | 931 | #ifndef QT_NO_POPUPMENU |
957 | QPopupMenu *QPEDecoration::menu(QWSManager*, const QWidget*, const QPoint&) | 932 | QPopupMenu *QPEDecoration::menu(QWSManager*, const QWidget*, const QPoint&) |
958 | { | 933 | { |
959 | return 0; | 934 | return 0; |
960 | } | 935 | } |
961 | #endif | 936 | #endif |
962 | */ | 937 | */ |
963 | 938 | ||
964 | 939 | ||
965 | 940 | ||
966 | 941 | ||
967 | #endif // QT_NO_QWS_QPE_WM_STYLE | 942 | #endif // QT_NO_QWS_QPE_WM_STYLE |
968 | #endif | 943 | #endif |