summaryrefslogtreecommitdiff
path: root/library/qpeapplication.cpp
authorzecke <zecke>2004-08-24 17:37:59 (UTC)
committer zecke <zecke>2004-08-24 17:37:59 (UTC)
commite90847c784c48bd21bf8768cb38edb853b832697 (patch) (unidiff)
tree7c95b22cc4e9b69aa384c041ae67babb8fafe319 /library/qpeapplication.cpp
parent0a141c4a9719aa273867ad45c4293208545489b1 (diff)
downloadopie-e90847c784c48bd21bf8768cb38edb853b832697.zip
opie-e90847c784c48bd21bf8768cb38edb853b832697.tar.gz
opie-e90847c784c48bd21bf8768cb38edb853b832697.tar.bz2
Allow to completely turn off/on Right on Hold Visual Feedback
mickey thanks for spotting the linking failures :}
Diffstat (limited to 'library/qpeapplication.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--library/qpeapplication.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index acad81d..35f433c 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -69,134 +69,139 @@
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> 100#include <qpe/rohfeedback.h>
101 101
102 102
103static bool useBigPixmaps = 0; 103static bool useBigPixmaps = 0;
104 104
105 105
106class HackWidget : public QWidget 106class HackWidget : public QWidget
107{ 107{
108public: 108public:
109 bool needsOk() 109 bool needsOk()
110 { return (getWState() & WState_Reserved1 ); } 110 { return (getWState() & WState_Reserved1 ); }
111 111
112 QRect normalGeometry() 112 QRect normalGeometry()
113 { return topData()->normalGeometry; }; 113 { return topData()->normalGeometry; };
114}; 114};
115 115
116class QPEApplicationData 116class QPEApplicationData
117{ 117{
118public: 118public:
119 QPEApplicationData ( ) 119 QPEApplicationData ( )
120 : presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ), 120 : presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ),
121 notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ), 121 notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ),
122 keep_running( true ), qcopQok( false ), 122 keep_running( true ), qcopQok( false ),
123 fontFamily( "Vera" ), fontSize( 10 ), smallIconSize( 14 ), 123 fontFamily( "Vera" ), fontSize( 10 ), smallIconSize( 14 ),
124 bigIconSize( 32 ), qpe_main_widget( 0 ) 124 bigIconSize( 32 ), qpe_main_widget( 0 )
125 { 125 {
126 Config cfg( "qpe" ); 126 Config cfg( "qpe" );
127 cfg.setGroup( "Appearance" ); 127 cfg.setGroup( "Appearance" );
128 useBigPixmaps = cfg.readBoolEntry( "useBigPixmaps", false ); 128 useBigPixmaps = cfg.readBoolEntry( "useBigPixmaps", false );
129 fontFamily = cfg.readEntry( "FontFamily", "Vera" ); 129 fontFamily = cfg.readEntry( "FontFamily", "Vera" );
130 fontSize = cfg.readNumEntry( "FontSize", 10 ); 130 fontSize = cfg.readNumEntry( "FontSize", 10 );
131 smallIconSize = cfg.readNumEntry( "SmallIconSize", 14 ); 131 smallIconSize = cfg.readNumEntry( "SmallIconSize", 14 );
132 bigIconSize = cfg.readNumEntry( "BigIconSize", 32 ); 132 bigIconSize = cfg.readNumEntry( "BigIconSize", 32 );
133#ifdef OPIE_ROHFEEDBACK
133 RoH = 0; 134 RoH = 0;
135#endif
134 } 136 }
135 137
136 int presstimer; 138 int presstimer;
137 QWidget* presswidget; 139 QWidget* presswidget;
138 QPoint presspos; 140 QPoint presspos;
141#ifdef OPIE_ROHFEEDBACK
142 Opie::Internal::RoHFeedback *RoH;
143#endif
139 144
140 bool rightpressed : 1; 145 bool rightpressed : 1;
141 bool kbgrabbed : 1; 146 bool kbgrabbed : 1;
142 bool notbusysent : 1; 147 bool notbusysent : 1;
143 bool preloaded : 1; 148 bool preloaded : 1;
144 bool forceshow : 1; 149 bool forceshow : 1;
145 bool nomaximize : 1; 150 bool nomaximize : 1;
146 bool keep_running : 1; 151 bool keep_running : 1;
147 bool qcopQok : 1; 152 bool qcopQok : 1;
148 153
149 QCString fontFamily; 154 QCString fontFamily;
150 int fontSize; 155 int fontSize;
151 int smallIconSize; 156 int smallIconSize;
152 int bigIconSize; 157 int bigIconSize;
153 158
154 QStringList langs; 159 QStringList langs;
155 QString appName; 160 QString appName;
156 struct QCopRec 161 struct QCopRec
157 { 162 {
158 QCopRec( const QCString &ch, const QCString &msg, 163 QCopRec( const QCString &ch, const QCString &msg,
159 const QByteArray &d ) : 164 const QByteArray &d ) :
160 channel( ch ), message( msg ), data( d ) 165 channel( ch ), message( msg ), data( d )
161 { } 166 { }
162 167
163 QCString channel; 168 QCString channel;
164 QCString message; 169 QCString message;
165 QByteArray data; 170 QByteArray data;
166 }; 171 };
167 QWidget* qpe_main_widget; 172 QWidget* qpe_main_widget;
168 QGuardedPtr<QWidget> lastraised; 173 QGuardedPtr<QWidget> lastraised;
169 QQueue<QCopRec> qcopq; 174 QQueue<QCopRec> qcopq;
170 QString styleName; 175 QString styleName;
171 QString decorationName; 176 QString decorationName;
172 177
173 void enqueueQCop( const QCString &ch, const QCString &msg, 178 void enqueueQCop( const QCString &ch, const QCString &msg,
174 const QByteArray &data ) 179 const QByteArray &data )
175 { 180 {
176 qcopq.enqueue( new QCopRec( ch, msg, data ) ); 181 qcopq.enqueue( new QCopRec( ch, msg, data ) );
177 } 182 }
178 void sendQCopQ() 183 void sendQCopQ()
179 { 184 {
180 if (!qcopQok ) 185 if (!qcopQok )
181 return; 186 return;
182 187
183 QCopRec * r; 188 QCopRec * r;
184 189
185 while((r=qcopq.dequeue())) { 190 while((r=qcopq.dequeue())) {
186 // remove from queue before sending... 191 // remove from queue before sending...
187 // event loop can come around again before getting 192 // event loop can come around again before getting
188 // back from sendLocally 193 // back from sendLocally
189#ifndef QT_NO_COP 194#ifndef QT_NO_COP
190 QCopChannel::sendLocally( r->channel, r->message, r->data ); 195 QCopChannel::sendLocally( r->channel, r->message, r->data );
191#endif 196#endif
192 197
193 delete r; 198 delete r;
194 } 199 }
195 } 200 }
196 201
197 static void show_mx(QWidget* mw, bool nomaximize, QString &strName) 202 static void show_mx(QWidget* mw, bool nomaximize, QString &strName)
198 { 203 {
199 if ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) 204 if ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") )
200 { 205 {
201 ( ( QMainWindow* ) mw )->setUsesBigPixmaps( useBigPixmaps ); 206 ( ( QMainWindow* ) mw )->setUsesBigPixmaps( useBigPixmaps );
202 } 207 }
@@ -436,130 +441,128 @@ static void qpe_show_dialog( QDialog* d, bool nomax )
436 show_mx(mw, nomax, appName); 441 show_mx(mw, nomax, appName);
437 } 442 }
438 else if ( keep_running ) { 443 else if ( keep_running ) {
439 show_mx(mw, nomax, appName); 444 show_mx(mw, nomax, appName);
440 } 445 }
441 } 446 }
442 447
443 void loadTextCodecs() 448 void loadTextCodecs()
444 { 449 {
445 QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; 450 QString path = QPEApplication::qpeDir() + "/plugins/textcodecs";
446#ifdef Q_OS_MACX 451#ifdef Q_OS_MACX
447 QDir dir( path, "lib*.dylib" ); 452 QDir dir( path, "lib*.dylib" );
448#else 453#else
449 QDir dir( path, "lib*.so" ); 454 QDir dir( path, "lib*.so" );
450#endif 455#endif
451 QStringList list; 456 QStringList list;
452 if ( dir. exists ( )) 457 if ( dir. exists ( ))
453 list = dir.entryList(); 458 list = dir.entryList();
454 QStringList::Iterator it; 459 QStringList::Iterator it;
455 for ( it = list.begin(); it != list.end(); ++it ) { 460 for ( it = list.begin(); it != list.end(); ++it ) {
456 TextCodecInterface *iface = 0; 461 TextCodecInterface *iface = 0;
457 QLibrary *lib = new QLibrary( path + "/" + *it ); 462 QLibrary *lib = new QLibrary( path + "/" + *it );
458 if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { 463 if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) {
459 QValueList<int> mibs = iface->mibEnums(); 464 QValueList<int> mibs = iface->mibEnums();
460 for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { 465 for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) {
461 (void)iface->createForMib(*i); 466 (void)iface->createForMib(*i);
462 // ### it exists now; need to remember if we can delete it 467 // ### it exists now; need to remember if we can delete it
463 } 468 }
464 } 469 }
465 else { 470 else {
466 lib->unload(); 471 lib->unload();
467 delete lib; 472 delete lib;
468 } 473 }
469 } 474 }
470 } 475 }
471 476
472 void loadImageCodecs() 477 void loadImageCodecs()
473 { 478 {
474 QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; 479 QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs";
475#ifdef Q_OS_MACX 480#ifdef Q_OS_MACX
476 QDir dir( path, "lib*.dylib" ); 481 QDir dir( path, "lib*.dylib" );
477#else 482#else
478 QDir dir( path, "lib*.so" ); 483 QDir dir( path, "lib*.so" );
479#endif 484#endif
480 QStringList list; 485 QStringList list;
481 if ( dir. exists ( )) 486 if ( dir. exists ( ))
482 list = dir.entryList(); 487 list = dir.entryList();
483 QStringList::Iterator it; 488 QStringList::Iterator it;
484 for ( it = list.begin(); it != list.end(); ++it ) { 489 for ( it = list.begin(); it != list.end(); ++it ) {
485 ImageCodecInterface *iface = 0; 490 ImageCodecInterface *iface = 0;
486 QLibrary *lib = new QLibrary( path + "/" + *it ); 491 QLibrary *lib = new QLibrary( path + "/" + *it );
487 if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { 492 if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) {
488 QStringList formats = iface->keys(); 493 QStringList formats = iface->keys();
489 for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { 494 for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) {
490 (void)iface->installIOHandler(*i); 495 (void)iface->installIOHandler(*i);
491 // ### it exists now; need to remember if we can delete it 496 // ### it exists now; need to remember if we can delete it
492 } 497 }
493 } 498 }
494 else { 499 else {
495 lib->unload(); 500 lib->unload();
496 delete lib; 501 delete lib;
497 } 502 }
498 } 503 }
499 } 504 }
500
501 Opie::Internal::RoHFeedback * RoH;
502}; 505};
503 506
504class ResourceMimeFactory : public QMimeSourceFactory 507class ResourceMimeFactory : public QMimeSourceFactory
505{ 508{
506public: 509public:
507 ResourceMimeFactory() : resImage( 0 ) 510 ResourceMimeFactory() : resImage( 0 )
508 { 511 {
509 setFilePath( Global::helpPath() ); 512 setFilePath( Global::helpPath() );
510 setExtensionType( "html", "text/html;charset=UTF-8" ); 513 setExtensionType( "html", "text/html;charset=UTF-8" );
511 } 514 }
512 ~ResourceMimeFactory() { 515 ~ResourceMimeFactory() {
513 delete resImage; 516 delete resImage;
514 } 517 }
515 518
516 const QMimeSource* data( const QString& abs_name ) const 519 const QMimeSource* data( const QString& abs_name ) const
517 { 520 {
518 const QMimeSource * r = QMimeSourceFactory::data( abs_name ); 521 const QMimeSource * r = QMimeSourceFactory::data( abs_name );
519 if ( !r ) { 522 if ( !r ) {
520 int sl = abs_name.length(); 523 int sl = abs_name.length();
521 do { 524 do {
522 sl = abs_name.findRev( '/', sl - 1 ); 525 sl = abs_name.findRev( '/', sl - 1 );
523 QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; 526 QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name;
524 int dot = name.findRev( '.' ); 527 int dot = name.findRev( '.' );
525 if ( dot >= 0 ) 528 if ( dot >= 0 )
526 name = name.left( dot ); 529 name = name.left( dot );
527 QImage img = Resource::loadImage( name ); 530 QImage img = Resource::loadImage( name );
528 if ( !img.isNull() ) { 531 if ( !img.isNull() ) {
529 delete resImage; 532 delete resImage;
530 resImage = new QImageDrag( img ); 533 resImage = new QImageDrag( img );
531 r = resImage; 534 r = resImage;
532 } 535 }
533 } 536 }
534 while ( !r && sl > 0 ); 537 while ( !r && sl > 0 );
535 } 538 }
536 return r; 539 return r;
537 } 540 }
538private: 541private:
539 mutable QImageDrag *resImage; 542 mutable QImageDrag *resImage;
540}; 543};
541 544
542static int& hack(int& i) 545static int& hack(int& i)
543{ 546{
544#if QT_VERSION <= 230 && defined(QT_NO_CODECS) 547#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
545 // These should be created, but aren't in Qt 2.3.0 548 // These should be created, but aren't in Qt 2.3.0
546 (void)new QUtf8Codec; 549 (void)new QUtf8Codec;
547 (void)new QUtf16Codec; 550 (void)new QUtf16Codec;
548#endif 551#endif
549 return i; 552 return i;
550} 553}
551 554
552static int muted = 0; 555static int muted = 0;
553static int micMuted = 0; 556static int micMuted = 0;
554 557
555static void setVolume( int t = 0, int percent = -1 ) 558static void setVolume( int t = 0, int percent = -1 )
556{ 559{
557 switch ( t ) { 560 switch ( t ) {
558 case 0: { 561 case 0: {
559 Config cfg( "qpe" ); 562 Config cfg( "qpe" );
560 cfg.setGroup( "Volume" ); 563 cfg.setGroup( "Volume" );
561 if ( percent < 0 ) 564 if ( percent < 0 )
562 percent = cfg.readNumEntry( "VolumePercent", 50 ); 565 percent = cfg.readNumEntry( "VolumePercent", 50 );
563#ifndef QT_NO_SOUND 566#ifndef QT_NO_SOUND
564 int fd = 0; 567 int fd = 0;
565 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 568 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
@@ -1151,129 +1154,131 @@ bool QPEApplication::qwsEventFilter( QWSEvent * e )
1151 ke-> simpleData.modifiers, 1154 ke-> simpleData.modifiers,
1152 QString ( ch ), 1155 QString ( ch ),
1153 ke-> simpleData.is_auto_repeat, 1 ); 1156 ke-> simpleData.is_auto_repeat, 1 );
1154 1157
1155 QObject *which = QWidget::keyboardGrabber ( ); 1158 QObject *which = QWidget::keyboardGrabber ( );
1156 if ( !which ) 1159 if ( !which )
1157 which = QApplication::focusWidget ( ); 1160 which = QApplication::focusWidget ( );
1158 if ( !which ) 1161 if ( !which )
1159 which = QApplication::activeWindow ( ); 1162 which = QApplication::activeWindow ( );
1160 if ( !which ) 1163 if ( !which )
1161 which = qApp; 1164 which = qApp;
1162 1165
1163 QApplication::sendEvent ( which, &qke ); 1166 QApplication::sendEvent ( which, &qke );
1164 } 1167 }
1165 else { // we didn't grab the keyboard, so send the event to the launcher 1168 else { // we didn't grab the keyboard, so send the event to the launcher
1166 QCopEnvelope e ( "QPE/Launcher", "deviceButton(int,int,int)" ); 1169 QCopEnvelope e ( "QPE/Launcher", "deviceButton(int,int,int)" );
1167 e << int( ke-> simpleData.keycode ) << int( ke-> simpleData. is_press ) << int( ke-> simpleData.is_auto_repeat ); 1170 e << int( ke-> simpleData.keycode ) << int( ke-> simpleData. is_press ) << int( ke-> simpleData.is_auto_repeat );
1168 } 1171 }
1169 } 1172 }
1170 return true; 1173 return true;
1171 } 1174 }
1172 } 1175 }
1173 if ( e->type == QWSEvent::Focus ) { 1176 if ( e->type == QWSEvent::Focus ) {
1174 QWSFocusEvent * fe = ( QWSFocusEvent* ) e; 1177 QWSFocusEvent * fe = ( QWSFocusEvent* ) e;
1175 if ( !fe->simpleData.get_focus ) { 1178 if ( !fe->simpleData.get_focus ) {
1176 QWidget * active = activeWindow(); 1179 QWidget * active = activeWindow();
1177 while ( active && active->isPopup() ) { 1180 while ( active && active->isPopup() ) {
1178 active->close(); 1181 active->close();
1179 active = activeWindow(); 1182 active = activeWindow();
1180 } 1183 }
1181 } 1184 }
1182 else { 1185 else {
1183 // make sure our modal widget is ALWAYS on top 1186 // make sure our modal widget is ALWAYS on top
1184 QWidget *topm = activeModalWidget(); 1187 QWidget *topm = activeModalWidget();
1185 if ( topm && static_cast<int>( topm->winId() ) != fe->simpleData.window) { 1188 if ( topm && static_cast<int>( topm->winId() ) != fe->simpleData.window) {
1186 topm->raise(); 1189 topm->raise();
1187 } 1190 }
1188 } 1191 }
1189 if ( fe->simpleData.get_focus && inputMethodDict ) { 1192 if ( fe->simpleData.get_focus && inputMethodDict ) {
1190 InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) ); 1193 InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) );
1191 if ( m == AlwaysOff ) 1194 if ( m == AlwaysOff )
1192 Global::hideInputMethod(); 1195 Global::hideInputMethod();
1193 if ( m == AlwaysOn ) 1196 if ( m == AlwaysOn )
1194 Global::showInputMethod(); 1197 Global::showInputMethod();
1195 } 1198 }
1196 } 1199 }
1197 1200
1198 1201
1199 return QApplication::qwsEventFilter( e ); 1202 return QApplication::qwsEventFilter( e );
1200} 1203}
1201#endif 1204#endif
1202 1205
1203/*! 1206/*!
1204 Destroys the QPEApplication. 1207 Destroys the QPEApplication.
1205*/ 1208*/
1206QPEApplication::~QPEApplication() 1209QPEApplication::~QPEApplication()
1207{ 1210{
1208 ungrabKeyboard(); 1211 ungrabKeyboard();
1209#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 1212#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
1210 // Need to delete QCopChannels early, since the display will 1213 // Need to delete QCopChannels early, since the display will
1211 // be gone by the time we get to ~QObject(). 1214 // be gone by the time we get to ~QObject().
1212 delete sysChannel; 1215 delete sysChannel;
1213 delete pidChannel; 1216 delete pidChannel;
1214#endif 1217#endif
1218#ifdef OPIE_ROHFEEDBACK
1215 delete d->RoH; 1219 delete d->RoH;
1220#endif
1216 delete d; 1221 delete d;
1217} 1222}
1218 1223
1219/*! 1224/*!
1220 Returns <tt>$OPIEDIR/</tt>. 1225 Returns <tt>$OPIEDIR/</tt>.
1221*/ 1226*/
1222QString QPEApplication::qpeDir() 1227QString QPEApplication::qpeDir()
1223{ 1228{
1224 const char * base = getenv( "OPIEDIR" ); 1229 const char * base = getenv( "OPIEDIR" );
1225 if ( base ) 1230 if ( base )
1226 return QString( base ) + "/"; 1231 return QString( base ) + "/";
1227 1232
1228 return QString( "../" ); 1233 return QString( "../" );
1229} 1234}
1230 1235
1231/*! 1236/*!
1232 Returns the user's current Document directory. There is a trailing "/". 1237 Returns the user's current Document directory. There is a trailing "/".
1233 .. well, it does now,, and there's no trailing '/' 1238 .. well, it does now,, and there's no trailing '/'
1234*/ 1239*/
1235QString QPEApplication::documentDir() 1240QString QPEApplication::documentDir()
1236{ 1241{
1237 const char* base = getenv( "HOME"); 1242 const char* base = getenv( "HOME");
1238 if ( base ) 1243 if ( base )
1239 return QString( base ) + "/Documents"; 1244 return QString( base ) + "/Documents";
1240 1245
1241 return QString( "../Documents" ); 1246 return QString( "../Documents" );
1242} 1247}
1243 1248
1244static int deforient = -1; 1249static int deforient = -1;
1245 1250
1246/*! 1251/*!
1247 \internal 1252 \internal
1248*/ 1253*/
1249int QPEApplication::defaultRotation() 1254int QPEApplication::defaultRotation()
1250{ 1255{
1251 if ( deforient < 0 ) { 1256 if ( deforient < 0 ) {
1252 QString d = getenv( "QWS_DISPLAY" ); 1257 QString d = getenv( "QWS_DISPLAY" );
1253 if ( d.contains( "Rot90" ) ) { 1258 if ( d.contains( "Rot90" ) ) {
1254 deforient = 90; 1259 deforient = 90;
1255 } 1260 }
1256 else if ( d.contains( "Rot180" ) ) { 1261 else if ( d.contains( "Rot180" ) ) {
1257 deforient = 180; 1262 deforient = 180;
1258 } 1263 }
1259 else if ( d.contains( "Rot270" ) ) { 1264 else if ( d.contains( "Rot270" ) ) {
1260 deforient = 270; 1265 deforient = 270;
1261 } 1266 }
1262 else { 1267 else {
1263 deforient = 0; 1268 deforient = 0;
1264 } 1269 }
1265 } 1270 }
1266 return deforient; 1271 return deforient;
1267} 1272}
1268 1273
1269/*! 1274/*!
1270 \internal 1275 \internal
1271*/ 1276*/
1272void QPEApplication::setDefaultRotation( int r ) 1277void QPEApplication::setDefaultRotation( int r )
1273{ 1278{
1274 if ( qApp->type() == GuiServer ) { 1279 if ( qApp->type() == GuiServer ) {
1275 deforient = r; 1280 deforient = r;
1276 setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); 1281 setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 );
1277 Config config("qpe"); 1282 Config config("qpe");
1278 config.setGroup( "Rotation" ); 1283 config.setGroup( "Rotation" );
1279 config.writeEntry( "Rot", r ); 1284 config.writeEntry( "Rot", r );
@@ -1974,212 +1979,214 @@ static void createDict()
1974 1979
1975 \sa setStylusOperation() StylusMode 1980 \sa setStylusOperation() StylusMode
1976*/ 1981*/
1977QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w ) 1982QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w )
1978{ 1983{
1979 if ( stylusDict ) 1984 if ( stylusDict )
1980 return ( StylusMode ) ( int ) stylusDict->find( w ); 1985 return ( StylusMode ) ( int ) stylusDict->find( w );
1981 return LeftOnly; 1986 return LeftOnly;
1982} 1987}
1983 1988
1984/*! 1989/*!
1985 \enum QPEApplication::StylusMode 1990 \enum QPEApplication::StylusMode
1986 1991
1987 \value LeftOnly the stylus only generates LeftButton 1992 \value LeftOnly the stylus only generates LeftButton
1988 events (the default). 1993 events (the default).
1989 \value RightOnHold the stylus generates RightButton events 1994 \value RightOnHold the stylus generates RightButton events
1990 if the user uses the press-and-hold gesture. 1995 if the user uses the press-and-hold gesture.
1991 1996
1992 \sa setStylusOperation() stylusOperation() 1997 \sa setStylusOperation() stylusOperation()
1993*/ 1998*/
1994 1999
1995/*! 2000/*!
1996 Causes widget \a w to receive mouse events according to the stylus 2001 Causes widget \a w to receive mouse events according to the stylus
1997 \a mode. 2002 \a mode.
1998 2003
1999 \sa stylusOperation() StylusMode 2004 \sa stylusOperation() StylusMode
2000*/ 2005*/
2001void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode ) 2006void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode )
2002{ 2007{
2003 createDict(); 2008 createDict();
2004 if ( mode == LeftOnly ) { 2009 if ( mode == LeftOnly ) {
2005 stylusDict->remove 2010 stylusDict->remove
2006 ( w ); 2011 ( w );
2007 w->removeEventFilter( qApp ); 2012 w->removeEventFilter( qApp );
2008 } 2013 }
2009 else { 2014 else {
2010 stylusDict->insert( w, ( void* ) mode ); 2015 stylusDict->insert( w, ( void* ) mode );
2011 connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) ); 2016 connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) );
2012 w->installEventFilter( qApp ); 2017 w->installEventFilter( qApp );
2013 } 2018 }
2014} 2019}
2015 2020
2016 2021
2017/*! 2022/*!
2018 \reimp 2023 \reimp
2019*/ 2024*/
2020bool QPEApplication::eventFilter( QObject *o, QEvent *e ) 2025bool QPEApplication::eventFilter( QObject *o, QEvent *e )
2021{ 2026{
2022 if ( !o->isWidgetType() ) 2027 if ( !o->isWidgetType() )
2023 return FALSE; 2028 return FALSE;
2024 2029
2025 if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { 2030 if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) {
2026 QMouseEvent * me = ( QMouseEvent* ) e; 2031 QMouseEvent * me = ( QMouseEvent* ) e;
2027 StylusMode mode = (StylusMode)(int)stylusDict->find(o); 2032 StylusMode mode = (StylusMode)(int)stylusDict->find(o);
2028 switch (mode) { 2033 switch (mode) {
2029 case RightOnHold: 2034 case RightOnHold:
2030 switch ( me->type() ) { 2035 switch ( me->type() ) {
2031 case QEvent::MouseButtonPress: 2036 case QEvent::MouseButtonPress:
2032 if ( me->button() == LeftButton ) { 2037 if ( me->button() == LeftButton ) {
2033 d->presswidget = (QWidget*)o; 2038 d->presswidget = (QWidget*)o;
2034 d->presspos = me->pos(); 2039 d->presspos = me->pos();
2035 d->rightpressed = FALSE; 2040 d->rightpressed = FALSE;
2036 // just for the time being 2041 // just for the time being
2037 static int pref = 500; 2042 static int pref = 500;
2038#ifdef WITHROHFEEDBACK 2043#ifdef OPIE_ROHFEEDBACK
2039 if( ! d->RoH ) 2044 if( ! d->RoH )
2040 d->RoH = new Opie::Internal::RoHFeedback; 2045 d->RoH = new Opie::Internal::RoHFeedback;
2041 2046
2042 d->RoH->init( me->globalPos(), d->presswidget ); 2047 d->RoH->init( me->globalPos(), d->presswidget );
2043 pref = d->RoH->delay(); 2048 pref = d->RoH->delay();
2044#endif 2049#endif
2045 if (!d->presstimer ) 2050 if (!d->presstimer )
2046 d->presstimer = startTimer( pref ); // #### pref. 2051 d->presstimer = startTimer( pref ); // #### pref.
2047 2052
2048 } 2053 }
2049 break; 2054 break;
2050 case QEvent::MouseMove: 2055 case QEvent::MouseMove:
2051 if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) { 2056 if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) {
2052 killTimer(d->presstimer); 2057 killTimer(d->presstimer);
2053#ifdef WITHROHFEEDBACK 2058#ifdef OPIE_ROHFEEDBACK
2054 if( d->RoH ) 2059 if( d->RoH )
2055 d->RoH->stop( ); 2060 d->RoH->stop( );
2056#endif 2061#endif
2057 d->presstimer = 0; 2062 d->presstimer = 0;
2058 } 2063 }
2059 break; 2064 break;
2060 case QEvent::MouseButtonRelease: 2065 case QEvent::MouseButtonRelease:
2061 if ( me->button() == LeftButton ) { 2066 if ( me->button() == LeftButton ) {
2062 if ( d->presstimer ) { 2067 if ( d->presstimer ) {
2063 killTimer(d->presstimer); 2068 killTimer(d->presstimer);
2064#ifdef WITHROHFEEDBACK 2069#ifdef OPIE_ROHFEEDBACK
2065 if( d->RoH ) 2070 if( d->RoH )
2066 d->RoH->stop( ); 2071 d->RoH->stop( );
2067#endif 2072#endif
2068 d->presstimer = 0; 2073 d->presstimer = 0;
2069 } 2074 }
2070 if ( d->rightpressed && d->presswidget ) { 2075 if ( d->rightpressed && d->presswidget ) {
2071 // Right released 2076 // Right released
2072 postEvent( d->presswidget, 2077 postEvent( d->presswidget,
2073 new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), 2078 new QMouseEvent( QEvent::MouseButtonRelease, me->pos(),
2074 RightButton, LeftButton + RightButton ) ); 2079 RightButton, LeftButton + RightButton ) );
2075 // Left released, off-widget 2080 // Left released, off-widget
2076 postEvent( d->presswidget, 2081 postEvent( d->presswidget,
2077 new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1), 2082 new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1),
2078 LeftButton, LeftButton ) ); 2083 LeftButton, LeftButton ) );
2079 postEvent( d->presswidget, 2084 postEvent( d->presswidget,
2080 new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1), 2085 new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1),
2081 LeftButton, LeftButton ) ); 2086 LeftButton, LeftButton ) );
2082 d->rightpressed = FALSE; 2087 d->rightpressed = FALSE;
2083 return TRUE; // don't send the real Left release 2088 return TRUE; // don't send the real Left release
2084 } 2089 }
2085 } 2090 }
2086 break; 2091 break;
2087 default: 2092 default:
2088 break; 2093 break;
2089 } 2094 }
2090 break; 2095 break;
2091 default: 2096 default:
2092 ; 2097 ;
2093 } 2098 }
2094 } 2099 }
2095 else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { 2100 else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) {
2096 QKeyEvent *ke = (QKeyEvent *)e; 2101 QKeyEvent *ke = (QKeyEvent *)e;
2097 if ( ke->key() == Key_Enter ) { 2102 if ( ke->key() == Key_Enter ) {
2098 if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { 2103 if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) {
2099 postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', 2104 postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ',
2100 ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); 2105 ke->state(), " ", ke->isAutoRepeat(), ke->count() ) );
2101 return TRUE; 2106 return TRUE;
2102 } 2107 }
2103 } 2108 }
2104 } 2109 }
2105 return FALSE; 2110 return FALSE;
2106} 2111}
2107 2112
2108/*! 2113/*!
2109 \reimp 2114 \reimp
2110*/ 2115*/
2111void QPEApplication::timerEvent( QTimerEvent *e ) 2116void QPEApplication::timerEvent( QTimerEvent *e )
2112{ 2117{
2113 if ( e->timerId() == d->presstimer && d->presswidget ) { 2118 if ( e->timerId() == d->presstimer && d->presswidget ) {
2114 // Right pressed 2119 // Right pressed
2115 postEvent( d->presswidget, 2120 postEvent( d->presswidget,
2116 new QMouseEvent( QEvent::MouseButtonPress, d->presspos, 2121 new QMouseEvent( QEvent::MouseButtonPress, d->presspos,
2117 RightButton, LeftButton ) ); 2122 RightButton, LeftButton ) );
2118 killTimer( d->presstimer ); 2123 killTimer( d->presstimer );
2119 d->presstimer = 0; 2124 d->presstimer = 0;
2120 d->rightpressed = TRUE; 2125 d->rightpressed = TRUE;
2126#ifdef OPIE_ROHFEEDBACK
2121 d->RoH->stop(); 2127 d->RoH->stop();
2128#endif
2122 } 2129 }
2123} 2130}
2124 2131
2125void QPEApplication::removeSenderFromStylusDict() 2132void QPEApplication::removeSenderFromStylusDict()
2126{ 2133{
2127 stylusDict->remove 2134 stylusDict->remove
2128 ( ( void* ) sender() ); 2135 ( ( void* ) sender() );
2129 if ( d->presswidget == sender() ) 2136 if ( d->presswidget == sender() )
2130 d->presswidget = 0; 2137 d->presswidget = 0;
2131} 2138}
2132 2139
2133/*! 2140/*!
2134 \internal 2141 \internal
2135*/ 2142*/
2136bool QPEApplication::keyboardGrabbed() const 2143bool QPEApplication::keyboardGrabbed() const
2137{ 2144{
2138 return d->kbgrabbed; 2145 return d->kbgrabbed;
2139} 2146}
2140 2147
2141 2148
2142/*! 2149/*!
2143 Reverses the effect of grabKeyboard(). This is called automatically 2150 Reverses the effect of grabKeyboard(). This is called automatically
2144 on program exit. 2151 on program exit.
2145*/ 2152*/
2146void QPEApplication::ungrabKeyboard() 2153void QPEApplication::ungrabKeyboard()
2147{ 2154{
2148 ((QPEApplication *) qApp )-> d-> kbgrabbed = false; 2155 ((QPEApplication *) qApp )-> d-> kbgrabbed = false;
2149} 2156}
2150 2157
2151/*! 2158/*!
2152 Grabs the physical keyboard keys, e.g. the application's launching 2159 Grabs the physical keyboard keys, e.g. the application's launching
2153 keys. Instead of launching applications when these keys are pressed 2160 keys. Instead of launching applications when these keys are pressed
2154 the signals emitted are sent to this application instead. Some games 2161 the signals emitted are sent to this application instead. Some games
2155 programs take over the launch keys in this way to make interaction 2162 programs take over the launch keys in this way to make interaction
2156 easier. 2163 easier.
2157 2164
2158 \sa ungrabKeyboard() 2165 \sa ungrabKeyboard()
2159*/ 2166*/
2160void QPEApplication::grabKeyboard() 2167void QPEApplication::grabKeyboard()
2161{ 2168{
2162 ((QPEApplication *) qApp )-> d-> kbgrabbed = true; 2169 ((QPEApplication *) qApp )-> d-> kbgrabbed = true;
2163} 2170}
2164 2171
2165/*! 2172/*!
2166 \reimp 2173 \reimp
2167*/ 2174*/
2168int QPEApplication::exec() 2175int QPEApplication::exec()
2169{ 2176{
2170 d->qcopQok = true; 2177 d->qcopQok = true;
2171#ifndef QT_NO_COP 2178#ifndef QT_NO_COP
2172 d->sendQCopQ(); 2179 d->sendQCopQ();
2173 if ( !d->keep_running ) 2180 if ( !d->keep_running )
2174 processEvents(); // we may have received QCop messages in the meantime. 2181 processEvents(); // we may have received QCop messages in the meantime.
2175#endif 2182#endif
2176 2183
2177 if ( d->keep_running ) 2184 if ( d->keep_running )
2178 //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) 2185 //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() )
2179 return QApplication::exec(); 2186 return QApplication::exec();
2180 2187
2181#ifndef QT_NO_COP 2188#ifndef QT_NO_COP
2182 2189
2183 { 2190 {
2184 QCopEnvelope e( "QPE/System", "closing(QString)" ); 2191 QCopEnvelope e( "QPE/System", "closing(QString)" );
2185 e << d->appName; 2192 e << d->appName;