summaryrefslogtreecommitdiff
path: root/library/qpeapplication.cpp
authorzecke <zecke>2003-10-02 19:50:57 (UTC)
committer zecke <zecke>2003-10-02 19:50:57 (UTC)
commita5622a23c3083e1ff8a526713aed6a36aaf7a5bd (patch) (unidiff)
treea11dd920c777ebceee2026e573d4e0111875174c /library/qpeapplication.cpp
parentb262f4cbe41c144c472f17996a8739952464e00c (diff)
downloadopie-a5622a23c3083e1ff8a526713aed6a36aaf7a5bd.zip
opie-a5622a23c3083e1ff8a526713aed6a36aaf7a5bd.tar.gz
opie-a5622a23c3083e1ff8a526713aed6a36aaf7a5bd.tar.bz2
Move the #ifdef so that the code actually compiles if the expression
is not true
Diffstat (limited to 'library/qpeapplication.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--library/qpeapplication.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index 98af70a..0e469ae 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -54,197 +54,198 @@
54 54
55#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 55#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
56#define QTOPIA_INTERNAL_INITAPP 56#define QTOPIA_INTERNAL_INITAPP
57#include "qpeapplication.h" 57#include "qpeapplication.h"
58#include "qpestyle.h" 58#include "qpestyle.h"
59#include "styleinterface.h" 59#include "styleinterface.h"
60#if QT_VERSION >= 300 60#if QT_VERSION >= 300
61#include <qstylefactory.h> 61#include <qstylefactory.h>
62#else 62#else
63#include <qplatinumstyle.h> 63#include <qplatinumstyle.h>
64#include <qwindowsstyle.h> 64#include <qwindowsstyle.h>
65#include <qmotifstyle.h> 65#include <qmotifstyle.h>
66#include <qmotifplusstyle.h> 66#include <qmotifplusstyle.h>
67#include "lightstyle.h" 67#include "lightstyle.h"
68 68
69#include <qpe/qlibrary.h> 69#include <qpe/qlibrary.h>
70#endif 70#endif
71#include "global.h" 71#include "global.h"
72#include "resource.h" 72#include "resource.h"
73#if QT_VERSION <= 230 && defined(QT_NO_CODECS) 73#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
74#include "qutfcodec.h" 74#include "qutfcodec.h"
75#endif 75#endif
76#include "config.h" 76#include "config.h"
77#include "network.h" 77#include "network.h"
78#ifdef QWS 78#ifdef QWS
79#include "fontmanager.h" 79#include "fontmanager.h"
80#endif 80#endif
81 81
82#include "alarmserver.h" 82#include "alarmserver.h"
83#include "applnk.h" 83#include "applnk.h"
84#include "qpemenubar.h" 84#include "qpemenubar.h"
85#include "textcodecinterface.h" 85#include "textcodecinterface.h"
86#include "imagecodecinterface.h" 86#include "imagecodecinterface.h"
87 87
88#include <unistd.h> 88#include <unistd.h>
89#include <sys/file.h> 89#include <sys/file.h>
90#include <sys/ioctl.h> 90#include <sys/ioctl.h>
91#include <sys/soundcard.h> 91#include <sys/soundcard.h>
92 92
93#include "qt_override_p.h" 93#include "qt_override_p.h"
94 94
95 95
96class QPEApplicationData 96class QPEApplicationData
97{ 97{
98public: 98public:
99 QPEApplicationData ( ) 99 QPEApplicationData ( )
100 : presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ), 100 : presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ),
101 notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ), 101 notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ),
102 keep_running( true ), qpe_main_widget( 0 ), qcopQok( false ) 102 keep_running( true ), qpe_main_widget( 0 ), qcopQok( false )
103 103
104 {} 104 {}
105 105
106 int presstimer; 106 int presstimer;
107 QWidget* presswidget; 107 QWidget* presswidget;
108 QPoint presspos; 108 QPoint presspos;
109 109
110 bool rightpressed : 1; 110 bool rightpressed : 1;
111 bool kbgrabbed : 1; 111 bool kbgrabbed : 1;
112 bool notbusysent : 1; 112 bool notbusysent : 1;
113 bool preloaded : 1; 113 bool preloaded : 1;
114 bool forceshow : 1; 114 bool forceshow : 1;
115 bool nomaximize : 1; 115 bool nomaximize : 1;
116 bool qcopQok : 1; 116 bool qcopQok : 1;
117 bool keep_running : 1; 117 bool keep_running : 1;
118 118
119 119
120 QStringList langs; 120 QStringList langs;
121 QString appName; 121 QString appName;
122 struct QCopRec 122 struct QCopRec
123 { 123 {
124 QCopRec( const QCString &ch, const QCString &msg, 124 QCopRec( const QCString &ch, const QCString &msg,
125 const QByteArray &d ) : 125 const QByteArray &d ) :
126 channel( ch ), message( msg ), data( d ) 126 channel( ch ), message( msg ), data( d )
127 { } 127 { }
128 128
129 QCString channel; 129 QCString channel;
130 QCString message; 130 QCString message;
131 QByteArray data; 131 QByteArray data;
132 }; 132 };
133 QWidget* qpe_main_widget; 133 QWidget* qpe_main_widget;
134 QGuardedPtr<QWidget> lastraised; 134 QGuardedPtr<QWidget> lastraised;
135 QQueue<QCopRec> qcopq; 135 QQueue<QCopRec> qcopq;
136 QString styleName; 136 QString styleName;
137 QString decorationName; 137 QString decorationName;
138 138
139 void enqueueQCop( const QCString &ch, const QCString &msg, 139 void enqueueQCop( const QCString &ch, const QCString &msg,
140 const QByteArray &data ) 140 const QByteArray &data )
141 { 141 {
142 qcopq.enqueue( new QCopRec( ch, msg, data ) ); 142 qcopq.enqueue( new QCopRec( ch, msg, data ) );
143 } 143 }
144 void sendQCopQ() 144 void sendQCopQ()
145 { 145 {
146 if (!qcopQok ) 146 if (!qcopQok )
147 return; 147 return;
148 148
149 QCopRec * r; 149 QCopRec * r;
150#ifndef QT_NO_COP 150
151 while((r=qcopq.dequeue())) { 151 while((r=qcopq.dequeue())) {
152 // remove from queue before sending... 152 // remove from queue before sending...
153 // event loop can come around again before getting 153 // event loop can come around again before getting
154 // back from sendLocally 154 // back from sendLocally
155#ifndef QT_NO_COP
155 QCopChannel::sendLocally( r->channel, r->message, r->data ); 156 QCopChannel::sendLocally( r->channel, r->message, r->data );
156#endif 157#endif
157 158
158 delete r; 159 delete r;
159 } 160 }
160 } 161 }
161 static void show_mx(QWidget* mw, bool nomaximize, const QString & = QString::null ) 162 static void show_mx(QWidget* mw, bool nomaximize, const QString & = QString::null )
162 { 163 {
163 164
164 // ugly hack, remove that later after finding a sane solution 165 // ugly hack, remove that later after finding a sane solution
165 // Addendum: Only Sharp currently has models with high resolution but (physically) small displays, 166 // Addendum: Only Sharp currently has models with high resolution but (physically) small displays,
166 // so this is only useful if QT_QWS_SIMPAD is NOT defined. E.g. SIMpad has 800x600 but has 167 // so this is only useful if QT_QWS_SIMPAD is NOT defined. E.g. SIMpad has 800x600 but has
167 // a (physically) large enough display to use the small icons 168 // a (physically) large enough display to use the small icons
168#ifndef QT_QWS_SIMPAD 169#ifndef QT_QWS_SIMPAD
169 if ( QPEApplication::desktop() ->width() >= 600 && ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) ) { 170 if ( QPEApplication::desktop() ->width() >= 600 && ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) ) {
170 ( ( QMainWindow* ) mw )->setUsesBigPixmaps( true ); 171 ( ( QMainWindow* ) mw )->setUsesBigPixmaps( true );
171 } 172 }
172#endif 173#endif
173 174
174 if ( mw->layout() && mw->inherits("QDialog") ) { 175 if ( mw->layout() && mw->inherits("QDialog") ) {
175 QPEApplication::showDialog((QDialog*)mw, nomaximize); 176 QPEApplication::showDialog((QDialog*)mw, nomaximize);
176 } 177 }
177 else { 178 else {
178#ifdef Q_WS_QWS 179#ifdef Q_WS_QWS
179 if ( !nomaximize ) 180 if ( !nomaximize )
180 mw->showMaximized(); 181 mw->showMaximized();
181 else 182 else
182#endif 183#endif
183 184
184 mw->show(); 185 mw->show();
185 } 186 }
186 } 187 }
187 static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) 188 static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ )
188 { 189 {
189 /* 190 /*
190 // This works but disable it for now until it is safe to apply 191 // This works but disable it for now until it is safe to apply
191 // What is does is scan the .desktop files of all the apps for 192 // What is does is scan the .desktop files of all the apps for
192 // the applnk that has the corresponding argv[0] as this program 193 // the applnk that has the corresponding argv[0] as this program
193 // then it uses the name stored in the .desktop file as the caption 194 // then it uses the name stored in the .desktop file as the caption
194 // for the main widget. This saves duplicating translations for 195 // for the main widget. This saves duplicating translations for
195 // the app name in the program and in the .desktop files. 196 // the app name in the program and in the .desktop files.
196 197
197 AppLnkSet apps( appsPath ); 198 AppLnkSet apps( appsPath );
198 199
199 QList<AppLnk> appsList = apps.children(); 200 QList<AppLnk> appsList = apps.children();
200 for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { 201 for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) {
201 if ( (*it)->exec() == appName ) { 202 if ( (*it)->exec() == appName ) {
202 mw->setCaption( (*it)->name() ); 203 mw->setCaption( (*it)->name() );
203 return TRUE; 204 return TRUE;
204 } 205 }
205 } 206 }
206 */ 207 */
207 return FALSE; 208 return FALSE;
208 } 209 }
209 210
210 211
211 void show(QWidget* mw, bool nomax) 212 void show(QWidget* mw, bool nomax)
212 { 213 {
213 setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); 214 setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" );
214 nomaximize = nomax; 215 nomaximize = nomax;
215 qpe_main_widget = mw; 216 qpe_main_widget = mw;
216#ifndef QT_NO_COP 217#ifndef QT_NO_COP
217 218
218 sendQCopQ(); 219 sendQCopQ();
219#endif 220#endif
220 221
221 if ( preloaded ) { 222 if ( preloaded ) {
222 if (forceshow) 223 if (forceshow)
223 show_mx(mw, nomax); 224 show_mx(mw, nomax);
224 } 225 }
225 else if ( keep_running ) { 226 else if ( keep_running ) {
226 show_mx(mw, nomax); 227 show_mx(mw, nomax);
227 } 228 }
228 } 229 }
229 230
230 void loadTextCodecs() 231 void loadTextCodecs()
231 { 232 {
232 QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; 233 QString path = QPEApplication::qpeDir() + "/plugins/textcodecs";
233 QDir dir( path, "lib*.so" ); 234 QDir dir( path, "lib*.so" );
234 QStringList list; 235 QStringList list;
235 if ( dir. exists ( )) 236 if ( dir. exists ( ))
236 list = dir.entryList(); 237 list = dir.entryList();
237 QStringList::Iterator it; 238 QStringList::Iterator it;
238 for ( it = list.begin(); it != list.end(); ++it ) { 239 for ( it = list.begin(); it != list.end(); ++it ) {
239 TextCodecInterface *iface = 0; 240 TextCodecInterface *iface = 0;
240 QLibrary *lib = new QLibrary( path + "/" + *it ); 241 QLibrary *lib = new QLibrary( path + "/" + *it );
241 if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { 242 if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) {
242 QValueList<int> mibs = iface->mibEnums(); 243 QValueList<int> mibs = iface->mibEnums();
243 for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { 244 for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) {
244 (void)iface->createForMib(*i); 245 (void)iface->createForMib(*i);
245 // ### it exists now; need to remember if we can delete it 246 // ### it exists now; need to remember if we can delete it
246 } 247 }
247 } 248 }
248 else { 249 else {
249 lib->unload(); 250 lib->unload();
250 delete lib; 251 delete lib;