summaryrefslogtreecommitdiff
authorzecke <zecke>2004-08-24 13:38:23 (UTC)
committer zecke <zecke>2004-08-24 13:38:23 (UTC)
commit0a141c4a9719aa273867ad45c4293208545489b1 (patch) (unidiff)
tree4059ae180d00d33cc31dd9083d38a14b946253a2
parent102bb2b65c71da12c4f9f1ce7a5d1b37b6eb50ee (diff)
downloadopie-0a141c4a9719aa273867ad45c4293208545489b1.zip
opie-0a141c4a9719aa273867ad45c4293208545489b1.tar.gz
opie-0a141c4a9719aa273867ad45c4293208545489b1.tar.bz2
Add RightOn Hold Visual Feedback and integrate it
into QPEApplication Icons and Config Option will be comitted by WIMPIE
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--library/backend/rohfeedback.cpp125
-rw-r--r--library/backend/rohfeedback.h62
-rw-r--r--library/qpeapplication.cpp32
3 files changed, 216 insertions, 3 deletions
diff --git a/library/backend/rohfeedback.cpp b/library/backend/rohfeedback.cpp
new file mode 100644
index 0000000..ff76a36
--- a/dev/null
+++ b/library/backend/rohfeedback.cpp
@@ -0,0 +1,125 @@
1#include <rohfeedback.h>
2
3
4#include <stdio.h>
5#include <qpeapplication.h>
6#include <qevent.h>
7#include <resource.h>
8#include <qpixmap.h>
9#include <qbitmap.h>
10
11#define SPEED 600
12#define DELAY 500
13
14namespace Opie {
15namespace Internal {
16/*
17
18 RightOnHold feedback
19
20*/
21
22QPixmap * RoHFeedback::Imgs[NOOFICONS] = { 0, 0, 0, 0, 0 };
23QBitmap * RoHFeedback::Masks[NOOFICONS];
24int RoHFeedback::IconWidth;
25int RoHFeedback::IconHeight;
26
27RoHFeedback::RoHFeedback() :
28 QLabel( 0, 0, Qt::WType_Popup ), Timer() {
29
30 Receiver = 0l;
31 connect( &Timer, SIGNAL( timeout() ), this, SLOT( iconShow() ) );
32
33 if( Imgs[0] == 0 ) {
34 QString S;
35
36
37 for( int i = 0; i < NOOFICONS ; i ++ ) {
38 Imgs[i] = new QPixmap( Resource::loadPixmap("RoH/star/"+
39 QString::number(i+1) +
40 ".png" ));
41 Masks[i] = new QBitmap();
42 (*Masks[i]) = Resource::loadPixmap("RoH/star/"+QString::number(i+1) +
43 ".png" );
44 }
45 }
46
47 IconWidth = Imgs[0]->size().width();
48 IconHeight = Imgs[0]->size().height();
49
50 resize( IconWidth, IconHeight );
51}
52
53int RoHFeedback::delay( void ) {
54 return DELAY+SPEED+50;
55}
56
57RoHFeedback::~RoHFeedback() {
58 for ( int i = 0; i < NOOFICONS; ++i ) {
59 delete Imgs [i];
60 delete Masks[i];
61 }
62}
63
64void RoHFeedback::init( const QPoint & P, QWidget* wid ) {
65 if( ! IconWidth )
66 return;
67
68 Receiver = wid;
69 IconNr = -1;
70 move( P.x()-IconWidth/2, P.y() - IconHeight/2 );
71 // to initialize
72 Timer.start( DELAY - SPEED/NOOFICONS );
73}
74
75void RoHFeedback::stop( void ) {
76 IconNr = -2; // stop
77 hide();
78 Timer.stop();
79}
80
81bool RoHFeedback::event( QEvent * E ) {
82
83 if( E->type() >= QEvent::MouseButtonPress &&
84 E->type() <= QEvent::MouseMove ) {
85 // pass the event to the receiver with translated coord
86 QMouseEvent QME( ((QMouseEvent *)E)->type(),
87 Receiver->mapFromGlobal(
88 ((QMouseEvent *)E)->globalPos() ),
89 ((QMouseEvent *)E)->globalPos(),
90 ((QMouseEvent *)E)->button(),
91 ((QMouseEvent *)E)->state()
92 );
93 return QPEApplication::sendEvent( Receiver, &QME );
94 }
95
96 // first let the label treat the event
97 return QLabel::event( E );
98}
99
100void RoHFeedback::iconShow( void ) {
101 switch( IconNr ) {
102 case FeedbackTimerStart:
103 IconNr = 0;
104 Timer.start( SPEED/NOOFICONS );
105 break;
106 case FeedbackStopped:
107 // stopped
108 IconNr = FeedbackTimerStart;
109 hide();
110 break;
111 case FeedbackShow: // first
112 show();
113 // FT
114 default :
115 // show
116
117 setPixmap( *(Imgs[IconNr]) );
118 setMask( *(Masks[IconNr]) );
119 IconNr = (IconNr+1)%NOOFICONS; // rotate
120 break;
121 }
122}
123
124}
125} \ No newline at end of file
diff --git a/library/backend/rohfeedback.h b/library/backend/rohfeedback.h
new file mode 100644
index 0000000..f38a095
--- a/dev/null
+++ b/library/backend/rohfeedback.h
@@ -0,0 +1,62 @@
1#ifndef ROHFEEDBACK_H
2#define ROHFEEDBACK_H
3
4/*
5
6 RightOnHold feedback show
7
8*/
9
10#define NOOFICONS 5
11
12#include <qlabel.h>
13#include <qtimer.h>
14
15class QEvent;
16class QPixmap;
17class QBitmap;
18class QMouseEvent;
19
20namespace Opie {
21namespace Internal {
22
23class RoHFeedback : public QLabel {
24
25 Q_OBJECT
26
27 enum Actions {
28 FeedbackStopped = -2,
29 FeedbackTimerStart = -1,
30 FeedbackShow = 0
31 };
32public :
33
34 RoHFeedback();
35 ~RoHFeedback();
36
37
38 void init( const QPoint & P, QWidget* wid );
39 void stop( void );
40 int delay( void );
41
42public slots :
43
44 void iconShow( void );
45
46protected :
47
48 bool event( QEvent * E );
49
50 QTimer Timer;
51 int IconNr;
52 QWidget * Receiver;
53
54 static int IconWidth;
55 static int IconHeight;
56 static QPixmap * Imgs[NOOFICONS];
57 static QBitmap * Masks[NOOFICONS];
58};
59}
60}
61
62#endif
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index 59ca61b..acad81d 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -36,157 +36,162 @@
36#include "qcopenvelope_qws.h" 36#include "qcopenvelope_qws.h"
37#endif 37#endif
38#endif 38#endif
39#include <qwindowsystem_qws.h> 39#include <qwindowsystem_qws.h>
40#endif 40#endif
41#include <qtextstream.h> 41#include <qtextstream.h>
42#include <qpalette.h> 42#include <qpalette.h>
43#include <qbuffer.h> 43#include <qbuffer.h>
44#include <qptrdict.h> 44#include <qptrdict.h>
45#include <qregexp.h> 45#include <qregexp.h>
46#include <qdir.h> 46#include <qdir.h>
47#include <qlabel.h> 47#include <qlabel.h>
48#include <qdialog.h> 48#include <qdialog.h>
49#include <qdragobject.h> 49#include <qdragobject.h>
50#include <qtextcodec.h> 50#include <qtextcodec.h>
51#include <qevent.h> 51#include <qevent.h>
52#include <qtooltip.h> 52#include <qtooltip.h>
53#include <qsignal.h> 53#include <qsignal.h>
54#include <qmainwindow.h> 54#include <qmainwindow.h>
55#include <qwidgetlist.h> 55#include <qwidgetlist.h>
56#include <qpixmapcache.h> 56#include <qpixmapcache.h>
57 57
58#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 58#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
59#define QTOPIA_INTERNAL_INITAPP 59#define QTOPIA_INTERNAL_INITAPP
60#include "qpeapplication.h" 60#include "qpeapplication.h"
61#include "qpestyle.h" 61#include "qpestyle.h"
62#include "styleinterface.h" 62#include "styleinterface.h"
63#if QT_VERSION >= 300 63#if QT_VERSION >= 300
64#include <qstylefactory.h> 64#include <qstylefactory.h>
65#else 65#else
66#include <qplatinumstyle.h> 66#include <qplatinumstyle.h>
67#include <qwindowsstyle.h> 67#include <qwindowsstyle.h>
68#include <qmotifstyle.h> 68#include <qmotifstyle.h>
69#include <qmotifplusstyle.h> 69#include <qmotifplusstyle.h>
70#include "lightstyle.h" 70#include "lightstyle.h"
71 71
72#include <qpe/qlibrary.h> 72#include <qpe/qlibrary.h>
73#endif 73#endif
74#include "global.h" 74#include "global.h"
75#include "resource.h" 75#include "resource.h"
76#if QT_VERSION <= 230 && defined(QT_NO_CODECS) 76#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
77#include "qutfcodec.h" 77#include "qutfcodec.h"
78#endif 78#endif
79#include "config.h" 79#include "config.h"
80#include "network.h" 80#include "network.h"
81#ifdef QWS 81#ifdef QWS
82#include "fontmanager.h" 82#include "fontmanager.h"
83#include "fontdatabase.h" 83#include "fontdatabase.h"
84#endif 84#endif
85 85
86#include "alarmserver.h" 86#include "alarmserver.h"
87#include "applnk.h" 87#include "applnk.h"
88#include "qpemenubar.h" 88#include "qpemenubar.h"
89#include "textcodecinterface.h" 89#include "textcodecinterface.h"
90#include "imagecodecinterface.h" 90#include "imagecodecinterface.h"
91 91
92#include <unistd.h> 92#include <unistd.h>
93#include <sys/file.h> 93#include <sys/file.h>
94#include <sys/ioctl.h> 94#include <sys/ioctl.h>
95#ifndef QT_NO_SOUND 95#ifndef QT_NO_SOUND
96#include <sys/soundcard.h> 96#include <sys/soundcard.h>
97#endif 97#endif
98#include "qt_override_p.h" 98#include "qt_override_p.h"
99 99
100#include <qpe/rohfeedback.h>
101
102
100static bool useBigPixmaps = 0; 103static bool useBigPixmaps = 0;
101 104
105
102class HackWidget : public QWidget 106class HackWidget : public QWidget
103{ 107{
104public: 108public:
105 bool needsOk() 109 bool needsOk()
106 { return (getWState() & WState_Reserved1 ); } 110 { return (getWState() & WState_Reserved1 ); }
107 111
108 QRect normalGeometry() 112 QRect normalGeometry()
109 { return topData()->normalGeometry; }; 113 { return topData()->normalGeometry; };
110}; 114};
111 115
112class QPEApplicationData 116class QPEApplicationData
113{ 117{
114public: 118public:
115 QPEApplicationData ( ) 119 QPEApplicationData ( )
116 : presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ), 120 : presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ),
117 notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ), 121 notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ),
118 keep_running( true ), qcopQok( false ), 122 keep_running( true ), qcopQok( false ),
119 fontFamily( "Vera" ), fontSize( 10 ), smallIconSize( 14 ), 123 fontFamily( "Vera" ), fontSize( 10 ), smallIconSize( 14 ),
120 bigIconSize( 32 ), qpe_main_widget( 0 ) 124 bigIconSize( 32 ), qpe_main_widget( 0 )
121 { 125 {
122 Config cfg( "qpe" ); 126 Config cfg( "qpe" );
123 cfg.setGroup( "Appearance" ); 127 cfg.setGroup( "Appearance" );
124 useBigPixmaps = cfg.readBoolEntry( "useBigPixmaps", false ); 128 useBigPixmaps = cfg.readBoolEntry( "useBigPixmaps", false );
125 fontFamily = cfg.readEntry( "FontFamily", "Vera" ); 129 fontFamily = cfg.readEntry( "FontFamily", "Vera" );
126 fontSize = cfg.readNumEntry( "FontSize", 10 ); 130 fontSize = cfg.readNumEntry( "FontSize", 10 );
127 smallIconSize = cfg.readNumEntry( "SmallIconSize", 14 ); 131 smallIconSize = cfg.readNumEntry( "SmallIconSize", 14 );
128 bigIconSize = cfg.readNumEntry( "BigIconSize", 32 ); 132 bigIconSize = cfg.readNumEntry( "BigIconSize", 32 );
133 RoH = 0;
129 } 134 }
130 135
131 int presstimer; 136 int presstimer;
132 QWidget* presswidget; 137 QWidget* presswidget;
133 QPoint presspos; 138 QPoint presspos;
134 139
135 bool rightpressed : 1; 140 bool rightpressed : 1;
136 bool kbgrabbed : 1; 141 bool kbgrabbed : 1;
137 bool notbusysent : 1; 142 bool notbusysent : 1;
138 bool preloaded : 1; 143 bool preloaded : 1;
139 bool forceshow : 1; 144 bool forceshow : 1;
140 bool nomaximize : 1; 145 bool nomaximize : 1;
141 bool keep_running : 1; 146 bool keep_running : 1;
142 bool qcopQok : 1; 147 bool qcopQok : 1;
143 148
144 QCString fontFamily; 149 QCString fontFamily;
145 int fontSize; 150 int fontSize;
146 int smallIconSize; 151 int smallIconSize;
147 int bigIconSize; 152 int bigIconSize;
148 153
149 QStringList langs; 154 QStringList langs;
150 QString appName; 155 QString appName;
151 struct QCopRec 156 struct QCopRec
152 { 157 {
153 QCopRec( const QCString &ch, const QCString &msg, 158 QCopRec( const QCString &ch, const QCString &msg,
154 const QByteArray &d ) : 159 const QByteArray &d ) :
155 channel( ch ), message( msg ), data( d ) 160 channel( ch ), message( msg ), data( d )
156 { } 161 { }
157 162
158 QCString channel; 163 QCString channel;
159 QCString message; 164 QCString message;
160 QByteArray data; 165 QByteArray data;
161 }; 166 };
162 QWidget* qpe_main_widget; 167 QWidget* qpe_main_widget;
163 QGuardedPtr<QWidget> lastraised; 168 QGuardedPtr<QWidget> lastraised;
164 QQueue<QCopRec> qcopq; 169 QQueue<QCopRec> qcopq;
165 QString styleName; 170 QString styleName;
166 QString decorationName; 171 QString decorationName;
167 172
168 void enqueueQCop( const QCString &ch, const QCString &msg, 173 void enqueueQCop( const QCString &ch, const QCString &msg,
169 const QByteArray &data ) 174 const QByteArray &data )
170 { 175 {
171 qcopq.enqueue( new QCopRec( ch, msg, data ) ); 176 qcopq.enqueue( new QCopRec( ch, msg, data ) );
172 } 177 }
173 void sendQCopQ() 178 void sendQCopQ()
174 { 179 {
175 if (!qcopQok ) 180 if (!qcopQok )
176 return; 181 return;
177 182
178 QCopRec * r; 183 QCopRec * r;
179 184
180 while((r=qcopq.dequeue())) { 185 while((r=qcopq.dequeue())) {
181 // remove from queue before sending... 186 // remove from queue before sending...
182 // event loop can come around again before getting 187 // event loop can come around again before getting
183 // back from sendLocally 188 // back from sendLocally
184#ifndef QT_NO_COP 189#ifndef QT_NO_COP
185 QCopChannel::sendLocally( r->channel, r->message, r->data ); 190 QCopChannel::sendLocally( r->channel, r->message, r->data );
186#endif 191#endif
187 192
188 delete r; 193 delete r;
189 } 194 }
190 } 195 }
191 196
192 static void show_mx(QWidget* mw, bool nomaximize, QString &strName) 197 static void show_mx(QWidget* mw, bool nomaximize, QString &strName)
@@ -431,128 +436,130 @@ static void qpe_show_dialog( QDialog* d, bool nomax )
431 show_mx(mw, nomax, appName); 436 show_mx(mw, nomax, appName);
432 } 437 }
433 else if ( keep_running ) { 438 else if ( keep_running ) {
434 show_mx(mw, nomax, appName); 439 show_mx(mw, nomax, appName);
435 } 440 }
436 } 441 }
437 442
438 void loadTextCodecs() 443 void loadTextCodecs()
439 { 444 {
440 QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; 445 QString path = QPEApplication::qpeDir() + "/plugins/textcodecs";
441#ifdef Q_OS_MACX 446#ifdef Q_OS_MACX
442 QDir dir( path, "lib*.dylib" ); 447 QDir dir( path, "lib*.dylib" );
443#else 448#else
444 QDir dir( path, "lib*.so" ); 449 QDir dir( path, "lib*.so" );
445#endif 450#endif
446 QStringList list; 451 QStringList list;
447 if ( dir. exists ( )) 452 if ( dir. exists ( ))
448 list = dir.entryList(); 453 list = dir.entryList();
449 QStringList::Iterator it; 454 QStringList::Iterator it;
450 for ( it = list.begin(); it != list.end(); ++it ) { 455 for ( it = list.begin(); it != list.end(); ++it ) {
451 TextCodecInterface *iface = 0; 456 TextCodecInterface *iface = 0;
452 QLibrary *lib = new QLibrary( path + "/" + *it ); 457 QLibrary *lib = new QLibrary( path + "/" + *it );
453 if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { 458 if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) {
454 QValueList<int> mibs = iface->mibEnums(); 459 QValueList<int> mibs = iface->mibEnums();
455 for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { 460 for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) {
456 (void)iface->createForMib(*i); 461 (void)iface->createForMib(*i);
457 // ### it exists now; need to remember if we can delete it 462 // ### it exists now; need to remember if we can delete it
458 } 463 }
459 } 464 }
460 else { 465 else {
461 lib->unload(); 466 lib->unload();
462 delete lib; 467 delete lib;
463 } 468 }
464 } 469 }
465 } 470 }
466 471
467 void loadImageCodecs() 472 void loadImageCodecs()
468 { 473 {
469 QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; 474 QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs";
470#ifdef Q_OS_MACX 475#ifdef Q_OS_MACX
471 QDir dir( path, "lib*.dylib" ); 476 QDir dir( path, "lib*.dylib" );
472#else 477#else
473 QDir dir( path, "lib*.so" ); 478 QDir dir( path, "lib*.so" );
474#endif 479#endif
475 QStringList list; 480 QStringList list;
476 if ( dir. exists ( )) 481 if ( dir. exists ( ))
477 list = dir.entryList(); 482 list = dir.entryList();
478 QStringList::Iterator it; 483 QStringList::Iterator it;
479 for ( it = list.begin(); it != list.end(); ++it ) { 484 for ( it = list.begin(); it != list.end(); ++it ) {
480 ImageCodecInterface *iface = 0; 485 ImageCodecInterface *iface = 0;
481 QLibrary *lib = new QLibrary( path + "/" + *it ); 486 QLibrary *lib = new QLibrary( path + "/" + *it );
482 if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { 487 if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) {
483 QStringList formats = iface->keys(); 488 QStringList formats = iface->keys();
484 for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { 489 for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) {
485 (void)iface->installIOHandler(*i); 490 (void)iface->installIOHandler(*i);
486 // ### it exists now; need to remember if we can delete it 491 // ### it exists now; need to remember if we can delete it
487 } 492 }
488 } 493 }
489 else { 494 else {
490 lib->unload(); 495 lib->unload();
491 delete lib; 496 delete lib;
492 } 497 }
493 } 498 }
494 } 499 }
500
501 Opie::Internal::RoHFeedback * RoH;
495}; 502};
496 503
497class ResourceMimeFactory : public QMimeSourceFactory 504class ResourceMimeFactory : public QMimeSourceFactory
498{ 505{
499public: 506public:
500 ResourceMimeFactory() : resImage( 0 ) 507 ResourceMimeFactory() : resImage( 0 )
501 { 508 {
502 setFilePath( Global::helpPath() ); 509 setFilePath( Global::helpPath() );
503 setExtensionType( "html", "text/html;charset=UTF-8" ); 510 setExtensionType( "html", "text/html;charset=UTF-8" );
504 } 511 }
505 ~ResourceMimeFactory() { 512 ~ResourceMimeFactory() {
506 delete resImage; 513 delete resImage;
507 } 514 }
508 515
509 const QMimeSource* data( const QString& abs_name ) const 516 const QMimeSource* data( const QString& abs_name ) const
510 { 517 {
511 const QMimeSource * r = QMimeSourceFactory::data( abs_name ); 518 const QMimeSource * r = QMimeSourceFactory::data( abs_name );
512 if ( !r ) { 519 if ( !r ) {
513 int sl = abs_name.length(); 520 int sl = abs_name.length();
514 do { 521 do {
515 sl = abs_name.findRev( '/', sl - 1 ); 522 sl = abs_name.findRev( '/', sl - 1 );
516 QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; 523 QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name;
517 int dot = name.findRev( '.' ); 524 int dot = name.findRev( '.' );
518 if ( dot >= 0 ) 525 if ( dot >= 0 )
519 name = name.left( dot ); 526 name = name.left( dot );
520 QImage img = Resource::loadImage( name ); 527 QImage img = Resource::loadImage( name );
521 if ( !img.isNull() ) { 528 if ( !img.isNull() ) {
522 delete resImage; 529 delete resImage;
523 resImage = new QImageDrag( img ); 530 resImage = new QImageDrag( img );
524 r = resImage; 531 r = resImage;
525 } 532 }
526 } 533 }
527 while ( !r && sl > 0 ); 534 while ( !r && sl > 0 );
528 } 535 }
529 return r; 536 return r;
530 } 537 }
531private: 538private:
532 mutable QImageDrag *resImage; 539 mutable QImageDrag *resImage;
533}; 540};
534 541
535static int& hack(int& i) 542static int& hack(int& i)
536{ 543{
537#if QT_VERSION <= 230 && defined(QT_NO_CODECS) 544#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
538 // These should be created, but aren't in Qt 2.3.0 545 // These should be created, but aren't in Qt 2.3.0
539 (void)new QUtf8Codec; 546 (void)new QUtf8Codec;
540 (void)new QUtf16Codec; 547 (void)new QUtf16Codec;
541#endif 548#endif
542 return i; 549 return i;
543} 550}
544 551
545static int muted = 0; 552static int muted = 0;
546static int micMuted = 0; 553static int micMuted = 0;
547 554
548static void setVolume( int t = 0, int percent = -1 ) 555static void setVolume( int t = 0, int percent = -1 )
549{ 556{
550 switch ( t ) { 557 switch ( t ) {
551 case 0: { 558 case 0: {
552 Config cfg( "qpe" ); 559 Config cfg( "qpe" );
553 cfg.setGroup( "Volume" ); 560 cfg.setGroup( "Volume" );
554 if ( percent < 0 ) 561 if ( percent < 0 )
555 percent = cfg.readNumEntry( "VolumePercent", 50 ); 562 percent = cfg.readNumEntry( "VolumePercent", 50 );
556#ifndef QT_NO_SOUND 563#ifndef QT_NO_SOUND
557 int fd = 0; 564 int fd = 0;
558 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 565 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
@@ -1144,129 +1151,129 @@ bool QPEApplication::qwsEventFilter( QWSEvent * e )
1144 ke-> simpleData.modifiers, 1151 ke-> simpleData.modifiers,
1145 QString ( ch ), 1152 QString ( ch ),
1146 ke-> simpleData.is_auto_repeat, 1 ); 1153 ke-> simpleData.is_auto_repeat, 1 );
1147 1154
1148 QObject *which = QWidget::keyboardGrabber ( ); 1155 QObject *which = QWidget::keyboardGrabber ( );
1149 if ( !which ) 1156 if ( !which )
1150 which = QApplication::focusWidget ( ); 1157 which = QApplication::focusWidget ( );
1151 if ( !which ) 1158 if ( !which )
1152 which = QApplication::activeWindow ( ); 1159 which = QApplication::activeWindow ( );
1153 if ( !which ) 1160 if ( !which )
1154 which = qApp; 1161 which = qApp;
1155 1162
1156 QApplication::sendEvent ( which, &qke ); 1163 QApplication::sendEvent ( which, &qke );
1157 } 1164 }
1158 else { // we didn't grab the keyboard, so send the event to the launcher 1165 else { // we didn't grab the keyboard, so send the event to the launcher
1159 QCopEnvelope e ( "QPE/Launcher", "deviceButton(int,int,int)" ); 1166 QCopEnvelope e ( "QPE/Launcher", "deviceButton(int,int,int)" );
1160 e << int( ke-> simpleData.keycode ) << int( ke-> simpleData. is_press ) << int( ke-> simpleData.is_auto_repeat ); 1167 e << int( ke-> simpleData.keycode ) << int( ke-> simpleData. is_press ) << int( ke-> simpleData.is_auto_repeat );
1161 } 1168 }
1162 } 1169 }
1163 return true; 1170 return true;
1164 } 1171 }
1165 } 1172 }
1166 if ( e->type == QWSEvent::Focus ) { 1173 if ( e->type == QWSEvent::Focus ) {
1167 QWSFocusEvent * fe = ( QWSFocusEvent* ) e; 1174 QWSFocusEvent * fe = ( QWSFocusEvent* ) e;
1168 if ( !fe->simpleData.get_focus ) { 1175 if ( !fe->simpleData.get_focus ) {
1169 QWidget * active = activeWindow(); 1176 QWidget * active = activeWindow();
1170 while ( active && active->isPopup() ) { 1177 while ( active && active->isPopup() ) {
1171 active->close(); 1178 active->close();
1172 active = activeWindow(); 1179 active = activeWindow();
1173 } 1180 }
1174 } 1181 }
1175 else { 1182 else {
1176 // make sure our modal widget is ALWAYS on top 1183 // make sure our modal widget is ALWAYS on top
1177 QWidget *topm = activeModalWidget(); 1184 QWidget *topm = activeModalWidget();
1178 if ( topm && static_cast<int>( topm->winId() ) != fe->simpleData.window) { 1185 if ( topm && static_cast<int>( topm->winId() ) != fe->simpleData.window) {
1179 topm->raise(); 1186 topm->raise();
1180 } 1187 }
1181 } 1188 }
1182 if ( fe->simpleData.get_focus && inputMethodDict ) { 1189 if ( fe->simpleData.get_focus && inputMethodDict ) {
1183 InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) ); 1190 InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) );
1184 if ( m == AlwaysOff ) 1191 if ( m == AlwaysOff )
1185 Global::hideInputMethod(); 1192 Global::hideInputMethod();
1186 if ( m == AlwaysOn ) 1193 if ( m == AlwaysOn )
1187 Global::showInputMethod(); 1194 Global::showInputMethod();
1188 } 1195 }
1189 } 1196 }
1190 1197
1191 1198
1192 return QApplication::qwsEventFilter( e ); 1199 return QApplication::qwsEventFilter( e );
1193} 1200}
1194#endif 1201#endif
1195 1202
1196/*! 1203/*!
1197 Destroys the QPEApplication. 1204 Destroys the QPEApplication.
1198*/ 1205*/
1199QPEApplication::~QPEApplication() 1206QPEApplication::~QPEApplication()
1200{ 1207{
1201 ungrabKeyboard(); 1208 ungrabKeyboard();
1202#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 1209#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
1203 // Need to delete QCopChannels early, since the display will 1210 // Need to delete QCopChannels early, since the display will
1204 // be gone by the time we get to ~QObject(). 1211 // be gone by the time we get to ~QObject().
1205 delete sysChannel; 1212 delete sysChannel;
1206 delete pidChannel; 1213 delete pidChannel;
1207#endif 1214#endif
1208 1215 delete d->RoH;
1209 delete d; 1216 delete d;
1210} 1217}
1211 1218
1212/*! 1219/*!
1213 Returns <tt>$OPIEDIR/</tt>. 1220 Returns <tt>$OPIEDIR/</tt>.
1214*/ 1221*/
1215QString QPEApplication::qpeDir() 1222QString QPEApplication::qpeDir()
1216{ 1223{
1217 const char * base = getenv( "OPIEDIR" ); 1224 const char * base = getenv( "OPIEDIR" );
1218 if ( base ) 1225 if ( base )
1219 return QString( base ) + "/"; 1226 return QString( base ) + "/";
1220 1227
1221 return QString( "../" ); 1228 return QString( "../" );
1222} 1229}
1223 1230
1224/*! 1231/*!
1225 Returns the user's current Document directory. There is a trailing "/". 1232 Returns the user's current Document directory. There is a trailing "/".
1226 .. well, it does now,, and there's no trailing '/' 1233 .. well, it does now,, and there's no trailing '/'
1227*/ 1234*/
1228QString QPEApplication::documentDir() 1235QString QPEApplication::documentDir()
1229{ 1236{
1230 const char* base = getenv( "HOME"); 1237 const char* base = getenv( "HOME");
1231 if ( base ) 1238 if ( base )
1232 return QString( base ) + "/Documents"; 1239 return QString( base ) + "/Documents";
1233 1240
1234 return QString( "../Documents" ); 1241 return QString( "../Documents" );
1235} 1242}
1236 1243
1237static int deforient = -1; 1244static int deforient = -1;
1238 1245
1239/*! 1246/*!
1240 \internal 1247 \internal
1241*/ 1248*/
1242int QPEApplication::defaultRotation() 1249int QPEApplication::defaultRotation()
1243{ 1250{
1244 if ( deforient < 0 ) { 1251 if ( deforient < 0 ) {
1245 QString d = getenv( "QWS_DISPLAY" ); 1252 QString d = getenv( "QWS_DISPLAY" );
1246 if ( d.contains( "Rot90" ) ) { 1253 if ( d.contains( "Rot90" ) ) {
1247 deforient = 90; 1254 deforient = 90;
1248 } 1255 }
1249 else if ( d.contains( "Rot180" ) ) { 1256 else if ( d.contains( "Rot180" ) ) {
1250 deforient = 180; 1257 deforient = 180;
1251 } 1258 }
1252 else if ( d.contains( "Rot270" ) ) { 1259 else if ( d.contains( "Rot270" ) ) {
1253 deforient = 270; 1260 deforient = 270;
1254 } 1261 }
1255 else { 1262 else {
1256 deforient = 0; 1263 deforient = 0;
1257 } 1264 }
1258 } 1265 }
1259 return deforient; 1266 return deforient;
1260} 1267}
1261 1268
1262/*! 1269/*!
1263 \internal 1270 \internal
1264*/ 1271*/
1265void QPEApplication::setDefaultRotation( int r ) 1272void QPEApplication::setDefaultRotation( int r )
1266{ 1273{
1267 if ( qApp->type() == GuiServer ) { 1274 if ( qApp->type() == GuiServer ) {
1268 deforient = r; 1275 deforient = r;
1269 setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); 1276 setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 );
1270 Config config("qpe"); 1277 Config config("qpe");
1271 config.setGroup( "Rotation" ); 1278 config.setGroup( "Rotation" );
1272 config.writeEntry( "Rot", r ); 1279 config.writeEntry( "Rot", r );
@@ -1962,198 +1969,217 @@ static void createDict()
1962 stylusDict = new QPtrDict<void>; 1969 stylusDict = new QPtrDict<void>;
1963} 1970}
1964 1971
1965/*! 1972/*!
1966 Returns the current StylusMode for widget \a w. 1973 Returns the current StylusMode for widget \a w.
1967 1974
1968 \sa setStylusOperation() StylusMode 1975 \sa setStylusOperation() StylusMode
1969*/ 1976*/
1970QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w ) 1977QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w )
1971{ 1978{
1972 if ( stylusDict ) 1979 if ( stylusDict )
1973 return ( StylusMode ) ( int ) stylusDict->find( w ); 1980 return ( StylusMode ) ( int ) stylusDict->find( w );
1974 return LeftOnly; 1981 return LeftOnly;
1975} 1982}
1976 1983
1977/*! 1984/*!
1978 \enum QPEApplication::StylusMode 1985 \enum QPEApplication::StylusMode
1979 1986
1980 \value LeftOnly the stylus only generates LeftButton 1987 \value LeftOnly the stylus only generates LeftButton
1981 events (the default). 1988 events (the default).
1982 \value RightOnHold the stylus generates RightButton events 1989 \value RightOnHold the stylus generates RightButton events
1983 if the user uses the press-and-hold gesture. 1990 if the user uses the press-and-hold gesture.
1984 1991
1985 \sa setStylusOperation() stylusOperation() 1992 \sa setStylusOperation() stylusOperation()
1986*/ 1993*/
1987 1994
1988/*! 1995/*!
1989 Causes widget \a w to receive mouse events according to the stylus 1996 Causes widget \a w to receive mouse events according to the stylus
1990 \a mode. 1997 \a mode.
1991 1998
1992 \sa stylusOperation() StylusMode 1999 \sa stylusOperation() StylusMode
1993*/ 2000*/
1994void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode ) 2001void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode )
1995{ 2002{
1996 createDict(); 2003 createDict();
1997 if ( mode == LeftOnly ) { 2004 if ( mode == LeftOnly ) {
1998 stylusDict->remove 2005 stylusDict->remove
1999 ( w ); 2006 ( w );
2000 w->removeEventFilter( qApp ); 2007 w->removeEventFilter( qApp );
2001 } 2008 }
2002 else { 2009 else {
2003 stylusDict->insert( w, ( void* ) mode ); 2010 stylusDict->insert( w, ( void* ) mode );
2004 connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) ); 2011 connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) );
2005 w->installEventFilter( qApp ); 2012 w->installEventFilter( qApp );
2006 } 2013 }
2007} 2014}
2008 2015
2009 2016
2010/*! 2017/*!
2011 \reimp 2018 \reimp
2012*/ 2019*/
2013bool QPEApplication::eventFilter( QObject *o, QEvent *e ) 2020bool QPEApplication::eventFilter( QObject *o, QEvent *e )
2014{ 2021{
2015 if ( !o->isWidgetType() ) 2022 if ( !o->isWidgetType() )
2016 return FALSE; 2023 return FALSE;
2017 2024
2018 if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { 2025 if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) {
2019 QMouseEvent * me = ( QMouseEvent* ) e; 2026 QMouseEvent * me = ( QMouseEvent* ) e;
2020 StylusMode mode = (StylusMode)(int)stylusDict->find(o); 2027 StylusMode mode = (StylusMode)(int)stylusDict->find(o);
2021 switch (mode) { 2028 switch (mode) {
2022 case RightOnHold: 2029 case RightOnHold:
2023 switch ( me->type() ) { 2030 switch ( me->type() ) {
2024 case QEvent::MouseButtonPress: 2031 case QEvent::MouseButtonPress:
2025 if ( me->button() == LeftButton ) { 2032 if ( me->button() == LeftButton ) {
2026 if (!d->presstimer )
2027 d->presstimer = startTimer(500); // #### pref.
2028 d->presswidget = (QWidget*)o; 2033 d->presswidget = (QWidget*)o;
2029 d->presspos = me->pos(); 2034 d->presspos = me->pos();
2030 d->rightpressed = FALSE; 2035 d->rightpressed = FALSE;
2036 // just for the time being
2037 static int pref = 500;
2038#ifdef WITHROHFEEDBACK
2039 if( ! d->RoH )
2040 d->RoH = new Opie::Internal::RoHFeedback;
2041
2042 d->RoH->init( me->globalPos(), d->presswidget );
2043 pref = d->RoH->delay();
2044#endif
2045 if (!d->presstimer )
2046 d->presstimer = startTimer( pref ); // #### pref.
2047
2031 } 2048 }
2032 break; 2049 break;
2033 case QEvent::MouseMove: 2050 case QEvent::MouseMove:
2034 if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) { 2051 if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) {
2035 killTimer(d->presstimer); 2052 killTimer(d->presstimer);
2053#ifdef WITHROHFEEDBACK
2054 if( d->RoH )
2055 d->RoH->stop( );
2056#endif
2036 d->presstimer = 0; 2057 d->presstimer = 0;
2037 } 2058 }
2038 break; 2059 break;
2039 case QEvent::MouseButtonRelease: 2060 case QEvent::MouseButtonRelease:
2040 if ( me->button() == LeftButton ) { 2061 if ( me->button() == LeftButton ) {
2041 if ( d->presstimer ) { 2062 if ( d->presstimer ) {
2042 killTimer(d->presstimer); 2063 killTimer(d->presstimer);
2064#ifdef WITHROHFEEDBACK
2065 if( d->RoH )
2066 d->RoH->stop( );
2067#endif
2043 d->presstimer = 0; 2068 d->presstimer = 0;
2044 } 2069 }
2045 if ( d->rightpressed && d->presswidget ) { 2070 if ( d->rightpressed && d->presswidget ) {
2046 // Right released 2071 // Right released
2047 postEvent( d->presswidget, 2072 postEvent( d->presswidget,
2048 new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), 2073 new QMouseEvent( QEvent::MouseButtonRelease, me->pos(),
2049 RightButton, LeftButton + RightButton ) ); 2074 RightButton, LeftButton + RightButton ) );
2050 // Left released, off-widget 2075 // Left released, off-widget
2051 postEvent( d->presswidget, 2076 postEvent( d->presswidget,
2052 new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1), 2077 new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1),
2053 LeftButton, LeftButton ) ); 2078 LeftButton, LeftButton ) );
2054 postEvent( d->presswidget, 2079 postEvent( d->presswidget,
2055 new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1), 2080 new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1),
2056 LeftButton, LeftButton ) ); 2081 LeftButton, LeftButton ) );
2057 d->rightpressed = FALSE; 2082 d->rightpressed = FALSE;
2058 return TRUE; // don't send the real Left release 2083 return TRUE; // don't send the real Left release
2059 } 2084 }
2060 } 2085 }
2061 break; 2086 break;
2062 default: 2087 default:
2063 break; 2088 break;
2064 } 2089 }
2065 break; 2090 break;
2066 default: 2091 default:
2067 ; 2092 ;
2068 } 2093 }
2069 } 2094 }
2070 else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { 2095 else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) {
2071 QKeyEvent *ke = (QKeyEvent *)e; 2096 QKeyEvent *ke = (QKeyEvent *)e;
2072 if ( ke->key() == Key_Enter ) { 2097 if ( ke->key() == Key_Enter ) {
2073 if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { 2098 if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) {
2074 postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', 2099 postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ',
2075 ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); 2100 ke->state(), " ", ke->isAutoRepeat(), ke->count() ) );
2076 return TRUE; 2101 return TRUE;
2077 } 2102 }
2078 } 2103 }
2079 } 2104 }
2080 return FALSE; 2105 return FALSE;
2081} 2106}
2082 2107
2083/*! 2108/*!
2084 \reimp 2109 \reimp
2085*/ 2110*/
2086void QPEApplication::timerEvent( QTimerEvent *e ) 2111void QPEApplication::timerEvent( QTimerEvent *e )
2087{ 2112{
2088 if ( e->timerId() == d->presstimer && d->presswidget ) { 2113 if ( e->timerId() == d->presstimer && d->presswidget ) {
2089 // Right pressed 2114 // Right pressed
2090 postEvent( d->presswidget, 2115 postEvent( d->presswidget,
2091 new QMouseEvent( QEvent::MouseButtonPress, d->presspos, 2116 new QMouseEvent( QEvent::MouseButtonPress, d->presspos,
2092 RightButton, LeftButton ) ); 2117 RightButton, LeftButton ) );
2093 killTimer( d->presstimer ); 2118 killTimer( d->presstimer );
2094 d->presstimer = 0; 2119 d->presstimer = 0;
2095 d->rightpressed = TRUE; 2120 d->rightpressed = TRUE;
2121 d->RoH->stop();
2096 } 2122 }
2097} 2123}
2098 2124
2099void QPEApplication::removeSenderFromStylusDict() 2125void QPEApplication::removeSenderFromStylusDict()
2100{ 2126{
2101 stylusDict->remove 2127 stylusDict->remove
2102 ( ( void* ) sender() ); 2128 ( ( void* ) sender() );
2103 if ( d->presswidget == sender() ) 2129 if ( d->presswidget == sender() )
2104 d->presswidget = 0; 2130 d->presswidget = 0;
2105} 2131}
2106 2132
2107/*! 2133/*!
2108 \internal 2134 \internal
2109*/ 2135*/
2110bool QPEApplication::keyboardGrabbed() const 2136bool QPEApplication::keyboardGrabbed() const
2111{ 2137{
2112 return d->kbgrabbed; 2138 return d->kbgrabbed;
2113} 2139}
2114 2140
2115 2141
2116/*! 2142/*!
2117 Reverses the effect of grabKeyboard(). This is called automatically 2143 Reverses the effect of grabKeyboard(). This is called automatically
2118 on program exit. 2144 on program exit.
2119*/ 2145*/
2120void QPEApplication::ungrabKeyboard() 2146void QPEApplication::ungrabKeyboard()
2121{ 2147{
2122 ((QPEApplication *) qApp )-> d-> kbgrabbed = false; 2148 ((QPEApplication *) qApp )-> d-> kbgrabbed = false;
2123} 2149}
2124 2150
2125/*! 2151/*!
2126 Grabs the physical keyboard keys, e.g. the application's launching 2152 Grabs the physical keyboard keys, e.g. the application's launching
2127 keys. Instead of launching applications when these keys are pressed 2153 keys. Instead of launching applications when these keys are pressed
2128 the signals emitted are sent to this application instead. Some games 2154 the signals emitted are sent to this application instead. Some games
2129 programs take over the launch keys in this way to make interaction 2155 programs take over the launch keys in this way to make interaction
2130 easier. 2156 easier.
2131 2157
2132 \sa ungrabKeyboard() 2158 \sa ungrabKeyboard()
2133*/ 2159*/
2134void QPEApplication::grabKeyboard() 2160void QPEApplication::grabKeyboard()
2135{ 2161{
2136 ((QPEApplication *) qApp )-> d-> kbgrabbed = true; 2162 ((QPEApplication *) qApp )-> d-> kbgrabbed = true;
2137} 2163}
2138 2164
2139/*! 2165/*!
2140 \reimp 2166 \reimp
2141*/ 2167*/
2142int QPEApplication::exec() 2168int QPEApplication::exec()
2143{ 2169{
2144 d->qcopQok = true; 2170 d->qcopQok = true;
2145#ifndef QT_NO_COP 2171#ifndef QT_NO_COP
2146 d->sendQCopQ(); 2172 d->sendQCopQ();
2147 if ( !d->keep_running ) 2173 if ( !d->keep_running )
2148 processEvents(); // we may have received QCop messages in the meantime. 2174 processEvents(); // we may have received QCop messages in the meantime.
2149#endif 2175#endif
2150 2176
2151 if ( d->keep_running ) 2177 if ( d->keep_running )
2152 //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) 2178 //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() )
2153 return QApplication::exec(); 2179 return QApplication::exec();
2154 2180
2155#ifndef QT_NO_COP 2181#ifndef QT_NO_COP
2156 2182
2157 { 2183 {
2158 QCopEnvelope e( "QPE/System", "closing(QString)" ); 2184 QCopEnvelope e( "QPE/System", "closing(QString)" );
2159 e << d->appName; 2185 e << d->appName;