summaryrefslogtreecommitdiff
path: root/library/qpeapplication.cpp
Unidiff
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
@@ -109,54 +109,59 @@ public:
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
@@ -476,50 +481,48 @@ static void qpe_show_dialog( QDialog* d, bool nomax )
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 )
@@ -1191,49 +1194,51 @@ bool QPEApplication::qwsEventFilter( QWSEvent * e )
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";
@@ -2014,75 +2019,75 @@ void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode )
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;
@@ -2097,49 +2102,51 @@ bool QPEApplication::eventFilter( QObject *o, QEvent *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*/