author | alwin <alwin> | 2004-03-02 12:21:11 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-03-02 12:21:11 (UTC) |
commit | b6b1c97559c0ed9f2e33632272426bf98f289232 (patch) (unidiff) | |
tree | d3a9987704770cdf5eb14e1136f6e3ecb2f36a04 /x11 | |
parent | 0d59c780513da78033f4d9040475dee9db0256d4 (diff) | |
download | opie-b6b1c97559c0ed9f2e33632272426bf98f289232.zip opie-b6b1c97559c0ed9f2e33632272426bf98f289232.tar.gz opie-b6b1c97559c0ed9f2e33632272426bf98f289232.tar.bz2 |
applied the patch generated by the optimize_connect script from
TT.
-rw-r--r-- | x11/libqpe-x11/qpe/qpeapplication.cpp | 8 | ||||
-rw-r--r-- | x11/libqpe-x11/qt/qcopchannel_qws.cpp | 4 |
2 files changed, 6 insertions, 6 deletions
diff --git a/x11/libqpe-x11/qpe/qpeapplication.cpp b/x11/libqpe-x11/qpe/qpeapplication.cpp index 0fce355..3cb8faf 100644 --- a/x11/libqpe-x11/qpe/qpeapplication.cpp +++ b/x11/libqpe-x11/qpe/qpeapplication.cpp | |||
@@ -1,688 +1,688 @@ | |||
1 | #define QTOPIA_INTERNAL_LANGLIST | 1 | #define QTOPIA_INTERNAL_LANGLIST |
2 | 2 | ||
3 | #include <stdio.h> | 3 | #include <stdio.h> |
4 | #include <stdlib.h> | 4 | #include <stdlib.h> |
5 | #include <unistd.h> | 5 | #include <unistd.h> |
6 | #include <sys/file.h> | 6 | #include <sys/file.h> |
7 | 7 | ||
8 | 8 | ||
9 | #include <qdir.h> | 9 | #include <qdir.h> |
10 | #include <qdialog.h> | 10 | #include <qdialog.h> |
11 | #include <qdragobject.h> | 11 | #include <qdragobject.h> |
12 | #include <qevent.h> | 12 | #include <qevent.h> |
13 | #include <qlabel.h> | 13 | #include <qlabel.h> |
14 | #include <qlist.h> | 14 | #include <qlist.h> |
15 | #include <qtextstream.h> | 15 | #include <qtextstream.h> |
16 | #include <qtextcodec.h> | 16 | #include <qtextcodec.h> |
17 | #include <qpalette.h> | 17 | #include <qpalette.h> |
18 | #include <qptrdict.h> | 18 | #include <qptrdict.h> |
19 | #include <qregexp.h> | 19 | #include <qregexp.h> |
20 | #include <qtimer.h> | 20 | #include <qtimer.h> |
21 | 21 | ||
22 | #include <qpe/custom.h> | 22 | #include <qpe/custom.h> |
23 | #include <qpe/alarmserver.h> | 23 | #include <qpe/alarmserver.h> |
24 | #include <qpe/applnk.h> | 24 | #include <qpe/applnk.h> |
25 | #include <qpe/qpemenubar.h> | 25 | #include <qpe/qpemenubar.h> |
26 | #include <qpe/textcodecinterface.h> | 26 | #include <qpe/textcodecinterface.h> |
27 | #include <qpe/imagecodecinterface.h> | 27 | #include <qpe/imagecodecinterface.h> |
28 | #include <qpe/qlibrary.h> | 28 | #include <qpe/qlibrary.h> |
29 | #include <qpe/qpestyle.h> | 29 | #include <qpe/qpestyle.h> |
30 | #include <qpe/styleinterface.h> | 30 | #include <qpe/styleinterface.h> |
31 | #include <qpe/global.h> | 31 | #include <qpe/global.h> |
32 | #include <qpe/resource.h> | 32 | #include <qpe/resource.h> |
33 | #include <qpe/config.h> | 33 | #include <qpe/config.h> |
34 | #include <qpe/network.h> | 34 | #include <qpe/network.h> |
35 | 35 | ||
36 | #include <qpe/qpeapplication.h> | 36 | #include <qpe/qpeapplication.h> |
37 | #include <qpe/timestring.h> | 37 | #include <qpe/timestring.h> |
38 | #include <qpe/qcopenvelope_qws.h> | 38 | #include <qpe/qcopenvelope_qws.h> |
39 | 39 | ||
40 | 40 | ||
41 | #include <X11/Xlib.h> | 41 | #include <X11/Xlib.h> |
42 | #include <X11/Xutil.h> | 42 | #include <X11/Xutil.h> |
43 | 43 | ||
44 | const int XKeyPress = KeyPress; | 44 | const int XKeyPress = KeyPress; |
45 | const int XKeyRelease = KeyRelease; | 45 | const int XKeyRelease = KeyRelease; |
46 | #undef KeyPress | 46 | #undef KeyPress |
47 | #undef KeyRelease | 47 | #undef KeyRelease |
48 | 48 | ||
49 | namespace { | 49 | namespace { |
50 | struct QCopRec{ | 50 | struct QCopRec{ |
51 | QCopRec( const QCString& ch, const QCString& msg, const QByteArray& ar ) | 51 | QCopRec( const QCString& ch, const QCString& msg, const QByteArray& ar ) |
52 | : channel(ch), message(msg), data(ar) { | 52 | : channel(ch), message(msg), data(ar) { |
53 | 53 | ||
54 | } | 54 | } |
55 | QCString channel; | 55 | QCString channel; |
56 | QCString message; | 56 | QCString message; |
57 | QByteArray data; | 57 | QByteArray data; |
58 | }; | 58 | }; |
59 | }; | 59 | }; |
60 | 60 | ||
61 | 61 | ||
62 | class QPEApplication::Private { | 62 | class QPEApplication::Private { |
63 | public: | 63 | public: |
64 | Private(); | 64 | Private(); |
65 | ~Private(); | 65 | ~Private(); |
66 | void enqueueQCop( const QCString& ch, const QCString& msg, | 66 | void enqueueQCop( const QCString& ch, const QCString& msg, |
67 | const QByteArray& ); | 67 | const QByteArray& ); |
68 | void sendQCopQ(); | 68 | void sendQCopQ(); |
69 | static void show_mx(QWidget* mw, bool nomaximize ); | 69 | static void show_mx(QWidget* mw, bool nomaximize ); |
70 | void show( QWidget* mw, bool nomax ); | 70 | void show( QWidget* mw, bool nomax ); |
71 | void loadTextCodecs(); | 71 | void loadTextCodecs(); |
72 | void loadImageCodecs(); | 72 | void loadImageCodecs(); |
73 | 73 | ||
74 | int kbgrabber; | 74 | int kbgrabber; |
75 | int presstimer; | 75 | int presstimer; |
76 | 76 | ||
77 | bool rightpressed : 1; | 77 | bool rightpressed : 1; |
78 | bool kbregrab : 1; | 78 | bool kbregrab : 1; |
79 | bool notbusysent : 1; | 79 | bool notbusysent : 1; |
80 | bool preloaded : 1; | 80 | bool preloaded : 1; |
81 | bool forceshow : 1; | 81 | bool forceshow : 1; |
82 | bool nomaximize : 1; | 82 | bool nomaximize : 1; |
83 | bool keep_running : 1; | 83 | bool keep_running : 1; |
84 | 84 | ||
85 | QWidget* presswidget; | 85 | QWidget* presswidget; |
86 | QPoint presspos; | 86 | QPoint presspos; |
87 | QWidget* qpe_main_widget; | 87 | QWidget* qpe_main_widget; |
88 | QString appName; | 88 | QString appName; |
89 | QString styleName; | 89 | QString styleName; |
90 | QString decorationName; | 90 | QString decorationName; |
91 | Atom wm_delete_window; | 91 | Atom wm_delete_window; |
92 | Atom wm_take_focus; | 92 | Atom wm_take_focus; |
93 | Atom wm_context_help; | 93 | Atom wm_context_help; |
94 | Atom wm_context_accept; | 94 | Atom wm_context_accept; |
95 | Atom wm_protocols; | 95 | Atom wm_protocols; |
96 | 96 | ||
97 | private: | 97 | private: |
98 | QList<QCopRec> qcopq; | 98 | QList<QCopRec> qcopq; |
99 | }; | 99 | }; |
100 | QPEApplication::Private::~Private() { | 100 | QPEApplication::Private::~Private() { |
101 | } | 101 | } |
102 | QPEApplication::Private::Private() | 102 | QPEApplication::Private::Private() |
103 | : kbgrabber(0 ), presstimer(0 ), rightpressed( FALSE ), kbregrab( FALSE ), notbusysent( FALSE ), | 103 | : kbgrabber(0 ), presstimer(0 ), rightpressed( FALSE ), kbregrab( FALSE ), notbusysent( FALSE ), |
104 | preloaded( FALSE ), forceshow( FALSE ), nomaximize( FALSE ), keep_running( TRUE ), | 104 | preloaded( FALSE ), forceshow( FALSE ), nomaximize( FALSE ), keep_running( TRUE ), |
105 | presswidget( 0 ), qpe_main_widget(0 ) { | 105 | presswidget( 0 ), qpe_main_widget(0 ) { |
106 | 106 | ||
107 | qcopq.setAutoDelete( TRUE ); | 107 | qcopq.setAutoDelete( TRUE ); |
108 | } | 108 | } |
109 | void QPEApplication::Private::enqueueQCop( const QCString& chan, const QCString& msg, | 109 | void QPEApplication::Private::enqueueQCop( const QCString& chan, const QCString& msg, |
110 | const QByteArray& ar ) { | 110 | const QByteArray& ar ) { |
111 | qcopq.append( new QCopRec(chan, msg, ar ) ); | 111 | qcopq.append( new QCopRec(chan, msg, ar ) ); |
112 | } | 112 | } |
113 | void QPEApplication::Private::sendQCopQ() { | 113 | void QPEApplication::Private::sendQCopQ() { |
114 | QCopRec* r; | 114 | QCopRec* r; |
115 | for ( r = qcopq.first(); r; r = qcopq.next() ) { | 115 | for ( r = qcopq.first(); r; r = qcopq.next() ) { |
116 | QCopChannel::sendLocally( r->channel, r->message, r->data ); | 116 | QCopChannel::sendLocally( r->channel, r->message, r->data ); |
117 | } | 117 | } |
118 | qcopq.clear(); | 118 | qcopq.clear(); |
119 | } | 119 | } |
120 | void QPEApplication::Private::show_mx(QWidget* mw, bool nomaximize ) { | 120 | void QPEApplication::Private::show_mx(QWidget* mw, bool nomaximize ) { |
121 | if (mw->layout() && mw->inherits("QDialog") ) { | 121 | if (mw->layout() && mw->inherits("QDialog") ) { |
122 | QPEApplication::showDialog( (QDialog*)mw, nomaximize ); | 122 | QPEApplication::showDialog( (QDialog*)mw, nomaximize ); |
123 | }else { | 123 | }else { |
124 | if (!nomaximize ) | 124 | if (!nomaximize ) |
125 | mw->showMaximized(); | 125 | mw->showMaximized(); |
126 | else | 126 | else |
127 | mw->show(); | 127 | mw->show(); |
128 | } | 128 | } |
129 | } | 129 | } |
130 | void QPEApplication::Private::show( QWidget* mw, bool nomax ) { | 130 | void QPEApplication::Private::show( QWidget* mw, bool nomax ) { |
131 | nomaximize = nomax; | 131 | nomaximize = nomax; |
132 | qpe_main_widget = mw; | 132 | qpe_main_widget = mw; |
133 | 133 | ||
134 | sendQCopQ(); | 134 | sendQCopQ(); |
135 | 135 | ||
136 | if ( preloaded ) { | 136 | if ( preloaded ) { |
137 | if (forceshow ) | 137 | if (forceshow ) |
138 | show_mx(mw, nomax ); | 138 | show_mx(mw, nomax ); |
139 | }else if ( keep_running ) | 139 | }else if ( keep_running ) |
140 | show_mx( mw, nomax ); | 140 | show_mx( mw, nomax ); |
141 | } | 141 | } |
142 | void QPEApplication::Private::loadTextCodecs() { | 142 | void QPEApplication::Private::loadTextCodecs() { |
143 | QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; | 143 | QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; |
144 | QDir dir( path, "lib*.so" ); | 144 | QDir dir( path, "lib*.so" ); |
145 | QStringList list = dir.entryList(); | 145 | QStringList list = dir.entryList(); |
146 | QStringList::Iterator it; | 146 | QStringList::Iterator it; |
147 | for ( it = list.begin(); it != list.end(); ++it ) { | 147 | for ( it = list.begin(); it != list.end(); ++it ) { |
148 | TextCodecInterface *iface = 0; | 148 | TextCodecInterface *iface = 0; |
149 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 149 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
150 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 150 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
151 | QValueList<int> mibs = iface->mibEnums(); | 151 | QValueList<int> mibs = iface->mibEnums(); |
152 | for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { | 152 | for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { |
153 | (void)iface->createForMib(*i); | 153 | (void)iface->createForMib(*i); |
154 | // ### it exists now; need to remember if we can delete it | 154 | // ### it exists now; need to remember if we can delete it |
155 | } | 155 | } |
156 | } | 156 | } |
157 | else { | 157 | else { |
158 | lib->unload(); | 158 | lib->unload(); |
159 | delete lib; | 159 | delete lib; |
160 | } | 160 | } |
161 | } | 161 | } |
162 | } | 162 | } |
163 | void QPEApplication::Private::loadImageCodecs() { | 163 | void QPEApplication::Private::loadImageCodecs() { |
164 | QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; | 164 | QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; |
165 | QDir dir( path, "lib*.so" ); | 165 | QDir dir( path, "lib*.so" ); |
166 | QStringList list = dir.entryList(); | 166 | QStringList list = dir.entryList(); |
167 | QStringList::Iterator it; | 167 | QStringList::Iterator it; |
168 | for ( it = list.begin(); it != list.end(); ++it ) { | 168 | for ( it = list.begin(); it != list.end(); ++it ) { |
169 | ImageCodecInterface *iface = 0; | 169 | ImageCodecInterface *iface = 0; |
170 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 170 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
171 | if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 171 | if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
172 | QStringList formats = iface->keys(); | 172 | QStringList formats = iface->keys(); |
173 | for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { | 173 | for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { |
174 | (void)iface->installIOHandler(*i); | 174 | (void)iface->installIOHandler(*i); |
175 | // ### it exists now; need to remember if we can delete it | 175 | // ### it exists now; need to remember if we can delete it |
176 | } | 176 | } |
177 | } | 177 | } |
178 | else { | 178 | else { |
179 | lib->unload(); | 179 | lib->unload(); |
180 | delete lib; | 180 | delete lib; |
181 | } | 181 | } |
182 | } | 182 | } |
183 | } | 183 | } |
184 | 184 | ||
185 | // The Help System hook | 185 | // The Help System hook |
186 | namespace { | 186 | namespace { |
187 | class ResourceMimeFactory : public QMimeSourceFactory | 187 | class ResourceMimeFactory : public QMimeSourceFactory |
188 | { | 188 | { |
189 | public: | 189 | public: |
190 | ResourceMimeFactory(); | 190 | ResourceMimeFactory(); |
191 | ~ResourceMimeFactory(); | 191 | ~ResourceMimeFactory(); |
192 | const QMimeSource* data( const QString& abs_name )const; | 192 | const QMimeSource* data( const QString& abs_name )const; |
193 | }; | 193 | }; |
194 | ResourceMimeFactory::ResourceMimeFactory() | 194 | ResourceMimeFactory::ResourceMimeFactory() |
195 | { | 195 | { |
196 | setFilePath( Global::helpPath() ); | 196 | setFilePath( Global::helpPath() ); |
197 | setExtensionType( "html", "text/html;charset=UTF-8" ); | 197 | setExtensionType( "html", "text/html;charset=UTF-8" ); |
198 | } | 198 | } |
199 | ResourceMimeFactory::~ResourceMimeFactory() { | 199 | ResourceMimeFactory::~ResourceMimeFactory() { |
200 | } | 200 | } |
201 | 201 | ||
202 | const QMimeSource* ResourceMimeFactory::data( const QString& abs_name ) const | 202 | const QMimeSource* ResourceMimeFactory::data( const QString& abs_name ) const |
203 | { | 203 | { |
204 | const QMimeSource * r = QMimeSourceFactory::data( abs_name ); | 204 | const QMimeSource * r = QMimeSourceFactory::data( abs_name ); |
205 | if ( !r ) { | 205 | if ( !r ) { |
206 | int sl = abs_name.length(); | 206 | int sl = abs_name.length(); |
207 | do { | 207 | do { |
208 | sl = abs_name.findRev( '/', sl - 1 ); | 208 | sl = abs_name.findRev( '/', sl - 1 ); |
209 | QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; | 209 | QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; |
210 | int dot = name.findRev( '.' ); | 210 | int dot = name.findRev( '.' ); |
211 | if ( dot >= 0 ) | 211 | if ( dot >= 0 ) |
212 | name = name.left( dot ); | 212 | name = name.left( dot ); |
213 | QImage img = Resource::loadImage( name ); | 213 | QImage img = Resource::loadImage( name ); |
214 | if ( !img.isNull() ) | 214 | if ( !img.isNull() ) |
215 | r = new QImageDrag( img ); | 215 | r = new QImageDrag( img ); |
216 | } | 216 | } |
217 | while ( !r && sl > 0 ); | 217 | while ( !r && sl > 0 ); |
218 | } | 218 | } |
219 | return r; | 219 | return r; |
220 | }; | 220 | }; |
221 | }; | 221 | }; |
222 | // QPEApplication | 222 | // QPEApplication |
223 | QPEApplication::~QPEApplication() { | 223 | QPEApplication::~QPEApplication() { |
224 | qWarning("~QPEApplication"); | 224 | qWarning("~QPEApplication"); |
225 | ungrabKeyboard(); | 225 | ungrabKeyboard(); |
226 | qWarning("UngrabKeyboard"); | 226 | qWarning("UngrabKeyboard"); |
227 | 227 | ||
228 | // delete m_sys; | 228 | // delete m_sys; |
229 | // delete m_pid; | 229 | // delete m_pid; |
230 | 230 | ||
231 | delete d; | 231 | delete d; |
232 | } | 232 | } |
233 | QPEApplication::QPEApplication(int &arg, char** argv, Type t) | 233 | QPEApplication::QPEApplication(int &arg, char** argv, Type t) |
234 | : QApplication( arg, argv, t ) { | 234 | : QApplication( arg, argv, t ) { |
235 | d = new Private; | 235 | d = new Private; |
236 | d->loadTextCodecs(); | 236 | d->loadTextCodecs(); |
237 | d->loadImageCodecs(); | 237 | d->loadImageCodecs(); |
238 | 238 | ||
239 | // Init X-Atom | 239 | // Init X-Atom |
240 | Atom *atoms[5]; | 240 | Atom *atoms[5]; |
241 | Atom atoms_re[5]; | 241 | Atom atoms_re[5]; |
242 | char* names[5]; | 242 | char* names[5]; |
243 | int n = 0; | 243 | int n = 0; |
244 | atoms[n] = &d->wm_delete_window; | 244 | atoms[n] = &d->wm_delete_window; |
245 | names[n++] = "WM_DELETE_WINDOW"; | 245 | names[n++] = "WM_DELETE_WINDOW"; |
246 | 246 | ||
247 | atoms[n] = &d->wm_take_focus; | 247 | atoms[n] = &d->wm_take_focus; |
248 | names[n++] = "WM_TAKE_FOCUS"; | 248 | names[n++] = "WM_TAKE_FOCUS"; |
249 | 249 | ||
250 | atoms[n] = &d->wm_context_help; | 250 | atoms[n] = &d->wm_context_help; |
251 | names[n++] = "_NET_WM_CONTEXT_HELP"; | 251 | names[n++] = "_NET_WM_CONTEXT_HELP"; |
252 | 252 | ||
253 | atoms[n] = &d->wm_context_accept; | 253 | atoms[n] = &d->wm_context_accept; |
254 | names[n++] = "_NET_WM_CONTEXT_ACCEPT"; | 254 | names[n++] = "_NET_WM_CONTEXT_ACCEPT"; |
255 | 255 | ||
256 | atoms[n] = &d->wm_protocols; | 256 | atoms[n] = &d->wm_protocols; |
257 | names[n++] = "WM_PROTOCOLS"; | 257 | names[n++] = "WM_PROTOCOLS"; |
258 | 258 | ||
259 | XInternAtoms( qt_xdisplay(), names, n, FALSE, atoms_re); | 259 | XInternAtoms( qt_xdisplay(), names, n, FALSE, atoms_re); |
260 | // now copy the values over to the properties | 260 | // now copy the values over to the properties |
261 | for (int i = 0; i < n; i++ ) | 261 | for (int i = 0; i < n; i++ ) |
262 | *atoms[i] = atoms_re[i]; | 262 | *atoms[i] = atoms_re[i]; |
263 | // done with X11 Stuff | 263 | // done with X11 Stuff |
264 | 264 | ||
265 | int dw = desktop()->width(); | 265 | int dw = desktop()->width(); |
266 | if ( dw < 200 ) { | 266 | if ( dw < 200 ) { |
267 | setFont( QFont( "helvetica", 8 ) ); | 267 | setFont( QFont( "helvetica", 8 ) ); |
268 | AppLnk::setSmallIconSize( 10 ); | 268 | AppLnk::setSmallIconSize( 10 ); |
269 | AppLnk::setBigIconSize( 28 ); | 269 | AppLnk::setBigIconSize( 28 ); |
270 | }else if ( dw > 600 ) { | 270 | }else if ( dw > 600 ) { |
271 | setFont( QFont( "helvetica", 12 ) ); | 271 | setFont( QFont( "helvetica", 12 ) ); |
272 | AppLnk::setSmallIconSize( 24 ); | 272 | AppLnk::setSmallIconSize( 24 ); |
273 | AppLnk::setBigIconSize( 48 ); | 273 | AppLnk::setBigIconSize( 48 ); |
274 | }else if ( dw > 200 ) { | 274 | }else if ( dw > 200 ) { |
275 | setFont( QFont( "helvetica", 10 ) ); | 275 | setFont( QFont( "helvetica", 10 ) ); |
276 | AppLnk::setSmallIconSize( 16 ); | 276 | AppLnk::setSmallIconSize( 16 ); |
277 | AppLnk::setBigIconSize( 32 ); | 277 | AppLnk::setBigIconSize( 32 ); |
278 | } | 278 | } |
279 | QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); | 279 | QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); |
280 | 280 | ||
281 | connect( this, SIGNAL( lastWindowClosed() ), this, SLOT(hideOrQuit() ) ); | 281 | connect( this, SIGNAL( lastWindowClosed() ), this, SLOT(hideOrQuit() ) ); |
282 | 282 | ||
283 | QString qcopfn( "/tmp/qcop-msg-" ); | 283 | QString qcopfn( "/tmp/qcop-msg-" ); |
284 | qcopfn += QString( argv[0] ); // append command name to the QCOP name | 284 | qcopfn += QString( argv[0] ); // append command name to the QCOP name |
285 | QFile file( qcopfn ); | 285 | QFile file( qcopfn ); |
286 | if (file.open(IO_ReadOnly ) ) { | 286 | if (file.open(IO_ReadOnly ) ) { |
287 | flock( file.handle(), LOCK_EX ); | 287 | flock( file.handle(), LOCK_EX ); |
288 | } | 288 | } |
289 | 289 | ||
290 | /* Hmmm damn we need to make the parent 0l otherwise it get's deleted | 290 | /* Hmmm damn we need to make the parent 0l otherwise it get's deleted |
291 | * past the QApplication | 291 | * past the QApplication |
292 | */ | 292 | */ |
293 | m_sys = new QCopChannel( "QPE/System", 0l); | 293 | m_sys = new QCopChannel( "QPE/System", 0l); |
294 | connect(m_sys, SIGNAL( received( const QCString&, const QByteArray& ) ), | 294 | connect(m_sys, SIGNAL( received(const QCString&,const QByteArray&) ), |
295 | this, SLOT(systemMessage( const QCString&, const QByteArray& ) ) ); | 295 | this, SLOT(systemMessage(const QCString&,const QByteArray&) ) ); |
296 | 296 | ||
297 | // private channel QPE/Application/appname | 297 | // private channel QPE/Application/appname |
298 | QCString channel = QCString( argv[0] ); | 298 | QCString channel = QCString( argv[0] ); |
299 | channel.replace( QRegExp( ".*/"), "" ); | 299 | channel.replace( QRegExp( ".*/"), "" ); |
300 | d->appName = channel; | 300 | d->appName = channel; |
301 | channel = "QPE/Application/"+ channel; | 301 | channel = "QPE/Application/"+ channel; |
302 | m_pid = new QCopChannel( channel, 0l ); | 302 | m_pid = new QCopChannel( channel, 0l ); |
303 | connect(m_pid, SIGNAL( received( const QCString&, const QByteArray& ) ), | 303 | connect(m_pid, SIGNAL( received(const QCString&,const QByteArray&) ), |
304 | this, SLOT( pidMessage( const QCString&, const QByteArray& ) ) ); | 304 | this, SLOT( pidMessage(const QCString&,const QByteArray&) ) ); |
305 | 305 | ||
306 | // read the Pre QCOP Stuff from the file | 306 | // read the Pre QCOP Stuff from the file |
307 | if ( file.isOpen() ) { | 307 | if ( file.isOpen() ) { |
308 | d->keep_running = FALSE; | 308 | d->keep_running = FALSE; |
309 | QDataStream ds( &file ); | 309 | QDataStream ds( &file ); |
310 | QCString chanel, message; | 310 | QCString chanel, message; |
311 | QByteArray data; | 311 | QByteArray data; |
312 | while (!ds.atEnd() ) { | 312 | while (!ds.atEnd() ) { |
313 | ds >> chanel >> message >> data; | 313 | ds >> chanel >> message >> data; |
314 | d->enqueueQCop( chanel, message, data ); | 314 | d->enqueueQCop( chanel, message, data ); |
315 | } | 315 | } |
316 | flock( file.handle(), LOCK_UN ); | 316 | flock( file.handle(), LOCK_UN ); |
317 | file.close(); | 317 | file.close(); |
318 | file.remove(); | 318 | file.remove(); |
319 | } | 319 | } |
320 | 320 | ||
321 | // read in some stuff from the command line | 321 | // read in some stuff from the command line |
322 | // we do not have setArgs so we need to take | 322 | // we do not have setArgs so we need to take |
323 | // care of that | 323 | // care of that |
324 | for ( int a = 0; a < arg; a++ ) { | 324 | for ( int a = 0; a < arg; a++ ) { |
325 | if ( qstrcmp( argv[a], "-preload" ) == 0 ) { | 325 | if ( qstrcmp( argv[a], "-preload" ) == 0 ) { |
326 | d->preloaded = TRUE; | 326 | d->preloaded = TRUE; |
327 | }else if ( qstrcmp( argv[a ] , "-preload-show" ) == 0 ) { | 327 | }else if ( qstrcmp( argv[a ] , "-preload-show" ) == 0 ) { |
328 | d->preloaded = TRUE; | 328 | d->preloaded = TRUE; |
329 | d->forceshow = TRUE; | 329 | d->forceshow = TRUE; |
330 | } | 330 | } |
331 | } | 331 | } |
332 | initTranslations(); | 332 | initTranslations(); |
333 | applyStyle(); | 333 | applyStyle(); |
334 | 334 | ||
335 | if ( type() == GuiServer ) | 335 | if ( type() == GuiServer ) |
336 | ; | 336 | ; |
337 | 337 | ||
338 | installEventFilter( this ); | 338 | installEventFilter( this ); |
339 | QPEMenuToolFocusManager::initialize(); | 339 | QPEMenuToolFocusManager::initialize(); |
340 | } | 340 | } |
341 | void QPEApplication::initTranslations() { | 341 | void QPEApplication::initTranslations() { |
342 | // Translations add it | 342 | // Translations add it |
343 | QStringList langs = Global::languageList(); | 343 | QStringList langs = Global::languageList(); |
344 | for ( QStringList::ConstIterator it = langs.begin(); it != langs.end(); ++it ) { | 344 | for ( QStringList::ConstIterator it = langs.begin(); it != langs.end(); ++it ) { |
345 | QString lang = *it; | 345 | QString lang = *it; |
346 | 346 | ||
347 | QTranslator * trans; | 347 | QTranslator * trans; |
348 | QString tfn; | 348 | QString tfn; |
349 | 349 | ||
350 | trans = new QTranslator( this ); | 350 | trans = new QTranslator( this ); |
351 | tfn = qpeDir() + "/i18n/" + lang + "/libqpe.qm"; | 351 | tfn = qpeDir() + "/i18n/" + lang + "/libqpe.qm"; |
352 | if ( trans->load( tfn ) ) | 352 | if ( trans->load( tfn ) ) |
353 | installTranslator( trans ); | 353 | installTranslator( trans ); |
354 | else | 354 | else |
355 | delete trans; | 355 | delete trans; |
356 | 356 | ||
357 | trans = new QTranslator( this ); | 357 | trans = new QTranslator( this ); |
358 | tfn = qpeDir() + "/i18n/" + lang + "/" + d->appName + ".qm"; | 358 | tfn = qpeDir() + "/i18n/" + lang + "/" + d->appName + ".qm"; |
359 | if ( trans->load( tfn ) ) | 359 | if ( trans->load( tfn ) ) |
360 | installTranslator( trans ); | 360 | installTranslator( trans ); |
361 | else | 361 | else |
362 | delete trans; | 362 | delete trans; |
363 | } | 363 | } |
364 | } | 364 | } |
365 | QString QPEApplication::qpeDir() { | 365 | QString QPEApplication::qpeDir() { |
366 | const char * base = getenv( "OPIEDIR" ); | 366 | const char * base = getenv( "OPIEDIR" ); |
367 | if ( base ) | 367 | if ( base ) |
368 | return QString( base ) + "/"; | 368 | return QString( base ) + "/"; |
369 | 369 | ||
370 | return QString( "../" ); | 370 | return QString( "../" ); |
371 | } | 371 | } |
372 | QString QPEApplication::documentDir() { | 372 | QString QPEApplication::documentDir() { |
373 | const char* base = getenv( "HOME"); | 373 | const char* base = getenv( "HOME"); |
374 | if ( base ) | 374 | if ( base ) |
375 | return QString( base ) + "/Documents"; | 375 | return QString( base ) + "/Documents"; |
376 | 376 | ||
377 | return QString( "../Documents" ); | 377 | return QString( "../Documents" ); |
378 | } | 378 | } |
379 | void QPEApplication::applyStyle() { | 379 | void QPEApplication::applyStyle() { |
380 | Config config( "qpe" ); | 380 | Config config( "qpe" ); |
381 | 381 | ||
382 | config.setGroup( "Appearance" ); | 382 | config.setGroup( "Appearance" ); |
383 | 383 | ||
384 | // Widget style | 384 | // Widget style |
385 | QString style = config.readEntry( "Style", "Light" ); | 385 | QString style = config.readEntry( "Style", "Light" ); |
386 | internalSetStyle( style ); | 386 | internalSetStyle( style ); |
387 | 387 | ||
388 | // Colors | 388 | // Colors |
389 | QColor bgcolor( config.readEntry( "Background", "#E5E1D5" ) ); | 389 | QColor bgcolor( config.readEntry( "Background", "#E5E1D5" ) ); |
390 | QColor btncolor( config.readEntry( "Button", "#D6CDBB" ) ); | 390 | QColor btncolor( config.readEntry( "Button", "#D6CDBB" ) ); |
391 | QPalette pal( btncolor, bgcolor ); | 391 | QPalette pal( btncolor, bgcolor ); |
392 | QString color = config.readEntry( "Highlight", "#800000" ); | 392 | QString color = config.readEntry( "Highlight", "#800000" ); |
393 | pal.setColor( QColorGroup::Highlight, QColor( color ) ); | 393 | pal.setColor( QColorGroup::Highlight, QColor( color ) ); |
394 | color = config.readEntry( "HighlightedText", "#FFFFFF" ); | 394 | color = config.readEntry( "HighlightedText", "#FFFFFF" ); |
395 | pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); | 395 | pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); |
396 | color = config.readEntry( "Text", "#000000" ); | 396 | color = config.readEntry( "Text", "#000000" ); |
397 | pal.setColor( QColorGroup::Text, QColor( color ) ); | 397 | pal.setColor( QColorGroup::Text, QColor( color ) ); |
398 | color = config.readEntry( "ButtonText", "#000000" ); | 398 | color = config.readEntry( "ButtonText", "#000000" ); |
399 | pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); | 399 | pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); |
400 | color = config.readEntry( "Base", "#FFFFFF" ); | 400 | color = config.readEntry( "Base", "#FFFFFF" ); |
401 | pal.setColor( QColorGroup::Base, QColor( color ) ); | 401 | pal.setColor( QColorGroup::Base, QColor( color ) ); |
402 | 402 | ||
403 | pal.setColor( QPalette::Disabled, QColorGroup::Text, | 403 | pal.setColor( QPalette::Disabled, QColorGroup::Text, |
404 | pal.color( QPalette::Active, QColorGroup::Background ).dark() ); | 404 | pal.color( QPalette::Active, QColorGroup::Background ).dark() ); |
405 | 405 | ||
406 | setPalette( pal, TRUE ); | 406 | setPalette( pal, TRUE ); |
407 | 407 | ||
408 | 408 | ||
409 | 409 | ||
410 | // Font | 410 | // Font |
411 | QString ff = config.readEntry( "FontFamily", font().family() ); | 411 | QString ff = config.readEntry( "FontFamily", font().family() ); |
412 | int fs = config.readNumEntry( "FontSize", font().pointSize() ); | 412 | int fs = config.readNumEntry( "FontSize", font().pointSize() ); |
413 | setFont( QFont(ff, fs) ); | 413 | setFont( QFont(ff, fs) ); |
414 | } | 414 | } |
415 | int QPEApplication::defaultRotation() { | 415 | int QPEApplication::defaultRotation() { |
416 | return 0; | 416 | return 0; |
417 | } | 417 | } |
418 | void QPEApplication::setDefaultRotation(int r ) { | 418 | void QPEApplication::setDefaultRotation(int r ) { |
419 | 419 | ||
420 | } | 420 | } |
421 | void QPEApplication::grabKeyboard() { | 421 | void QPEApplication::grabKeyboard() { |
422 | QPEApplication::Private * d = ( ( QPEApplication* ) qApp ) ->d; | 422 | QPEApplication::Private * d = ( ( QPEApplication* ) qApp ) ->d; |
423 | if ( qApp->type() == QApplication::GuiServer ) | 423 | if ( qApp->type() == QApplication::GuiServer ) |
424 | d->kbgrabber = 0; | 424 | d->kbgrabber = 0; |
425 | else { | 425 | else { |
426 | QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" ); | 426 | QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" ); |
427 | e << d->appName; | 427 | e << d->appName; |
428 | 428 | ||
429 | d->kbgrabber = 2; // me | 429 | d->kbgrabber = 2; // me |
430 | } | 430 | } |
431 | } | 431 | } |
432 | void QPEApplication::ungrabKeyboard() { | 432 | void QPEApplication::ungrabKeyboard() { |
433 | QPEApplication::Private * d = ( ( QPEApplication* ) qApp ) ->d; | 433 | QPEApplication::Private * d = ( ( QPEApplication* ) qApp ) ->d; |
434 | if ( d->kbgrabber == 2 ) { | 434 | if ( d->kbgrabber == 2 ) { |
435 | QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" ); | 435 | QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" ); |
436 | e << QString::null; | 436 | e << QString::null; |
437 | 437 | ||
438 | d->kbregrab = FALSE; | 438 | d->kbregrab = FALSE; |
439 | d->kbgrabber = 0; | 439 | d->kbgrabber = 0; |
440 | } | 440 | } |
441 | } | 441 | } |
442 | void QPEApplication::showMainWidget( QWidget* wid, bool b) { | 442 | void QPEApplication::showMainWidget( QWidget* wid, bool b) { |
443 | d->show(wid, b ); | 443 | d->show(wid, b ); |
444 | } | 444 | } |
445 | void QPEApplication::showMainDocumentWidget( QWidget* mw, bool m) { | 445 | void QPEApplication::showMainDocumentWidget( QWidget* mw, bool m) { |
446 | if ( mw && argc() == 2 ) | 446 | if ( mw && argc() == 2 ) |
447 | Global::setDocument( mw, QString::fromUtf8(argv()[1] ) ); | 447 | Global::setDocument( mw, QString::fromUtf8(argv()[1] ) ); |
448 | 448 | ||
449 | d->show(mw, m ); | 449 | d->show(mw, m ); |
450 | } | 450 | } |
451 | void QPEApplication::showDialog( QDialog* d, bool nomax ) { | 451 | void QPEApplication::showDialog( QDialog* d, bool nomax ) { |
452 | QSize sh = d->sizeHint(); | 452 | QSize sh = d->sizeHint(); |
453 | int w = QMAX(sh.width(),d->width()); | 453 | int w = QMAX(sh.width(),d->width()); |
454 | int h = QMAX(sh.height(),d->height()); | 454 | int h = QMAX(sh.height(),d->height()); |
455 | if ( !nomax | 455 | if ( !nomax |
456 | && ( w > qApp->desktop()->width()*3/4 | 456 | && ( w > qApp->desktop()->width()*3/4 |
457 | || h > qApp->desktop()->height()*3/4 ) ) | 457 | || h > qApp->desktop()->height()*3/4 ) ) |
458 | { | 458 | { |
459 | d->showMaximized(); | 459 | d->showMaximized(); |
460 | } else { | 460 | } else { |
461 | d->resize(w,h); | 461 | d->resize(w,h); |
462 | d->show(); | 462 | d->show(); |
463 | } | 463 | } |
464 | } | 464 | } |
465 | int QPEApplication::execDialog( QDialog* d, bool nomax) { | 465 | int QPEApplication::execDialog( QDialog* d, bool nomax) { |
466 | showDialog(d,nomax); | 466 | showDialog(d,nomax); |
467 | return d->exec(); | 467 | return d->exec(); |
468 | } | 468 | } |
469 | void QPEApplication::setKeepRunning() { | 469 | void QPEApplication::setKeepRunning() { |
470 | if ( qApp && qApp->inherits( "QPEApplication" ) ) { | 470 | if ( qApp && qApp->inherits( "QPEApplication" ) ) { |
471 | QPEApplication * qpeApp = ( QPEApplication* ) qApp; | 471 | QPEApplication * qpeApp = ( QPEApplication* ) qApp; |
472 | qpeApp->d->keep_running = TRUE; | 472 | qpeApp->d->keep_running = TRUE; |
473 | } | 473 | } |
474 | } | 474 | } |
475 | bool QPEApplication::keepRunning()const { | 475 | bool QPEApplication::keepRunning()const { |
476 | return d->keep_running; | 476 | return d->keep_running; |
477 | } | 477 | } |
478 | bool QPEApplication::keyboardGrabbed()const { | 478 | bool QPEApplication::keyboardGrabbed()const { |
479 | return d->kbgrabber; | 479 | return d->kbgrabber; |
480 | } | 480 | } |
481 | int QPEApplication::exec() { | 481 | int QPEApplication::exec() { |
482 | /* now send the QCOP stuff gotten from the file */ | 482 | /* now send the QCOP stuff gotten from the file */ |
483 | d->sendQCopQ(); | 483 | d->sendQCopQ(); |
484 | 484 | ||
485 | if ( d->keep_running ) { | 485 | if ( d->keep_running ) { |
486 | qWarning("going to exec"); | 486 | qWarning("going to exec"); |
487 | int a = QApplication::exec(); | 487 | int a = QApplication::exec(); |
488 | qWarning("left"); | 488 | qWarning("left"); |
489 | return a; | 489 | return a; |
490 | } | 490 | } |
491 | 491 | ||
492 | { | 492 | { |
493 | QCopEnvelope e( "QPE/System", "closing(QString)" ); | 493 | QCopEnvelope e( "QPE/System", "closing(QString)" ); |
494 | e << d->appName; | 494 | e << d->appName; |
495 | } | 495 | } |
496 | qWarning("processing events!"); | 496 | qWarning("processing events!"); |
497 | processEvents(); | 497 | processEvents(); |
498 | return 0; | 498 | return 0; |
499 | } | 499 | } |
500 | void QPEApplication::internalSetStyle( const QString& ) { | 500 | void QPEApplication::internalSetStyle( const QString& ) { |
501 | 501 | ||
502 | } | 502 | } |
503 | void QPEApplication::systemMessage( const QCString& chan, const QByteArray& ) { | 503 | void QPEApplication::systemMessage( const QCString& chan, const QByteArray& ) { |
504 | qWarning("QPEApplication::systemMessage( %s )", chan.data() ); | 504 | qWarning("QPEApplication::systemMessage( %s )", chan.data() ); |
505 | } | 505 | } |
506 | void QPEApplication::pidMessage( const QCString& msg, const QByteArray& ) { | 506 | void QPEApplication::pidMessage( const QCString& msg, const QByteArray& ) { |
507 | if ( msg == "flush()" ) { | 507 | if ( msg == "flush()" ) { |
508 | emit flush(); | 508 | emit flush(); |
509 | QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); | 509 | QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); |
510 | e << d->appName; | 510 | e << d->appName; |
511 | }else if ( msg == "reload()" ) { | 511 | }else if ( msg == "reload()" ) { |
512 | emit reload(); | 512 | emit reload(); |
513 | } | 513 | } |
514 | 514 | ||
515 | } | 515 | } |
516 | void QPEApplication::timerEvent( QTimerEvent* e ) { | 516 | void QPEApplication::timerEvent( QTimerEvent* e ) { |
517 | if ( e->timerId() == d->presstimer && d->presswidget ) { | 517 | if ( e->timerId() == d->presstimer && d->presswidget ) { |
518 | // Right pressed | 518 | // Right pressed |
519 | postEvent( d->presswidget, | 519 | postEvent( d->presswidget, |
520 | new QMouseEvent( QEvent::MouseButtonPress, d->presspos, | 520 | new QMouseEvent( QEvent::MouseButtonPress, d->presspos, |
521 | RightButton, LeftButton ) ); | 521 | RightButton, LeftButton ) ); |
522 | killTimer( d->presstimer ); | 522 | killTimer( d->presstimer ); |
523 | d->presstimer = 0; | 523 | d->presstimer = 0; |
524 | } | 524 | } |
525 | } | 525 | } |
526 | 526 | ||
527 | // InputMethods Hints | 527 | // InputMethods Hints |
528 | namespace { | 528 | namespace { |
529 | static QPtrDict<void>* inputMethodDict = 0; | 529 | static QPtrDict<void>* inputMethodDict = 0; |
530 | static void createInputMethodDict(){ | 530 | static void createInputMethodDict(){ |
531 | if ( !inputMethodDict ) | 531 | if ( !inputMethodDict ) |
532 | inputMethodDict = new QPtrDict<void>; | 532 | inputMethodDict = new QPtrDict<void>; |
533 | } | 533 | } |
534 | 534 | ||
535 | static QPtrDict<void>* stylusDict = 0; | 535 | static QPtrDict<void>* stylusDict = 0; |
536 | static void createDict() { | 536 | static void createDict() { |
537 | if ( !stylusDict ) | 537 | if ( !stylusDict ) |
538 | stylusDict = new QPtrDict<void>; | 538 | stylusDict = new QPtrDict<void>; |
539 | } | 539 | } |
540 | }; | 540 | }; |
541 | 541 | ||
542 | void QPEApplication::setInputMethodHint( QWidget* w, InputMethodHint mode ) { | 542 | void QPEApplication::setInputMethodHint( QWidget* w, InputMethodHint mode ) { |
543 | createInputMethodDict(); | 543 | createInputMethodDict(); |
544 | if ( mode == Normal ) { | 544 | if ( mode == Normal ) { |
545 | inputMethodDict->remove | 545 | inputMethodDict->remove |
546 | ( w ); | 546 | ( w ); |
547 | }else { | 547 | }else { |
548 | inputMethodDict->insert( w, ( void* ) mode ); | 548 | inputMethodDict->insert( w, ( void* ) mode ); |
549 | } | 549 | } |
550 | } | 550 | } |
551 | QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget* w) { | 551 | QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget* w) { |
552 | if ( inputMethodDict && w ) | 552 | if ( inputMethodDict && w ) |
553 | return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); | 553 | return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); |
554 | return Normal; | 554 | return Normal; |
555 | } | 555 | } |
556 | 556 | ||
557 | 557 | ||
558 | void QPEApplication::removeSenderFromStylusDict() { | 558 | void QPEApplication::removeSenderFromStylusDict() { |
559 | stylusDict->remove( ( void* ) sender() ); | 559 | stylusDict->remove( ( void* ) sender() ); |
560 | if ( d->presswidget == sender() ) | 560 | if ( d->presswidget == sender() ) |
561 | d->presswidget = 0; | 561 | d->presswidget = 0; |
562 | } | 562 | } |
563 | void QPEApplication::setStylusOperation( QWidget* w, StylusMode mode) { | 563 | void QPEApplication::setStylusOperation( QWidget* w, StylusMode mode) { |
564 | createDict(); | 564 | createDict(); |
565 | if ( mode == LeftOnly ) { | 565 | if ( mode == LeftOnly ) { |
566 | stylusDict->remove | 566 | stylusDict->remove |
567 | ( w ); | 567 | ( w ); |
568 | w->removeEventFilter( qApp ); | 568 | w->removeEventFilter( qApp ); |
569 | }else { | 569 | }else { |
570 | stylusDict->insert( w, ( void* ) mode ); | 570 | stylusDict->insert( w, ( void* ) mode ); |
571 | connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) ); | 571 | connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) ); |
572 | w->installEventFilter( qApp ); | 572 | w->installEventFilter( qApp ); |
573 | } | 573 | } |
574 | } | 574 | } |
575 | QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w) { | 575 | QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w) { |
576 | if ( stylusDict ) | 576 | if ( stylusDict ) |
577 | return ( StylusMode ) ( int ) stylusDict->find( w ); | 577 | return ( StylusMode ) ( int ) stylusDict->find( w ); |
578 | return LeftOnly; | 578 | return LeftOnly; |
579 | } | 579 | } |
580 | 580 | ||
581 | // eventFilter...... | 581 | // eventFilter...... |
582 | bool QPEApplication::eventFilter( QObject* o, QEvent* e ) { | 582 | bool QPEApplication::eventFilter( QObject* o, QEvent* e ) { |
583 | /* | 583 | /* |
584 | * We want our WM to show Ok and a X button | 584 | * We want our WM to show Ok and a X button |
585 | * on dialogs | 585 | * on dialogs |
586 | * our part is to set the _NET_WM_CONTEXT_ACCEPT | 586 | * our part is to set the _NET_WM_CONTEXT_ACCEPT |
587 | * propery | 587 | * propery |
588 | * and then wait for a client message -zecke | 588 | * and then wait for a client message -zecke |
589 | * on show we will add the prop | 589 | * on show we will add the prop |
590 | */ | 590 | */ |
591 | if (o->inherits("QDialog") && e->type() == QEvent::Show ) { | 591 | if (o->inherits("QDialog") && e->type() == QEvent::Show ) { |
592 | QDialog* dialog = (QDialog*)o; | 592 | QDialog* dialog = (QDialog*)o; |
593 | Atom wm_prot[45]; | 593 | Atom wm_prot[45]; |
594 | int n = 0; | 594 | int n = 0; |
595 | wm_prot[n++] = d->wm_delete_window; | 595 | wm_prot[n++] = d->wm_delete_window; |
596 | wm_prot[n++] = d->wm_take_focus; | 596 | wm_prot[n++] = d->wm_take_focus; |
597 | wm_prot[n++] = d->wm_context_accept; | 597 | wm_prot[n++] = d->wm_context_accept; |
598 | if ( dialog->testWFlags( WStyle_ContextHelp ) ) | 598 | if ( dialog->testWFlags( WStyle_ContextHelp ) ) |
599 | wm_prot[n++] = d->wm_context_help; | 599 | wm_prot[n++] = d->wm_context_help; |
600 | XSetWMProtocols( qt_xdisplay(), dialog->winId(), wm_prot, n ); | 600 | XSetWMProtocols( qt_xdisplay(), dialog->winId(), wm_prot, n ); |
601 | return TRUE; // should be save | 601 | return TRUE; // should be save |
602 | } | 602 | } |
603 | if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { | 603 | if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { |
604 | QMouseEvent * me = ( QMouseEvent* ) e; | 604 | QMouseEvent * me = ( QMouseEvent* ) e; |
605 | StylusMode mode = (StylusMode)(int)stylusDict->find(o); | 605 | StylusMode mode = (StylusMode)(int)stylusDict->find(o); |
606 | switch (mode) { | 606 | switch (mode) { |
607 | case RightOnHold: | 607 | case RightOnHold: |
608 | switch ( me->type() ) { | 608 | switch ( me->type() ) { |
609 | case QEvent::MouseButtonPress: | 609 | case QEvent::MouseButtonPress: |
610 | if ( me->button() == LeftButton ) { | 610 | if ( me->button() == LeftButton ) { |
611 | d->presstimer = startTimer(500); // #### pref. | 611 | d->presstimer = startTimer(500); // #### pref. |
612 | d->presswidget = (QWidget*)o; | 612 | d->presswidget = (QWidget*)o; |
613 | d->presspos = me->pos(); | 613 | d->presspos = me->pos(); |
614 | d->rightpressed = FALSE; | 614 | d->rightpressed = FALSE; |
615 | } | 615 | } |
616 | break; | 616 | break; |
617 | case QEvent::MouseMove: | 617 | case QEvent::MouseMove: |
618 | if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) { | 618 | if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) { |
619 | killTimer(d->presstimer); | 619 | killTimer(d->presstimer); |
620 | d->presstimer = 0; | 620 | d->presstimer = 0; |
621 | } | 621 | } |
622 | break; | 622 | break; |
623 | case QEvent::MouseButtonRelease: | 623 | case QEvent::MouseButtonRelease: |
624 | if ( me->button() == LeftButton ) { | 624 | if ( me->button() == LeftButton ) { |
625 | if ( d->presstimer ) { | 625 | if ( d->presstimer ) { |
626 | killTimer(d->presstimer); | 626 | killTimer(d->presstimer); |
627 | d->presstimer = 0; | 627 | d->presstimer = 0; |
628 | } | 628 | } |
629 | if ( d->rightpressed && d->presswidget ) { | 629 | if ( d->rightpressed && d->presswidget ) { |
630 | // Right released | 630 | // Right released |
631 | postEvent( d->presswidget, | 631 | postEvent( d->presswidget, |
632 | new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), | 632 | new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), |
633 | RightButton, LeftButton + RightButton ) ); | 633 | RightButton, LeftButton + RightButton ) ); |
634 | // Left released, off-widget | 634 | // Left released, off-widget |
635 | postEvent( d->presswidget, | 635 | postEvent( d->presswidget, |
636 | new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1), | 636 | new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1), |
637 | LeftButton, LeftButton ) ); | 637 | LeftButton, LeftButton ) ); |
638 | postEvent( d->presswidget, | 638 | postEvent( d->presswidget, |
639 | new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1), | 639 | new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1), |
640 | LeftButton, LeftButton ) ); | 640 | LeftButton, LeftButton ) ); |
641 | d->rightpressed = FALSE; | 641 | d->rightpressed = FALSE; |
642 | return TRUE; // don't send the real Left release | 642 | return TRUE; // don't send the real Left release |
643 | } | 643 | } |
644 | } | 644 | } |
645 | break; | 645 | break; |
646 | default: | 646 | default: |
647 | break; | 647 | break; |
648 | } | 648 | } |
649 | break; | 649 | break; |
650 | default: | 650 | default: |
651 | ; | 651 | ; |
652 | } | 652 | } |
653 | } | 653 | } |
654 | else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { | 654 | else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { |
655 | QKeyEvent *ke = (QKeyEvent *)e; | 655 | QKeyEvent *ke = (QKeyEvent *)e; |
656 | if ( ke->key() == Key_Enter ) { | 656 | if ( ke->key() == Key_Enter ) { |
657 | if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { | 657 | if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { |
658 | postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', | 658 | postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', |
659 | ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); | 659 | ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); |
660 | return TRUE; | 660 | return TRUE; |
661 | } | 661 | } |
662 | } | 662 | } |
663 | } | 663 | } |
664 | return FALSE; | 664 | return FALSE; |
665 | } | 665 | } |
666 | 666 | ||
667 | // Quit stuff | 667 | // Quit stuff |
668 | void QPEApplication::restart() { | 668 | void QPEApplication::restart() { |
669 | 669 | ||
670 | } | 670 | } |
671 | void QPEApplication::shutdown() { | 671 | void QPEApplication::shutdown() { |
672 | 672 | ||
673 | } | 673 | } |
674 | void QPEApplication::tryQuit() { | 674 | void QPEApplication::tryQuit() { |
675 | qWarning("TryQuit!!"); | 675 | qWarning("TryQuit!!"); |
676 | if ( activeModalWidget() || strcmp( argv() [ 0 ], "embeddedkonsole" ) == 0 ) | 676 | if ( activeModalWidget() || strcmp( argv() [ 0 ], "embeddedkonsole" ) == 0 ) |
677 | return ; // Inside modal loop or konsole. Too hard to save state. | 677 | return ; // Inside modal loop or konsole. Too hard to save state. |
678 | { | 678 | { |
679 | QCopEnvelope e( "QPE/System", "closing(QString)" ); | 679 | QCopEnvelope e( "QPE/System", "closing(QString)" ); |
680 | e << d->appName; | 680 | e << d->appName; |
681 | } | 681 | } |
682 | processEvents(); | 682 | processEvents(); |
683 | 683 | ||
684 | quit(); | 684 | quit(); |
685 | } | 685 | } |
686 | void QPEApplication::hideOrQuit() { | 686 | void QPEApplication::hideOrQuit() { |
687 | qWarning("hide or close"); | 687 | qWarning("hide or close"); |
688 | processEvents(); | 688 | processEvents(); |
diff --git a/x11/libqpe-x11/qt/qcopchannel_qws.cpp b/x11/libqpe-x11/qt/qcopchannel_qws.cpp index 706756e..a82ba4d 100644 --- a/x11/libqpe-x11/qt/qcopchannel_qws.cpp +++ b/x11/libqpe-x11/qt/qcopchannel_qws.cpp | |||
@@ -1,83 +1,83 @@ | |||
1 | 1 | ||
2 | #include "../../ipc/client/ocopclient.h" | 2 | #include "../../ipc/client/ocopclient.h" |
3 | 3 | ||
4 | #include <qcopchannel_qws.h> | 4 | #include <qcopchannel_qws.h> |
5 | 5 | ||
6 | QList<QCopChannel>* QCopChannel::m_list = 0; | 6 | QList<QCopChannel>* QCopChannel::m_list = 0; |
7 | QMap<QCString, int> QCopChannel::m_refCount; | 7 | QMap<QCString, int> QCopChannel::m_refCount; |
8 | 8 | ||
9 | QCopChannel::QCopChannel( const QCString& channel, QObject* parent, | 9 | QCopChannel::QCopChannel( const QCString& channel, QObject* parent, |
10 | const char* name ) | 10 | const char* name ) |
11 | : QObject( parent, name ),m_chan(channel) { | 11 | : QObject( parent, name ),m_chan(channel) { |
12 | if (!m_list ) { | 12 | if (!m_list ) { |
13 | m_list = new QList<QCopChannel>; | 13 | m_list = new QList<QCopChannel>; |
14 | /* only connect once */ | 14 | /* only connect once */ |
15 | connect(OCOPClient::self(), SIGNAL(called(const QCString&, const QCString&, const QByteArray& ) ), | 15 | connect(OCOPClient::self(), SIGNAL(called(const QCString&,const QCString&,const QByteArray&) ), |
16 | this, SLOT(rev(const QCString&, const QCString&, const QByteArray&) ) ); | 16 | this, SLOT(rev(const QCString&,const QCString&,const QByteArray&) ) ); |
17 | } | 17 | } |
18 | /* first registration or ref count is 0 for m_chan*/ | 18 | /* first registration or ref count is 0 for m_chan*/ |
19 | if (!m_refCount.contains( m_chan ) || !m_refCount[m_chan] ) { | 19 | if (!m_refCount.contains( m_chan ) || !m_refCount[m_chan] ) { |
20 | qWarning("adding channel %s", m_chan.data() ); | 20 | qWarning("adding channel %s", m_chan.data() ); |
21 | m_refCount[m_chan] = 1; | 21 | m_refCount[m_chan] = 1; |
22 | OCOPClient::self()->addChannel( m_chan ); | 22 | OCOPClient::self()->addChannel( m_chan ); |
23 | }else{ | 23 | }else{ |
24 | qWarning("reffing up for %s %d", m_chan.data(), m_refCount[m_chan] ); | 24 | qWarning("reffing up for %s %d", m_chan.data(), m_refCount[m_chan] ); |
25 | m_refCount[m_chan]++; | 25 | m_refCount[m_chan]++; |
26 | } | 26 | } |
27 | 27 | ||
28 | m_list->append(this); | 28 | m_list->append(this); |
29 | } | 29 | } |
30 | void QCopChannel::receive( const QCString& msg, const QByteArray& ar ) { | 30 | void QCopChannel::receive( const QCString& msg, const QByteArray& ar ) { |
31 | emit received( msg, ar ); | 31 | emit received( msg, ar ); |
32 | } | 32 | } |
33 | QCopChannel::~QCopChannel() { | 33 | QCopChannel::~QCopChannel() { |
34 | if (m_refCount[m_chan] == 1 ) { | 34 | if (m_refCount[m_chan] == 1 ) { |
35 | OCOPClient::self()->delChannel( m_chan ); | 35 | OCOPClient::self()->delChannel( m_chan ); |
36 | m_refCount[m_chan] = 0; | 36 | m_refCount[m_chan] = 0; |
37 | }else | 37 | }else |
38 | m_refCount[m_chan]--; | 38 | m_refCount[m_chan]--; |
39 | 39 | ||
40 | 40 | ||
41 | m_list->remove(this); | 41 | m_list->remove(this); |
42 | if (m_list->count() == 0 ) { | 42 | if (m_list->count() == 0 ) { |
43 | delete m_list; | 43 | delete m_list; |
44 | m_list = 0; | 44 | m_list = 0; |
45 | } | 45 | } |
46 | 46 | ||
47 | } | 47 | } |
48 | QCString QCopChannel::channel()const { | 48 | QCString QCopChannel::channel()const { |
49 | return m_chan; | 49 | return m_chan; |
50 | } | 50 | } |
51 | bool QCopChannel::isRegistered( const QCString& chan) { | 51 | bool QCopChannel::isRegistered( const QCString& chan) { |
52 | if (m_refCount.contains(chan) ) { | 52 | if (m_refCount.contains(chan) ) { |
53 | qDebug("Client:locally contains"); | 53 | qDebug("Client:locally contains"); |
54 | return true; | 54 | return true; |
55 | } | 55 | } |
56 | return OCOPClient::self()->isRegistered( chan ); | 56 | return OCOPClient::self()->isRegistered( chan ); |
57 | } | 57 | } |
58 | bool QCopChannel::send( const QCString& chan, const QCString& msg ) { | 58 | bool QCopChannel::send( const QCString& chan, const QCString& msg ) { |
59 | QByteArray ar; | 59 | QByteArray ar; |
60 | return send(chan, msg, ar ); | 60 | return send(chan, msg, ar ); |
61 | } | 61 | } |
62 | bool QCopChannel::send( const QCString& chan, const QCString& msg, | 62 | bool QCopChannel::send( const QCString& chan, const QCString& msg, |
63 | const QByteArray& ar ) { | 63 | const QByteArray& ar ) { |
64 | OCOPClient::self()->send( chan, msg, ar ); | 64 | OCOPClient::self()->send( chan, msg, ar ); |
65 | return true; | 65 | return true; |
66 | } | 66 | } |
67 | bool QCopChannel::sendLocally( const QCString& chann, const QCString& msg, | 67 | bool QCopChannel::sendLocally( const QCString& chann, const QCString& msg, |
68 | const QByteArray& ar ) { | 68 | const QByteArray& ar ) { |
69 | qWarning("Client:sendLocally %s %s", chann.data(), msg.data() ); | 69 | qWarning("Client:sendLocally %s %s", chann.data(), msg.data() ); |
70 | if (!m_list ) | 70 | if (!m_list ) |
71 | return true; | 71 | return true; |
72 | QCopChannel* chan; | 72 | QCopChannel* chan; |
73 | 73 | ||
74 | for ( chan = m_list->first(); chan; chan = m_list->next() ) { | 74 | for ( chan = m_list->first(); chan; chan = m_list->next() ) { |
75 | if ( chan->channel() == chann ) | 75 | if ( chan->channel() == chann ) |
76 | chan->receive( msg, ar ); | 76 | chan->receive( msg, ar ); |
77 | } | 77 | } |
78 | 78 | ||
79 | return true; | 79 | return true; |
80 | } | 80 | } |
81 | void QCopChannel::rev( const QCString& chan, const QCString& msg, const QByteArray& ar ) { | 81 | void QCopChannel::rev( const QCString& chan, const QCString& msg, const QByteArray& ar ) { |
82 | sendLocally( chan, msg, ar ); | 82 | sendLocally( chan, msg, ar ); |
83 | } | 83 | } |