summaryrefslogtreecommitdiff
path: root/library/qpeapplication.cpp
Unidiff
Diffstat (limited to 'library/qpeapplication.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--library/qpeapplication.cpp58
1 files changed, 30 insertions, 28 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index 35f433c..c6d9cfd 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -76,90 +76,89 @@
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 <backend/rohfeedback.h>
101 101
102 102
103static bool useBigPixmaps = 0; 103static bool useBigPixmaps = 0;
104 104
105
106class HackWidget : public QWidget 105class HackWidget : public QWidget
107{ 106{
108public: 107public:
109 bool needsOk() 108 bool needsOk()
110 { return (getWState() & WState_Reserved1 ); } 109 { return (getWState() & WState_Reserved1 ); }
111 110
112 QRect normalGeometry() 111 QRect normalGeometry()
113 { return topData()->normalGeometry; }; 112 { return topData()->normalGeometry; };
114}; 113};
115 114
116class QPEApplicationData 115class QPEApplicationData
117{ 116{
118public: 117public:
119 QPEApplicationData ( ) 118 QPEApplicationData ( ) :
120 : presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ), 119 presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ),
121 notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ), 120 notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ),
122 keep_running( true ), qcopQok( false ), 121 keep_running( true ), qcopQok( false ),
123 fontFamily( "Vera" ), fontSize( 10 ), smallIconSize( 14 ), 122 fontFamily( "Vera" ), fontSize( 10 ), smallIconSize( 14 ),
124 bigIconSize( 32 ), qpe_main_widget( 0 ) 123 bigIconSize( 32 ), qpe_main_widget( 0 )
125 { 124 {
126 Config cfg( "qpe" ); 125 Config cfg( "qpe" );
127 cfg.setGroup( "Appearance" ); 126 cfg.setGroup( "Appearance" );
128 useBigPixmaps = cfg.readBoolEntry( "useBigPixmaps", false ); 127 useBigPixmaps = cfg.readBoolEntry( "useBigPixmaps", false );
129 fontFamily = cfg.readEntry( "FontFamily", "Vera" ); 128 fontFamily = cfg.readEntry( "FontFamily", "Vera" );
130 fontSize = cfg.readNumEntry( "FontSize", 10 ); 129 fontSize = cfg.readNumEntry( "FontSize", 10 );
131 smallIconSize = cfg.readNumEntry( "SmallIconSize", 14 ); 130 smallIconSize = cfg.readNumEntry( "SmallIconSize", 14 );
132 bigIconSize = cfg.readNumEntry( "BigIconSize", 32 ); 131 bigIconSize = cfg.readNumEntry( "BigIconSize", 32 );
133#ifdef OPIE_ROHFEEDBACK 132#ifdef OPIE_WITHROHFEEDBACK
134 RoH = 0; 133 RoH = 0;
135#endif 134#endif
136 } 135 }
137 136
138 int presstimer; 137 int presstimer;
139 QWidget* presswidget; 138 QWidget* presswidget;
140 QPoint presspos; 139 QPoint presspos;
141#ifdef OPIE_ROHFEEDBACK 140#ifdef OPIE_WITHROHFEEDBACK
142 Opie::Internal::RoHFeedback *RoH; 141 Opie::Internal::RoHFeedback *RoH;
143#endif 142#endif
144 143
145 bool rightpressed : 1; 144 bool rightpressed : 1;
146 bool kbgrabbed : 1; 145 bool kbgrabbed : 1;
147 bool notbusysent : 1; 146 bool notbusysent : 1;
148 bool preloaded : 1; 147 bool preloaded : 1;
149 bool forceshow : 1; 148 bool forceshow : 1;
150 bool nomaximize : 1; 149 bool nomaximize : 1;
151 bool keep_running : 1; 150 bool keep_running : 1;
152 bool qcopQok : 1; 151 bool qcopQok : 1;
153 152
154 QCString fontFamily; 153 QCString fontFamily;
155 int fontSize; 154 int fontSize;
156 int smallIconSize; 155 int smallIconSize;
157 int bigIconSize; 156 int bigIconSize;
158 157
159 QStringList langs; 158 QStringList langs;
160 QString appName; 159 QString appName;
161 struct QCopRec 160 struct QCopRec
162 { 161 {
163 QCopRec( const QCString &ch, const QCString &msg, 162 QCopRec( const QCString &ch, const QCString &msg,
164 const QByteArray &d ) : 163 const QByteArray &d ) :
165 channel( ch ), message( msg ), data( d ) 164 channel( ch ), message( msg ), data( d )
@@ -481,48 +480,49 @@ static void qpe_show_dialog( QDialog* d, bool nomax )
481 QDir dir( path, "lib*.dylib" ); 480 QDir dir( path, "lib*.dylib" );
482#else 481#else
483 QDir dir( path, "lib*.so" ); 482 QDir dir( path, "lib*.so" );
484#endif 483#endif
485 QStringList list; 484 QStringList list;
486 if ( dir. exists ( )) 485 if ( dir. exists ( ))
487 list = dir.entryList(); 486 list = dir.entryList();
488 QStringList::Iterator it; 487 QStringList::Iterator it;
489 for ( it = list.begin(); it != list.end(); ++it ) { 488 for ( it = list.begin(); it != list.end(); ++it ) {
490 ImageCodecInterface *iface = 0; 489 ImageCodecInterface *iface = 0;
491 QLibrary *lib = new QLibrary( path + "/" + *it ); 490 QLibrary *lib = new QLibrary( path + "/" + *it );
492 if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { 491 if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) {
493 QStringList formats = iface->keys(); 492 QStringList formats = iface->keys();
494 for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { 493 for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) {
495 (void)iface->installIOHandler(*i); 494 (void)iface->installIOHandler(*i);
496 // ### it exists now; need to remember if we can delete it 495 // ### it exists now; need to remember if we can delete it
497 } 496 }
498 } 497 }
499 else { 498 else {
500 lib->unload(); 499 lib->unload();
501 delete lib; 500 delete lib;
502 } 501 }
503 } 502 }
504 } 503 }
504
505}; 505};
506 506
507class ResourceMimeFactory : public QMimeSourceFactory 507class ResourceMimeFactory : public QMimeSourceFactory
508{ 508{
509public: 509public:
510 ResourceMimeFactory() : resImage( 0 ) 510 ResourceMimeFactory() : resImage( 0 )
511 { 511 {
512 setFilePath( Global::helpPath() ); 512 setFilePath( Global::helpPath() );
513 setExtensionType( "html", "text/html;charset=UTF-8" ); 513 setExtensionType( "html", "text/html;charset=UTF-8" );
514 } 514 }
515 ~ResourceMimeFactory() { 515 ~ResourceMimeFactory() {
516 delete resImage; 516 delete resImage;
517 } 517 }
518 518
519 const QMimeSource* data( const QString& abs_name ) const 519 const QMimeSource* data( const QString& abs_name ) const
520 { 520 {
521 const QMimeSource * r = QMimeSourceFactory::data( abs_name ); 521 const QMimeSource * r = QMimeSourceFactory::data( abs_name );
522 if ( !r ) { 522 if ( !r ) {
523 int sl = abs_name.length(); 523 int sl = abs_name.length();
524 do { 524 do {
525 sl = abs_name.findRev( '/', sl - 1 ); 525 sl = abs_name.findRev( '/', sl - 1 );
526 QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; 526 QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name;
527 int dot = name.findRev( '.' ); 527 int dot = name.findRev( '.' );
528 if ( dot >= 0 ) 528 if ( dot >= 0 )
@@ -1194,50 +1194,52 @@ bool QPEApplication::qwsEventFilter( QWSEvent * e )
1194 if ( m == AlwaysOff ) 1194 if ( m == AlwaysOff )
1195 Global::hideInputMethod(); 1195 Global::hideInputMethod();
1196 if ( m == AlwaysOn ) 1196 if ( m == AlwaysOn )
1197 Global::showInputMethod(); 1197 Global::showInputMethod();
1198 } 1198 }
1199 } 1199 }
1200 1200
1201 1201
1202 return QApplication::qwsEventFilter( e ); 1202 return QApplication::qwsEventFilter( e );
1203} 1203}
1204#endif 1204#endif
1205 1205
1206/*! 1206/*!
1207 Destroys the QPEApplication. 1207 Destroys the QPEApplication.
1208*/ 1208*/
1209QPEApplication::~QPEApplication() 1209QPEApplication::~QPEApplication()
1210{ 1210{
1211 ungrabKeyboard(); 1211 ungrabKeyboard();
1212#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 1212#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
1213 // Need to delete QCopChannels early, since the display will 1213 // Need to delete QCopChannels early, since the display will
1214 // be gone by the time we get to ~QObject(). 1214 // be gone by the time we get to ~QObject().
1215 delete sysChannel; 1215 delete sysChannel;
1216 delete pidChannel; 1216 delete pidChannel;
1217#endif 1217#endif
1218#ifdef OPIE_ROHFEEDBACK 1218
1219 delete d->RoH; 1219#ifdef OPIE_WITHROHFEEDBACK
1220 if( d->RoH )
1221 delete d->RoH;
1220#endif 1222#endif
1221 delete d; 1223 delete d;
1222} 1224}
1223 1225
1224/*! 1226/*!
1225 Returns <tt>$OPIEDIR/</tt>. 1227 Returns <tt>$OPIEDIR/</tt>.
1226*/ 1228*/
1227QString QPEApplication::qpeDir() 1229QString QPEApplication::qpeDir()
1228{ 1230{
1229 const char * base = getenv( "OPIEDIR" ); 1231 const char * base = getenv( "OPIEDIR" );
1230 if ( base ) 1232 if ( base )
1231 return QString( base ) + "/"; 1233 return QString( base ) + "/";
1232 1234
1233 return QString( "../" ); 1235 return QString( "../" );
1234} 1236}
1235 1237
1236/*! 1238/*!
1237 Returns the user's current Document directory. There is a trailing "/". 1239 Returns the user's current Document directory. There is a trailing "/".
1238 .. well, it does now,, and there's no trailing '/' 1240 .. well, it does now,, and there's no trailing '/'
1239*/ 1241*/
1240QString QPEApplication::documentDir() 1242QString QPEApplication::documentDir()
1241{ 1243{
1242 const char* base = getenv( "HOME"); 1244 const char* base = getenv( "HOME");
1243 if ( base ) 1245 if ( base )
@@ -2014,138 +2016,138 @@ void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode )
2014 else { 2016 else {
2015 stylusDict->insert( w, ( void* ) mode ); 2017 stylusDict->insert( w, ( void* ) mode );
2016 connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) ); 2018 connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) );
2017 w->installEventFilter( qApp ); 2019 w->installEventFilter( qApp );
2018 } 2020 }
2019} 2021}
2020 2022
2021 2023
2022/*! 2024/*!
2023 \reimp 2025 \reimp
2024*/ 2026*/
2025bool QPEApplication::eventFilter( QObject *o, QEvent *e ) 2027bool QPEApplication::eventFilter( QObject *o, QEvent *e )
2026{ 2028{
2027 if ( !o->isWidgetType() ) 2029 if ( !o->isWidgetType() )
2028 return FALSE; 2030 return FALSE;
2029 2031
2030 if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { 2032 if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) {
2031 QMouseEvent * me = ( QMouseEvent* ) e; 2033 QMouseEvent * me = ( QMouseEvent* ) e;
2032 StylusMode mode = (StylusMode)(int)stylusDict->find(o); 2034 StylusMode mode = (StylusMode)(int)stylusDict->find(o);
2033 switch (mode) { 2035 switch (mode) {
2034 case RightOnHold: 2036 case RightOnHold:
2035 switch ( me->type() ) { 2037 switch ( me->type() ) {
2036 case QEvent::MouseButtonPress: 2038 case QEvent::MouseButtonPress:
2037 if ( me->button() == LeftButton ) { 2039 if ( me->button() == LeftButton ) {
2040 static long Pref = 500; // #### pref.
2038 d->presswidget = (QWidget*)o; 2041 d->presswidget = (QWidget*)o;
2039 d->presspos = me->pos(); 2042 d->presspos = me->pos();
2040 d->rightpressed = FALSE; 2043 d->rightpressed = FALSE;
2041 // just for the time being 2044#ifdef OPIE_WITHROHFEEDBACK
2042 static int pref = 500;
2043#ifdef OPIE_ROHFEEDBACK
2044 if( ! d->RoH ) 2045 if( ! d->RoH )
2045 d->RoH = new Opie::Internal::RoHFeedback; 2046 d->RoH = new Opie::Internal::RoHFeedback;
2046 2047
2047 d->RoH->init( me->globalPos(), d->presswidget ); 2048 d->RoH->init( me->globalPos(), d->presswidget );
2048 pref = d->RoH->delay(); 2049 Pref = d->RoH->delay();
2050
2049#endif 2051#endif
2050 if (!d->presstimer ) 2052 if (!d->presstimer )
2051 d->presstimer = startTimer( pref ); // #### pref. 2053 d->presstimer = startTimer( Pref ); // #### pref.
2052 2054
2053 } 2055 }
2054 break; 2056 break;
2055 case QEvent::MouseMove: 2057 case QEvent::MouseMove:
2056 if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) { 2058 if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) {
2057 killTimer(d->presstimer); 2059 killTimer(d->presstimer);
2058#ifdef OPIE_ROHFEEDBACK 2060#ifdef OPIE_WITHROHFEEDBACK
2059 if( d->RoH ) 2061 d->RoH->stop();
2060 d->RoH->stop( );
2061#endif 2062#endif
2062 d->presstimer = 0; 2063 d->presstimer = 0;
2063 } 2064 }
2064 break; 2065 break;
2065 case QEvent::MouseButtonRelease: 2066 case QEvent::MouseButtonRelease:
2066 if ( me->button() == LeftButton ) { 2067 if ( me->button() == LeftButton ) {
2067 if ( d->presstimer ) { 2068 if ( d->presstimer ) {
2068 killTimer(d->presstimer); 2069 killTimer(d->presstimer);
2069#ifdef OPIE_ROHFEEDBACK 2070#ifdef OPIE_WITHROHFEEDBACK
2070 if( d->RoH ) 2071 d->RoH->stop( );
2071 d->RoH->stop( );
2072#endif 2072#endif
2073 d->presstimer = 0; 2073 d->presstimer = 0;
2074 } 2074 }
2075 if ( d->rightpressed && d->presswidget ) { 2075 if ( d->rightpressed && d->presswidget ) {
2076 printf( "Send ButtonRelease\n" );
2076 // Right released 2077 // Right released
2077 postEvent( d->presswidget, 2078 postEvent( d->presswidget,
2078 new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), 2079 new QMouseEvent( QEvent::MouseButtonRelease, me->pos(),
2079 RightButton, LeftButton + RightButton ) ); 2080 RightButton, LeftButton + RightButton ) );
2080 // Left released, off-widget 2081 // Left released, off-widget
2081 postEvent( d->presswidget, 2082 postEvent( d->presswidget,
2082 new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1), 2083 new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1),
2083 LeftButton, LeftButton ) ); 2084 LeftButton, LeftButton ) );
2084 postEvent( d->presswidget, 2085 postEvent( d->presswidget,
2085 new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1), 2086 new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1),
2086 LeftButton, LeftButton ) ); 2087 LeftButton, LeftButton ) );
2087 d->rightpressed = FALSE; 2088 d->rightpressed = FALSE;
2088 return TRUE; // don't send the real Left release 2089 return TRUE; // don't send the real Left release
2089 } 2090 }
2090 } 2091 }
2091 break; 2092 break;
2092 default: 2093 default:
2093 break; 2094 break;
2094 } 2095 }
2095 break; 2096 break;
2096 default: 2097 default:
2097 ; 2098 ;
2098 } 2099 }
2099 } 2100 }
2100 else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { 2101 else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) {
2101 QKeyEvent *ke = (QKeyEvent *)e; 2102 QKeyEvent *ke = (QKeyEvent *)e;
2102 if ( ke->key() == Key_Enter ) { 2103 if ( ke->key() == Key_Enter ) {
2103 if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { 2104 if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) {
2104 postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', 2105 postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ',
2105 ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); 2106 ke->state(), " ", ke->isAutoRepeat(), ke->count() ) );
2106 return TRUE; 2107 return TRUE;
2107 } 2108 }
2108 } 2109 }
2109 } 2110 }
2110 return FALSE; 2111 return FALSE;
2111} 2112}
2112 2113
2113/*! 2114/*!
2114 \reimp 2115 \reimp
2115*/ 2116*/
2116void QPEApplication::timerEvent( QTimerEvent *e ) 2117void QPEApplication::timerEvent( QTimerEvent *e )
2117{ 2118{
2118 if ( e->timerId() == d->presstimer && d->presswidget ) { 2119 if ( e->timerId() == d->presstimer && d->presswidget ) {
2119 // Right pressed 2120
2120 postEvent( d->presswidget, 2121 // Right pressed
2121 new QMouseEvent( QEvent::MouseButtonPress, d->presspos, 2122 postEvent( d->presswidget,
2122 RightButton, LeftButton ) ); 2123 new QMouseEvent( QEvent::MouseButtonPress, d->presspos,
2123 killTimer( d->presstimer ); 2124 RightButton, LeftButton ) );
2124 d->presstimer = 0; 2125 killTimer( d->presstimer );
2125 d->rightpressed = TRUE; 2126 d->presstimer = 0;
2126#ifdef OPIE_ROHFEEDBACK 2127 d->rightpressed = TRUE;
2127 d->RoH->stop(); 2128#ifdef OPIE_WITHROHFEEDBACK
2129 d->RoH->stop();
2128#endif 2130#endif
2129 } 2131 }
2130} 2132}
2131 2133
2132void QPEApplication::removeSenderFromStylusDict() 2134void QPEApplication::removeSenderFromStylusDict()
2133{ 2135{
2134 stylusDict->remove 2136 stylusDict->remove
2135 ( ( void* ) sender() ); 2137 ( ( void* ) sender() );
2136 if ( d->presswidget == sender() ) 2138 if ( d->presswidget == sender() )
2137 d->presswidget = 0; 2139 d->presswidget = 0;
2138} 2140}
2139 2141
2140/*! 2142/*!
2141 \internal 2143 \internal
2142*/ 2144*/
2143bool QPEApplication::keyboardGrabbed() const 2145bool QPEApplication::keyboardGrabbed() const
2144{ 2146{
2145 return d->kbgrabbed; 2147 return d->kbgrabbed;
2146} 2148}
2147 2149
2148 2150
2149/*! 2151/*!
2150 Reverses the effect of grabKeyboard(). This is called automatically 2152 Reverses the effect of grabKeyboard(). This is called automatically
2151 on program exit. 2153 on program exit.