summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/serverinterface.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/core/launcher/serverinterface.cpp b/core/launcher/serverinterface.cpp
index 7002243..9eb7f75 100644
--- a/core/launcher/serverinterface.cpp
+++ b/core/launcher/serverinterface.cpp
@@ -1,372 +1,374 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include "serverinterface.h" 20#include "serverinterface.h"
21#include "server.h" 21#include "server.h"
22#include "documentlist.h" 22#include "documentlist.h"
23 23
24#include <qtopia/qpeapplication.h> 24#include <qtopia/qpeapplication.h>
25#include <qwindowsystem_qws.h> 25#include <qwindowsystem_qws.h>
26#include <qgfx_qws.h> 26#include <qgfx_qws.h>
27 27
28class LayoutManager : public QObject 28class LayoutManager : public QObject
29{ 29{
30 Q_OBJECT 30 Q_OBJECT
31public: 31public:
32 LayoutManager(); 32 LayoutManager();
33 33
34 void addDocked( QWidget *w, ServerInterface::DockArea placement ); 34 void addDocked( QWidget *w, ServerInterface::DockArea placement );
35 35
36private: 36private:
37 struct Item { 37 struct Item {
38 QWidget *w; 38 QWidget *w;
39 ServerInterface::DockArea p; 39 ServerInterface::DockArea p;
40 }; 40 };
41 41
42 bool eventFilter( QObject *object, QEvent *event ); 42 bool eventFilter( QObject *object, QEvent *event );
43 void layout(); 43 void layout();
44 Item *findWidget( const QWidget *w ) const; 44 Item *findWidget( const QWidget *w ) const;
45 45
46 QList<Item> docked; 46 QList<Item> docked;
47}; 47};
48 48
49LayoutManager::LayoutManager() 49LayoutManager::LayoutManager()
50{ 50{
51 docked.setAutoDelete( TRUE ); 51 docked.setAutoDelete( TRUE );
52 qApp->desktop()->installEventFilter( this ); 52 qApp->desktop()->installEventFilter( this );
53} 53}
54 54
55void LayoutManager::addDocked( QWidget *w, ServerInterface::DockArea placement ) 55void LayoutManager::addDocked( QWidget *w, ServerInterface::DockArea placement )
56{ 56{
57 Item *i = new Item; 57 Item *i = new Item;
58 i->w = w; 58 i->w = w;
59 i->p = placement; 59 i->p = placement;
60 w->installEventFilter( this ); 60 w->installEventFilter( this );
61 docked.append(i); 61 docked.append(i);
62 layout(); 62 layout();
63} 63}
64 64
65bool LayoutManager::eventFilter( QObject *object, QEvent *event ) 65bool LayoutManager::eventFilter( QObject *object, QEvent *event )
66{ 66{
67 if ( object == qApp->desktop() ) { 67 if ( object == qApp->desktop() ) {
68 if ( event->type() == QEvent::Resize ) 68 if ( event->type() == QEvent::Resize )
69 layout(); 69 layout();
70 return QObject::eventFilter( object, event ); 70 return QObject::eventFilter( object, event );
71 } 71 }
72 72
73 Item *item; 73 Item *item;
74 74
75 switch ( event->type() ) { 75 switch ( event->type() ) {
76 case QEvent::Destroy: 76 case QEvent::Destroy:
77 item = findWidget( (QWidget *)object ); 77 item = findWidget( (QWidget *)object );
78 if ( item ) { 78 if ( item ) {
79 docked.removeRef( item ); 79 docked.removeRef( item );
80 layout(); 80 layout();
81 } 81 }
82 break; 82 break;
83 83
84 case QEvent::Hide: 84 case QEvent::Hide:
85 case QEvent::Show: 85 case QEvent::Show:
86 item = findWidget( (QWidget *)object ); 86 item = findWidget( (QWidget *)object );
87 if ( item ) 87 if ( item )
88 layout(); 88 layout();
89 break; 89 break;
90 90
91 default: 91 default:
92 break; 92 break;
93 } 93 }
94 94
95 return QObject::eventFilter( object, event ); 95 return QObject::eventFilter( object, event );
96} 96}
97 97
98void LayoutManager::layout() 98void LayoutManager::layout()
99{ 99{
100 QRect mwr( qApp->desktop()->geometry() ); 100 QRect mwr( qApp->desktop()->geometry() );
101 QListIterator<Item> it( docked ); 101 QListIterator<Item> it( docked );
102 Item *item; 102 Item *item;
103 for ( ; (item = it.current()); ++it ) { 103 for ( ; (item = it.current()); ++it ) {
104 QWidget *w = item->w; 104 QWidget *w = item->w;
105 if ( !w->isVisible() ) 105 if ( !w->isVisible() )
106 continue; 106 continue;
107
108 QSize sh = w->sizeHint();
107 switch ( item->p ) { 109 switch ( item->p ) {
108 case ServerInterface::Top: 110 case ServerInterface::Top:
109 w->resize( mwr.width(), w->sizeHint().height() ); 111 w->setGeometry( mwr.left(), mwr.top(),
110 w->move( mwr.topLeft() ); 112 mwr.width(), sh.height() );
111 mwr.setTop( w->geometry().bottom() + 1 ); 113 mwr.setTop( w->geometry().bottom() + 1 );
112 break; 114 break;
113 case ServerInterface::Bottom: 115 case ServerInterface::Bottom:
114 w->resize( mwr.width(), w->sizeHint().height() ); 116 w->setGeometry( mwr.left(), mwr.bottom() - sh.height(),
115 w->move( mwr.left(), mwr.bottom()-w->height()+1 ); 117 mwr.width(), sh.height() );
116 mwr.setBottom( w->geometry().top() - 1 ); 118 mwr.setBottom( w->geometry().top() - 1 );
117 break; 119 break;
118 case ServerInterface::Left: 120 case ServerInterface::Left:
119 w->resize( w->sizeHint().width(), mwr.height() ); 121 w->setGeometry( mwr.left(), mwr.top(),
120 w->move( mwr.topLeft() ); 122 sh.width(), mwr.height() );
121 mwr.setLeft( w->geometry().right() + 1 ); 123 mwr.setLeft( w->geometry().right() + 1 );
122 break; 124 break;
123 case ServerInterface::Right: 125 case ServerInterface::Right:
124 w->resize( w->sizeHint().width(), mwr.height() ); 126 w->setGeometry( mwr.right() - sh.width(), mwr.top(),
125 w->move( mwr.right()-w->width()+1, mwr.top() ); 127 sh.width(), mwr.height() );
126 mwr.setRight( w->geometry().left() - 1 ); 128 mwr.setRight( w->geometry().left() - 1 );
127 break; 129 break;
128 } 130 }
129 } 131 }
130 132
131#ifdef Q_WS_QWS 133#ifdef Q_WS_QWS
132# if QT_VERSION < 0x030000 134# if QT_VERSION < 0x030000
133 QWSServer::setMaxWindowRect( qt_screen->mapToDevice(mwr, 135 QWSServer::setMaxWindowRect( qt_screen->mapToDevice(mwr,
134 QSize(qt_screen->width(),qt_screen->height())) ); 136 QSize(qt_screen->width(),qt_screen->height())) );
135# else 137# else
136 QWSServer::setMaxWindowRect( mwr ); 138 QWSServer::setMaxWindowRect( mwr );
137# endif 139# endif
138#endif 140#endif
139} 141}
140 142
141LayoutManager::Item *LayoutManager::findWidget( const QWidget *w ) const 143LayoutManager::Item *LayoutManager::findWidget( const QWidget *w ) const
142{ 144{
143 QListIterator<Item> it( docked ); 145 QListIterator<Item> it( docked );
144 Item *item; 146 Item *item;
145 for ( ; (item = it.current()); ++it ) { 147 for ( ; (item = it.current()); ++it ) {
146 if ( item->w == w ) 148 if ( item->w == w )
147 return item; 149 return item;
148 } 150 }
149 151
150 return 0; 152 return 0;
151} 153}
152 154
153//--------------------------------------------------------------------------- 155//---------------------------------------------------------------------------
154 156
155/*! \class ServerInterface serverinterface.h 157/*! \class ServerInterface serverinterface.h
156 \brief The ServerInterface class provides an interface for Qtopia 158 \brief The ServerInterface class provides an interface for Qtopia
157 custom launchers. 159 custom launchers.
158 160
159 The ServerInterface allows the user interface of the launcher to be 161 The ServerInterface allows the user interface of the launcher to be
160 customized to suit the device. For a PDA style device, the default 162 customized to suit the device. For a PDA style device, the default
161 launcher is strongly recommended, however specialist devices may 163 launcher is strongly recommended, however specialist devices may
162 choose to provide a launcher better suited to the application. 164 choose to provide a launcher better suited to the application.
163 165
164 The launcher is fixed for any particular device and is not loaded 166 The launcher is fixed for any particular device and is not loaded
165 as a plugin. Launcher interfaces must 167 as a plugin. Launcher interfaces must
166 be compilied into the server by editing server.pro and server.cpp. 168 be compilied into the server by editing server.pro and server.cpp.
167*/ 169*/
168 170
169/*! 171/*!
170 \fn ServerInterface::createGUI() 172 \fn ServerInterface::createGUI()
171 173
172 Implement this function to create the custom launcher UI. 174 Implement this function to create the custom launcher UI.
173*/ 175*/
174 176
175/*! 177/*!
176 \fn ServerInterface::destroyGUI() 178 \fn ServerInterface::destroyGUI()
177 179
178 Implement this function to destroy the custom launcher UI. All resources 180 Implement this function to destroy the custom launcher UI. All resources
179 allocated by createGUI() must be released. 181 allocated by createGUI() must be released.
180*/ 182*/
181 183
182/*! 184/*!
183 \enum ServerInterface::ApplicationState 185 \enum ServerInterface::ApplicationState
184 186
185 The ApplicationState enum type specifies the state of an application. 187 The ApplicationState enum type specifies the state of an application.
186 The possible values are: <ul> 188 The possible values are: <ul>
187 189
188 <li> \c Launching - the application has been requested, but is not yet running. 190 <li> \c Launching - the application has been requested, but is not yet running.
189 <li> \c Running - the application is running. 191 <li> \c Running - the application is running.
190 <li> \c Terminated - the application has been terminated. 192 <li> \c Terminated - the application has been terminated.
191</ul> 193</ul>
192*/ 194*/
193 195
194/*! 196/*!
195 \fn ServerInterface::applicationStateChanged(const QString& name, ApplicationState state) 197 \fn ServerInterface::applicationStateChanged(const QString& name, ApplicationState state)
196 198
197 The application \a name has changed state to \a state. This can be used 199 The application \a name has changed state to \a state. This can be used
198 to show launch notification and update a list of running applications. 200 to show launch notification and update a list of running applications.
199*/ 201*/
200 202
201/*! 203/*!
202 \fn ServerInterface::typeAdded(const QString& type, const QString& name, const QPixmap& pixmap, const QPixmap& bgPixmap) 204 \fn ServerInterface::typeAdded(const QString& type, const QString& name, const QPixmap& pixmap, const QPixmap& bgPixmap)
203 205
204 An application category \a type has been added, for example "Games". 206 An application category \a type has been added, for example "Games".
205 \a name is the translated name of the category. \a pixmap and 207 \a name is the translated name of the category. \a pixmap and
206 \a bgPixmap are small and large icons for the new type. 208 \a bgPixmap are small and large icons for the new type.
207 209
208 Types can be added or removed at any time, for example, when a storage 210 Types can be added or removed at any time, for example, when a storage
209 card containing a non-standard category is inserted or removed. 211 card containing a non-standard category is inserted or removed.
210 212
211 \sa typeRemoved() 213 \sa typeRemoved()
212*/ 214*/
213 215
214/*! 216/*!
215 \fn ServerInterface::typeRemoved(const QString& type) 217 \fn ServerInterface::typeRemoved(const QString& type)
216 218
217 An application category \a type has been removed. 219 An application category \a type has been removed.
218 220
219 Types can be added or removed at any time, for example, when a storage 221 Types can be added or removed at any time, for example, when a storage
220 card containing a non-standard category is inserted or removed. 222 card containing a non-standard category is inserted or removed.
221 223
222 \sa typeAdded() 224 \sa typeAdded()
223*/ 225*/
224 226
225/*! 227/*!
226 \fn ServerInterface::applicationAdded(const QString& type, const AppLnk& app) 228 \fn ServerInterface::applicationAdded(const QString& type, const AppLnk& app)
227 229
228 Add an application \a app of type \a type to the launcher. 230 Add an application \a app of type \a type to the launcher.
229 231
230 \sa applicationRemoved() 232 \sa applicationRemoved()
231*/ 233*/
232 234
233/*! 235/*!
234 \fn ServerInterface::applicationRemoved(const QString& type, const AppLnk& app) 236 \fn ServerInterface::applicationRemoved(const QString& type, const AppLnk& app)
235 237
236 Remove an application \a app of type \a type from the launcher. 238 Remove an application \a app of type \a type from the launcher.
237 239
238 \sa applicationAdded() 240 \sa applicationAdded()
239*/ 241*/
240 242
241/*! 243/*!
242 \fn ServerInterface::allApplicationsRemoved() 244 \fn ServerInterface::allApplicationsRemoved()
243 245
244 Remove all applications from the launcher. 246 Remove all applications from the launcher.
245*/ 247*/
246 248
247/*! 249/*!
248 \fn const AppLnkSet &ServerInterface::appLnks() 250 \fn const AppLnkSet &ServerInterface::appLnks()
249 251
250 Returns the current set of available applications. 252 Returns the current set of available applications.
251*/ 253*/
252 254
253/*! 255/*!
254 \fn ServerInterface::documentAdded(const DocLnk& doc) 256 \fn ServerInterface::documentAdded(const DocLnk& doc)
255 257
256 Add a document \a doc to the launcher. 258 Add a document \a doc to the launcher.
257 259
258 \sa documentRemoved() 260 \sa documentRemoved()
259*/ 261*/
260 262
261/*! 263/*!
262 \fn ServerInterface::documentRemoved(const DocLnk& doc) 264 \fn ServerInterface::documentRemoved(const DocLnk& doc)
263 265
264 Remove a document \a doc to the launcher. 266 Remove a document \a doc to the launcher.
265 267
266 \sa documentAdded() 268 \sa documentAdded()
267*/ 269*/
268 270
269/*! 271/*!
270 \fn ServerInterface::documentChanged(const DocLnk& oldDoc, const DocLnk& newDoc) 272 \fn ServerInterface::documentChanged(const DocLnk& oldDoc, const DocLnk& newDoc)
271 273
272 Change document properties of existing document \a oldDoc to \a newDoc. 274 Change document properties of existing document \a oldDoc to \a newDoc.
273*/ 275*/
274 276
275/*! 277/*!
276 \fn ServerInterface::allDocumentsRemoved() 278 \fn ServerInterface::allDocumentsRemoved()
277 279
278 Remove all documents from the launcher. 280 Remove all documents from the launcher.
279*/ 281*/
280 282
281/*! 283/*!
282 \fn ServerInterface::storageChanged(const QList<FileSystem> &) 284 \fn ServerInterface::storageChanged(const QList<FileSystem> &)
283 285
284 A filesystem has been added or removed. 286 A filesystem has been added or removed.
285*/ 287*/
286 288
287/*! 289/*!
288 \fn ServerInterface::applicationScanningProgress(int percent) 290 \fn ServerInterface::applicationScanningProgress(int percent)
289 291
290 The system is scanning for installed applications. \a percent 292 The system is scanning for installed applications. \a percent
291 provides the percentage of the filesystems scanned. This function will 293 provides the percentage of the filesystems scanned. This function will
292 always be called with \a percent equal to zero when scanning starts, 294 always be called with \a percent equal to zero when scanning starts,
293 and with \a percent equal to 100 when scanning is complete. 295 and with \a percent equal to 100 when scanning is complete.
294*/ 296*/
295 297
296/*! 298/*!
297 \fn ServerInterface::documentScanningProgress(int percent) 299 \fn ServerInterface::documentScanningProgress(int percent)
298 300
299 The system is scanning for documents. \a percent 301 The system is scanning for documents. \a percent
300 provides the percentage of the filesystems scanned. This function will 302 provides the percentage of the filesystems scanned. This function will
301 always be called with \a percent equal to zero when scanning starts, 303 always be called with \a percent equal to zero when scanning starts,
302 and with \a percent equal to 100 when scanning is complete. 304 and with \a percent equal to 100 when scanning is complete.
303*/ 305*/
304 306
305/*! 307/*!
306 \fn bool ServerInterface::requiresApplications() const 308 \fn bool ServerInterface::requiresApplications() const
307 309
308 Return TRUE if the custom launcher requires the server to scan for 310 Return TRUE if the custom launcher requires the server to scan for
309 applications. 311 applications.
310*/ 312*/
311 313
312/*! 314/*!
313 \fn bool ServerInterface::requiresDocuments() const 315 \fn bool ServerInterface::requiresDocuments() const
314 316
315 Return TRUE if the custom launcher requires the server to scan for 317 Return TRUE if the custom launcher requires the server to scan for
316 documents. 318 documents.
317*/ 319*/
318 320
319/*! 321/*!
320 \enum ServerInterface::DockArea 322 \enum ServerInterface::DockArea
321 323
322 The DockArea enum type defines the areas where widgets can be docked: 324 The DockArea enum type defines the areas where widgets can be docked:
323 <ul> 325 <ul>
324 <li> \c Top - the top of the screen. 326 <li> \c Top - the top of the screen.
325 <li> \c Bottom - the Bottom of the screen. 327 <li> \c Bottom - the Bottom of the screen.
326 <li> \c Left - the Left of the screen. 328 <li> \c Left - the Left of the screen.
327 <li> \c Right - the Right of the screen. 329 <li> \c Right - the Right of the screen.
328 </ul> 330 </ul>
329*/ 331*/
330 332
331/*! 333/*!
332 \fn ServerInterface::dockWidget(QWidget *w, DockArea placement) 334 \fn ServerInterface::dockWidget(QWidget *w, DockArea placement)
333 335
334 Docks a top-level widget \a w on a side of the screen specified by 336 Docks a top-level widget \a w on a side of the screen specified by
335 \a placement. The widget is placed 337 \a placement. The widget is placed
336 according to the order that it was docked, its sizeHint() and whether 338 according to the order that it was docked, its sizeHint() and whether
337 previously docked widgets are visible. The desktop area available to 339 previously docked widgets are visible. The desktop area available to
338 QWidget::showMaximized() will exclude any visible docked widgets. 340 QWidget::showMaximized() will exclude any visible docked widgets.
339 341
340 For example, if a widget is 342 For example, if a widget is
341 docked at the bottom of the screen, its sizeHint() will define its 343 docked at the bottom of the screen, its sizeHint() will define its
342 height and it will use the full width of the screen. If a widget is 344 height and it will use the full width of the screen. If a widget is
343 then docked to the right, its sizeHint() will define its width and 345 then docked to the right, its sizeHint() will define its width and
344 it will be as high as possible without covering 346 it will be as high as possible without covering
345 the widget docked at the bottom. 347 the widget docked at the bottom.
346 348
347 This function is useful for reserving system areas such as taskbars 349 This function is useful for reserving system areas such as taskbars
348 and input methods that should not be covered by applications. 350 and input methods that should not be covered by applications.
349*/ 351*/
350 352
351 353
352ServerInterface::~ServerInterface() 354ServerInterface::~ServerInterface()
353{ 355{
354} 356}
355 357
356void ServerInterface::dockWidget( QWidget *w, DockArea placement ) 358void ServerInterface::dockWidget( QWidget *w, DockArea placement )
357{ 359{
358 static LayoutManager *lm = 0; 360 static LayoutManager *lm = 0;
359 361
360 if ( !lm ) 362 if ( !lm )
361 lm = new LayoutManager; 363 lm = new LayoutManager;
362 364
363 lm->addDocked( w, placement ); 365 lm->addDocked( w, placement );
364} 366}
365 367
366const AppLnkSet& ServerInterface::appLnks() 368const AppLnkSet& ServerInterface::appLnks()
367{ 369{
368 return *DocumentList::appLnkSet; 370 return *DocumentList::appLnkSet;
369} 371}
370 372
371#include "serverinterface.moc" 373#include "serverinterface.moc"
372 374