summaryrefslogtreecommitdiff
path: root/library
Unidiff
Diffstat (limited to 'library') (more/less context) (ignore whitespace changes)
-rw-r--r--library/qpeapplication.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index 19e99f2..286c6ef 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -94,263 +94,263 @@
94#include <sys/file.h> 94#include <sys/file.h>
95#include <sys/ioctl.h> 95#include <sys/ioctl.h>
96#ifndef QT_NO_SOUND 96#ifndef QT_NO_SOUND
97#include <sys/soundcard.h> 97#include <sys/soundcard.h>
98#endif 98#endif
99 99
100#include <backend/rohfeedback.h> 100#include <backend/rohfeedback.h>
101 101
102 102
103static bool useBigPixmaps = 0; 103static bool useBigPixmaps = 0;
104 104
105class HackWidget : public QWidget 105class HackWidget : public QWidget
106{ 106{
107public: 107public:
108 bool needsOk() 108 bool needsOk()
109 { return (getWState() & WState_Reserved1 ); } 109 { return (getWState() & WState_Reserved1 ); }
110 110
111 QRect normalGeometry() 111 QRect normalGeometry()
112 { return topData()->normalGeometry; }; 112 { return topData()->normalGeometry; };
113}; 113};
114 114
115class QPEApplicationData 115class QPEApplicationData
116{ 116{
117public: 117public:
118 QPEApplicationData ( ) : 118 QPEApplicationData ( ) :
119 presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ), 119 presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ),
120 notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ), 120 notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ),
121 keep_running( true ), qcopQok( false ), 121 keep_running( true ), qcopQok( false ),
122 fontFamily( "Vera" ), fontSize( 10 ), smallIconSize( 14 ), 122 fontFamily( "Vera" ), fontSize( 10 ), smallIconSize( 14 ),
123 bigIconSize( 32 ), qpe_main_widget( 0 ) 123 bigIconSize( 32 ), qpe_main_widget( 0 )
124 { 124 {
125 Config cfg( "qpe" ); 125 Config cfg( "qpe" );
126 cfg.setGroup( "Appearance" ); 126 cfg.setGroup( "Appearance" );
127 useBigPixmaps = cfg.readBoolEntry( "useBigPixmaps", false ); 127 useBigPixmaps = cfg.readBoolEntry( "useBigPixmaps", false );
128 fontFamily = cfg.readEntry( "FontFamily", "Vera" ); 128 fontFamily = cfg.readEntry( "FontFamily", "Vera" );
129 fontSize = cfg.readNumEntry( "FontSize", 10 ); 129 fontSize = cfg.readNumEntry( "FontSize", 10 );
130 smallIconSize = cfg.readNumEntry( "SmallIconSize", 14 ); 130 smallIconSize = cfg.readNumEntry( "SmallIconSize", 14 );
131 bigIconSize = cfg.readNumEntry( "BigIconSize", 32 ); 131 bigIconSize = cfg.readNumEntry( "BigIconSize", 32 );
132#ifdef OPIE_WITHROHFEEDBACK 132#ifdef OPIE_WITHROHFEEDBACK
133 RoH = 0; 133 RoH = 0;
134#endif 134#endif
135 } 135 }
136 136
137 int presstimer; 137 int presstimer;
138 QWidget* presswidget; 138 QWidget* presswidget;
139 QPoint presspos; 139 QPoint presspos;
140#ifdef OPIE_WITHROHFEEDBACK 140#ifdef OPIE_WITHROHFEEDBACK
141 Opie::Internal::RoHFeedback *RoH; 141 Opie::Internal::RoHFeedback *RoH;
142#endif 142#endif
143 143
144 bool rightpressed : 1; 144 bool rightpressed : 1;
145 bool kbgrabbed : 1; 145 bool kbgrabbed : 1;
146 bool notbusysent : 1; 146 bool notbusysent : 1;
147 bool preloaded : 1; 147 bool preloaded : 1;
148 bool forceshow : 1; 148 bool forceshow : 1;
149 bool nomaximize : 1; 149 bool nomaximize : 1;
150 bool keep_running : 1; 150 bool keep_running : 1;
151 bool qcopQok : 1; 151 bool qcopQok : 1;
152 152
153 QCString fontFamily; 153 QCString fontFamily;
154 int fontSize; 154 int fontSize;
155 int smallIconSize; 155 int smallIconSize;
156 int bigIconSize; 156 int bigIconSize;
157 157
158 QString appName; 158 QString appName;
159 struct QCopRec 159 struct QCopRec
160 { 160 {
161 QCopRec( const QCString &ch, const QCString &msg, 161 QCopRec( const QCString &ch, const QCString &msg,
162 const QByteArray &d ) : 162 const QByteArray &d ) :
163 channel( ch ), message( msg ), data( d ) 163 channel( ch ), message( msg ), data( d )
164 { } 164 { }
165 165
166 QCString channel; 166 QCString channel;
167 QCString message; 167 QCString message;
168 QByteArray data; 168 QByteArray data;
169 }; 169 };
170 QGuardedPtr<QWidget> qpe_main_widget; 170 QGuardedPtr<QWidget> qpe_main_widget;
171 QGuardedPtr<QWidget> lastraised; 171 QGuardedPtr<QWidget> lastraised;
172 QQueue<QCopRec> qcopq; 172 QQueue<QCopRec> qcopq;
173 QString styleName; 173 QString styleName;
174 QString decorationName; 174 QString decorationName;
175 175
176 void enqueueQCop( const QCString &ch, const QCString &msg, 176 void enqueueQCop( const QCString &ch, const QCString &msg,
177 const QByteArray &data ) 177 const QByteArray &data )
178 { 178 {
179 qcopq.enqueue( new QCopRec( ch, msg, data ) ); 179 qcopq.enqueue( new QCopRec( ch, msg, data ) );
180 } 180 }
181 void sendQCopQ() 181 void sendQCopQ()
182 { 182 {
183 if (!qcopQok ) 183 if (!qcopQok )
184 return; 184 return;
185 185
186 QCopRec * r; 186 QCopRec * r;
187 187
188 while((r=qcopq.dequeue())) { 188 while((r=qcopq.dequeue())) {
189 // remove from queue before sending... 189 // remove from queue before sending...
190 // event loop can come around again before getting 190 // event loop can come around again before getting
191 // back from sendLocally 191 // back from sendLocally
192#ifndef QT_NO_COP 192#ifndef QT_NO_COP
193 QCopChannel::sendLocally( r->channel, r->message, r->data ); 193 QCopChannel::sendLocally( r->channel, r->message, r->data );
194#endif 194#endif
195 195
196 delete r; 196 delete r;
197 } 197 }
198 } 198 }
199 199
200 static void show_mx(QWidget* mw, bool nomaximize, QString &strName) { 200 static void show_mx(QWidget* mw, bool nomaximize, QString &strName) {
201 if ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) 201 if ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") )
202 { 202 {
203 ( ( QMainWindow* ) mw )->setUsesBigPixmaps( useBigPixmaps ); 203 ( ( QMainWindow* ) mw )->setUsesBigPixmaps( useBigPixmaps );
204 } 204 }
205 QPoint p; 205 QPoint p;
206 QSize s; 206 QSize s;
207 bool max; 207 bool max;
208 208
209 if ( mw->isVisible() ) { 209 if ( mw->isVisible() ) {
210 if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { 210 if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) {
211 mw->resize(s); 211 mw->resize(s);
212 mw->move(p); 212 mw->move(p);
213 } 213 }
214 mw->raise(); 214 mw->raise();
215 } else { 215 } else {
216 216
217 if ( mw->layout() && mw->inherits("QDialog") ) { 217 if ( mw->layout() && mw->inherits("QDialog") ) {
218 if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { 218 if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) {
219 mw->resize(s); 219 mw->resize(s);
220 mw->move(p); 220 mw->move(p);
221 221
222 if ( max && !nomaximize ) { 222 if ( max && !nomaximize ) {
223 mw->showMaximized(); 223 mw->showMaximized();
224 } else { 224 } else {
225 mw->show(); 225 mw->show();
226 } 226 }
227 } else { 227 } else {
228 QPEApplication::showDialog((QDialog*)mw,nomaximize); 228 QPEApplication::showDialog((QDialog*)mw, !nomaximize);
229 } 229 }
230 } else { 230 } else {
231 if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { 231 if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) {
232 mw->resize(s); 232 mw->resize(s);
233 mw->move(p); 233 mw->move(p);
234 } else { //no stored rectangle, make an estimation 234 } else { //no stored rectangle, make an estimation
235 int x = (qApp->desktop()->width()-mw->frameGeometry().width())/2; 235 int x = (qApp->desktop()->width()-mw->frameGeometry().width())/2;
236 int y = (qApp->desktop()->height()-mw->frameGeometry().height())/2; 236 int y = (qApp->desktop()->height()-mw->frameGeometry().height())/2;
237 mw->move( QMAX(x,0), QMAX(y,0) ); 237 mw->move( QMAX(x,0), QMAX(y,0) );
238#ifdef Q_WS_QWS 238#ifdef Q_WS_QWS
239 if ( !nomaximize ) 239 if ( !nomaximize )
240 mw->showMaximized(); 240 mw->showMaximized();
241#endif 241#endif
242 } 242 }
243 if ( max && !nomaximize ) 243 if ( max && !nomaximize )
244 mw->showMaximized(); 244 mw->showMaximized();
245 else 245 else
246 mw->show(); 246 mw->show();
247 } 247 }
248 } 248 }
249 } 249 }
250 250
251 static bool read_widget_rect(const QString &app, bool &maximized, QPoint &p, QSize &s) 251 static bool read_widget_rect(const QString &app, bool &maximized, QPoint &p, QSize &s)
252 { 252 {
253#ifndef OPIE_NO_WINDOWED 253#ifndef OPIE_NO_WINDOWED
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#endif 275#endif
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 )
314 p.setX( maxX - wWidth ); 314 p.setX( maxX - wWidth );
315 if ( p.y() + wHeight > maxY ) 315 if ( p.y() + wHeight > maxY )
316 p.setY( maxY - wHeight ); 316 p.setY( maxY - wHeight );
317 317
318 return TRUE; 318 return TRUE;
319 } 319 }
320 320
321 static void store_widget_rect(QWidget *w, QString &app) 321 static void store_widget_rect(QWidget *w, QString &app)
322 { 322 {
323 if( !w ) 323 if( !w )
324 return; 324 return;
325#ifndef OPIE_NO_WINDOWED 325#ifndef OPIE_NO_WINDOWED
326 // 350 is the trigger in qwsdefaultdecoration for providing a resize button 326 // 350 is the trigger in qwsdefaultdecoration for providing a resize button
327 if ( qApp->desktop()->width() <= 350 ) 327 if ( qApp->desktop()->width() <= 350 )
328 return; 328 return;
329 // we use these to map the offset of geometry and pos. ( we can only use normalGeometry to 329 // we use these to map the offset of geometry and pos. ( we can only use normalGeometry to
330 // get the non-maximized version, so we have to do it the hard way ) 330 // get the non-maximized version, so we have to do it the hard way )
331 int offsetX = w->x() - w->geometry().left(); 331 int offsetX = w->x() - w->geometry().left();
332 int offsetY = w->y() - w->geometry().top(); 332 int offsetY = w->y() - w->geometry().top();
333 333
334 QRect r; 334 QRect r;
335 if ( w->isMaximized() ) 335 if ( w->isMaximized() )
336 r = ( (HackWidget *) w)->normalGeometry(); 336 r = ( (HackWidget *) w)->normalGeometry();
337 else 337 else
338 r = w->geometry(); 338 r = w->geometry();
339 339
340 // Stores the window placement as pos(), size() (due to the offset mapping) 340 // Stores the window placement as pos(), size() (due to the offset mapping)
341 Config cfg( "qpe" ); 341 Config cfg( "qpe" );
342 cfg.setGroup("ApplicationPositions"); 342 cfg.setGroup("ApplicationPositions");
343 QString s; 343 QString s;
344 s.sprintf("%d,%d,%d,%d,%d", r.left() + offsetX, r.top() + offsetY, r.width(), r.height(), w->isMaximized() ); 344 s.sprintf("%d,%d,%d,%d,%d", r.left() + offsetX, r.top() + offsetY, r.width(), r.height(), w->isMaximized() );
345 cfg.writeEntry( app, s ); 345 cfg.writeEntry( app, s );
346#endif 346#endif
347 } 347 }
348 348
349 static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) 349 static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ )
350 { 350 {
351 /* 351 /*
352 // This works but disable it for now until it is safe to apply 352 // This works but disable it for now until it is safe to apply
353 // What is does is scan the .desktop files of all the apps for 353 // What is does is scan the .desktop files of all the apps for
354 // the applnk that has the corresponding argv[0] as this program 354 // the applnk that has the corresponding argv[0] as this program
355 // then it uses the name stored in the .desktop file as the caption 355 // then it uses the name stored in the .desktop file as the caption
356 // for the main widget. This saves duplicating translations for 356 // for the main widget. This saves duplicating translations for