author | zecke <zecke> | 2004-12-20 22:11:44 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-12-20 22:11:44 (UTC) |
commit | a50334dddaa542fd63726a639e852c30036f53a0 (patch) (unidiff) | |
tree | 30d0a41308f752c72d2c685fab60e2bd7c650bec /library/qpeapplication.cpp | |
parent | 29e93ce47f7a52ded8956811d50b93e754caa3a6 (diff) | |
download | opie-a50334dddaa542fd63726a639e852c30036f53a0.zip opie-a50334dddaa542fd63726a639e852c30036f53a0.tar.gz opie-a50334dddaa542fd63726a639e852c30036f53a0.tar.bz2 |
Restore Files:
-QWSDecoration scaling fixes by mickeyl
-Readd macros for DEPRECATED and VISIBILITY
-Move out showWidget and execDialog to widget_sowing.cpp
-QPE_EXPORT_SYMBOL for Q_EXPORT_INTERFACE
-Deprecated for FileSelector, QPEMenubar and Toolbar
-rw-r--r-- | library/qpeapplication.cpp | 80 |
1 files changed, 40 insertions, 40 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index 4adfc8f..43a9be5 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -137,177 +137,177 @@ public: | |||
137 | 137 | ||
138 | int presstimer; | 138 | int presstimer; |
139 | QWidget* presswidget; | 139 | QWidget* presswidget; |
140 | QPoint presspos; | 140 | QPoint presspos; |
141 | #ifdef OPIE_WITHROHFEEDBACK | 141 | #ifdef OPIE_WITHROHFEEDBACK |
142 | Opie::Internal::RoHFeedback *RoH; | 142 | Opie::Internal::RoHFeedback *RoH; |
143 | #endif | 143 | #endif |
144 | 144 | ||
145 | bool rightpressed : 1; | 145 | bool rightpressed : 1; |
146 | bool kbgrabbed : 1; | 146 | bool kbgrabbed : 1; |
147 | bool notbusysent : 1; | 147 | bool notbusysent : 1; |
148 | bool preloaded : 1; | 148 | bool preloaded : 1; |
149 | bool forceshow : 1; | 149 | bool forceshow : 1; |
150 | bool nomaximize : 1; | 150 | bool nomaximize : 1; |
151 | bool keep_running : 1; | 151 | bool keep_running : 1; |
152 | bool qcopQok : 1; | 152 | bool qcopQok : 1; |
153 | 153 | ||
154 | QCString fontFamily; | 154 | QCString fontFamily; |
155 | int fontSize; | 155 | int fontSize; |
156 | int smallIconSize; | 156 | int smallIconSize; |
157 | int bigIconSize; | 157 | int bigIconSize; |
158 | 158 | ||
159 | QString appName; | 159 | QString appName; |
160 | struct QCopRec | 160 | struct QCopRec |
161 | { | 161 | { |
162 | QCopRec( const QCString &ch, const QCString &msg, | 162 | QCopRec( const QCString &ch, const QCString &msg, |
163 | const QByteArray &d ) : | 163 | const QByteArray &d ) : |
164 | channel( ch ), message( msg ), data( d ) | 164 | channel( ch ), message( msg ), data( d ) |
165 | { } | 165 | { } |
166 | 166 | ||
167 | QCString channel; | 167 | QCString channel; |
168 | QCString message; | 168 | QCString message; |
169 | QByteArray data; | 169 | QByteArray data; |
170 | }; | 170 | }; |
171 | QWidget* qpe_main_widget; | 171 | QWidget* qpe_main_widget; |
172 | QGuardedPtr<QWidget> lastraised; | 172 | QGuardedPtr<QWidget> lastraised; |
173 | QQueue<QCopRec> qcopq; | 173 | QQueue<QCopRec> qcopq; |
174 | QString styleName; | 174 | QString styleName; |
175 | QString decorationName; | 175 | QString decorationName; |
176 | 176 | ||
177 | void enqueueQCop( const QCString &ch, const QCString &msg, | 177 | void enqueueQCop( const QCString &ch, const QCString &msg, |
178 | const QByteArray &data ) | 178 | const QByteArray &data ) |
179 | { | 179 | { |
180 | qcopq.enqueue( new QCopRec( ch, msg, data ) ); | 180 | qcopq.enqueue( new QCopRec( ch, msg, data ) ); |
181 | } | 181 | } |
182 | void sendQCopQ() | 182 | void sendQCopQ() |
183 | { | 183 | { |
184 | if (!qcopQok ) | 184 | if (!qcopQok ) |
185 | return; | 185 | return; |
186 | 186 | ||
187 | QCopRec * r; | 187 | QCopRec * r; |
188 | 188 | ||
189 | while((r=qcopq.dequeue())) { | 189 | while((r=qcopq.dequeue())) { |
190 | // remove from queue before sending... | 190 | // remove from queue before sending... |
191 | // event loop can come around again before getting | 191 | // event loop can come around again before getting |
192 | // back from sendLocally | 192 | // back from sendLocally |
193 | #ifndef QT_NO_COP | 193 | #ifndef QT_NO_COP |
194 | QCopChannel::sendLocally( r->channel, r->message, r->data ); | 194 | QCopChannel::sendLocally( r->channel, r->message, r->data ); |
195 | #endif | 195 | #endif |
196 | 196 | ||
197 | delete r; | 197 | delete r; |
198 | } | 198 | } |
199 | } | 199 | } |
200 | 200 | ||
201 | static void show_mx(QWidget* mw, bool nomaximize, QString &strName) | 201 | static void show_mx(QWidget* mw, bool nomaximize, QString &strName) { |
202 | { | 202 | if ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) |
203 | if ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) | 203 | { |
204 | { | 204 | ( ( QMainWindow* ) mw )->setUsesBigPixmaps( useBigPixmaps ); |
205 | ( ( QMainWindow* ) mw )->setUsesBigPixmaps( useBigPixmaps ); | 205 | } |
206 | } | ||
207 | QPoint p; | 206 | QPoint p; |
208 | QSize s; | 207 | QSize s; |
209 | bool max; | 208 | bool max; |
210 | if ( mw->isVisible() ) { | ||
211 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { | ||
212 | mw->resize(s); | ||
213 | mw->move(p); | ||
214 | } | ||
215 | mw->raise(); | ||
216 | } else { | ||
217 | 209 | ||
218 | if ( mw->layout() && mw->inherits("QDialog") ) { | 210 | if ( mw->isVisible() ) { |
219 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { | 211 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { |
220 | mw->resize(s); | 212 | mw->resize(s); |
221 | mw->move(p); | 213 | mw->move(p); |
214 | } | ||
215 | mw->raise(); | ||
216 | } else { | ||
222 | 217 | ||
223 | if ( max && !nomaximize ) { | 218 | if ( mw->layout() && mw->inherits("QDialog") ) { |
224 | mw->showMaximized(); | 219 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { |
225 | } else { | 220 | mw->resize(s); |
226 | mw->show(); | 221 | mw->move(p); |
222 | |||
223 | if ( max && !nomaximize ) { | ||
224 | mw->showMaximized(); | ||
225 | } else { | ||
226 | mw->show(); | ||
227 | } | ||
228 | } else { | ||
229 | QPEApplication::showDialog((QDialog*)mw,nomaximize); | ||
227 | } | 230 | } |
228 | } else { | 231 | } else { |
229 | QPEApplication::showDialog((QDialog*)mw,nomaximize); | 232 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { |
230 | } | 233 | mw->resize(s); |
231 | } else { | 234 | mw->move(p); |
232 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { | 235 | } else { //no stored rectangle, make an estimation |
233 | mw->resize(s); | 236 | int x = (qApp->desktop()->width()-mw->frameGeometry().width())/2; |
234 | mw->move(p); | 237 | int y = (qApp->desktop()->height()-mw->frameGeometry().height())/2; |
235 | } else { //no stored rectangle, make an estimation | 238 | mw->move( QMAX(x,0), QMAX(y,0) ); |
236 | int x = (qApp->desktop()->width()-mw->frameGeometry().width())/2; | ||
237 | int y = (qApp->desktop()->height()-mw->frameGeometry().height())/2; | ||
238 | mw->move( QMAX(x,0), QMAX(y,0) ); | ||
239 | #ifdef Q_WS_QWS | 239 | #ifdef Q_WS_QWS |
240 | if ( !nomaximize ) | 240 | if ( !nomaximize ) |
241 | mw->showMaximized(); | 241 | mw->showMaximized(); |
242 | #endif | 242 | #endif |
243 | } | ||
244 | if ( max && !nomaximize ) | ||
245 | mw->showMaximized(); | ||
246 | else | ||
247 | mw->show(); | ||
248 | } | ||
243 | } | 249 | } |
244 | if ( max && !nomaximize ) | ||
245 | mw->showMaximized(); | ||
246 | else | ||
247 | mw->show(); | ||
248 | } | ||
249 | } | ||
250 | } | 250 | } |
251 | 251 | ||
252 | static bool read_widget_rect(const QString &app, bool &maximized, QPoint &p, QSize &s) | 252 | static bool read_widget_rect(const QString &app, bool &maximized, QPoint &p, QSize &s) |
253 | { | 253 | { |
254 | maximized = TRUE; | 254 | maximized = TRUE; |
255 | // 350 is the trigger in qwsdefaultdecoration for providing a resize button | 255 | // 350 is the trigger in qwsdefaultdecoration for providing a resize button |
256 | if ( qApp->desktop()->width() <= 350 ) | 256 | if ( qApp->desktop()->width() <= 350 ) |
257 | return FALSE; | 257 | return FALSE; |
258 | 258 | ||
259 | Config cfg( "qpe" ); | 259 | Config cfg( "qpe" ); |
260 | cfg.setGroup("ApplicationPositions"); | 260 | cfg.setGroup("ApplicationPositions"); |
261 | QString str = cfg.readEntry( app, QString::null ); | 261 | QString str = cfg.readEntry( app, QString::null ); |
262 | QStringList l = QStringList::split(",", str); | 262 | QStringList l = QStringList::split(",", str); |
263 | 263 | ||
264 | if ( l.count() == 5) { | 264 | if ( l.count() == 5) { |
265 | p.setX( l[0].toInt() ); | 265 | p.setX( l[0].toInt() ); |
266 | p.setY( l[1].toInt() ); | 266 | p.setY( l[1].toInt() ); |
267 | 267 | ||
268 | s.setWidth( l[2].toInt() ); | 268 | s.setWidth( l[2].toInt() ); |
269 | s.setHeight( l[3].toInt() ); | 269 | s.setHeight( l[3].toInt() ); |
270 | 270 | ||
271 | maximized = l[4].toInt(); | 271 | maximized = l[4].toInt(); |
272 | 272 | ||
273 | return TRUE; | 273 | return TRUE; |
274 | } | 274 | } |
275 | 275 | ||
276 | return FALSE; | 276 | return FALSE; |
277 | } | 277 | } |
278 | 278 | ||
279 | 279 | ||
280 | static bool validate_widget_size(const QWidget *w, QPoint &p, QSize &s) | 280 | static bool validate_widget_size(const QWidget *w, QPoint &p, QSize &s) |
281 | { | 281 | { |
282 | #ifndef Q_WS_QWS | 282 | #ifndef Q_WS_QWS |
283 | QRect qt_maxWindowRect = qApp->desktop()->geometry(); | 283 | QRect qt_maxWindowRect = qApp->desktop()->geometry(); |
284 | #endif | 284 | #endif |
285 | int maxX = qt_maxWindowRect.width(); | 285 | int maxX = qt_maxWindowRect.width(); |
286 | int maxY = qt_maxWindowRect.height(); | 286 | int maxY = qt_maxWindowRect.height(); |
287 | int wWidth = s.width() + ( w->frameGeometry().width() - w->geometry().width() ); | 287 | int wWidth = s.width() + ( w->frameGeometry().width() - w->geometry().width() ); |
288 | int wHeight = s.height() + ( w->frameGeometry().height() - w->geometry().height() ); | 288 | int wHeight = s.height() + ( w->frameGeometry().height() - w->geometry().height() ); |
289 | 289 | ||
290 | // total window size is not allowed to be larger than desktop window size | 290 | // total window size is not allowed to be larger than desktop window size |
291 | if ( ( wWidth >= maxX ) && ( wHeight >= maxY ) ) | 291 | if ( ( wWidth >= maxX ) && ( wHeight >= maxY ) ) |
292 | return FALSE; | 292 | return FALSE; |
293 | 293 | ||
294 | if ( wWidth > maxX ) { | 294 | if ( wWidth > maxX ) { |
295 | s.setWidth( maxX - (w->frameGeometry().width() - w->geometry().width() ) ); | 295 | s.setWidth( maxX - (w->frameGeometry().width() - w->geometry().width() ) ); |
296 | wWidth = maxX; | 296 | wWidth = maxX; |
297 | } | 297 | } |
298 | 298 | ||
299 | if ( wHeight > maxY ) { | 299 | if ( wHeight > maxY ) { |
300 | s.setHeight( maxY - (w->frameGeometry().height() - w->geometry().height() ) ); | 300 | s.setHeight( maxY - (w->frameGeometry().height() - w->geometry().height() ) ); |
301 | wHeight = maxY; | 301 | wHeight = maxY; |
302 | } | 302 | } |
303 | 303 | ||
304 | // any smaller than this and the maximize/close/help buttons will be overlapping | 304 | // any smaller than this and the maximize/close/help buttons will be overlapping |
305 | if ( wWidth < 80 || wHeight < 60 ) | 305 | if ( wWidth < 80 || wHeight < 60 ) |
306 | return FALSE; | 306 | return FALSE; |
307 | 307 | ||
308 | if ( p.x() < 0 ) | 308 | if ( p.x() < 0 ) |
309 | p.setX(0); | 309 | p.setX(0); |
310 | if ( p.y() < 0 ) | 310 | if ( p.y() < 0 ) |
311 | p.setY(0); | 311 | p.setY(0); |
312 | 312 | ||
313 | if ( p.x() + wWidth > maxX ) | 313 | if ( p.x() + wWidth > maxX ) |