summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2005-07-03 22:13:00 (UTC)
committer mickeyl <mickeyl>2005-07-03 22:13:00 (UTC)
commit2cabd9ad4b49eefccdf99ad59550c76546b473c9 (patch) (unidiff)
tree00bab275ac356aecc5a39b86ca22ce172d01f622
parent47011752d4457a1055894479e5bf855e100fddac (diff)
downloadopie-2cabd9ad4b49eefccdf99ad59550c76546b473c9.zip
opie-2cabd9ad4b49eefccdf99ad59550c76546b473c9.tar.gz
opie-2cabd9ad4b49eefccdf99ad59550c76546b473c9.tar.bz2
Resource -> OResource
This is a large diff and I'd appreciate some additional pairs of eyes checking it
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/documentlist.cpp72
-rw-r--r--core/launcher/firstuse.cpp62
-rw-r--r--core/launcher/launcher.cpp60
-rw-r--r--core/launcher/launcherview.cpp53
-rw-r--r--core/launcher/startmenu.cpp79
-rw-r--r--core/launcher/syncdialog.cpp59
-rw-r--r--core/launcher/taskbar.cpp52
-rw-r--r--core/launcher/wait.cpp54
8 files changed, 260 insertions, 231 deletions
diff --git a/core/launcher/documentlist.cpp b/core/launcher/documentlist.cpp
index b8bf4e0..fd385d6 100644
--- a/core/launcher/documentlist.cpp
+++ b/core/launcher/documentlist.cpp
@@ -1,759 +1,761 @@
1/********************************************************************** 1/*
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2                 This file is part of the Opie Project
3** 3 =. (C) 2000-2002 Trolltech AS
4** This file is part of the Qtopia Environment. 4 .=l. (C) 2002-2005 The Opie Team <opie-devel@handhelds.org>
5** 5           .>+-=
6** This file may be distributed and/or modified under the terms of the 6 _;:,     .>    :=|. This program is free software; you can
7** GNU General Public License version 2 as published by the Free Software 7.> <`_,   >  .   <= redistribute it and/or modify it under
8** Foundation and appearing in the file LICENSE.GPL included in the 8 :`=1 )Y*s>-.--   : the terms of the GNU Library General Public
9** packaging of this file. 9.="- .-=="i,     .._ License as published by the Free Software
10** 10 - .   .-<_>     .<> Foundation; version 2 of the License.
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11     ._= =}       :
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12    .%`+i>       _;_.
13** 13    .i_,=:_.      -<s. This program is distributed in the hope that
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15** 15 : ..    .:,     . . . without even the implied warranty of
16** Contact info@trolltech.com if any conditions of this licensing are 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17** not clear to you. 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
18** 18..}^=.=       =       ; Library General Public License for more
19**********************************************************************/ 19++=   -.     .`     .: details.
20 :     =  ...= . :.=-
21 -.   .:....=;==+<; You should have received a copy of the GNU
22  -_. . .   )=.  = Library General Public License along with
23    --        :-=` this library; see the file COPYING.LIB.
24 If not, write to the Free Software Foundation,
25 Inc., 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA.
27*/
20#include "documentlist.h" 28#include "documentlist.h"
21#include "serverinterface.h" 29#include "serverinterface.h"
22#include "mediadlg.h" 30#include "mediadlg.h"
23 31
24/* OPIE */ 32/* OPIE */
25#include <opie2/oglobal.h> 33#include <opie2/oglobal.h>
26#include <opie2/odebug.h> 34#include <opie2/odebug.h>
35#include <opie2/oresource.h>
27#include <qtopia/config.h> 36#include <qtopia/config.h>
28#include <qtopia/mimetype.h> 37#include <qtopia/mimetype.h>
29#include <qtopia/resource.h>
30#include <qtopia/private/categories.h> 38#include <qtopia/private/categories.h>
31#include <qtopia/qpeapplication.h> 39#include <qtopia/qpeapplication.h>
32#include <qtopia/applnk.h> 40#include <qtopia/applnk.h>
33#include <qtopia/storage.h> 41#include <qtopia/storage.h>
34#ifdef Q_WS_QWS 42#ifdef Q_WS_QWS
35#include <qtopia/qcopenvelope_qws.h> 43#include <qtopia/qcopenvelope_qws.h>
36#endif 44#endif
37using namespace Opie::Core; 45using namespace Opie::Core;
38 46
39/* QT */ 47/* QT */
40#include <qtimer.h> 48#include <qtimer.h>
41#include <qfileinfo.h> 49#include <qfileinfo.h>
42#include <qtextstream.h> 50#include <qtextstream.h>
43#include <qfile.h> 51#include <qfile.h>
44#include <qdir.h> 52#include <qdir.h>
45#include <qpainter.h> 53#include <qpainter.h>
46#include <qimage.h> 54#include <qimage.h>
47#include <qcopchannel_qws.h> 55#include <qcopchannel_qws.h>
48#include <qlistview.h> 56#include <qlistview.h>
49#include <qlist.h> 57#include <qlist.h>
50#include <qpixmap.h> 58#include <qpixmap.h>
51 59
52 60
53AppLnkSet *DocumentList::appLnkSet = 0; 61AppLnkSet *DocumentList::appLnkSet = 0;
54 62
55static const int MAX_SEARCH_DEPTH = 10; 63static const int MAX_SEARCH_DEPTH = 10;
56 64
57 65
58class DocumentListPrivate : public QObject { 66class DocumentListPrivate : public QObject {
59 Q_OBJECT 67 Q_OBJECT
60public: 68public:
61 DocumentListPrivate( ServerInterface *gui ); 69 DocumentListPrivate( ServerInterface *gui );
62 ~DocumentListPrivate(); 70 ~DocumentListPrivate();
63 71
64 void initialize(); 72 void initialize();
65 73
66 const QString nextFile(); 74 const QString nextFile();
67 const DocLnk *iterate(); 75 const DocLnk *iterate();
68 bool store( DocLnk* dl ); 76 bool store( DocLnk* dl );
69 void estimatedPercentScanned(); 77 void estimatedPercentScanned();
70 void appendDocpath(FileSystem*); 78 void appendDocpath(FileSystem*);
71 79
72 80
73 DocLnkSet dls; 81 DocLnkSet dls;
74 QDict<void> reference; 82 QDict<void> reference;
75 QDictIterator<void> *dit; 83 QDictIterator<void> *dit;
76 enum { Find, RemoveKnownFiles, MakeUnknownFiles, Done } state; 84 enum { Find, RemoveKnownFiles, MakeUnknownFiles, Done } state;
77 85
78 QStringList docPaths; 86 QStringList docPaths;
79 unsigned int docPathsSearched; 87 unsigned int docPathsSearched;
80 88
81 int searchDepth; 89 int searchDepth;
82 QDir *listDirs[MAX_SEARCH_DEPTH]; 90 QDir *listDirs[MAX_SEARCH_DEPTH];
83 const QFileInfoList *lists[MAX_SEARCH_DEPTH]; 91 const QFileInfoList *lists[MAX_SEARCH_DEPTH];
84 unsigned int listPositions[MAX_SEARCH_DEPTH]; 92 unsigned int listPositions[MAX_SEARCH_DEPTH];
85 93
86 StorageInfo *storage; 94 StorageInfo *storage;
87 95
88 int tid; 96 int tid;
89 97
90 ServerInterface *serverGui; 98 ServerInterface *serverGui;
91 99
92 bool needToSendAllDocLinks; 100 bool needToSendAllDocLinks;
93 bool sendAppLnks; 101 bool sendAppLnks;
94 bool sendDocLnks; 102 bool sendDocLnks;
95 bool scanDocs; 103 bool scanDocs;
96}; 104};
97 105
98 106
99/* 107/*
100 * scandocs will be read from Config 108 * scandocs will be read from Config
101 */ 109 */
102DocumentList::DocumentList( ServerInterface *serverGui, bool /*scanDocs*/, 110DocumentList::DocumentList( ServerInterface *serverGui, bool /*scanDocs*/,
103 QObject *parent, const char *name ) 111 QObject *parent, const char *name )
104 : QObject( parent, name ) 112 : QObject( parent, name )
105{ 113{
106 appLnkSet = new AppLnkSet( MimeType::appsFolderName() ); 114 appLnkSet = new AppLnkSet( MimeType::appsFolderName() );
107 d = new DocumentListPrivate( serverGui ); 115 d = new DocumentListPrivate( serverGui );
108 d->needToSendAllDocLinks = false; 116 d->needToSendAllDocLinks = false;
109 117
110 Config cfg( "Launcher" ); 118 Config cfg( "Launcher" );
111 cfg.setGroup( "DocTab" ); 119 cfg.setGroup( "DocTab" );
112 d->scanDocs = cfg.readBoolEntry( "Enable", true ); 120 d->scanDocs = cfg.readBoolEntry( "Enable", true );
113 odebug << "DocumentList::DocumentList() : scanDocs = " << d->scanDocs << "" << oendl; 121 odebug << "DocumentList::DocumentList() : scanDocs = " << d->scanDocs << "" << oendl;
114 122
115 QTimer::singleShot( 10, this, SLOT( startInitialScan() ) ); 123 QTimer::singleShot( 10, this, SLOT( startInitialScan() ) );
116} 124}
117 125
118void DocumentList::startInitialScan() 126void DocumentList::startInitialScan()
119{ 127{
120 reloadAppLnks(); 128 reloadAppLnks();
121 reloadDocLnks(); 129 reloadDocLnks();
122} 130}
123 131
124DocumentList::~DocumentList() 132DocumentList::~DocumentList()
125{ 133{
126 delete appLnkSet; 134 delete appLnkSet;
127 delete d; 135 delete d;
128} 136}
129 137
130 138
131void DocumentList::add( const DocLnk& doc ) 139void DocumentList::add( const DocLnk& doc )
132{ 140{
133 if ( d->serverGui && QFile::exists( doc.file() ) ) 141 if ( d->serverGui && QFile::exists( doc.file() ) )
134 d->serverGui->documentAdded( doc ); 142 d->serverGui->documentAdded( doc );
135} 143}
136 144
137 145
138void DocumentList::start() 146void DocumentList::start()
139{ 147{
140 resume(); 148 resume();
141} 149}
142 150
143 151
144void DocumentList::pause() 152void DocumentList::pause()
145{ 153{
146 //odebug << "pause " << d->tid << "" << oendl; 154 //odebug << "pause " << d->tid << "" << oendl;
147 killTimer( d->tid ); 155 killTimer( d->tid );
148 d->tid = 0; 156 d->tid = 0;
149} 157}
150 158
151 159
152void DocumentList::resume() 160void DocumentList::resume()
153{ 161{
154 if ( d->tid == 0 ) { 162 if ( d->tid == 0 ) {
155 d->tid = startTimer( 20 ); 163 d->tid = startTimer( 20 );
156 //odebug << "resumed " << d->tid << "" << oendl; 164 //odebug << "resumed " << d->tid << "" << oendl;
157 } 165 }
158} 166}
159 167
160/* 168/*
161void DocumentList::resend() 169void DocumentList::resend()
162{ 170{
163 // Re-emits all the added items to the list (firstly letting everyone know to 171 // Re-emits all the added items to the list (firstly letting everyone know to
164 // clear what they have as it is being sent again) 172 // clear what they have as it is being sent again)
165 pause(); 173 pause();
166 emit allRemoved(); 174 emit allRemoved();
167 QTimer::singleShot( 5, this, SLOT( resendWorker() ) ); 175 QTimer::singleShot( 5, this, SLOT( resendWorker() ) );
168} 176}
169 177
170 178
171void DocumentList::resendWorker() 179void DocumentList::resendWorker()
172{ 180{
173 const QList<DocLnk> &list = d->dls.children(); 181 const QList<DocLnk> &list = d->dls.children();
174 for ( QListIterator<DocLnk> it( list ); it.current(); ++it ) 182 for ( QListIterator<DocLnk> it( list ); it.current(); ++it )
175 add( *(*it) ); 183 add( *(*it) );
176 resume(); 184 resume();
177} 185}
178*/ 186*/
179 187
180void DocumentList::rescan() 188void DocumentList::rescan()
181{ 189{
182 //odebug << "rescan" << oendl; 190 //odebug << "rescan" << oendl;
183 pause(); 191 pause();
184 d->initialize(); 192 d->initialize();
185 resume(); 193 resume();
186} 194}
187 195
188 196
189void DocumentList::timerEvent( QTimerEvent *te ) 197void DocumentList::timerEvent( QTimerEvent *te )
190{ 198{
191 if ( te->timerId() == d->tid ) { 199 if ( te->timerId() == d->tid ) {
192 // Do 3 at a time 200 // Do 3 at a time
193 if ( d->serverGui ) 201 if ( d->serverGui )
194 d->serverGui->aboutToAddBegin(); 202 d->serverGui->aboutToAddBegin();
195 for (int i = 0; i < 3; i++ ) { 203 for (int i = 0; i < 3; i++ ) {
196 const DocLnk *lnk = d->iterate(); 204 const DocLnk *lnk = d->iterate();
197 if ( lnk ) { 205 if ( lnk ) {
198 add( *lnk ); 206 add( *lnk );
199 } else { 207 } else {
200 // stop when done 208 // stop when done
201 pause(); 209 pause();
202 if ( d->serverGui ) 210 if ( d->serverGui )
203 d->serverGui->documentScanningProgress( 100 ); 211 d->serverGui->documentScanningProgress( 100 );
204 if ( d->needToSendAllDocLinks ) 212 if ( d->needToSendAllDocLinks )
205 sendAllDocLinks(); 213 sendAllDocLinks();
206 break; 214 break;
207 } 215 }
208 } 216 }
209 if ( d->serverGui ) 217 if ( d->serverGui )
210 d->serverGui->aboutToAddEnd(); 218 d->serverGui->aboutToAddEnd();
211 } 219 }
212} 220}
213 221
214 222
215void DocumentList::reloadAppLnks() 223void DocumentList::reloadAppLnks()
216{ 224{
217 if ( d->sendAppLnks && d->serverGui ) { 225 if ( d->sendAppLnks && d->serverGui ) {
218 d->serverGui->applicationScanningProgress( 0 ); 226 d->serverGui->applicationScanningProgress( 0 );
219 d->serverGui->allApplicationsRemoved(); 227 d->serverGui->allApplicationsRemoved();
220 } 228 }
221 229
222 delete appLnkSet; 230 delete appLnkSet;
223 appLnkSet = new AppLnkSet( MimeType::appsFolderName() ); 231 appLnkSet = new AppLnkSet( MimeType::appsFolderName() );
224 232
225 if ( d->sendAppLnks && d->serverGui ) { 233 if ( d->sendAppLnks && d->serverGui ) {
226 static QStringList prevTypeList; 234 static QStringList prevTypeList;
227 QStringList types = appLnkSet->types(); 235 QStringList types = appLnkSet->types();
228 for ( QStringList::Iterator ittypes=types.begin(); ittypes!=types.end(); ++ittypes) { 236 for ( QStringList::Iterator ittypes=types.begin(); ittypes!=types.end(); ++ittypes) {
229 if ( !(*ittypes).isEmpty() ) { 237 if ( !(*ittypes).isEmpty() ) {
230 if ( !prevTypeList.contains(*ittypes) ) { 238 if ( !prevTypeList.contains(*ittypes) ) {
231 QString name = appLnkSet->typeName(*ittypes); 239 QString name = appLnkSet->typeName(*ittypes);
232 QPixmap pm = appLnkSet->typePixmap(*ittypes); 240 QPixmap pm = appLnkSet->typePixmap(*ittypes);
233 QPixmap bgPm = appLnkSet->typeBigPixmap(*ittypes); 241 QPixmap bgPm = appLnkSet->typeBigPixmap(*ittypes);
234 242
235 if (pm.isNull()) { 243 if (pm.isNull())
236 QImage img( Resource::loadImage( "UnknownDocument" ) ); 244 {
237 pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); 245 pm = OResource::loadImage( "UnknownDocument", OResource::SmallIcon );
238 bgPm = img.smoothScale( AppLnk::bigIconSize(), AppLnk::bigIconSize() ); 246 bgPm = OResource::loadImage( "UnknownDocument", OResource::BigIcon );
239 } 247 }
240 248
241 //odebug << "adding type " << (*ittypes) << "" << oendl; 249 //FIXME our current launcher expects docs tab to be last
242
243 // ### our current launcher expects docs tab to be last
244 d->serverGui->typeAdded( *ittypes, name.isNull() ? (*ittypes) : name, pm, bgPm ); 250 d->serverGui->typeAdded( *ittypes, name.isNull() ? (*ittypes) : name, pm, bgPm );
245 } 251 }
246 prevTypeList.remove(*ittypes); 252 prevTypeList.remove(*ittypes);
247 } 253 }
248 } 254 }
249 for ( QStringList::Iterator ittypes=prevTypeList.begin(); ittypes!=prevTypeList.end(); ++ittypes) { 255 for ( QStringList::Iterator ittypes=prevTypeList.begin(); ittypes!=prevTypeList.end(); ++ittypes) {
250 //odebug << "removing type " << (*ittypes) << "" << oendl;
251 d->serverGui->typeRemoved(*ittypes); 256 d->serverGui->typeRemoved(*ittypes);
252 } 257 }
253 prevTypeList = types; 258 prevTypeList = types;
254 } 259 }
255 260
256 QListIterator<AppLnk> itapp( appLnkSet->children() ); 261 QListIterator<AppLnk> itapp( appLnkSet->children() );
257 AppLnk* l; 262 AppLnk* l;
258 while ( (l=itapp.current()) ) { 263 while ( (l=itapp.current()) ) {
259 ++itapp; 264 ++itapp;
260 if ( d->sendAppLnks && d->serverGui ) 265 if ( d->sendAppLnks && d->serverGui )
261 d->serverGui->applicationAdded( l->type(), *l ); 266 d->serverGui->applicationAdded( l->type(), *l );
262 } 267 }
263 268
264 if ( d->sendAppLnks && d->serverGui ) 269 if ( d->sendAppLnks && d->serverGui )
265 d->serverGui->applicationScanningProgress( 100 ); 270 d->serverGui->applicationScanningProgress( 100 );
266} 271}
267 272
268void DocumentList::reloadDocLnks() 273void DocumentList::reloadDocLnks()
269{ 274{
270 if ( !d->scanDocs ) 275 if ( !d->scanDocs )
271 return; 276 return;
272 277
273 if ( d->sendDocLnks && d->serverGui ) { 278 if ( d->sendDocLnks && d->serverGui ) {
274 d->serverGui->documentScanningProgress( 0 ); 279 d->serverGui->documentScanningProgress( 0 );
275 d->serverGui->allDocumentsRemoved(); 280 d->serverGui->allDocumentsRemoved();
276 } 281 }
277 282
278 rescan(); 283 rescan();
279} 284}
280 285
281void DocumentList::reforceDocuments() 286void DocumentList::reforceDocuments()
282{ 287{
283 Config cfg( "Launcher" ); 288 Config cfg( "Launcher" );
284 cfg.setGroup( "DocTab" ); 289 cfg.setGroup( "DocTab" );
285 d->scanDocs = cfg.readBoolEntry( "Enable", true ); 290 d->scanDocs = cfg.readBoolEntry( "Enable", true );
286 reloadDocLnks(); 291 reloadDocLnks();
287} 292}
288 293
289void DocumentList::linkChanged( QString arg ) 294void DocumentList::linkChanged( QString arg )
290{ 295{
291 odebug << "linkchanged( " << arg << " )" << oendl; 296 odebug << "linkchanged( " << arg << " )" << oendl;
292 297
293 if ( arg.isNull() || OGlobal::isAppLnkFileName( arg ) ) { 298 if ( arg.isNull() || OGlobal::isAppLnkFileName( arg ) ) {
294 reloadAppLnks(); 299 reloadAppLnks();
295 } else { 300 } else {
296 301
297 const QList<DocLnk> &list = d->dls.children(); 302 const QList<DocLnk> &list = d->dls.children();
298 QListIterator<DocLnk> it( list ); 303 QListIterator<DocLnk> it( list );
299 while ( it.current() ) { 304 while ( it.current() ) {
300 DocLnk *doc = it.current(); 305 DocLnk *doc = it.current();
301 ++it; 306 ++it;
302 if ( ( doc->linkFileKnown() && doc->linkFile() == arg ) 307 if ( ( doc->linkFileKnown() && doc->linkFile() == arg )
303 || ( doc->fileKnown() && doc->file() == arg ) ) { 308 || ( doc->fileKnown() && doc->file() == arg ) ) {
304 //odebug << "found old link" << oendl; 309 //odebug << "found old link" << oendl;
305 DocLnk* dl = new DocLnk( arg ); 310 DocLnk* dl = new DocLnk( arg );
306 // add new one if it exists and matches the mimetype 311 // add new one if it exists and matches the mimetype
307 if ( d->store( dl ) ) { 312 if ( d->store( dl ) ) {
308 // Existing link has been changed, send old link ref and a ref 313 // Existing link has been changed, send old link ref and a ref
309 // to the new link 314 // to the new link
310 //odebug << "change case" << oendl; 315 //odebug << "change case" << oendl;
311 if ( d->serverGui ) 316 if ( d->serverGui )
312 d->serverGui->documentChanged( *doc, *dl ); 317 d->serverGui->documentChanged( *doc, *dl );
313 318
314 } else { 319 } else {
315 // Link has been removed or doesn't match the mimetypes any more 320 // Link has been removed or doesn't match the mimetypes any more
316 // so we aren't interested in it, so take it away from the list 321 // so we aren't interested in it, so take it away from the list
317 //odebug << "removal case" << oendl; 322 //odebug << "removal case" << oendl;
318 if ( d->serverGui ) 323 if ( d->serverGui )
319 d->serverGui->documentRemoved( *doc ); 324 d->serverGui->documentRemoved( *doc );
320 325
321 } 326 }
322 d->dls.remove( doc ); // remove old link from docLnkSet 327 d->dls.remove( doc ); // remove old link from docLnkSet
323 delete doc; 328 delete doc;
324 return; 329 return;
325 } 330 }
326 } 331 }
327 // Didn't find existing link, must be new 332 // Didn't find existing link, must be new
328 DocLnk* dl = new DocLnk( arg ); 333 DocLnk* dl = new DocLnk( arg );
329 if ( d->store( dl ) ) { 334 if ( d->store( dl ) ) {
330 // Add if it's a link we are interested in 335 // Add if it's a link we are interested in
331 //odebug << "add case" << oendl; 336 //odebug << "add case" << oendl;
332 add( *dl ); 337 add( *dl );
333 } 338 }
334 339
335 } 340 }
336} 341}
337 342
338void DocumentList::restoreDone() 343void DocumentList::restoreDone()
339{ 344{
340 reloadAppLnks(); 345 reloadAppLnks();
341 reloadDocLnks(); 346 reloadDocLnks();
342} 347}
343 348
344void DocumentList::DiffAppLnks() 349void DocumentList::DiffAppLnks()
345{ 350{
346 static AppLnkSet *appLnkSet2; 351 static AppLnkSet *appLnkSet2;
347 352
348 appLnkSet2 = new AppLnkSet( MimeType::appsFolderName() ); 353 appLnkSet2 = new AppLnkSet( MimeType::appsFolderName() );
349 354
350 if ( d->sendAppLnks && d->serverGui ) { 355 if ( d->sendAppLnks && d->serverGui ) {
351 static QStringList prevTypeList = appLnkSet->types(); 356 static QStringList prevTypeList = appLnkSet->types();
352 QStringList types = appLnkSet2->types(); 357 QStringList types = appLnkSet2->types();
353 for ( QStringList::Iterator ittypes=types.begin(); ittypes!=types.end(); ++ittypes) { 358 for ( QStringList::Iterator ittypes=types.begin(); ittypes!=types.end(); ++ittypes) {
354 if ( !(*ittypes).isEmpty() ) { 359 if ( !(*ittypes).isEmpty() ) {
355 if ( !prevTypeList.contains(*ittypes) ) { 360 if ( !prevTypeList.contains(*ittypes) ) {
356 QString name = appLnkSet2->typeName(*ittypes); 361 QString name = appLnkSet2->typeName(*ittypes);
357 QPixmap pm = appLnkSet2->typePixmap(*ittypes); 362 QPixmap pm = appLnkSet2->typePixmap(*ittypes);
358 QPixmap bgPm = appLnkSet2->typeBigPixmap(*ittypes); 363 QPixmap bgPm = appLnkSet2->typeBigPixmap(*ittypes);
359 364
360 if (pm.isNull()) { 365 if (pm.isNull())
361 QImage img( Resource::loadImage( "UnknownDocument" ) ); 366 {
362 pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); 367 pm = OResource::loadImage( "UnknownDocument", OResource::SmallIcon );
363 bgPm = img.smoothScale( AppLnk::bigIconSize(), AppLnk::bigIconSize() ); 368 bgPm = OResource::loadImage( "UnknownDocument", OResource::BigIcon );
364 } 369 }
365 370
366 odebug << "adding type " << (*ittypes) << "" << oendl;
367
368 // ### our current launcher expects docs tab to be last 371 // ### our current launcher expects docs tab to be last
369 d->serverGui->typeAdded( *ittypes, name.isNull() ? (*ittypes) : name, pm, bgPm ); 372 d->serverGui->typeAdded( *ittypes, name.isNull() ? (*ittypes) : name, pm, bgPm );
370 } 373 }
371 prevTypeList.remove(*ittypes); 374 prevTypeList.remove(*ittypes);
372 } 375 }
373 } 376 }
374 for ( QStringList::Iterator ittypes=prevTypeList.begin(); ittypes!=prevTypeList.end(); ++ittypes) { 377 for ( QStringList::Iterator ittypes=prevTypeList.begin(); ittypes!=prevTypeList.end(); ++ittypes) {
375 odebug << "removing type " << (*ittypes) << "" << oendl;
376 d->serverGui->typeRemoved(*ittypes); 378 d->serverGui->typeRemoved(*ittypes);
377 } 379 }
378 prevTypeList = types; 380 prevTypeList = types;
379 } 381 }
380 382
381 383
382 QListIterator<AppLnk> it1( appLnkSet->children() ); 384 QListIterator<AppLnk> it1( appLnkSet->children() );
383 QListIterator<AppLnk> it2( appLnkSet2->children() ); 385 QListIterator<AppLnk> it2( appLnkSet2->children() );
384 386
385 AppLnk *i; 387 AppLnk *i;
386 AppLnk *j; 388 AppLnk *j;
387 bool found; 389 bool found;
388 390
389 while ( (j=it2.current()) ) { 391 while ( (j=it2.current()) ) {
390 it1 = appLnkSet->children(); 392 it1 = appLnkSet->children();
391 found = false; 393 found = false;
392 while ( (i=it1.current()) ){ 394 while ( (i=it1.current()) ){
393 if (j->name().ascii() && i->name().ascii() && strcmp(i->name().ascii(),j->name().ascii()) == 0) 395 if (j->name().ascii() && i->name().ascii() && strcmp(i->name().ascii(),j->name().ascii()) == 0)
394 found = true; 396 found = true;
395 ++it1; 397 ++it1;
396 } 398 }
397 if (!found) { 399 if (!found) {
398 odebug << "Item " << j->name().ascii() << " needs to be added" << oendl; 400 odebug << "Item " << j->name().ascii() << " needs to be added" << oendl;
399 d->serverGui->applicationAdded( j->type(), *j ); 401 d->serverGui->applicationAdded( j->type(), *j );
400 } 402 }
401 ++it2; 403 ++it2;
402 } 404 }
403 405
404 it1 = appLnkSet->children(); 406 it1 = appLnkSet->children();
405 while ( (i=it1.current()) ) { 407 while ( (i=it1.current()) ) {
406 it2 = appLnkSet2->children(); 408 it2 = appLnkSet2->children();
407 found = false; 409 found = false;
408 while ( (j=it2.current()) ){ 410 while ( (j=it2.current()) ){
409 if (j->name().ascii() && i->name().ascii() && strcmp(i->name().ascii(),j->name().ascii()) == 0) 411 if (j->name().ascii() && i->name().ascii() && strcmp(i->name().ascii(),j->name().ascii()) == 0)
410 found = true; 412 found = true;
411 ++it2; 413 ++it2;
412 } 414 }
413 if (!found) { 415 if (!found) {
414 odebug << "Item " << i->name().ascii() << " needs to be removed" << oendl; 416 odebug << "Item " << i->name().ascii() << " needs to be removed" << oendl;
415 d->serverGui->applicationRemoved( i->type(), *i ); 417 d->serverGui->applicationRemoved( i->type(), *i );
416 } 418 }
417 419
418 ++it1; 420 ++it1;
419 } 421 }
420 422
421 delete appLnkSet; 423 delete appLnkSet;
422 appLnkSet = appLnkSet2; 424 appLnkSet = appLnkSet2;
423 425
424} 426}
425void DocumentList::storageChanged() 427void DocumentList::storageChanged()
426{ 428{
427 QTime t; 429 QTime t;
428 // ### can implement better 430 // ### can implement better
429 431
430 t.start(); 432 t.start();
431 DiffAppLnks(); 433 DiffAppLnks();
432// reloadAppLnks(); 434// reloadAppLnks();
433 odebug << "Reload App links took " << t.elapsed() << " ms" << oendl; 435 odebug << "Reload App links took " << t.elapsed() << " ms" << oendl;
434 reloadDocLnks(); 436 reloadDocLnks();
435// odebug << "Reload links took " << t.elapsed() << " ms " << oendl; 437// odebug << "Reload links took " << t.elapsed() << " ms " << oendl;
436 odebug << "Reload All links took " << t.elapsed() << " ms" << oendl; 438 odebug << "Reload All links took " << t.elapsed() << " ms" << oendl;
437// ### Optimization opportunity 439// ### Optimization opportunity
438 // Could be a bit more intelligent and somehow work out which 440 // Could be a bit more intelligent and somehow work out which
439 // mtab entry has changed and then only scan that and add and remove 441 // mtab entry has changed and then only scan that and add and remove
440 // links appropriately. 442 // links appropriately.
441// rescan(); 443// rescan();
442} 444}
443 445
444void DocumentList::sendAllDocLinks() 446void DocumentList::sendAllDocLinks()
445{ 447{
446 if ( d->tid != 0 ) { 448 if ( d->tid != 0 ) {
447 // We are in the middle of scanning, set a flag so 449 // We are in the middle of scanning, set a flag so
448 // we do this when we finish our scanning 450 // we do this when we finish our scanning
449 d->needToSendAllDocLinks = true; 451 d->needToSendAllDocLinks = true;
450 return; 452 return;
451 } 453 }
452 454
453 QString contents; 455 QString contents;
454 Categories cats; 456 Categories cats;
455 for ( QListIterator<DocLnk> it( d->dls.children() ); it.current(); ++it ) { 457 for ( QListIterator<DocLnk> it( d->dls.children() ); it.current(); ++it ) {
456 DocLnk *doc = it.current(); 458 DocLnk *doc = it.current();
457 QFileInfo fi( doc->file() ); 459 QFileInfo fi( doc->file() );
458 if ( !fi.exists() ) 460 if ( !fi.exists() )
459 continue; 461 continue;
460 462
461 bool fake = !doc->linkFileKnown(); 463 bool fake = !doc->linkFileKnown();
462 if ( !fake ) { 464 if ( !fake ) {
463 QFile f( doc->linkFile() ); 465 QFile f( doc->linkFile() );
464 if ( f.open( IO_ReadOnly ) ) { 466 if ( f.open( IO_ReadOnly ) ) {
465 QTextStream ts( &f ); 467 QTextStream ts( &f );
466 ts.setEncoding( QTextStream::UnicodeUTF8 ); 468 ts.setEncoding( QTextStream::UnicodeUTF8 );
467 QString docLnk = ts.read(); 469 QString docLnk = ts.read();
468 // Strip out the (stale) LinkFile entry 470 // Strip out the (stale) LinkFile entry
469 int start = docLnk.find( "\nLinkFile = " ) + 1; 471 int start = docLnk.find( "\nLinkFile = " ) + 1;
470 if ( start > 0 ) { 472 if ( start > 0 ) {
471 int end = docLnk.find( "\n", start + 1 ) + 1; 473 int end = docLnk.find( "\n", start + 1 ) + 1;
472 contents += docLnk.left(start); 474 contents += docLnk.left(start);
473 contents += docLnk.mid(end); 475 contents += docLnk.mid(end);
474 } else { 476 } else {
475 contents += docLnk; 477 contents += docLnk;
476 } 478 }
477 contents += "LinkFile = " + doc->linkFile() + "\n"; 479 contents += "LinkFile = " + doc->linkFile() + "\n";
478 480
479 f.close(); 481 f.close();
480 } else 482 } else
481 fake = TRUE; 483 fake = TRUE;
482 } 484 }
483 if (fake) { 485 if (fake) {
484 contents += "[Desktop Entry]\n"; // No tr 486 contents += "[Desktop Entry]\n"; // No tr
485 contents += "Categories = " + // No tr 487 contents += "Categories = " + // No tr
486 cats.labels("Document View",doc->categories()).join(";") + "\n"; // No tr 488 cats.labels("Document View",doc->categories()).join(";") + "\n"; // No tr
487 contents += "Name = "+doc->name()+"\n"; // No tr 489 contents += "Name = "+doc->name()+"\n"; // No tr
488 contents += "Type = "+doc->type()+"\n"; // No tr 490 contents += "Type = "+doc->type()+"\n"; // No tr
489 } 491 }
490 contents += "File = "+doc->file()+"\n"; // No tr // (resolves path) 492 contents += "File = "+doc->file()+"\n"; // No tr // (resolves path)
491 contents += QString("Size = %1\n").arg( fi.size() ); // No tr 493 contents += QString("Size = %1\n").arg( fi.size() ); // No tr
492 } 494 }
493 495
494 //odebug << "sending length " << contents.length() << "" << oendl; 496 //odebug << "sending length " << contents.length() << "" << oendl;
495#ifndef QT_NO_COP 497#ifndef QT_NO_COP
496 QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" ); 498 QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" );
497 e << contents; 499 e << contents;
498#endif 500#endif
499 //odebug << "================ \n\n" << contents << "\n\n===============" << oendl; 501 //odebug << "================ \n\n" << contents << "\n\n===============" << oendl;
500 502
501 d->needToSendAllDocLinks = false; 503 d->needToSendAllDocLinks = false;
502} 504}
503 505
504 506
505 507
506 508
507 509
508 510
509 511
510 512
511 513
512 514
513 515
514 516
515 517
516 518
517 519
518 520
519 521
520 522
521 523
522 524
523 525
524 526
525 527
526 528
527DocumentListPrivate::DocumentListPrivate( ServerInterface *gui ) 529DocumentListPrivate::DocumentListPrivate( ServerInterface *gui )
528{ 530{
529 storage = new StorageInfo( this ); 531 storage = new StorageInfo( this );
530 serverGui = gui; 532 serverGui = gui;
531 if ( serverGui ) { 533 if ( serverGui ) {
532 sendAppLnks = serverGui->requiresApplications(); 534 sendAppLnks = serverGui->requiresApplications();
533 sendDocLnks = serverGui->requiresDocuments(); 535 sendDocLnks = serverGui->requiresDocuments();
534 } else { 536 } else {
535 sendAppLnks = false; 537 sendAppLnks = false;
536 sendDocLnks = false; 538 sendDocLnks = false;
537 } 539 }
538 for ( int i = 0; i < MAX_SEARCH_DEPTH; i++ ) { 540 for ( int i = 0; i < MAX_SEARCH_DEPTH; i++ ) {
539 listDirs[i] = 0; 541 listDirs[i] = 0;
540 lists[i] = 0; 542 lists[i] = 0;
541 listPositions[i] = 0; 543 listPositions[i] = 0;
542 } 544 }
543 initialize(); 545 initialize();
544 tid = 0; 546 tid = 0;
545} 547}
546 548
547void DocumentListPrivate::appendDocpath(FileSystem*fs) 549void DocumentListPrivate::appendDocpath(FileSystem*fs)
548{ 550{
549 Config c( "qpe" ); 551 Config c( "qpe" );
550 c.setGroup( "Startup" ); 552 c.setGroup( "Startup" );
551 QDir defPath(fs->path()+"/Documents"); 553 QDir defPath(fs->path()+"/Documents");
552 QFileInfo f(fs->path()+"/.opiestorage.cf"); 554 QFileInfo f(fs->path()+"/.opiestorage.cf");
553 if ( c.readNumEntry( "FirstUse", 42 ) == 0 && !f.exists()) { 555 if ( c.readNumEntry( "FirstUse", 42 ) == 0 && !f.exists()) {
554 Mediadlg dlg(fs); 556 Mediadlg dlg(fs);
555 if (QDialog::Accepted != QPEApplication::execDialog( &dlg )) { 557 if (QDialog::Accepted != QPEApplication::execDialog( &dlg )) {
556 return; 558 return;
557 } 559 }
558 } 560 }
559 Config conf(f.filePath(), Config::File ); 561 Config conf(f.filePath(), Config::File );
560 conf.setGroup("main"); 562 conf.setGroup("main");
561 if (!conf.readBoolEntry("check",false)) { 563 if (!conf.readBoolEntry("check",false)) {
562 return; 564 return;
563 } 565 }
564 conf.setGroup("subdirs"); 566 conf.setGroup("subdirs");
565 bool read_all = conf.readBoolEntry("wholemedia",true); 567 bool read_all = conf.readBoolEntry("wholemedia",true);
566 if (read_all) { 568 if (read_all) {
567 docPaths+=fs->path(); 569 docPaths+=fs->path();
568 return; 570 return;
569 } 571 }
570 QStringList subDirs = conf.readListEntry("subdirs",':'); 572 QStringList subDirs = conf.readListEntry("subdirs",':');
571 if (subDirs.isEmpty()) { 573 if (subDirs.isEmpty()) {
572 if (defPath.exists()) { 574 if (defPath.exists()) {
573 docPaths+=defPath.path(); 575 docPaths+=defPath.path();
574 } 576 }
575 return; 577 return;
576 } 578 }
577 for (unsigned c = 0; c < subDirs.count();++c) { 579 for (unsigned c = 0; c < subDirs.count();++c) {
578 QDir docDir(QString(fs->path()+"/"+subDirs[c])); 580 QDir docDir(QString(fs->path()+"/"+subDirs[c]));
579 if (docDir.exists()) { 581 if (docDir.exists()) {
580 docPaths+=docDir.path(); 582 docPaths+=docDir.path();
581 } 583 }
582 } 584 }
583} 585}
584 586
585void DocumentListPrivate::initialize() 587void DocumentListPrivate::initialize()
586{ 588{
587 // Reset 589 // Reset
588 dls.clear(); 590 dls.clear();
589 docPaths.clear(); 591 docPaths.clear();
590 reference.clear(); 592 reference.clear();
591 593
592 QDir docDir( QPEApplication::documentDir() ); 594 QDir docDir( QPEApplication::documentDir() );
593 if ( docDir.exists() ) 595 if ( docDir.exists() )
594 docPaths += QPEApplication::documentDir(); 596 docPaths += QPEApplication::documentDir();
595 int i = 1; 597 int i = 1;
596 const QList<FileSystem> &fs = storage->fileSystems(); 598 const QList<FileSystem> &fs = storage->fileSystems();
597 QListIterator<FileSystem> it( fs ); 599 QListIterator<FileSystem> it( fs );
598 for ( ; it.current(); ++it ) { 600 for ( ; it.current(); ++it ) {
599 if ( (*it)->isRemovable() ) { 601 if ( (*it)->isRemovable() ) {
600 appendDocpath((*it)); 602 appendDocpath((*it));
601 ++i; 603 ++i;
602 } 604 }
603 } 605 }
604 606
605 for ( int i = 0; i < MAX_SEARCH_DEPTH; ++i ) { 607 for ( int i = 0; i < MAX_SEARCH_DEPTH; ++i ) {
606 if ( listDirs[i] ) { 608 if ( listDirs[i] ) {
607 delete listDirs[i]; 609 delete listDirs[i];
608 listDirs[i] = 0; 610 listDirs[i] = 0;
609 } 611 }
610 lists[i] = 0; 612 lists[i] = 0;
611 listPositions[i] = 0; 613 listPositions[i] = 0;
612 } 614 }
613 615
614 docPathsSearched = 0; 616 docPathsSearched = 0;
615 searchDepth = -1; 617 searchDepth = -1;
616 state = Find; 618 state = Find;
617 dit = 0; 619 dit = 0;
618} 620}
619 621
620 622
621DocumentListPrivate::~DocumentListPrivate() 623DocumentListPrivate::~DocumentListPrivate()
622{ 624{
623 for ( int i = 0; i < MAX_SEARCH_DEPTH; i++ ) 625 for ( int i = 0; i < MAX_SEARCH_DEPTH; i++ )
624 if ( listDirs[i] ) 626 if ( listDirs[i] )
625 delete listDirs[i]; 627 delete listDirs[i];
626 delete dit; 628 delete dit;
627} 629}
628 630
629 631
630void DocumentListPrivate::estimatedPercentScanned() 632void DocumentListPrivate::estimatedPercentScanned()
631{ 633{
632 double overallProgress = 0.0; 634 double overallProgress = 0.0;
633 double levelWeight = 75.0; 635 double levelWeight = 75.0;
634 636
635 int topCount = docPaths.count(); 637 int topCount = docPaths.count();
636 if ( topCount > 1 ) { 638 if ( topCount > 1 ) {
637 levelWeight = levelWeight / topCount; 639 levelWeight = levelWeight / topCount;
638 overallProgress += (docPathsSearched - 1) * levelWeight; 640 overallProgress += (docPathsSearched - 1) * levelWeight;
639 } 641 }
640 642
641 for ( int d = 0; d <= searchDepth; d++ ) { 643 for ( int d = 0; d <= searchDepth; d++ ) {
642 if ( listDirs[d] ) { 644 if ( listDirs[d] ) {
643 int items = lists[d]->count(); 645 int items = lists[d]->count();
644 if ( items > 1 ) { 646 if ( items > 1 ) {
645 levelWeight = levelWeight / items; 647 levelWeight = levelWeight / items;
646 // Take in to account "." and ".." 648 // Take in to account "." and ".."
647 overallProgress += (listPositions[d] - 3) * levelWeight; 649 overallProgress += (listPositions[d] - 3) * levelWeight;
648 } 650 }
649 } else { 651 } else {
650 break; 652 break;
651 } 653 }
652 } 654 }
653 655
654 // odebug << "overallProgress: " << overallProgress << "" << oendl; 656 // odebug << "overallProgress: " << overallProgress << "" << oendl;
655 657
656 if ( serverGui ) 658 if ( serverGui )
657 serverGui->documentScanningProgress( (int)overallProgress ); 659 serverGui->documentScanningProgress( (int)overallProgress );
658} 660}
659 661
660 662
661const QString DocumentListPrivate::nextFile() 663const QString DocumentListPrivate::nextFile()
662{ 664{
663 while ( TRUE ) { 665 while ( TRUE ) {
664 while ( searchDepth < 0 ) { 666 while ( searchDepth < 0 ) {
665 // go to next base path 667 // go to next base path
666 if ( docPathsSearched >= docPaths.count() ) { 668 if ( docPathsSearched >= docPaths.count() ) {
667 // end of base paths 669 // end of base paths
668 return QString::null; 670 return QString::null;
669 } else { 671 } else {
670 QDir dir( docPaths[docPathsSearched] ); 672 QDir dir( docPaths[docPathsSearched] );
671 // odebug << "now using base path: " << docPaths[docPathsSearched] << "" << oendl; 673 // odebug << "now using base path: " << docPaths[docPathsSearched] << "" << oendl;
672 docPathsSearched++; 674 docPathsSearched++;
673 if ( !dir.exists( ".Qtopia-ignore" ) ) { 675 if ( !dir.exists( ".Qtopia-ignore" ) ) {
674 listDirs[0] = new QDir( dir ); 676 listDirs[0] = new QDir( dir );
675 lists[0] = listDirs[0]->entryInfoList(); 677 lists[0] = listDirs[0]->entryInfoList();
676 listPositions[0] = 0; 678 listPositions[0] = 0;
677 searchDepth = 0; 679 searchDepth = 0;
678 } 680 }
679 } 681 }
680 } 682 }
681 683
682 const QFileInfoList *fil = lists[searchDepth]; 684 const QFileInfoList *fil = lists[searchDepth];
683 if (!fil) { 685 if (!fil) {
684 return QString::null; 686 return QString::null;
685 } 687 }
686 QFileInfoList *fl = (QFileInfoList *)fil; 688 QFileInfoList *fl = (QFileInfoList *)fil;
687 unsigned int pos = listPositions[searchDepth]; 689 unsigned int pos = listPositions[searchDepth];
688 690
689 if ( pos >= fl->count() ) { 691 if ( pos >= fl->count() ) {
690 // go up a depth 692 // go up a depth
691 delete listDirs[searchDepth]; 693 delete listDirs[searchDepth];
692 listDirs[searchDepth] = 0; 694 listDirs[searchDepth] = 0;
693 lists[searchDepth] = 0; 695 lists[searchDepth] = 0;
694 listPositions[searchDepth] = 0; 696 listPositions[searchDepth] = 0;
695 searchDepth--; 697 searchDepth--;
696 } else { 698 } else {
697 const QFileInfo *fi = fl->at(pos); 699 const QFileInfo *fi = fl->at(pos);
698 listPositions[searchDepth]++; 700 listPositions[searchDepth]++;
699 QString bn = fi->fileName(); 701 QString bn = fi->fileName();
700 if ( bn[0] != '.' ) { 702 if ( bn[0] != '.' ) {
701 if ( fi->isDir() ) { 703 if ( fi->isDir() ) {
702 if ( bn != "CVS" && bn != "Qtopia" && bn != "QtPalmtop" ) { 704 if ( bn != "CVS" && bn != "Qtopia" && bn != "QtPalmtop" ) {
703 // go down a depth 705 // go down a depth
704 QDir dir( fi->filePath() ); 706 QDir dir( fi->filePath() );
705 // odebug << "now going in to path: " << bn << "" << oendl; 707 // odebug << "now going in to path: " << bn << "" << oendl;
706 if ( !dir.exists( ".Qtopia-ignore" ) ) { 708 if ( !dir.exists( ".Qtopia-ignore" ) ) {
707 if ( searchDepth < MAX_SEARCH_DEPTH - 1) { 709 if ( searchDepth < MAX_SEARCH_DEPTH - 1) {
708 searchDepth++; 710 searchDepth++;
709 listDirs[searchDepth] = new QDir( dir ); 711 listDirs[searchDepth] = new QDir( dir );
710 lists[searchDepth] = listDirs[searchDepth]->entryInfoList(); 712 lists[searchDepth] = listDirs[searchDepth]->entryInfoList();
711 listPositions[searchDepth] = 0; 713 listPositions[searchDepth] = 0;
712 } 714 }
713 } 715 }
714 } 716 }
715 } else { 717 } else {
716 estimatedPercentScanned(); 718 estimatedPercentScanned();
717 return fl->at(pos)->filePath(); 719 return fl->at(pos)->filePath();
718 } 720 }
719 } 721 }
720 } 722 }
721 } 723 }
722 724
723 return QString::null; 725 return QString::null;
724} 726}
725 727
726 728
727bool DocumentListPrivate::store( DocLnk* dl ) 729bool DocumentListPrivate::store( DocLnk* dl )
728{ 730{
729 // if ( dl->fileKnown() && !dl->file().isEmpty() ) { 731 // if ( dl->fileKnown() && !dl->file().isEmpty() ) {
730 if ( dl && dl->fileKnown() ) { 732 if ( dl && dl->fileKnown() ) {
731 dls.add( dl ); // store 733 dls.add( dl ); // store
732 return TRUE; 734 return TRUE;
733 } 735 }
734 736
735 // don't store - delete 737 // don't store - delete
736 delete dl; 738 delete dl;
737 return FALSE; 739 return FALSE;
738} 740}
739 741
740 742
741#define MAGIC_NUMBER ((void*)2) 743#define MAGIC_NUMBER ((void*)2)
742 744
743const DocLnk *DocumentListPrivate::iterate() 745const DocLnk *DocumentListPrivate::iterate()
744{ 746{
745 if ( state == Find ) { 747 if ( state == Find ) {
746 //odebug << "state Find" << oendl; 748 //odebug << "state Find" << oendl;
747 QString file = nextFile(); 749 QString file = nextFile();
748 while ( !file.isNull() ) { 750 while ( !file.isNull() ) {
749 if ( file.right(8) == ".desktop" ) { // No tr 751 if ( file.right(8) == ".desktop" ) { // No tr
750 DocLnk* dl = new DocLnk( file ); 752 DocLnk* dl = new DocLnk( file );
751 if ( store(dl) ) 753 if ( store(dl) )
752 return dl; 754 return dl;
753 } else { 755 } else {
754 reference.insert( file, MAGIC_NUMBER ); 756 reference.insert( file, MAGIC_NUMBER );
755 } 757 }
756 file = nextFile(); 758 file = nextFile();
757 } 759 }
758 state = RemoveKnownFiles; 760 state = RemoveKnownFiles;
759 761
diff --git a/core/launcher/firstuse.cpp b/core/launcher/firstuse.cpp
index 8344787..8c02ab0 100644
--- a/core/launcher/firstuse.cpp
+++ b/core/launcher/firstuse.cpp
@@ -1,514 +1,512 @@
1/********************************************************************** 1/*
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2                 This file is part of the Opie Project
3** 3 =. (C) 2000-2002 Trolltech AS
4** This file is part of the Qtopia Environment. 4 .=l. (C) 2002-2005 The Opie Team <opie-devel@handhelds.org>
5** 5           .>+-=
6** This file may be distributed and/or modified under the terms of the 6 _;:,     .>    :=|. This program is free software; you can
7** GNU General Public License version 2 as published by the Free Software 7.> <`_,   >  .   <= redistribute it and/or modify it under
8** Foundation and appearing in the file LICENSE.GPL included in the 8 :`=1 )Y*s>-.--   : the terms of the GNU Library General Public
9** packaging of this file. 9.="- .-=="i,     .._ License as published by the Free Software
10** 10 - .   .-<_>     .<> Foundation; version 2 of the License.
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11     ._= =}       :
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12    .%`+i>       _;_.
13** 13    .i_,=:_.      -<s. This program is distributed in the hope that
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15** 15 : ..    .:,     . . . without even the implied warranty of
16** Contact info@trolltech.com if any conditions of this licensing are 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17** not clear to you. 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
18** 18..}^=.=       =       ; Library General Public License for more
19**********************************************************************/ 19++=   -.     .`     .: details.
20 :     =  ...= . :.=-
21 -.   .:....=;==+<; You should have received a copy of the GNU
22  -_. . .   )=.  = Library General Public License along with
23    --        :-=` this library; see the file COPYING.LIB.
24 If not, write to the Free Software Foundation,
25 Inc., 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA.
27*/
20 28
21// I need access to some things you don't normally get access to. 29// I need access to some things you don't normally get access to.
22
23#ifndef _MSC_VER 30#ifndef _MSC_VER
24 //### revise to allow removal of translators under MSVC 31 //### revise to allow removal of translators under MSVC
25#define private public 32#define private public
26#define protected public 33#define protected public
27#endif 34#endif
28#include "firstuse.h" 35#include "firstuse.h"
29#include "inputmethods.h" 36#include "inputmethods.h"
30#include "applauncher.h" 37#include "applauncher.h"
31#include "serverapp.h" 38#include "serverapp.h"
32#include "calibrate.h" 39#include "calibrate.h"
33#include "documentlist.h" 40#include "documentlist.h"
34 41
35/* OPIE */ 42/* OPIE */
36#include <opie2/odebug.h> 43#include <opie2/odebug.h>
37#include <qtopia/resource.h> 44#include <opie2/oresource.h>
38#include <qtopia/qcopenvelope_qws.h> 45#include <qtopia/qcopenvelope_qws.h>
39#include <qtopia/config.h> 46#include <qtopia/config.h>
40#include <qtopia/fontmanager.h> 47#include <qtopia/fontmanager.h>
41using namespace Opie::Core; 48using namespace Opie::Core;
42 49
43/* QT */ 50/* QT */
44#include <qfile.h> 51#include <qfile.h>
45#include <qpainter.h> 52#include <qpainter.h>
46#include <qsimplerichtext.h> 53#include <qsimplerichtext.h>
47#include <qpushbutton.h> 54#include <qpushbutton.h>
48#include <qlabel.h> 55#include <qlabel.h>
49#include <qtimer.h> 56#include <qtimer.h>
50 57
51#if defined( Q_WS_QWS ) 58#if defined( Q_WS_QWS )
52#include <qwsdisplay_qws.h> 59#include <qwsdisplay_qws.h>
53#include <qgfx_qws.h> 60#include <qgfx_qws.h>
54#endif 61#endif
55 62
56/* STD */ 63/* STD */
57#include <stdlib.h> 64#include <stdlib.h>
58#include <sys/types.h> 65#include <sys/types.h>
59#if defined(Q_OS_LINUX) || defined(_OS_LINUX_) 66#if defined(Q_OS_LINUX) || defined(_OS_LINUX_)
60#include <unistd.h> 67#include <unistd.h>
61#endif 68#endif
62 69
63 70
64struct settingsTable_t { 71struct settingsTable_t {
65 bool enabled : 1; 72 bool enabled : 1;
66 const char *app; 73 const char *app;
67 const char *start; 74 const char *start;
68 const char *stop; 75 const char *stop;
69 const char *desc; 76 const char *desc;
70}; 77};
71 78
72static settingsTable_t settingsTable [] = 79static settingsTable_t settingsTable [] =
73{ 80{
74 { FALSE, "language", "raise()", "accept()", // No tr 81 { FALSE, "language", "raise()", "accept()", // No tr
75 QT_TR_NOOP("Language") }, 82 QT_TR_NOOP("Language") },
76 { FALSE, "doctab", "raise()", "accept()", // No tr 83 { FALSE, "doctab", "raise()", "accept()", // No tr
77 QT_TR_NOOP("DocTab") }, 84 QT_TR_NOOP("DocTab") },
78#ifndef Q_OS_WIN32 85#ifndef Q_OS_WIN32
79 { FALSE, "systemtime", "raise()", "accept()", // No tr 86 { FALSE, "systemtime", "raise()", "accept()", // No tr
80 QT_TR_NOOP("Time and Date") }, 87 QT_TR_NOOP("Time and Date") },
81#endif 88#endif
82 { FALSE, "addressbook", "editPersonalAndClose()", "accept()", // No tr 89 { FALSE, "addressbook", "editPersonalAndClose()", "accept()", // No tr
83 QT_TR_NOOP("Personal Information") }, 90 QT_TR_NOOP("Personal Information") },
84 { FALSE, 0, 0, 0, 0 } 91 { FALSE, 0, 0, 0, 0 }
85}; 92};
86 93
87 94
88FirstUse::FirstUse(QWidget* parent, const char * name, WFlags wf) : 95FirstUse::FirstUse(QWidget* parent, const char * name, WFlags wf) :
89 QDialog( parent, name, TRUE, wf), 96 QDialog( parent, name, TRUE, wf),
90 transApp(0), transLib(0), needCalibrate(FALSE), currApp(-1), 97 transApp(0), transLib(0), needCalibrate(FALSE), currApp(-1),
91 waitForExit(-1), waitingForLaunch(FALSE), needRestart(FALSE) 98 waitForExit(-1), waitingForLaunch(FALSE), needRestart(FALSE)
92{ 99{
93 ServerApplication::allowRestart = FALSE; 100 ServerApplication::allowRestart = FALSE;
94 // we force our height beyound the maximum (which we set anyway) 101 // we force our height beyound the maximum (which we set anyway)
95 QRect desk = qApp->desktop()->geometry(); 102 QRect desk = qApp->desktop()->geometry();
96 setGeometry( 0, 0, desk.width(), desk.height() ); 103 setGeometry( 0, 0, desk.width(), desk.height() );
97 104
98 connect(qwsServer, SIGNAL(newChannel(const QString&)), 105 connect(qwsServer, SIGNAL(newChannel(const QString&)),
99 this, SLOT(newQcopChannel(const QString&))); 106 this, SLOT(newQcopChannel(const QString&)));
100 107
101 // Create a DocumentList so appLauncher has appLnkSet to search 108 // Create a DocumentList so appLauncher has appLnkSet to search
102 docList = new DocumentList( 0, FALSE ); 109 docList = new DocumentList( 0, FALSE );
103 appLauncher = new AppLauncher( this ); 110 appLauncher = new AppLauncher( this );
104 connect( appLauncher, SIGNAL(terminated(int,const QString&)), 111 connect( appLauncher, SIGNAL(terminated(int,const QString&)),
105 this, SLOT(terminated(int,const QString&)) ); 112 this, SLOT(terminated(int,const QString&)) );
106 113
107 // more hackery 114 // more hackery
108 // I will be run as either the main server or as part of the main server 115 // I will be run as either the main server or as part of the main server
109 QWSServer::setScreenSaverIntervals(0); 116 QWSServer::setScreenSaverIntervals(0);
110 loadPixmaps(); 117 loadPixmaps();
111 118
112 //check if there is a language program 119 //check if there is a language program
113#ifndef Q_OS_WIN32 120#ifndef Q_OS_WIN32
114 QString exeSuffix; 121 QString exeSuffix;
115#else 122#else
116 QString exeSuffix(".exe"); 123 QString exeSuffix(".exe");
117#endif 124#endif
118 125
119 for ( int i = 0; settingsTable[i].app; i++ ) { 126 for ( int i = 0; settingsTable[i].app; i++ ) {
120 QString file = QPEApplication::qpeDir() + "bin/"; 127 QString file = QPEApplication::qpeDir() + "bin/";
121 file += settingsTable[i].app; 128 file += settingsTable[i].app;
122 file += exeSuffix; 129 file += exeSuffix;
123 if ( QFile::exists(file) ) 130 if ( QFile::exists(file) )
124 settingsTable[i].enabled = TRUE; 131 settingsTable[i].enabled = TRUE;
125 } 132 }
126 133
127 setFocusPolicy(NoFocus); 134 setFocusPolicy(NoFocus);
128 135
129 taskBar = new QWidget(0, 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop | WGroupLeader); 136 taskBar = new QWidget(0, 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop | WGroupLeader);
130 137
131 inputMethods = new InputMethods(taskBar); 138 inputMethods = new InputMethods(taskBar);
132 connect(inputMethods, SIGNAL(inputToggled(bool)), 139 connect(inputMethods, SIGNAL(inputToggled(bool)),
133 this, SLOT(calcMaxWindowRect())); 140 this, SLOT(calcMaxWindowRect()));
134 141
135 back = new QPushButton(tr("<< Back"), taskBar); 142 back = new QPushButton(tr("<< Back"), taskBar);
136 back->setFocusPolicy(NoFocus); 143 back->setFocusPolicy(NoFocus);
137 connect(back, SIGNAL(clicked()), this, SLOT(previousDialog()) ); 144 connect(back, SIGNAL(clicked()), this, SLOT(previousDialog()) );
138 145
139 next = new QPushButton(tr("Next >>"), taskBar); 146 next = new QPushButton(tr("Next >>"), taskBar);
140 next->setFocusPolicy(NoFocus); 147 next->setFocusPolicy(NoFocus);
141 connect(next, SIGNAL(clicked()), this, SLOT(nextDialog()) ); 148 connect(next, SIGNAL(clicked()), this, SLOT(nextDialog()) );
142 149
143 // need to set the geom to lower corner 150 // need to set the geom to lower corner
144 QSize sz = inputMethods->sizeHint(); 151 QSize sz = inputMethods->sizeHint();
145 int buttonWidth = (width() - sz.width()) / 2; 152 int buttonWidth = (width() - sz.width()) / 2;
146 int x = 0; 153 int x = 0;
147 154
148 controlHeight = back->sizeHint().height(); 155 controlHeight = back->sizeHint().height();
149 156
150 inputMethods->setGeometry(0,0, sz.width(), controlHeight ); 157 inputMethods->setGeometry(0,0, sz.width(), controlHeight );
151 x += sz.width(); 158 x += sz.width();
152 159
153 back->setGeometry(x, 0, buttonWidth, controlHeight); 160 back->setGeometry(x, 0, buttonWidth, controlHeight);
154 x += buttonWidth; 161 x += buttonWidth;
155 next->setGeometry(x, 0, buttonWidth, controlHeight); 162 next->setGeometry(x, 0, buttonWidth, controlHeight);
156 163
157 taskBar->setGeometry( 0, height() - controlHeight, desk.width(), controlHeight); 164 taskBar->setGeometry( 0, height() - controlHeight, desk.width(), controlHeight);
158 taskBar->hide(); 165 taskBar->hide();
159 166
160#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 167#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
161 odebug << "Setting up QCop to QPE/System" << oendl; 168 odebug << "Setting up QCop to QPE/System" << oendl;
162 QCopChannel* sysChannel = new QCopChannel( "QPE/System", this ); 169 QCopChannel* sysChannel = new QCopChannel( "QPE/System", this );
163 connect(sysChannel, SIGNAL(received(const QCString&,const QByteArray&)), 170 connect(sysChannel, SIGNAL(received(const QCString&,const QByteArray&)),
164 this, SLOT(message(const QCString&,const QByteArray&)) ); 171 this, SLOT(message(const QCString&,const QByteArray&)) );
165#endif 172#endif
166 calcMaxWindowRect(); 173 calcMaxWindowRect();
167 174
168 m_calHandler = ( QWSServer::mouseHandler() && QWSServer::mouseHandler()->inherits("QCalibratedMouseHandler") ) ? true : false; 175 m_calHandler = ( QWSServer::mouseHandler() && QWSServer::mouseHandler()->inherits("QCalibratedMouseHandler") ) ? true : false;
169 176
170 if ( m_calHandler) { 177 if ( m_calHandler) {
171 if ( !QFile::exists("/etc/pointercal") ) { 178 if ( !QFile::exists("/etc/pointercal") ) {
172 needCalibrate = TRUE; 179 needCalibrate = TRUE;
173 grabMouse(); 180 grabMouse();
174 } 181 }
175 } 182 }
176 183
177 Config config("locale"); 184 Config config("locale");
178 config.setGroup( "Language"); 185 config.setGroup( "Language");
179 lang = config.readEntry( "Language", "en"); 186 lang = config.readEntry( "Language", "en");
180 187
181 defaultFont = font(); 188 defaultFont = font();
182 189
183 //###language/font hack; should look it up somewhere 190 //###language/font hack; should look it up somewhere
184#ifdef Q_WS_QWS 191#ifdef Q_WS_QWS
185 if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { 192 if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) {
186 QFont fn = FontManager::unicodeFont( FontManager::Proportional ); 193 QFont fn = FontManager::unicodeFont( FontManager::Proportional );
187 qApp->setFont( fn, TRUE ); 194 qApp->setFont( fn, TRUE );
188 } 195 }
189#endif 196#endif
190} 197}
191 198
192FirstUse::~FirstUse() 199FirstUse::~FirstUse()
193{ 200{
194 delete appLauncher; 201 delete appLauncher;
195 delete docList; 202 delete docList;
196 delete taskBar; 203 delete taskBar;
197 ServerApplication::allowRestart = TRUE; 204 ServerApplication::allowRestart = TRUE;
198} 205}
199 206
200void FirstUse::calcMaxWindowRect() 207void FirstUse::calcMaxWindowRect()
201{ 208{
202#ifdef Q_WS_QWS 209#ifdef Q_WS_QWS
203 QRect wr; 210 QRect wr;
204 int displayWidth = qApp->desktop()->width(); 211 int displayWidth = qApp->desktop()->width();
205 QRect ir = inputMethods->inputRect(); 212 QRect ir = inputMethods->inputRect();
206 if ( ir.isValid() ) { 213 if ( ir.isValid() ) {
207 wr.setCoords( 0, 0, displayWidth-1, ir.top()-1 ); 214 wr.setCoords( 0, 0, displayWidth-1, ir.top()-1 );
208 } else { 215 } else {
209 wr.setCoords( 0, 0, displayWidth-1, 216 wr.setCoords( 0, 0, displayWidth-1,
210 qApp->desktop()->height() - controlHeight-1); 217 qApp->desktop()->height() - controlHeight-1);
211 } 218 }
212 219
213#if QT_VERSION < 0x030000 220#if QT_VERSION < 0x030000
214 QWSServer::setMaxWindowRect( qt_screen->mapToDevice(wr, 221 QWSServer::setMaxWindowRect( qt_screen->mapToDevice(wr,
215 QSize(qt_screen->width(),qt_screen->height())) 222 QSize(qt_screen->width(),qt_screen->height()))
216 ); 223 );
217#else 224#else
218 QWSServer::setMaxWindowRect( wr ); 225 QWSServer::setMaxWindowRect( wr );
219#endif 226#endif
220#endif 227#endif
221} 228}
222 229
223/* cancel current dialog, and bring up next */ 230/* cancel current dialog, and bring up next */
224void FirstUse::nextDialog() 231void FirstUse::nextDialog()
225{ 232{
226 int prevApp = currApp; 233 int prevApp = currApp;
227 do { 234 do {
228 currApp++; 235 currApp++;
229 odebug << "currApp = " << currApp << "" << oendl; 236 odebug << "currApp = " << currApp << "" << oendl;
230 if ( settingsTable[currApp].app == 0 ) { 237 if ( settingsTable[currApp].app == 0 ) {
231 if ( prevApp >= 0 && appLauncher->isRunning(settingsTable[prevApp].app) ) { 238 if ( prevApp >= 0 && appLauncher->isRunning(settingsTable[prevApp].app) ) {
232 // The last application is still running. 239 // The last application is still running.
233 // Tell it to stop, and when its done we'll come back 240 // Tell it to stop, and when its done we'll come back
234 // to nextDialog and exit. 241 // to nextDialog and exit.
235 odebug << "Waiting for " << settingsTable[prevApp].app << " to exit" << oendl; 242 odebug << "Waiting for " << settingsTable[prevApp].app << " to exit" << oendl;
236 QCopEnvelope e(QCString("QPE/Application/") + settingsTable[prevApp].app, 243 QCopEnvelope e(QCString("QPE/Application/") + settingsTable[prevApp].app,
237 settingsTable[prevApp].stop ); 244 settingsTable[prevApp].stop );
238 currApp = prevApp; 245 currApp = prevApp;
239 } else { 246 } else {
240 odebug << "Done!" << oendl; 247 odebug << "Done!" << oendl;
241 Config config( "qpe" ); 248 Config config( "qpe" );
242 config.setGroup( "Startup" ); 249 config.setGroup( "Startup" );
243 config.writeEntry( "FirstUse", FALSE ); 250 config.writeEntry( "FirstUse", FALSE );
244 QPixmap pix = Resource::loadPixmap("bigwait"); 251 QLabel *lblWait = new QLabel("Please Wait...", 0, "wait hack!", // No tr
245 QLabel *lblWait = new QLabel(0, "wait hack!", // No tr
246 QWidget::WStyle_Customize | QWidget::WDestructiveClose | 252 QWidget::WStyle_Customize | QWidget::WDestructiveClose |
247 QWidget::WStyle_NoBorder | QWidget::WStyle_Tool | 253 QWidget::WStyle_NoBorder | QWidget::WStyle_Tool |
248 QWidget::WStyle_StaysOnTop); 254 QWidget::WStyle_StaysOnTop);
249 lblWait->setPixmap( pix );
250 lblWait->setAlignment( QWidget::AlignCenter ); 255 lblWait->setAlignment( QWidget::AlignCenter );
251 lblWait->setGeometry( qApp->desktop()->geometry() ); 256 lblWait->setGeometry( qApp->desktop()->geometry() );
252 lblWait->show(); 257 lblWait->show();
253 qApp->processEvents(); 258 qApp->processEvents();
254 QTimer::singleShot( 1000, lblWait, SLOT(close()) ); 259 QTimer::singleShot( 1000, lblWait, SLOT(close()) );
255 repaint(); 260 repaint();
256 close(); 261 close();
257 ServerApplication::allowRestart = TRUE; 262 ServerApplication::allowRestart = TRUE;
258 } 263 }
259 return; 264 return;
260 } 265 }
261 } while ( !settingsTable[currApp].enabled ); 266 } while ( !settingsTable[currApp].enabled );
262 267
263 if ( prevApp >= 0 && appLauncher->isRunning(settingsTable[prevApp].app) ) { 268 if ( prevApp >= 0 && appLauncher->isRunning(settingsTable[prevApp].app) ) {
264 odebug << "Shutdown: " << settingsTable[prevApp].app << "" << oendl; 269 odebug << "Shutdown: " << settingsTable[prevApp].app << "" << oendl;
265 QCopEnvelope e(QCString("QPE/Application/") + settingsTable[prevApp].app, 270 QCopEnvelope e(QCString("QPE/Application/") + settingsTable[prevApp].app,
266 settingsTable[prevApp].stop ); 271 settingsTable[prevApp].stop );
267 waitForExit = prevApp; 272 waitForExit = prevApp;
268 } else { 273 } else {
269 odebug << "Startup: " << settingsTable[currApp].app << "" << oendl; 274 odebug << "Startup: " << settingsTable[currApp].app << "" << oendl;
270 QCopEnvelope e(QCString("QPE/Application/") + settingsTable[currApp].app, 275 QCopEnvelope e(QCString("QPE/Application/") + settingsTable[currApp].app,
271 settingsTable[currApp].start ); 276 settingsTable[currApp].start );
272 waitingForLaunch = TRUE; 277 waitingForLaunch = TRUE;
273 } 278 }
274 279
275 updateButtons(); 280 updateButtons();
276} 281}
277 282
278/* accept current dialog and bring up previous */ 283/* accept current dialog and bring up previous */
279void FirstUse::previousDialog() 284void FirstUse::previousDialog()
280{ 285{
281 int prevApp = currApp; 286 int prevApp = currApp;
282 do { 287 do {
283 currApp--; 288 currApp--;
284 if ( currApp < 0 ) { 289 if ( currApp < 0 ) {
285 currApp = prevApp; 290 currApp = prevApp;
286 return; 291 return;
287 } 292 }
288 } while ( !settingsTable[currApp].enabled ); 293 } while ( !settingsTable[currApp].enabled );
289 294
290 if ( prevApp >= 0 ) { 295 if ( prevApp >= 0 ) {
291 odebug << "Shutdown: " << settingsTable[prevApp].app << "" << oendl; 296 odebug << "Shutdown: " << settingsTable[prevApp].app << "" << oendl;
292 QCopEnvelope e(QCString("QPE/Application/") + settingsTable[prevApp].app, 297 QCopEnvelope e(QCString("QPE/Application/") + settingsTable[prevApp].app,
293 settingsTable[prevApp].stop ); 298 settingsTable[prevApp].stop );
294/* 299/*
295 if (settingsTable[prevApp].app == QString("systemtime")) 300 if (settingsTable[prevApp].app == QString("systemtime"))
296 QCopEnvelope e("QPE/Application/citytime", "close()"); 301 QCopEnvelope e("QPE/Application/citytime", "close()");
297*/ 302*/
298 waitForExit = prevApp; 303 waitForExit = prevApp;
299 } else { 304 } else {
300 odebug << "Startup: " << settingsTable[currApp].app << "" << oendl; 305 odebug << "Startup: " << settingsTable[currApp].app << "" << oendl;
301 QCopEnvelope e(QCString("QPE/Application/") + settingsTable[currApp].app, 306 QCopEnvelope e(QCString("QPE/Application/") + settingsTable[currApp].app,
302 settingsTable[currApp].start ); 307 settingsTable[currApp].start );
303 waitingForLaunch = TRUE; 308 waitingForLaunch = TRUE;
304 } 309 }
305 310
306 updateButtons(); 311 updateButtons();
307} 312}
308 313
309void FirstUse::message(const QCString &msg, const QByteArray &data) 314void FirstUse::message(const QCString &msg, const QByteArray &data)
310{ 315{
311 QDataStream stream( data, IO_ReadOnly ); 316 QDataStream stream( data, IO_ReadOnly );
312 if ( msg == "timeChange(QString)" ) { 317 if ( msg == "timeChange(QString)" ) {
313 QString t; 318 QString t;
314 stream >> t; 319 stream >> t;
315 if ( t.isNull() ) 320 if ( t.isNull() )
316 unsetenv("TZ"); 321 unsetenv("TZ");
317 else 322 else
318 setenv( "TZ", t.latin1(), 1 ); 323 setenv( "TZ", t.latin1(), 1 );
319 } 324 }
320} 325}
321 326
322void FirstUse::terminated( int, const QString &app ) 327void FirstUse::terminated( int, const QString &app )
323{ 328{
324 odebug << "--- terminated: " << app << "" << oendl; 329 odebug << "--- terminated: " << app << "" << oendl;
325 if ( waitForExit != -1 && settingsTable[waitForExit].app == app ) { 330 if ( waitForExit != -1 && settingsTable[waitForExit].app == app ) {
326 odebug << "Startup: " << settingsTable[currApp].app << "" << oendl; 331 odebug << "Startup: " << settingsTable[currApp].app << "" << oendl;
327 if ( settingsTable[waitForExit].app == "language" ) { // No tr 332 if ( settingsTable[waitForExit].app == "language" ) { // No tr
328 Config config("locale"); 333 Config config("locale");
329 config.setGroup( "Language"); 334 config.setGroup( "Language");
330 QString l = config.readEntry( "Language", "en"); 335 QString l = config.readEntry( "Language", "en");
331 if ( l != lang ) { 336 if ( l != lang ) {
332 reloadLanguages(); 337 reloadLanguages();
333 needRestart = TRUE; 338 needRestart = TRUE;
334 lang = l; 339 lang = l;
335 } 340 }
336 } 341 }
337 QCopEnvelope e(QCString("QPE/Application/") + settingsTable[currApp].app, 342 QCopEnvelope e(QCString("QPE/Application/") + settingsTable[currApp].app,
338 settingsTable[currApp].start ); 343 settingsTable[currApp].start );
339 waitingForLaunch = TRUE; 344 waitingForLaunch = TRUE;
340 updateButtons(); 345 updateButtons();
341 repaint(); 346 repaint();
342 waitForExit = -1; 347 waitForExit = -1;
343 } else if ( settingsTable[currApp].app == app ) { 348 } else if ( settingsTable[currApp].app == app ) {
344 nextDialog(); 349 nextDialog();
345 } else { 350 } else {
346 back->setEnabled(TRUE); 351 back->setEnabled(TRUE);
347 next->setEnabled(TRUE); 352 next->setEnabled(TRUE);
348 } 353 }
349} 354}
350 355
351void FirstUse::newQcopChannel(const QString& channelName) 356void FirstUse::newQcopChannel(const QString& channelName)
352{ 357{
353 odebug << "channel " << channelName.data() << " added" << oendl; 358 odebug << "channel " << channelName.data() << " added" << oendl;
354 QString prefix("QPE/Application/"); 359 QString prefix("QPE/Application/");
355 if (channelName.startsWith(prefix)) { 360 if (channelName.startsWith(prefix)) {
356 QString appName = channelName.mid(prefix.length()); 361 QString appName = channelName.mid(prefix.length());
357 if ( currApp >= 0 && appName == settingsTable[currApp].app ) { 362 if ( currApp >= 0 && appName == settingsTable[currApp].app ) {
358 odebug << "Application: " << settingsTable[currApp].app << " started" << oendl; 363 odebug << "Application: " << settingsTable[currApp].app << " started" << oendl;
359 waitingForLaunch = FALSE; 364 waitingForLaunch = FALSE;
360 updateButtons(); 365 updateButtons();
361 repaint(); 366 repaint();
362 } else if (appName != "quicklauncher") { 367 } else if (appName != "quicklauncher") {
363 back->setEnabled(FALSE); 368 back->setEnabled(FALSE);
364 next->setEnabled(FALSE); 369 next->setEnabled(FALSE);
365 } 370 }
366 } 371 }
367} 372}
368 373
369void FirstUse::reloadLanguages() 374void FirstUse::reloadLanguages()
370{ 375{
371 // read language from config file. Waiting on QCop takes too long. 376 // read language from config file. Waiting on QCop takes too long.
372 Config config("locale"); 377 Config config("locale");
373 config.setGroup( "Language"); 378 config.setGroup( "Language");
374 QString l = config.readEntry( "Language", "en"); 379 QString l = config.readEntry( "Language", "en");
375 QString cl = getenv("LANG"); 380 QString cl = getenv("LANG");
376 owarn << "language message - " + l << oendl; 381 owarn << "language message - " + l << oendl;
377 // setting anyway... 382 // setting anyway...
378 if (l.isNull() ) 383 if (l.isNull() )
379 unsetenv( "LANG" ); 384 unsetenv( "LANG" );
380 else { 385 else {
381 owarn << "and its not null" << oendl; 386 owarn << "and its not null" << oendl;
382 setenv( "LANG", l.latin1(), 1 ); 387 setenv( "LANG", l.latin1(), 1 );
383 } 388 }
384#ifndef QT_NO_TRANSLATION 389#ifndef QT_NO_TRANSLATION
385 // clear old translators 390 // clear old translators
386#ifndef _MSC_VER 391#ifndef _MSC_VER
387 //### revise to allow removal of translators under MSVC 392 //### revise to allow removal of translators under MSVC
388 if(qApp->translators) { 393 if(qApp->translators) {
389 qApp->translators->setAutoDelete(TRUE); 394 qApp->translators->setAutoDelete(TRUE);
390 delete (qApp->translators); 395 delete (qApp->translators);
391 qApp->translators = 0; 396 qApp->translators = 0;
392 } 397 }
393#endif 398#endif
394 399
395 // load translation tables 400 // load translation tables
396 transApp = new QTranslator(qApp); 401 transApp = new QTranslator(qApp);
397 QString tfn = QPEApplication::qpeDir() + "i18n/"+l+"/qpe.qm"; 402 QString tfn = QPEApplication::qpeDir() + "i18n/"+l+"/qpe.qm";
398 owarn << "loading " + tfn << oendl; 403 owarn << "loading " + tfn << oendl;
399 if ( transApp->load(tfn) ) { 404 if ( transApp->load(tfn) ) {
400 owarn << "installing translator" << oendl; 405 owarn << "installing translator" << oendl;
401 qApp->installTranslator( transApp ); 406 qApp->installTranslator( transApp );
402 } else { 407 } else {
403 delete transApp; 408 delete transApp;
404 transApp = 0; 409 transApp = 0;
405 } 410 }
406 411
407 transLib = new QTranslator(qApp); 412 transLib = new QTranslator(qApp);
408 tfn = QPEApplication::qpeDir() + "i18n/"+l+"/libqpe.qm"; 413 tfn = QPEApplication::qpeDir() + "i18n/"+l+"/libqpe.qm";
409 owarn << "loading " + tfn << oendl; 414 owarn << "loading " + tfn << oendl;
410 if ( transLib->load(tfn) ) { 415 if ( transLib->load(tfn) ) {
411 owarn << "installing translator library" << oendl; 416 owarn << "installing translator library" << oendl;
412 qApp->installTranslator( transLib ); 417 qApp->installTranslator( transLib );
413 } else { 418 } else {
414 delete transLib; 419 delete transLib;
415 transLib = 0; 420 transLib = 0;
416 } 421 }
417 loadPixmaps(); 422 loadPixmaps();
418 //###language/font hack; should look it up somewhere 423 //###language/font hack; should look it up somewhere
419#ifdef Q_WS_QWS 424#ifdef Q_WS_QWS
420 if ( l == "ja" || l == "zh_CN" || l == "zh_TW" || l == "ko" ) { 425 if ( l == "ja" || l == "zh_CN" || l == "zh_TW" || l == "ko" ) {
421 QFont fn = FontManager::unicodeFont( FontManager::Proportional ); 426 QFont fn = FontManager::unicodeFont( FontManager::Proportional );
422 qApp->setFont( fn, TRUE ); 427 qApp->setFont( fn, TRUE );
423 } else { 428 } else {
424 qApp->setFont( defaultFont, TRUE ); 429 qApp->setFont( defaultFont, TRUE );
425 } 430 }
426#endif 431#endif
427#endif 432#endif
428} 433}
429 434
430void FirstUse::paintEvent( QPaintEvent * ) 435void FirstUse::paintEvent( QPaintEvent * )
431{ 436{
432 QPainter p( this ); 437 QPainter p( this );
433
434 p.drawPixmap(0,0, splash); 438 p.drawPixmap(0,0, splash);
435 439
436 QFont f = p.font();
437 f.setPointSize(15);
438 f.setItalic(FALSE);
439 f.setBold(FALSE);
440 p.setFont(f);
441
442 if ( currApp < 0 ) { 440 if ( currApp < 0 ) {
443 drawText(p, tr( "Tap anywhere on the screen to continue." )); 441 drawText(p, tr( "Tap anywhere on the screen to continue." ));
444 } else if ( settingsTable[currApp].app ) { 442 } else if ( settingsTable[currApp].app ) {
445 if ( waitingForLaunch ) 443 if ( waitingForLaunch )
446 drawText(p, tr("Please wait, loading %1 settings.").arg(tr(settingsTable[currApp].desc)) ); 444 drawText(p, tr("Please wait, loading %1 settings.").arg(tr(settingsTable[currApp].desc)) );
447 } else { 445 } else {
448 drawText(p, tr("Please wait...")); 446 drawText(p, tr("Please wait..."));
449 } 447 }
450} 448}
451 449
452void FirstUse::loadPixmaps() 450void FirstUse::loadPixmaps()
453{ 451{
454 splash.convertFromImage( Resource::loadImage("launcher/firstuse") 452 splash.convertFromImage( OResource::loadImage("launcher/firstuse", OResource::NoScale )
455 .smoothScale( width(), height() ) ); 453 .smoothScale( width(), height() ) );
456 454
457 setBackgroundPixmap(splash); 455 setBackgroundPixmap(splash);
458} 456}
459 457
460void FirstUse::drawText(QPainter &p, const QString &text) 458void FirstUse::drawText(QPainter &p, const QString &text)
461{ 459{
462 QString altered = "<CENTER>" + text + "</CENTER>"; 460 QString altered = "<CENTER>" + text + "</CENTER>";
463 461
464 QSimpleRichText rt(altered, p.font()); 462 QSimpleRichText rt(altered, p.font());
465 rt.setWidth(width() - 20); 463 rt.setWidth(width() - 20);
466 464
467 int h = (height() * 3) / 10; // start at 30% 465 int h = (height() * 3) / 10; // start at 30%
468 if (rt.height() < height() / 2) 466 if (rt.height() < height() / 2)
469 h += ((height() / 2) - rt.height()) / 2; 467 h += ((height() / 2) - rt.height()) / 2;
470 rt.draw(&p, 10, h, QRegion(0,0, width()-20, height()), palette()); 468 rt.draw(&p, 10, h, QRegion(0,0, width()-20, height()), palette());
471} 469}
472 470
473void FirstUse::updateButtons() 471void FirstUse::updateButtons()
474{ 472{
475 if ( currApp >= 0 ) { 473 if ( currApp >= 0 ) {
476 taskBar->show(); 474 taskBar->show();
477 } 475 }
478 476
479 int i = currApp-1; 477 int i = currApp-1;
480 while ( i >= 0 && !settingsTable[i].enabled ) 478 while ( i >= 0 && !settingsTable[i].enabled )
481 i--; 479 i--;
482 back->setText(tr("<< Back")); 480 back->setText(tr("<< Back"));
483 back->setEnabled( i >= 0 && !waitingForLaunch ); 481 back->setEnabled( i >= 0 && !waitingForLaunch );
484 482
485 i = currApp+1; 483 i = currApp+1;
486 while ( settingsTable[i].app && !settingsTable[i].enabled ) 484 while ( settingsTable[i].app && !settingsTable[i].enabled )
487 i++; 485 i++;
488 if ( !settingsTable[i].app ) 486 if ( !settingsTable[i].app )
489 next->setText(tr("Finish")); 487 next->setText(tr("Finish"));
490 else 488 else
491 next->setText(tr("Next >>")); 489 next->setText(tr("Next >>"));
492 490
493 next->setEnabled( !waitingForLaunch ); 491 next->setEnabled( !waitingForLaunch );
494} 492}
495 493
496void FirstUse::keyPressEvent( QKeyEvent *e ) 494void FirstUse::keyPressEvent( QKeyEvent *e )
497{ 495{
498 // Allow cancelling at first dialog, in case display is broken. 496 // Allow cancelling at first dialog, in case display is broken.
499 if ( e->key() == Key_Escape && currApp < 0 ) 497 if ( e->key() == Key_Escape && currApp < 0 )
500 QDialog::keyPressEvent(e); 498 QDialog::keyPressEvent(e);
501} 499}
502 500
503void FirstUse::mouseReleaseEvent( QMouseEvent * ) 501void FirstUse::mouseReleaseEvent( QMouseEvent * )
504{ 502{
505 if ( currApp < 0 ) { 503 if ( currApp < 0 ) {
506 if ( m_calHandler && needCalibrate ) { 504 if ( m_calHandler && needCalibrate ) {
507 releaseMouse(); 505 releaseMouse();
508 Calibrate *cal = new Calibrate; 506 Calibrate *cal = new Calibrate;
509 cal->exec(); 507 cal->exec();
510 delete cal; 508 delete cal;
511 } 509 }
512 nextDialog(); 510 nextDialog();
513 } 511 }
514} 512}
diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp
index 4ec5f4c..361a159 100644
--- a/core/launcher/launcher.cpp
+++ b/core/launcher/launcher.cpp
@@ -1,827 +1,831 @@
1/********************************************************************** 1/*
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2                 This file is part of the Opie Project
3** 3 =. (C) 2000-2002 Trolltech AS
4** This file is part of the Qtopia Environment. 4 .=l. (C) 2002-2005 The Opie Team <opie-devel@handhelds.org>
5** 5           .>+-=
6** This file may be distributed and/or modified under the terms of the 6 _;:,     .>    :=|. This program is free software; you can
7** GNU General Public License version 2 as published by the Free Software 7.> <`_,   >  .   <= redistribute it and/or modify it under
8** Foundation and appearing in the file LICENSE.GPL included in the 8 :`=1 )Y*s>-.--   : the terms of the GNU Library General Public
9** packaging of this file. 9.="- .-=="i,     .._ License as published by the Free Software
10** 10 - .   .-<_>     .<> Foundation; version 2 of the License.
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11     ._= =}       :
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12    .%`+i>       _;_.
13** 13    .i_,=:_.      -<s. This program is distributed in the hope that
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15** 15 : ..    .:,     . . . without even the implied warranty of
16** Contact info@trolltech.com if any conditions of this licensing are 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17** not clear to you. 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
18** 18..}^=.=       =       ; Library General Public License for more
19**********************************************************************/ 19++=   -.     .`     .: details.
20 20 :     =  ...= . :.=-
21 -.   .:....=;==+<; You should have received a copy of the GNU
22  -_. . .   )=.  = Library General Public License along with
23    --        :-=` this library; see the file COPYING.LIB.
24 If not, write to the Free Software Foundation,
25 Inc., 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA.
27*/
21#include "startmenu.h" 28#include "startmenu.h"
22#include "taskbar.h" 29#include "taskbar.h"
23#include "serverinterface.h" 30#include "serverinterface.h"
24#include "launcherview.h" 31#include "launcherview.h"
25#include "launcher.h" 32#include "launcher.h"
26#include "server.h" 33#include "server.h"
27
28/* OPIE */ 34/* OPIE */
29#include <opie2/odebug.h> 35#include <opie2/odebug.h>
36#include <opie2/oresource.h>
37using namespace Opie::Core;
38
30#include <qtopia/global.h> 39#include <qtopia/global.h>
31#ifdef Q_WS_QWS 40#ifdef Q_WS_QWS
32#include <qtopia/qcopenvelope_qws.h> 41#include <qtopia/qcopenvelope_qws.h>
33#endif 42#endif
34#include <qtopia/resource.h>
35#include <qtopia/applnk.h> 43#include <qtopia/applnk.h>
36#include <qtopia/config.h> 44#include <qtopia/config.h>
37#include <qtopia/qpeapplication.h> 45#include <qtopia/qpeapplication.h>
38#include <qtopia/mimetype.h> 46#include <qtopia/mimetype.h>
39#include <qtopia/private/categories.h> 47#include <qtopia/private/categories.h>
40#define QTOPIA_INTERNAL_FSLP 48#define QTOPIA_INTERNAL_FSLP
41#include <qtopia/lnkproperties.h> 49#include <qtopia/lnkproperties.h>
42 50
43/* QT */ 51/* QT */
44#include <qdir.h> 52#include <qdir.h>
45#ifdef Q_WS_QWS 53#ifdef Q_WS_QWS
46#include <qkeyboard_qws.h> 54#include <qkeyboard_qws.h>
47#include <qwindowsystem_qws.h> 55#include <qwindowsystem_qws.h>
48#endif 56#endif
49#include <qtimer.h> 57#include <qtimer.h>
50#include <qcombobox.h> 58#include <qcombobox.h>
51#include <qvbox.h> 59#include <qvbox.h>
52#include <qlayout.h> 60#include <qlayout.h>
53#include <qstyle.h> 61#include <qstyle.h>
54#include <qpushbutton.h> 62#include <qpushbutton.h>
55#include <qtabbar.h> 63#include <qtabbar.h>
56#include <qwidgetstack.h> 64#include <qwidgetstack.h>
57#include <qregexp.h> 65#include <qregexp.h>
58#include <qmessagebox.h> 66#include <qmessagebox.h>
59#include <qframe.h> 67#include <qframe.h>
60#include <qpainter.h> 68#include <qpainter.h>
61#include <qlabel.h> 69#include <qlabel.h>
62#include <qtextstream.h> 70#include <qtextstream.h>
63#include <qpopupmenu.h> 71#include <qpopupmenu.h>
64 72
65/* STD */ 73/* STD */
66#include <stdlib.h> 74#include <stdlib.h>
67#include <assert.h> 75#include <assert.h>
68#if defined(_OS_LINUX_) || defined(Q_OS_LINUX) 76#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
69#include <unistd.h> 77#include <unistd.h>
70#include <stdio.h> 78#include <stdio.h>
71#include <sys/vfs.h> 79#include <sys/vfs.h>
72#include <mntent.h> 80#include <mntent.h>
73#endif 81#endif
74 82
75 83
76static bool isVisibleWindow( int ); 84static bool isVisibleWindow( int );
77//=========================================================================== 85//===========================================================================
78 86
79LauncherTabWidget::LauncherTabWidget( Launcher* parent ) : 87LauncherTabWidget::LauncherTabWidget( Launcher* parent ) :
80 QVBox( parent ), docview( 0 ),docTabEnabled(true),m_DocumentTabId(0) 88 QVBox( parent ), docview( 0 ),docTabEnabled(true),m_DocumentTabId(0)
81{ 89{
82 docLoadingWidgetEnabled = false; 90 docLoadingWidgetEnabled = false;
83 docLoadingWidget = 0; 91 docLoadingWidget = 0;
84 docLoadingWidgetProgress = 0; 92 docLoadingWidgetProgress = 0;
85 launcher = parent; 93 launcher = parent;
86 categoryBar = new LauncherTabBar( this ); 94 categoryBar = new LauncherTabBar( this );
87 QPalette pal = categoryBar->palette(); 95 QPalette pal = categoryBar->palette();
88 pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); 96 pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) );
89 pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); 97 pal.setColor( QColorGroup::Background, pal.active().background().light(110) );
90 categoryBar->setPalette( pal ); 98 categoryBar->setPalette( pal );
91 stack = new QWidgetStack(this); 99 stack = new QWidgetStack(this);
92 connect( categoryBar, SIGNAL(selected(int)), this, SLOT(raiseTabWidget()) ); 100 connect( categoryBar, SIGNAL(selected(int)), this, SLOT(raiseTabWidget()) );
93 categoryBar->show(); 101 categoryBar->show();
94 stack->show(); 102 stack->show();
95 103
96#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 104#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
97 QCopChannel *channel = new QCopChannel( "QPE/Launcher", this ); 105 QCopChannel *channel = new QCopChannel( "QPE/Launcher", this );
98 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), 106 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)),
99 this, SLOT(launcherMessage(const QCString&,const QByteArray&)) ); 107 this, SLOT(launcherMessage(const QCString&,const QByteArray&)) );
100 connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), 108 connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)),
101 this, SLOT(appMessage(const QCString&,const QByteArray&))); 109 this, SLOT(appMessage(const QCString&,const QByteArray&)));
102#endif 110#endif
103 111
104 createDocLoadingWidget(); 112 createDocLoadingWidget();
105} 113}
106 114
107void LauncherTabWidget::createDocLoadingWidget() 115void LauncherTabWidget::createDocLoadingWidget()
108{ 116{
109 // Construct the 'doc loading widget' shown when finding documents 117 // Construct the 'doc loading widget' shown when finding documents
110 118
111 // ### LauncherView class needs changing to be more generic so 119 // ### LauncherView class needs changing to be more generic so
112 // this widget can change its background similar to the iconviews 120 // this widget can change its background similar to the iconviews
113 // so the background for this matches 121 // so the background for this matches
114 docLoadingWidget = new LauncherView( stack ); 122 docLoadingWidget = new LauncherView( stack );
115 docLoadingWidget->hideIcons(); 123 docLoadingWidget->hideIcons();
116 QVBox *docLoadingVBox = new QVBox( docLoadingWidget ); 124 QVBox *docLoadingVBox = new QVBox( docLoadingWidget );
117 125
118 docLoadingVBox->setSpacing( 20 ); 126 docLoadingVBox->setSpacing( 20 );
119 docLoadingVBox->setMargin( 10 ); 127 docLoadingVBox->setMargin( 10 );
120 128
121 QWidget *space1 = new QWidget( docLoadingVBox ); 129 QWidget *space1 = new QWidget( docLoadingVBox );
122 docLoadingVBox->setStretchFactor( space1, 1 ); 130 docLoadingVBox->setStretchFactor( space1, 1 );
123 131
124 QLabel *waitPixmap = new QLabel( docLoadingVBox ); 132 QLabel *waitPixmap = new QLabel( "Please Wait...", docLoadingVBox );
125 waitPixmap->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, waitPixmap->sizePolicy().hasHeightForWidth() ) ); 133 waitPixmap->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, waitPixmap->sizePolicy().hasHeightForWidth() ) );
126 waitPixmap->setPixmap( Resource::loadPixmap( "bigwait" ) );
127 waitPixmap->setAlignment( int( QLabel::AlignCenter ) ); 134 waitPixmap->setAlignment( int( QLabel::AlignCenter ) );
128 135
129 Config cfg( "Launcher" ); 136 Config cfg( "Launcher" );
130 cfg.setGroup( "DocTab" ); 137 cfg.setGroup( "DocTab" );
131 docTabEnabled = cfg.readBoolEntry( "Enable", true ); 138 docTabEnabled = cfg.readBoolEntry( "Enable", true );
132 139
133 QLabel *textLabel = new QLabel( docLoadingVBox ); 140 QLabel *textLabel = new QLabel( docLoadingVBox );
134 textLabel->setAlignment( int( QLabel::AlignCenter ) ); 141 textLabel->setAlignment( int( QLabel::AlignCenter ) );
135 docLoadingWidgetProgress = new QProgressBar( docLoadingVBox ); 142 docLoadingWidgetProgress = new QProgressBar( docLoadingVBox );
136 docLoadingWidgetProgress->setProgress( 0 ); 143 docLoadingWidgetProgress->setProgress( 0 );
137 docLoadingWidgetProgress->setCenterIndicator( TRUE ); 144 docLoadingWidgetProgress->setCenterIndicator( TRUE );
138 docLoadingWidgetProgress->setBackgroundMode( NoBackground ); // No flicker 145 docLoadingWidgetProgress->setBackgroundMode( NoBackground ); // No flicker
139 setProgressStyle(); 146 setProgressStyle();
140 147
141 if ( docTabEnabled ) 148 if ( docTabEnabled )
142 { 149 {
143 textLabel->setText( tr( "<b>Finding Documents...</b>" ) ); 150 textLabel->setText( tr( "<b>Finding Documents...</b>" ) );
144 } 151 }
145 else 152 else
146 { 153 {
147 textLabel->setText( tr( "<b>The Documents Tab<p>has been disabled.<p>" 154 textLabel->setText( tr( "<b>The Documents Tab<p>has been disabled.<p>"
148 "Use Settings->Launcher->DocTab<p>to reenable it.</b></center>" ) ); 155 "Use Settings->Launcher->DocTab<p>to reenable it.</b></center>" ) );
149 docLoadingWidgetProgress->hide(); 156 docLoadingWidgetProgress->hide();
150 docLoadingWidgetEnabled = true; 157 docLoadingWidgetEnabled = true;
151 } 158 }
152 159
153 QWidget *space2 = new QWidget( docLoadingVBox ); 160 QWidget *space2 = new QWidget( docLoadingVBox );
154 docLoadingVBox->setStretchFactor( space2, 1 ); 161 docLoadingVBox->setStretchFactor( space2, 1 );
155 162
156 cfg.setGroup( "Tab Documents" ); // No tr 163 cfg.setGroup( "Tab Documents" ); // No tr
157 setTabViewAppearance( docLoadingWidget, cfg ); 164 setTabViewAppearance( docLoadingWidget, cfg );
158 165
159 stack->addWidget( docLoadingWidget, 0 ); 166 stack->addWidget( docLoadingWidget, 0 );
160} 167}
161 168
162void LauncherTabWidget::initLayout() 169void LauncherTabWidget::initLayout()
163{ 170{
164 layout()->activate(); 171 layout()->activate();
165 docView()->setFocus(); 172 docView()->setFocus();
166 categoryBar->showTab("Documents"); 173 categoryBar->showTab("Documents");
167} 174}
168 175
169void LauncherTabWidget::appMessage(const QCString& message, const QByteArray&) 176void LauncherTabWidget::appMessage(const QCString& message, const QByteArray&)
170{ 177{
171 if ( message == "nextView()" ) 178 if ( message == "nextView()" )
172 categoryBar->nextTab(); 179 categoryBar->nextTab();
173} 180}
174 181
175void LauncherTabWidget::raiseTabWidget() 182void LauncherTabWidget::raiseTabWidget()
176{ 183{
177 if ( categoryBar->currentView() == docView() 184 if ( categoryBar->currentView() == docView()
178 && docLoadingWidgetEnabled ) { 185 && docLoadingWidgetEnabled ) {
179 stack->raiseWidget( docLoadingWidget ); 186 stack->raiseWidget( docLoadingWidget );
180 docLoadingWidget->updateGeometry(); 187 docLoadingWidget->updateGeometry();
181 } else { 188 } else {
182 stack->raiseWidget( categoryBar->currentView() ); 189 stack->raiseWidget( categoryBar->currentView() );
183 } 190 }
184} 191}
185 192
186void LauncherTabWidget::tabProperties() 193void LauncherTabWidget::tabProperties()
187{ 194{
188 LauncherView *view = categoryBar->currentView(); 195 LauncherView *view = categoryBar->currentView();
189 QPopupMenu *m = new QPopupMenu( this ); 196 QPopupMenu *m = new QPopupMenu( this );
190 m->insertItem( tr("Icon View"), LauncherView::Icon ); 197 m->insertItem( tr("Icon View"), LauncherView::Icon );
191 m->insertItem( tr("List View"), LauncherView::List ); 198 m->insertItem( tr("List View"), LauncherView::List );
192 m->setItemChecked( (int)view->viewMode(), TRUE ); 199 m->setItemChecked( (int)view->viewMode(), TRUE );
193 int rv = m->exec( QCursor::pos() ); 200 int rv = m->exec( QCursor::pos() );
194 if ( rv >= 0 && rv != view->viewMode() ) { 201 if ( rv >= 0 && rv != view->viewMode() ) {
195 view->setViewMode( (LauncherView::ViewMode)rv ); 202 view->setViewMode( (LauncherView::ViewMode)rv );
196 } 203 }
197 204
198 delete m; 205 delete m;
199} 206}
200 207
201void LauncherTabWidget::deleteView( const QString& id ) 208void LauncherTabWidget::deleteView( const QString& id )
202{ 209{
203 LauncherTab *t = categoryBar->launcherTab(id); 210 LauncherTab *t = categoryBar->launcherTab(id);
204 if ( t ) { 211 if ( t ) {
205 stack->removeWidget( t->view ); 212 stack->removeWidget( t->view );
206 delete t->view; 213 delete t->view;
207 categoryBar->removeTab( t ); 214 categoryBar->removeTab( t );
208 } 215 }
209} 216}
210 217
211LauncherView* LauncherTabWidget::newView( const QString& id, const QPixmap& pm, const QString& label ) 218LauncherView* LauncherTabWidget::newView( const QString& id, const QPixmap& pm, const QString& label )
212{ 219{
213 LauncherView* view = new LauncherView( stack ); 220 LauncherView* view = new LauncherView( stack );
214 connect( view, SIGNAL(clicked(const AppLnk*)), 221 connect( view, SIGNAL(clicked(const AppLnk*)),
215 this, SIGNAL(clicked(const AppLnk*))); 222 this, SIGNAL(clicked(const AppLnk*)));
216 connect( view, SIGNAL(rightPressed(AppLnk*)), 223 connect( view, SIGNAL(rightPressed(AppLnk*)),
217 this, SIGNAL(rightPressed(AppLnk*))); 224 this, SIGNAL(rightPressed(AppLnk*)));
218 225
219 226
220 int n = categoryBar->count(); 227 int n = categoryBar->count();
221 228
222 stack->addWidget( view, n ); 229 stack->addWidget( view, n );
223 230
224 LauncherTab *tab = new LauncherTab( id, view, pm, label ); 231 LauncherTab *tab = new LauncherTab( id, view, pm, label );
225 categoryBar->insertTab( tab, n-1 ); 232 categoryBar->insertTab( tab, n-1 );
226 if ( id == "Documents" ) { 233 if ( id == "Documents" ) {
227 docview = view; 234 docview = view;
228 m_DocumentTabId = n; 235 m_DocumentTabId = n;
229 } 236 }
230 237
231 odebug << "inserting " << id << " at " << n-1 << "" << oendl; 238 odebug << "inserting " << id << " at " << n-1 << "" << oendl;
232 239
233 Config cfg("Launcher"); 240 Config cfg("Launcher");
234 setTabAppearance( tab, cfg ); 241 setTabAppearance( tab, cfg );
235 242
236 cfg.setGroup( "GUI" ); 243 cfg.setGroup( "GUI" );
237 view->setBusyIndicatorType( cfg.readEntry( "BusyType", QString::null ) ); 244 view->setBusyIndicatorType( cfg.readEntry( "BusyType", QString::null ) );
238 245
239 return view; 246 return view;
240} 247}
241 248
242LauncherView *LauncherTabWidget::view( const QString &id ) 249LauncherView *LauncherTabWidget::view( const QString &id )
243{ 250{
244 LauncherTab *t = categoryBar->launcherTab(id); 251 LauncherTab *t = categoryBar->launcherTab(id);
245 if ( !t ) 252 if ( !t )
246 return 0; 253 return 0;
247 return t->view; 254 return t->view;
248} 255}
249 256
250LauncherView *LauncherTabWidget::docView() 257LauncherView *LauncherTabWidget::docView()
251{ 258{
252 return docview; 259 return docview;
253} 260}
254 261
255void LauncherTabWidget::setLoadingWidgetEnabled( bool v ) 262void LauncherTabWidget::setLoadingWidgetEnabled( bool v )
256{ 263{
257 if ( v != docLoadingWidgetEnabled && docLoadingWidget ) { 264 if ( v != docLoadingWidgetEnabled && docLoadingWidget ) {
258 docLoadingWidgetEnabled = v; 265 docLoadingWidgetEnabled = v;
259 raiseTabWidget(); 266 raiseTabWidget();
260 } 267 }
261} 268}
262 269
263void LauncherTabWidget::setLoadingProgress( int percent ) 270void LauncherTabWidget::setLoadingProgress( int percent )
264{ 271{
265 docLoadingWidgetProgress->setProgress( (percent / 4) * 4 ); 272 docLoadingWidgetProgress->setProgress( (percent / 4) * 4 );
266} 273}
267 274
268// ### this function could more to LauncherView 275// ### this function could more to LauncherView
269void LauncherTabWidget::setTabViewAppearance( LauncherView *v, Config &cfg ) 276void LauncherTabWidget::setTabViewAppearance( LauncherView *v, Config &cfg )
270{ 277{
271 // View 278 // View
272 QString view = cfg.readEntry( "View", "Icon" ); 279 QString view = cfg.readEntry( "View", "Icon" );
273 if ( view == "List" ) // No tr 280 if ( view == "List" ) // No tr
274 v->setViewMode( LauncherView::List ); 281 v->setViewMode( LauncherView::List );
275 QString bgType = cfg.readEntry( "BackgroundType", "Image" ); 282 QString bgType = cfg.readEntry( "BackgroundType", "Image" );
276 if ( bgType == "Image" ) { // No tr 283 if ( bgType == "Image" ) { // No tr
277 QString pm = cfg.readEntry( "BackgroundImage", "launcher/opie-background" ); 284 QString pm = cfg.readEntry( "BackgroundImage", "launcher/opie-background" );
278 v->setBackgroundType( LauncherView::Image, pm ); 285 v->setBackgroundType( LauncherView::Image, pm );
279 } else if ( bgType == "SolidColor" ) { 286 } else if ( bgType == "SolidColor" ) {
280 QString c = cfg.readEntry( "BackgroundColor" ); 287 QString c = cfg.readEntry( "BackgroundColor" );
281 v->setBackgroundType( LauncherView::SolidColor, c ); 288 v->setBackgroundType( LauncherView::SolidColor, c );
282 } else { 289 } else {
283 v->setBackgroundType( LauncherView::Ruled, QString::null ); 290 v->setBackgroundType( LauncherView::Ruled, QString::null );
284 } 291 }
285 QString textCol = cfg.readEntry( "TextColor" ); 292 QString textCol = cfg.readEntry( "TextColor" );
286 if ( textCol.isEmpty() ) 293 if ( textCol.isEmpty() )
287 v->setTextColor( QColor() ); 294 v->setTextColor( QColor() );
288 else 295 else
289 v->setTextColor( QColor(textCol) ); 296 v->setTextColor( QColor(textCol) );
290// bool customFont = cfg.readBoolEntry( "CustomFont", FALSE ); 297// bool customFont = cfg.readBoolEntry( "CustomFont", FALSE );
291 298
292 v->setColNumber( cfg.readNumEntry( "Columns", 0 ) ); 299 v->setColNumber( cfg.readNumEntry( "Columns", 0 ) );
293 300
294 QStringList font = cfg.readListEntry( "Font", ',' ); 301 QStringList font = cfg.readListEntry( "Font", ',' );
295 if ( font.count() == 4 ) 302 if ( font.count() == 4 )
296 v->setViewFont( QFont(font[0], font[1].toInt(), font[2].toInt(), font[3].toInt()!=0) ); 303 v->setViewFont( QFont(font[0], font[1].toInt(), font[2].toInt(), font[3].toInt()!=0) );
297 304
298 // ### FIXME TabColor TabTextColor 305 // ### FIXME TabColor TabTextColor
299 306
300} 307}
301 308
302// ### Could move to LauncherTab 309// ### Could move to LauncherTab
303void LauncherTabWidget::setTabAppearance( LauncherTab *tab, Config &cfg ) 310void LauncherTabWidget::setTabAppearance( LauncherTab *tab, Config &cfg )
304{ 311{
305 cfg.setGroup( QString( "Tab %1" ).arg(tab->type) ); // No tr 312 cfg.setGroup( QString( "Tab %1" ).arg(tab->type) ); // No tr
306 313
307 setTabViewAppearance( tab->view, cfg ); 314 setTabViewAppearance( tab->view, cfg );
308 315
309 // Tabs 316 // Tabs
310 QString tabCol = cfg.readEntry( "TabColor" ); 317 QString tabCol = cfg.readEntry( "TabColor" );
311 if ( tabCol.isEmpty() ) 318 if ( tabCol.isEmpty() )
312 tab->bgColor = QColor(); 319 tab->bgColor = QColor();
313 else 320 else
314 tab->bgColor = QColor(tabCol); 321 tab->bgColor = QColor(tabCol);
315 QString tabTextCol = cfg.readEntry( "TabTextColor" ); 322 QString tabTextCol = cfg.readEntry( "TabTextColor" );
316 if ( tabTextCol.isEmpty() ) 323 if ( tabTextCol.isEmpty() )
317 tab->fgColor = QColor(); 324 tab->fgColor = QColor();
318 else 325 else
319 tab->fgColor = QColor(tabTextCol); 326 tab->fgColor = QColor(tabTextCol);
320} 327}
321 328
322void LauncherTabWidget::paletteChange( const QPalette &p ) 329void LauncherTabWidget::paletteChange( const QPalette &p )
323{ 330{
324 QVBox::paletteChange( p ); 331 QVBox::paletteChange( p );
325 QPalette pal = palette(); 332 QPalette pal = palette();
326 pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); 333 pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) );
327 pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); 334 pal.setColor( QColorGroup::Background, pal.active().background().light(110) );
328 categoryBar->setPalette( pal ); 335 categoryBar->setPalette( pal );
329 categoryBar->update(); 336 categoryBar->update();
330} 337}
331 338
332void LauncherTabWidget::styleChange( QStyle & ) 339void LauncherTabWidget::styleChange( QStyle & )
333{ 340{
334 QTimer::singleShot( 0, this, SLOT(setProgressStyle()) ); 341 QTimer::singleShot( 0, this, SLOT(setProgressStyle()) );
335} 342}
336 343
337void LauncherTabWidget::setProgressStyle() 344void LauncherTabWidget::setProgressStyle()
338{ 345{
339 if (docLoadingWidgetProgress) { 346 if (docLoadingWidgetProgress) {
340 docLoadingWidgetProgress->setFrameShape( QProgressBar::Box ); 347 docLoadingWidgetProgress->setFrameShape( QProgressBar::Box );
341 docLoadingWidgetProgress->setFrameShadow( QProgressBar::Plain ); 348 docLoadingWidgetProgress->setFrameShadow( QProgressBar::Plain );
342 docLoadingWidgetProgress->setMargin( 1 ); 349 docLoadingWidgetProgress->setMargin( 1 );
343 docLoadingWidgetProgress->setLineWidth( 1 ); 350 docLoadingWidgetProgress->setLineWidth( 1 );
344 } 351 }
345} 352}
346 353
347/* 354/*
348 * FIXME 355 * FIXME
349 * The following NULL check is triggered by inserting, then removing a tab on the fly 356 * The following NULL check is triggered by inserting, then removing a tab on the fly
350 * as you would if you had removable media (which I do). Without this check 357 * as you would if you had removable media (which I do). Without this check
351 * the first app launched after a tab removal causes qpe to Segfault. 358 * the first app launched after a tab removal causes qpe to Segfault.
352 * This obviously has a more sinister cause, but this works around it with no 359 * This obviously has a more sinister cause, but this works around it with no
353 * obvious adverse effects. Please FIXME 360 * obvious adverse effects. Please FIXME
354 * bkc - 17/6/2004 361 * bkc - 17/6/2004
355 * 362 *
356 */ 363 */
357 364
358void LauncherTabWidget::setBusy(bool on) 365void LauncherTabWidget::setBusy(bool on)
359{ 366{
360 if ( on ) 367 if ( on )
361 currentView()->setBusy(TRUE); 368 currentView()->setBusy(TRUE);
362 else { 369 else {
363 for ( int i = 0; i < categoryBar->count(); i++ ) { 370 for ( int i = 0; i < categoryBar->count(); i++ ) {
364 if (categoryBar->tab(i)) { 371 if (categoryBar->tab(i)) {
365 LauncherView *view = ((LauncherTab *)categoryBar->tab(i))->view; 372 LauncherView *view = ((LauncherTab *)categoryBar->tab(i))->view;
366 view->setBusy( FALSE ); 373 view->setBusy( FALSE );
367 } else { 374 } else {
368 odebug << "Averting Disaster with tab " << i << " == NULL! " << oendl; 375 odebug << "Averting Disaster with tab " << i << " == NULL! " << oendl;
369 } 376 }
370 } 377 }
371 } 378 }
372} 379}
373 380
374void LauncherTabWidget::setBusyIndicatorType( const QString& str ) { 381void LauncherTabWidget::setBusyIndicatorType( const QString& str ) {
375 for (int i = 0; i < categoryBar->count(); i++ ) { 382 for (int i = 0; i < categoryBar->count(); i++ ) {
376 LauncherView* view = static_cast<LauncherTab*>( categoryBar->tab(i) )->view; 383 LauncherView* view = static_cast<LauncherTab*>( categoryBar->tab(i) )->view;
377 view->setBusyIndicatorType( str ); 384 view->setBusyIndicatorType( str );
378 } 385 }
379} 386}
380 387
381LauncherView *LauncherTabWidget::currentView(void) 388LauncherView *LauncherTabWidget::currentView(void)
382{ 389{
383 return (LauncherView*)stack->visibleWidget(); 390 return (LauncherView*)stack->visibleWidget();
384} 391}
385 392
386 393
387 394
388void LauncherTabWidget::launcherMessage( const QCString &msg, const QByteArray &data) 395void LauncherTabWidget::launcherMessage( const QCString &msg, const QByteArray &data)
389{ 396{
390 QDataStream stream( data, IO_ReadOnly ); 397 QDataStream stream( data, IO_ReadOnly );
391 if ( msg == "setTabView(QString,int)" ) { 398 if ( msg == "setTabView(QString,int)" ) {
392 QString id; 399 QString id;
393 stream >> id; 400 stream >> id;
394 int mode; 401 int mode;
395 stream >> mode; 402 stream >> mode;
396 if ( view(id) ) 403 if ( view(id) )
397 view(id)->setViewMode( (LauncherView::ViewMode)mode ); 404 view(id)->setViewMode( (LauncherView::ViewMode)mode );
398 } else if ( msg == "setTabBackground(QString,int,QString)" ) { 405 } else if ( msg == "setTabBackground(QString,int,QString)" ) {
399 QString id; 406 QString id;
400 stream >> id; 407 stream >> id;
401 int mode; 408 int mode;
402 stream >> mode; 409 stream >> mode;
403 QString pixmapOrColor; 410 QString pixmapOrColor;
404 stream >> pixmapOrColor; 411 stream >> pixmapOrColor;
405 if ( view(id) ) 412 if ( view(id) )
406 view(id)->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor ); 413 view(id)->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor );
407 if ( id == "Documents" ) 414 if ( id == "Documents" )
408 docLoadingWidget->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor ); 415 docLoadingWidget->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor );
409 } else if ( msg == "setTextColor(QString,QString)" ) { 416 } else if ( msg == "setTextColor(QString,QString)" ) {
410 QString id; 417 QString id;
411 stream >> id; 418 stream >> id;
412 QString color; 419 QString color;
413 stream >> color; 420 stream >> color;
414 if ( view(id) ) 421 if ( view(id) )
415 view(id)->setTextColor( QColor(color) ); 422 view(id)->setTextColor( QColor(color) );
416 if ( id == "Documents" ) 423 if ( id == "Documents" )
417 docLoadingWidget->setTextColor( QColor(color) ); 424 docLoadingWidget->setTextColor( QColor(color) );
418 } else if ( msg == "setIconColumns(QString,int)" ) { 425 } else if ( msg == "setIconColumns(QString,int)" ) {
419 QString id; 426 QString id;
420 stream >> id; 427 stream >> id;
421 int number; 428 int number;
422 stream >> number; 429 stream >> number;
423 if ( view(id ) ) 430 if ( view(id ) )
424 view(id)->setColNumber( number ); 431 view(id)->setColNumber( number );
425 } else if ( msg == "setFont(QString,QString,int,int,int)" ) { 432 } else if ( msg == "setFont(QString,QString,int,int,int)" ) {
426 QString id; 433 QString id;
427 stream >> id; 434 stream >> id;
428 QString fam; 435 QString fam;
429 stream >> fam; 436 stream >> fam;
430 int size; 437 int size;
431 stream >> size; 438 stream >> size;
432 int weight; 439 int weight;
433 stream >> weight; 440 stream >> weight;
434 int italic; 441 int italic;
435 stream >> italic; 442 stream >> italic;
436 if ( view(id) ) { 443 if ( view(id) ) {
437 if ( !fam.isEmpty() ) { 444 if ( !fam.isEmpty() ) {
438 view(id)->setViewFont( QFont(fam, size, weight, italic!=0) ); 445 view(id)->setViewFont( QFont(fam, size, weight, italic!=0) );
439 odebug << "setFont: " << fam << ", " << size << ", " << weight << ", " << italic << "" << oendl; 446 odebug << "setFont: " << fam << ", " << size << ", " << weight << ", " << italic << "" << oendl;
440 } else { 447 } else {
441 view(id)->clearViewFont(); 448 view(id)->clearViewFont();
442 } 449 }
443 } 450 }
444 }else if ( msg == "setBusyIndicatorType(QString)" ) { 451 }else if ( msg == "setBusyIndicatorType(QString)" ) {
445 QString type; 452 QString type;
446 stream >> type; 453 stream >> type;
447 setBusyIndicatorType( type ); 454 setBusyIndicatorType( type );
448 }else if ( msg == "home()" ) { 455 }else if ( msg == "home()" ) {
449 if ( isVisibleWindow( static_cast<QWidget*>(parent())->winId() ) ) { 456 if ( isVisibleWindow( static_cast<QWidget*>(parent())->winId() ) ) {
450 if (categoryBar) 457 if (categoryBar)
451 categoryBar->nextTab(); 458 categoryBar->nextTab();
452 }else { 459 }else {
453 static_cast<QWidget*>(parent())->raise(); 460 static_cast<QWidget*>(parent())->raise();
454 } 461 }
455 } else if (msg=="doctabEnabled(int)") { 462 } else if (msg=="doctabEnabled(int)") {
456 int id; stream >> id; 463 int id; stream >> id;
457 odebug << "Doctab enabled " << id << oendl; 464 odebug << "Doctab enabled " << id << oendl;
458 reCheckDoctab(id); 465 reCheckDoctab(id);
459 } else if ( msg == "setStaticBackground(bool)" ) { 466 } else if ( msg == "setStaticBackground(bool)" ) {
460 int set; stream >> set; 467 int set; stream >> set;
461 odebug << "setStaticBackground " << set << oendl; 468 odebug << "setStaticBackground " << set << oendl;
462 for (int i = 0; i < categoryBar->count(); i++ ) 469 for (int i = 0; i < categoryBar->count(); i++ )
463 { 470 {
464 LauncherView* view = static_cast<LauncherTab*>( categoryBar->tab(i) )->view; 471 LauncherView* view = static_cast<LauncherTab*>( categoryBar->tab(i) )->view;
465 view->iconView()->setStaticBackgroundPicture( set ); 472 view->iconView()->setStaticBackgroundPicture( set );
466 } 473 }
467 } 474 }
468} 475}
469 476
470void LauncherTabWidget::reCheckDoctab(int how) 477void LauncherTabWidget::reCheckDoctab(int how)
471{ 478{
472 if ((bool)how == docTabEnabled) { 479 if ((bool)how == docTabEnabled) {
473 /* nothing to do */ 480 /* nothing to do */
474 return; 481 return;
475 } 482 }
476 if (docLoadingWidget) { 483 if (docLoadingWidget) {
477 stack->removeWidget(docLoadingWidget); 484 stack->removeWidget(docLoadingWidget);
478 delete docLoadingWidget; 485 delete docLoadingWidget;
479 docLoadingWidget = 0; 486 docLoadingWidget = 0;
480 } 487 }
481 createDocLoadingWidget(); 488 createDocLoadingWidget();
482 { 489 {
483 QCopEnvelope( "QPE/System", "reforceDocuments()" ); 490 QCopEnvelope( "QPE/System", "reforceDocuments()" );
484 odebug << "Sending doc rescan" << oendl; 491 odebug << "Sending doc rescan" << oendl;
485 } 492 }
486} 493}
487 494
488//--------------------------------------------------------------------------- 495//---------------------------------------------------------------------------
489 496
490Launcher::Launcher() 497Launcher::Launcher()
491 : QMainWindow( 0, "PDA User Interface", QWidget::WStyle_Customize | QWidget::WGroupLeader ) 498 : QMainWindow( 0, "PDA User Interface", QWidget::WStyle_Customize | QWidget::WGroupLeader )
492{ 499{
493 tabs = 0; 500 tabs = 0;
494 tb = 0; 501 tb = 0;
495 Config cfg( "Launcher" ); 502 Config cfg( "Launcher" );
496 cfg.setGroup( "DocTab" ); 503 cfg.setGroup( "DocTab" );
497 docTabEnabled = cfg.readBoolEntry( "Enable", true ); 504 docTabEnabled = cfg.readBoolEntry( "Enable", true );
498} 505}
499 506
500void Launcher::createGUI() 507void Launcher::createGUI()
501{ 508{
502 setCaption( tr("Launcher") ); 509 setCaption( tr("Launcher") );
503 510
504 // we have a pretty good idea how big we'll be 511 // we have a pretty good idea how big we'll be
505 setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() ); 512 setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() );
506 513
507 tb = new TaskBar; 514 tb = new TaskBar;
508 tabs = new LauncherTabWidget( this ); 515 tabs = new LauncherTabWidget( this );
509 setCentralWidget( tabs ); 516 setCentralWidget( tabs );
510 517
511 ServerInterface::dockWidget( tb, ServerInterface::Bottom ); 518 ServerInterface::dockWidget( tb, ServerInterface::Bottom );
512 tb->show(); 519 tb->show();
513 520
514 qApp->installEventFilter( this ); 521 qApp->installEventFilter( this );
515 522
516 connect( tb, SIGNAL(tabSelected(const QString&)), 523 connect( tb, SIGNAL(tabSelected(const QString&)),
517 this, SLOT(showTab(const QString&)) ); 524 this, SLOT(showTab(const QString&)) );
518 connect( tabs, SIGNAL(selected(const QString&)), 525 connect( tabs, SIGNAL(selected(const QString&)),
519 this, SLOT(viewSelected(const QString&)) ); 526 this, SLOT(viewSelected(const QString&)) );
520 connect( tabs, SIGNAL(clicked(const AppLnk*)), 527 connect( tabs, SIGNAL(clicked(const AppLnk*)),
521 this, SLOT(select(const AppLnk*))); 528 this, SLOT(select(const AppLnk*)));
522 connect( tabs, SIGNAL(rightPressed(AppLnk*)), 529 connect( tabs, SIGNAL(rightPressed(AppLnk*)),
523 this, SLOT(properties(AppLnk*))); 530 this, SLOT(properties(AppLnk*)));
524 531
525#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 532#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
526 QCopChannel* sysChannel = new QCopChannel( "QPE/System", this ); 533 QCopChannel* sysChannel = new QCopChannel( "QPE/System", this );
527 connect( sysChannel, SIGNAL(received(const QCString&,const QByteArray&)), 534 connect( sysChannel, SIGNAL(received(const QCString&,const QByteArray&)),
528 this, SLOT(systemMessage(const QCString&,const QByteArray&)) ); 535 this, SLOT(systemMessage(const QCString&,const QByteArray&)) );
529#endif 536#endif
530 537
531 // all documents 538 // all documents
532 QImage img( Resource::loadImage( "DocsIcon" ) ); 539 QPixmap pm = OResource::loadPixmap( "DocsIcon", OResource::SmallIcon );
533 QPixmap pm;
534 pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() );
535 // It could add this itself if it handles docs 540 // It could add this itself if it handles docs
536
537 tabs->newView("Documents", pm, tr("Documents") )->setToolsEnabled( TRUE ); 541 tabs->newView("Documents", pm, tr("Documents") )->setToolsEnabled( TRUE );
538 542
539 QTimer::singleShot( 0, tabs, SLOT( initLayout() ) ); 543 QTimer::singleShot( 0, tabs, SLOT( initLayout() ) );
540 qApp->setMainWidget( this ); 544 qApp->setMainWidget( this );
541 QTimer::singleShot( 500, this, SLOT( makeVisible() ) ); 545 QTimer::singleShot( 500, this, SLOT( makeVisible() ) );
542} 546}
543 547
544Launcher::~Launcher() 548Launcher::~Launcher()
545{ 549{
546 if ( tb ) 550 if ( tb )
547 destroyGUI(); 551 destroyGUI();
548} 552}
549 553
550 bool Launcher::requiresDocuments() const 554 bool Launcher::requiresDocuments() const
551 { 555 {
552 Config cfg( "Launcher" ); 556 Config cfg( "Launcher" );
553 cfg.setGroup( "DocTab" ); 557 cfg.setGroup( "DocTab" );
554 return cfg.readBoolEntry( "Enable", true ); 558 return cfg.readBoolEntry( "Enable", true );
555} 559}
556 560
557void Launcher::makeVisible() 561void Launcher::makeVisible()
558{ 562{
559 showMaximized(); 563 showMaximized();
560} 564}
561 565
562void Launcher::destroyGUI() 566void Launcher::destroyGUI()
563{ 567{
564 delete tb; 568 delete tb;
565 tb = 0; 569 tb = 0;
566 delete tabs; 570 delete tabs;
567 tabs =0; 571 tabs =0;
568} 572}
569 573
570bool Launcher::eventFilter( QObject*, QEvent *ev ) 574bool Launcher::eventFilter( QObject*, QEvent *ev )
571{ 575{
572#ifdef QT_QWS_CUSTOM 576#ifdef QT_QWS_CUSTOM
573 if ( ev->type() == QEvent::KeyPress ) { 577 if ( ev->type() == QEvent::KeyPress ) {
574 QKeyEvent *ke = (QKeyEvent *)ev; 578 QKeyEvent *ke = (QKeyEvent *)ev;
575 if ( ke->key() == Qt::Key_F11 ) { // menu key 579 if ( ke->key() == Qt::Key_F11 ) { // menu key
576 QWidget *active = qApp->activeWindow(); 580 QWidget *active = qApp->activeWindow();
577 if ( active && active->isPopup() ) 581 if ( active && active->isPopup() )
578 active->close(); 582 active->close();
579 else { 583 else {
580 Global::terminateBuiltin("calibrate"); // No tr 584 Global::terminateBuiltin("calibrate"); // No tr
581 tb->launchStartMenu(); 585 tb->launchStartMenu();
582 } 586 }
583 return TRUE; 587 return TRUE;
584 } 588 }
585 } 589 }
586#else 590#else
587 Q_UNUSED(ev); 591 Q_UNUSED(ev);
588#endif 592#endif
589 return FALSE; 593 return FALSE;
590} 594}
591 595
592static bool isVisibleWindow(int wid) 596static bool isVisibleWindow(int wid)
593{ 597{
594#ifdef Q_WS_QWS 598#ifdef Q_WS_QWS
595 const QList<QWSWindow> &list = qwsServer->clientWindows(); 599 const QList<QWSWindow> &list = qwsServer->clientWindows();
596 QWSWindow* w; 600 QWSWindow* w;
597 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { 601 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) {
598 if ( w->winId() == wid ) 602 if ( w->winId() == wid )
599 return !w->isFullyObscured(); 603 return !w->isFullyObscured();
600 } 604 }
601#endif 605#endif
602 return FALSE; 606 return FALSE;
603} 607}
604 608
605void Launcher::viewSelected(const QString& s) 609void Launcher::viewSelected(const QString& s)
606{ 610{
607 setCaption( s + tr(" - Launcher") ); 611 setCaption( s + tr(" - Launcher") );
608} 612}
609 613
610void Launcher::showTab(const QString& id) 614void Launcher::showTab(const QString& id)
611{ 615{
612 tabs->categoryBar->showTab(id); 616 tabs->categoryBar->showTab(id);
613 raise(); 617 raise();
614} 618}
615 619
616void Launcher::select( const AppLnk *appLnk ) 620void Launcher::select( const AppLnk *appLnk )
617{ 621{
618 if ( appLnk->type() == "Folder" ) { // No tr 622 if ( appLnk->type() == "Folder" ) { // No tr
619 // Not supported: flat is simpler for the user 623 // Not supported: flat is simpler for the user
620 } else { 624 } else {
621 if ( appLnk->exec().isNull() ) { 625 if ( appLnk->exec().isNull() ) {
622 int i = QMessageBox::information(this,tr("No application"), 626 int i = QMessageBox::information(this,tr("No application"),
623 tr("<p>No application is defined for this document." 627 tr("<p>No application is defined for this document."
624 "<p>Type is %1.").arg(appLnk->type()), tr("OK"), tr("View as text"), 0, 0, 1); 628 "<p>Type is %1.").arg(appLnk->type()), tr("OK"), tr("View as text"), 0, 0, 1);
625 629
626 /* ### Fixme */ 630 /* ### Fixme */
627 if ( i == 1 ) 631 if ( i == 1 )
628 Global::execute("textedit",appLnk->file()); 632 Global::execute("textedit",appLnk->file());
629 633
630 return; 634 return;
631 } 635 }
632 tabs->setBusy(TRUE); 636 tabs->setBusy(TRUE);
633 emit executing( appLnk ); 637 emit executing( appLnk );
634 appLnk->execute(); 638 appLnk->execute();
635 } 639 }
636} 640}
637 641
638void Launcher::properties( AppLnk *appLnk ) 642void Launcher::properties( AppLnk *appLnk )
639{ 643{
640 if ( appLnk->type() == "Folder" ) { // No tr 644 if ( appLnk->type() == "Folder" ) { // No tr
641 // Not supported: flat is simpler for the user 645 // Not supported: flat is simpler for the user
642 } else { 646 } else {
643/* ### libqtopia FIXME also moving docLnks... */ 647/* ### libqtopia FIXME also moving docLnks... */
644 LnkProperties prop(appLnk,0 ); 648 LnkProperties prop(appLnk,0 );
645 649
646 if (QPEApplication::execDialog( &prop )==QDialog::Accepted && tabs->currentView()==tabs->docView()) { 650 if (QPEApplication::execDialog( &prop )==QDialog::Accepted && tabs->currentView()==tabs->docView()) {
647 } 651 }
648 } 652 }
649} 653}
650 654
651void Launcher::storageChanged( const QList<FileSystem> & ) 655void Launcher::storageChanged( const QList<FileSystem> & )
652{ 656{
653 // ### update combo boxes if we had a combo box for the storage type 657 // ### update combo boxes if we had a combo box for the storage type
654} 658}
655 659
656void Launcher::systemMessage( const QCString &msg, const QByteArray &data) 660void Launcher::systemMessage( const QCString &msg, const QByteArray &data)
657{ 661{
658 QDataStream stream( data, IO_ReadOnly ); 662 QDataStream stream( data, IO_ReadOnly );
659 if ( msg == "busy()" ) { 663 if ( msg == "busy()" ) {
660 tb->startWait(); 664 tb->startWait();
661 } else if ( msg == "notBusy(QString)" ) { 665 } else if ( msg == "notBusy(QString)" ) {
662 QString app; 666 QString app;
663 stream >> app; 667 stream >> app;
664 tabs->setBusy(FALSE); 668 tabs->setBusy(FALSE);
665 tb->stopWait(app); 669 tb->stopWait(app);
666 } else if (msg == "applyStyle()") { 670 } else if (msg == "applyStyle()") {
667 tabs->currentView()->relayout(); 671 tabs->currentView()->relayout();
668 } 672 }
669} 673}
670 674
671// These are the update functions from the server 675// These are the update functions from the server
672void Launcher::typeAdded( const QString& type, const QString& name, 676void Launcher::typeAdded( const QString& type, const QString& name,
673 const QPixmap& pixmap, const QPixmap& ) 677 const QPixmap& pixmap, const QPixmap& )
674{ 678{
675 tabs->newView( type, pixmap, name ); 679 tabs->newView( type, pixmap, name );
676 ids.append( type ); 680 ids.append( type );
677 /* this will be called in applicationScanningProgress with value 100! */ 681 /* this will be called in applicationScanningProgress with value 100! */
678// tb->refreshStartMenu(); 682// tb->refreshStartMenu();
679 683
680 static bool first = TRUE; 684 static bool first = TRUE;
681 if ( first ) { 685 if ( first ) {
682 first = FALSE; 686 first = FALSE;
683 tabs->categoryBar->showTab(type); 687 tabs->categoryBar->showTab(type);
684 } 688 }
685 689
686 tabs->view( type )->setUpdatesEnabled( FALSE ); 690 tabs->view( type )->setUpdatesEnabled( FALSE );
687 tabs->view( type )->setSortEnabled( FALSE ); 691 tabs->view( type )->setSortEnabled( FALSE );
688} 692}
689 693
690void Launcher::typeRemoved( const QString& type ) 694void Launcher::typeRemoved( const QString& type )
691{ 695{
692 tabs->view( type )->removeAllItems(); 696 tabs->view( type )->removeAllItems();
693 tabs->deleteView( type ); 697 tabs->deleteView( type );
694 ids.remove( type ); 698 ids.remove( type );
695 /* this will be called in applicationScanningProgress with value 100! */ 699 /* this will be called in applicationScanningProgress with value 100! */
696// tb->refreshStartMenu(); 700// tb->refreshStartMenu();
697} 701}
698 702
699void Launcher::applicationAdded( const QString& type, const AppLnk& app ) 703void Launcher::applicationAdded( const QString& type, const AppLnk& app )
700{ 704{
701 if ( app.type() == "Separator" ) // No tr 705 if ( app.type() == "Separator" ) // No tr
702 return; 706 return;
703 707
704 LauncherView *view = tabs->view( type ); 708 LauncherView *view = tabs->view( type );
705 if ( view ) 709 if ( view )
706 view->addItem( new AppLnk( app ), FALSE ); 710 view->addItem( new AppLnk( app ), FALSE );
707 else 711 else
708 owarn << "addAppLnk: No view for type " << type.latin1() << ". Can't add app " 712 owarn << "addAppLnk: No view for type " << type.latin1() << ". Can't add app "
709 << app.name().latin1() << "!", 713 << app.name().latin1() << "!",
710 714
711 MimeType::registerApp( app ); 715 MimeType::registerApp( app );
712} 716}
713 717
714void Launcher::applicationRemoved( const QString& type, const AppLnk& app ) 718void Launcher::applicationRemoved( const QString& type, const AppLnk& app )
715{ 719{
716 LauncherView *view = tabs->view( type ); 720 LauncherView *view = tabs->view( type );
717 if ( view ) 721 if ( view )
718 view->removeLink( app.linkFile() ); 722 view->removeLink( app.linkFile() );
719 else 723 else
720 owarn << "removeAppLnk: No view for " << type << "!" << oendl; 724 owarn << "removeAppLnk: No view for " << type << "!" << oendl;
721} 725}
722 726
723void Launcher::allApplicationsRemoved() 727void Launcher::allApplicationsRemoved()
724{ 728{
725 MimeType::clear(); 729 MimeType::clear();
726 for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) 730 for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it)
727 tabs->view( (*it) )->removeAllItems(); 731 tabs->view( (*it) )->removeAllItems();
728} 732}
729 733
730void Launcher::documentAdded( const DocLnk& doc ) 734void Launcher::documentAdded( const DocLnk& doc )
731{ 735{
732 tabs->docView()->addItem( new DocLnk( doc ), FALSE ); 736 tabs->docView()->addItem( new DocLnk( doc ), FALSE );
733} 737}
734 738
735void Launcher::aboutToAddBegin() 739void Launcher::aboutToAddBegin()
736{ 740{
737 tabs->docView()->setUpdatesEnabled( false ); 741 tabs->docView()->setUpdatesEnabled( false );
738} 742}
739 743
740void Launcher::aboutToAddEnd() 744void Launcher::aboutToAddEnd()
741{ 745{
742 tabs->docView()->setUpdatesEnabled( true ); 746 tabs->docView()->setUpdatesEnabled( true );
743} 747}
744 748
745void Launcher::showLoadingDocs() 749void Launcher::showLoadingDocs()
746{ 750{
747 tabs->docView()->hide(); 751 tabs->docView()->hide();
748} 752}
749 753
750void Launcher::showDocTab() 754void Launcher::showDocTab()
751{ 755{
752 if ( tabs->categoryBar->currentView() == tabs->docView() ) 756 if ( tabs->categoryBar->currentView() == tabs->docView() )
753 tabs->docView()->show(); 757 tabs->docView()->show();
754} 758}
755 759
756void Launcher::documentRemoved( const DocLnk& doc ) 760void Launcher::documentRemoved( const DocLnk& doc )
757{ 761{
758 tabs->docView()->removeLink( doc.linkFile() ); 762 tabs->docView()->removeLink( doc.linkFile() );
759} 763}
760 764
761void Launcher::documentChanged( const DocLnk& oldDoc, const DocLnk& newDoc ) 765void Launcher::documentChanged( const DocLnk& oldDoc, const DocLnk& newDoc )
762{ 766{
763#if 0 767#if 0
764 documentRemoved( oldDoc ); 768 documentRemoved( oldDoc );
765 documentAdded( newDoc ); 769 documentAdded( newDoc );
766// tabs->docView()->updateTools(); 770// tabs->docView()->updateTools();
767#else 771#else
768 tabs->docView()->changeItem(oldDoc,new DocLnk(newDoc)); 772 tabs->docView()->changeItem(oldDoc,new DocLnk(newDoc));
769#endif 773#endif
770} 774}
771 775
772void Launcher::allDocumentsRemoved() 776void Launcher::allDocumentsRemoved()
773{ 777{
774 tabs->docView()->removeAllItems(); 778 tabs->docView()->removeAllItems();
775} 779}
776 780
777void Launcher::applicationStateChanged( const QString& name, ApplicationState state ) 781void Launcher::applicationStateChanged( const QString& name, ApplicationState state )
778{ 782{
779 tb->setApplicationState( name, state ); 783 tb->setApplicationState( name, state );
780} 784}
781 785
782void Launcher::applicationScanningProgress( int percent ) 786void Launcher::applicationScanningProgress( int percent )
783{ 787{
784 switch ( percent ) { 788 switch ( percent ) {
785 case 0: { 789 case 0: {
786 for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) { 790 for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) {
787 tabs->view( (*it) )->setUpdatesEnabled( FALSE ); 791 tabs->view( (*it) )->setUpdatesEnabled( FALSE );
788 tabs->view( (*it) )->setSortEnabled( FALSE ); 792 tabs->view( (*it) )->setSortEnabled( FALSE );
789 } 793 }
790 break; 794 break;
791 } 795 }
792 case 100: { 796 case 100: {
793 for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) { 797 for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) {
794 tabs->view( (*it) )->setUpdatesEnabled( TRUE ); 798 tabs->view( (*it) )->setUpdatesEnabled( TRUE );
795 tabs->view( (*it) )->setSortEnabled( TRUE ); 799 tabs->view( (*it) )->setSortEnabled( TRUE );
796 } 800 }
797 tb->refreshStartMenu(); 801 tb->refreshStartMenu();
798 break; 802 break;
799 } 803 }
800 default: 804 default:
801 break; 805 break;
802 } 806 }
803} 807}
804 808
805void Launcher::documentScanningProgress( int percent ) 809void Launcher::documentScanningProgress( int percent )
806{ 810{
807 switch ( percent ) { 811 switch ( percent ) {
808 case 0: { 812 case 0: {
809 tabs->setLoadingProgress( 0 ); 813 tabs->setLoadingProgress( 0 );
810 tabs->setLoadingWidgetEnabled( TRUE ); 814 tabs->setLoadingWidgetEnabled( TRUE );
811 tabs->docView()->setUpdatesEnabled( FALSE ); 815 tabs->docView()->setUpdatesEnabled( FALSE );
812 tabs->docView()->setSortEnabled( FALSE ); 816 tabs->docView()->setSortEnabled( FALSE );
813 break; 817 break;
814 } 818 }
815 case 100: { 819 case 100: {
816 tabs->docView()->updateTools(); 820 tabs->docView()->updateTools();
817 tabs->docView()->setSortEnabled( TRUE ); 821 tabs->docView()->setSortEnabled( TRUE );
818 tabs->docView()->setUpdatesEnabled( TRUE ); 822 tabs->docView()->setUpdatesEnabled( TRUE );
819 tabs->setLoadingWidgetEnabled( FALSE ); 823 tabs->setLoadingWidgetEnabled( FALSE );
820 break; 824 break;
821 } 825 }
822 default: 826 default:
823 tabs->setLoadingProgress( percent ); 827 tabs->setLoadingProgress( percent );
824 break; 828 break;
825 } 829 }
826} 830}
827 831
diff --git a/core/launcher/launcherview.cpp b/core/launcher/launcherview.cpp
index d960908..6275fcb 100644
--- a/core/launcher/launcherview.cpp
+++ b/core/launcher/launcherview.cpp
@@ -1,1280 +1,1287 @@
1/********************************************************************** 1/*
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2                 This file is part of the Opie Project
3** 3 =. (C) 2000-2002 Trolltech AS
4** This file is part of the Qtopia Environment. 4 .=l. (C) 2002-2005 The Opie Team <opie-devel@handhelds.org>
5** 5           .>+-=
6** This file may be distributed and/or modified under the terms of the 6 _;:,     .>    :=|. This program is free software; you can
7** GNU General Public License version 2 as published by the Free Software 7.> <`_,   >  .   <= redistribute it and/or modify it under
8** Foundation and appearing in the file LICENSE.GPL included in the 8 :`=1 )Y*s>-.--   : the terms of the GNU Library General Public
9** packaging of this file. 9.="- .-=="i,     .._ License as published by the Free Software
10** 10 - .   .-<_>     .<> Foundation; version 2 of the License.
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11     ._= =}       :
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12    .%`+i>       _;_.
13** 13    .i_,=:_.      -<s. This program is distributed in the hope that
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15** 15 : ..    .:,     . . . without even the implied warranty of
16** Contact info@trolltech.com if any conditions of this licensing are 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17** not clear to you. 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
18** 18..}^=.=       =       ; Library General Public License for more
19**********************************************************************/ 19++=   -.     .`     .: details.
20 20 :     =  ...= . :.=-
21 -.   .:....=;==+<; You should have received a copy of the GNU
22  -_. . .   )=.  = Library General Public License along with
23    --        :-=` this library; see the file COPYING.LIB.
24 If not, write to the Free Software Foundation,
25 Inc., 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA.
27*/
21#include "launcherview.h" 28#include "launcherview.h"
22 29
23/* OPIE */ 30/* OPIE */
24#include <opie2/odebug.h> 31#include <opie2/odebug.h>
32#include <opie2/oresource.h>
25#include <qpe/config.h> 33#include <qpe/config.h>
26#include <qtopia/qpeapplication.h> 34#include <qtopia/qpeapplication.h>
27#include <qtopia/private/categories.h> 35#include <qtopia/private/categories.h>
28#include <qtopia/categoryselect.h> 36#include <qtopia/categoryselect.h>
29#include <qtopia/mimetype.h> 37#include <qtopia/mimetype.h>
30#include <qtopia/resource.h>
31using namespace Opie::Core; 38using namespace Opie::Core;
32 39
33#include <qpe/qcopenvelope_qws.h> 40#include <qpe/qcopenvelope_qws.h>
34 41
35/* QT */ 42/* QT */
36#include <qtimer.h> 43#include <qtimer.h>
37#include <qfileinfo.h> 44#include <qfileinfo.h>
38#include <qiconview.h> 45#include <qiconview.h>
39#include <qobjectlist.h> 46#include <qobjectlist.h>
40 47
41 48
42// These define how the busy icon is animated and highlighted 49// These define how the busy icon is animated and highlighted
43#define BRIGHTEN_BUSY_ICON 50#define BRIGHTEN_BUSY_ICON
44//#define ALPHA_FADE_BUSY_ICON 51//#define ALPHA_FADE_BUSY_ICON
45//#define USE_ANIMATED_BUSY_ICON_OVERLAY 52//#define USE_ANIMATED_BUSY_ICON_OVERLAY
46#define BOUNCE_BUSY_ICON 53#define BOUNCE_BUSY_ICON
47 54
48typedef QMap<QString,QPixmap>::Iterator pixiter; 55typedef QMap<QString,QPixmap>::Iterator pixiter;
49 56
50class BgPixmap 57class BgPixmap
51{ 58{
52public: 59public:
53 BgPixmap( const QPixmap &p ) : pm(p), ref(1) {} 60 BgPixmap( const QPixmap &p ) : pm(p), ref(1) {}
54 QPixmap pm; 61 QPixmap pm;
55 int ref; 62 int ref;
56}; 63};
57 64
58 65
59static QMap<QString,BgPixmap*> *bgCache = 0; 66static QMap<QString,BgPixmap*> *bgCache = 0;
60 67
61static void cleanup_cache() 68static void cleanup_cache()
62{ 69{
63 QMap<QString,BgPixmap*>::Iterator it = bgCache->begin(); 70 QMap<QString,BgPixmap*>::Iterator it = bgCache->begin();
64 while ( it != bgCache->end() ) { 71 while ( it != bgCache->end() ) {
65 QMap<QString,BgPixmap*>::Iterator curr = it; 72 QMap<QString,BgPixmap*>::Iterator curr = it;
66 ++it; 73 ++it;
67 delete (*curr); 74 delete (*curr);
68 bgCache->remove( curr ); 75 bgCache->remove( curr );
69 } 76 }
70 delete bgCache; 77 delete bgCache;
71 bgCache = 0; 78 bgCache = 0;
72} 79}
73 80
74 81
75class LauncherItem : public QIconViewItem 82class LauncherItem : public QIconViewItem
76{ 83{
77public: 84public:
78 enum iconstate_t { 85 enum iconstate_t {
79 BASE_ICON, 86 BASE_ICON,
80 WAITING_ICON, 87 WAITING_ICON,
81 EYE_ICON 88 EYE_ICON
82 }; 89 };
83 90
84 LauncherItem( QIconView *parent, AppLnk* applnk, bool bigIcon=TRUE ); 91 LauncherItem( QIconView *parent, AppLnk* applnk, bool bigIcon=TRUE );
85 ~LauncherItem(); 92 ~LauncherItem();
86 93
87 AppLnk *appLnk() const { return app; } 94 AppLnk *appLnk() const { return app; }
88 AppLnk *takeAppLnk() { AppLnk* r=app; app=0; return r; } 95 AppLnk *takeAppLnk() { AppLnk* r=app; app=0; return r; }
89 96
90 void animateIcon(); 97 void animateIcon();
91 void resetIcon(); 98 void resetIcon();
92 bool isEyeImage()const{return m_EyeImage;} 99 bool isEyeImage()const{return m_EyeImage;}
93 100
94 virtual int compare ( QIconViewItem * i ) const; 101 virtual int compare ( QIconViewItem * i ) const;
95 void paintItem( QPainter *p, const QColorGroup &cg ); 102 void paintItem( QPainter *p, const QColorGroup &cg );
96 103
97 void setBusyIndicatorType ( BusyIndicatorType t ) { busyType = t; } 104 void setBusyIndicatorType ( BusyIndicatorType t ) { busyType = t; }
98 void setEyePixmap(const QPixmap&aIcon); 105 void setEyePixmap(const QPixmap&aIcon);
99 virtual QPixmap*pixmap()const; 106 virtual QPixmap*pixmap()const;
100 107
101protected: 108protected:
102 bool isBigIcon; 109 bool isBigIcon;
103 int iteration; 110 int iteration;
104 AppLnk* app; 111 AppLnk* app;
105 112
106private: 113private:
107 void paintAnimatedIcon( QPainter *p ); 114 void paintAnimatedIcon( QPainter *p );
108 BusyIndicatorType busyType; 115 BusyIndicatorType busyType;
109 int psize; 116 int psize;
110 bool m_EyeImage; 117 bool m_EyeImage;
111 iconstate_t m_EyeImageSet; 118 iconstate_t m_EyeImageSet;
112}; 119};
113 120
114static bool s_IgnoreNextPix = false; 121static bool s_IgnoreNextPix = false;
115 122
116LauncherItem::LauncherItem( QIconView *parent, AppLnk *applnk, bool bigIcon ) 123LauncherItem::LauncherItem( QIconView *parent, AppLnk *applnk, bool bigIcon )
117 : QIconViewItem( parent, applnk->name(), 124 : QIconViewItem( parent, applnk->name(),
118 bigIcon ? applnk->bigPixmap() :applnk->pixmap() ), 125 bigIcon ? applnk->bigPixmap() :applnk->pixmap() ),
119 isBigIcon( bigIcon ), 126 isBigIcon( bigIcon ),
120 iteration(0), 127 iteration(0),
121 app(applnk), // Takes ownership 128 app(applnk), // Takes ownership
122 psize( (bigIcon ? applnk->bigPixmap().width() :applnk->pixmap().width() ) ), 129 psize( (bigIcon ? applnk->bigPixmap().width() :applnk->pixmap().width() ) ),
123 m_EyeImage(false), 130 m_EyeImage(false),
124 m_EyeImageSet(BASE_ICON) 131 m_EyeImageSet(BASE_ICON)
125{ 132{
126 if (applnk->type().lower().startsWith("image/") && applnk->exec().contains("opie-eye",false)) { 133 if (applnk->type().lower().startsWith("image/") && applnk->exec().contains("opie-eye",false)) {
127 m_EyeImage = true; 134 m_EyeImage = true;
128 QMap<QString,QPixmap>::Iterator it = LauncherIconView::sm_EyeCache->find(applnk->file()); 135 QMap<QString,QPixmap>::Iterator it = LauncherIconView::sm_EyeCache->find(applnk->file());
129 if (it != LauncherIconView::sm_EyeCache->end()) { 136 if (it != LauncherIconView::sm_EyeCache->end()) {
130 m_EyeImageSet = EYE_ICON; 137 m_EyeImageSet = EYE_ICON;
131 setPixmap(*it); 138 setPixmap(*it);
132 } 139 }
133 } 140 }
134} 141}
135 142
136LauncherItem::~LauncherItem() 143LauncherItem::~LauncherItem()
137{ 144{
138 LauncherIconView* liv = (LauncherIconView*)iconView(); 145 LauncherIconView* liv = (LauncherIconView*)iconView();
139 if ( liv->busyItem() == this ) 146 if ( liv->busyItem() == this )
140 liv->setBusy(FALSE); 147 liv->setBusy(FALSE);
141 delete app; 148 delete app;
142} 149}
143 150
144QPixmap*LauncherItem::pixmap()const 151QPixmap*LauncherItem::pixmap()const
145{ 152{
146 if (m_EyeImage && m_EyeImageSet == BASE_ICON && s_IgnoreNextPix==false) { 153 if (m_EyeImage && m_EyeImageSet == BASE_ICON && s_IgnoreNextPix==false) {
147 LauncherIconView* liv = (LauncherIconView*)iconView(); 154 LauncherIconView* liv = (LauncherIconView*)iconView();
148 liv->requestEyePix(this); 155 liv->requestEyePix(this);
149 } 156 }
150 return QIconViewItem::pixmap(); 157 return QIconViewItem::pixmap();
151} 158}
152 159
153int LauncherItem::compare ( QIconViewItem * i ) const 160int LauncherItem::compare ( QIconViewItem * i ) const
154{ 161{
155 LauncherIconView* view = (LauncherIconView*)iconView(); 162 LauncherIconView* view = (LauncherIconView*)iconView();
156 return view->compare(app,((LauncherItem *)i)->appLnk()); 163 return view->compare(app,((LauncherItem *)i)->appLnk());
157} 164}
158 165
159void LauncherItem::paintItem( QPainter *p, const QColorGroup &cg ) 166void LauncherItem::paintItem( QPainter *p, const QColorGroup &cg )
160{ 167{
161 LauncherIconView* liv = (LauncherIconView*)iconView(); 168 LauncherIconView* liv = (LauncherIconView*)iconView();
162 QBrush oldBrush( liv->itemTextBackground() ); 169 QBrush oldBrush( liv->itemTextBackground() );
163 QColorGroup mycg( cg ); 170 QColorGroup mycg( cg );
164 if ( liv->currentItem() == this ) { 171 if ( liv->currentItem() == this ) {
165 liv->setItemTextBackground( cg.brush( QColorGroup::Highlight ) ); 172 liv->setItemTextBackground( cg.brush( QColorGroup::Highlight ) );
166 mycg.setColor( QColorGroup::Text, cg.color( QColorGroup::HighlightedText ) ); 173 mycg.setColor( QColorGroup::Text, cg.color( QColorGroup::HighlightedText ) );
167 } 174 }
168 175
169 QIconViewItem::paintItem(p,mycg); 176 QIconViewItem::paintItem(p,mycg);
170 177
171 // Paint animation overlay 178 // Paint animation overlay
172 if ( liv->busyItem() == this ) 179 if ( liv->busyItem() == this )
173 paintAnimatedIcon(p); 180 paintAnimatedIcon(p);
174 181
175 if ( liv->currentItem() == this ) 182 if ( liv->currentItem() == this )
176 liv->setItemTextBackground( oldBrush ); 183 liv->setItemTextBackground( oldBrush );
177} 184}
178 185
179void LauncherItem::paintAnimatedIcon( QPainter *p ) 186void LauncherItem::paintAnimatedIcon( QPainter *p )
180{ 187{
181 LauncherIconView* liv = (LauncherIconView*)iconView(); 188 LauncherIconView* liv = (LauncherIconView*)iconView();
182 int pic = iteration % 16; 189 int pic = iteration % 16;
183 int w = pixmap()->width(), h = pixmap()->height(); 190 int w = pixmap()->width(), h = pixmap()->height();
184 QPixmap dblBuf( w, h + 4 ); 191 QPixmap dblBuf( w, h + 4 );
185 QPainter p2( &dblBuf ); 192 QPainter p2( &dblBuf );
186 int x1, y1; 193 int x1, y1;
187 if ( liv->itemTextPos() == QIconView::Bottom ) { 194 if ( liv->itemTextPos() == QIconView::Bottom ) {
188 x1 = x() + (width() - w) / 2 - liv->contentsX(); 195 x1 = x() + (width() - w) / 2 - liv->contentsX();
189 y1 = y() - liv->contentsY(); 196 y1 = y() - liv->contentsY();
190 } else { 197 } else {
191 x1 = x() - liv->contentsX(); 198 x1 = x() - liv->contentsX();
192 y1 = y() + (height() - h) / 2 - liv->contentsY(); 199 y1 = y() + (height() - h) / 2 - liv->contentsY();
193 } 200 }
194 y1 -= 2; 201 y1 -= 2;
195 p2.translate(-x1,-y1); 202 p2.translate(-x1,-y1);
196 liv->drawBackground( &p2, QRect(x1,y1,w,h+4) ); 203 liv->drawBackground( &p2, QRect(x1,y1,w,h+4) );
197 int bounceY = 2; 204 int bounceY = 2;
198#ifdef BOUNCE_BUSY_ICON 205#ifdef BOUNCE_BUSY_ICON
199 if ( busyType == BIT_Animated ) { 206 if ( busyType == BIT_Animated ) {
200 bounceY = 4 - ((iteration+2)%8); 207 bounceY = 4 - ((iteration+2)%8);
201 bounceY = bounceY < 0 ? -bounceY : bounceY; 208 bounceY = bounceY < 0 ? -bounceY : bounceY;
202 } 209 }
203#endif 210#endif
204 p2.drawPixmap( x1, y1 + bounceY, *pixmap() ); 211 p2.drawPixmap( x1, y1 + bounceY, *pixmap() );
205#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY 212#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY
206 p2.drawPixmap( x1, y1 + bounceY, liv->busyPixmap(), w * pic, 0, w, h ); 213 p2.drawPixmap( x1, y1 + bounceY, liv->busyPixmap(), w * pic, 0, w, h );
207#else 214#else
208 Q_UNUSED( pic ) 215 Q_UNUSED( pic )
209#endif 216#endif
210 p->drawPixmap( x1, y1, dblBuf ); 217 p->drawPixmap( x1, y1, dblBuf );
211} 218}
212 219
213void LauncherItem::animateIcon() 220void LauncherItem::animateIcon()
214{ 221{
215 LauncherIconView* liv = (LauncherIconView*)iconView(); 222 LauncherIconView* liv = (LauncherIconView*)iconView();
216 223
217 if ( liv->busyItem() != this || !app ) 224 if ( liv->busyItem() != this || !app )
218 return; 225 return;
219 226
220 // Highlight the icon 227 // Highlight the icon
221 if ( iteration == 0 ) { 228 if ( iteration == 0 ) {
222 QPixmap src; 229 QPixmap src;
223 pixiter it; 230 pixiter it;
224 if (isEyeImage() && (it=LauncherIconView::sm_EyeCache->find(appLnk()->file()))!=LauncherIconView::sm_EyeCache->end()) { 231 if (isEyeImage() && (it=LauncherIconView::sm_EyeCache->find(appLnk()->file()))!=LauncherIconView::sm_EyeCache->end()) {
225 src = (*it); 232 src = (*it);
226 } else { 233 } else {
227 src = ((isBigIcon ? app->bigPixmap() : app->pixmap())); 234 src = ((isBigIcon ? app->bigPixmap() : app->pixmap()));
228 } 235 }
229 QImage img = src.convertToImage(); 236 QImage img = src.convertToImage();
230 QRgb *rgb; 237 QRgb *rgb;
231 int count; 238 int count;
232 if ( img.depth() == 32 ) { 239 if ( img.depth() == 32 ) {
233 rgb = (QRgb*)img.bits(); 240 rgb = (QRgb*)img.bits();
234 count = img.bytesPerLine()/sizeof(QRgb)*img.height(); 241 count = img.bytesPerLine()/sizeof(QRgb)*img.height();
235 } else { 242 } else {
236 rgb = img.colorTable(); 243 rgb = img.colorTable();
237 count = img.numColors(); 244 count = img.numColors();
238 } 245 }
239 for ( int r = 0; r < count; r++, rgb++ ) { 246 for ( int r = 0; r < count; r++, rgb++ ) {
240#if defined(BRIGHTEN_BUSY_ICON) 247#if defined(BRIGHTEN_BUSY_ICON)
241 QColor c(*rgb); 248 QColor c(*rgb);
242 int h, s, v; 249 int h, s, v;
243 c.hsv(&h,&s,&v); 250 c.hsv(&h,&s,&v);
244 c.setHsv(h,QMAX(s-24,0),QMIN(v+48,255)); 251 c.setHsv(h,QMAX(s-24,0),QMIN(v+48,255));
245 *rgb = qRgba(c.red(),c.green(),c.blue(),qAlpha(*rgb)); 252 *rgb = qRgba(c.red(),c.green(),c.blue(),qAlpha(*rgb));
246#elif defined(ALPHA_FADE_BUSY_ICON) 253#elif defined(ALPHA_FADE_BUSY_ICON)
247 *rgb = qRgba(qRed(*rgb),qGreen(*rgb),qBlue(*rgb),qAlpha(*rgb)/2); 254 *rgb = qRgba(qRed(*rgb),qGreen(*rgb),qBlue(*rgb),qAlpha(*rgb)/2);
248#endif 255#endif
249 } 256 }
250 src.convertFromImage( img ); 257 src.convertFromImage( img );
251 setPixmap( src ); 258 setPixmap( src );
252 } 259 }
253 260
254 iteration++; 261 iteration++;
255 262
256 // Paint animation overlay 263 // Paint animation overlay
257 QPainter p( liv->viewport() ); 264 QPainter p( liv->viewport() );
258 paintAnimatedIcon( &p ); 265 paintAnimatedIcon( &p );
259} 266}
260 267
261void LauncherItem::resetIcon() 268void LauncherItem::resetIcon()
262{ 269{
263 iteration = 0; 270 iteration = 0;
264 if (isEyeImage()) { 271 if (isEyeImage()) {
265 QMap<QString,QPixmap>::Iterator it = LauncherIconView::sm_EyeCache->find(appLnk()->file()); 272 QMap<QString,QPixmap>::Iterator it = LauncherIconView::sm_EyeCache->find(appLnk()->file());
266 if (it != LauncherIconView::sm_EyeCache->end()) { 273 if (it != LauncherIconView::sm_EyeCache->end()) {
267 setPixmap(*it); 274 setPixmap(*it);
268 return; 275 return;
269 } 276 }
270 } 277 }
271 setPixmap(isBigIcon ? app->bigPixmap() : app->pixmap()); 278 setPixmap(isBigIcon ? app->bigPixmap() : app->pixmap());
272} 279}
273 280
274void LauncherItem::setEyePixmap(const QPixmap&aIcon) 281void LauncherItem::setEyePixmap(const QPixmap&aIcon)
275{ 282{
276 if (!isEyeImage()) return; 283 if (!isEyeImage()) return;
277 setPixmap(aIcon); 284 setPixmap(aIcon);
278 m_EyeImageSet = EYE_ICON; 285 m_EyeImageSet = EYE_ICON;
279} 286}
280 287
281//=========================================================================== 288//===========================================================================
282// Implemantation of LauncherIconview start 289// Implemantation of LauncherIconview start
283//=========================================================================== 290//===========================================================================
284 291
285QMap<QString,QPixmap>* LauncherIconView::sm_EyeCache=0; 292QMap<QString,QPixmap>* LauncherIconView::sm_EyeCache=0;
286 293
287LauncherIconView::LauncherIconView( QWidget* parent, const char* name ) 294LauncherIconView::LauncherIconView( QWidget* parent, const char* name )
288 : QIconView(parent,name),tf(""),cf(0),bsy(0),busyTimer(0),bigIcns(TRUE),bgColor(white),numColumns(0) 295 : QIconView(parent,name),tf(""),cf(0),bsy(0),busyTimer(0),bigIcns(TRUE),bgColor(white),numColumns(0)
289{ 296{
290 m_EyeCallBack = 0; 297 m_EyeCallBack = 0;
291 if (!sm_EyeCache) sm_EyeCache = new QMap<QString,QPixmap>(); 298 if (!sm_EyeCache) sm_EyeCache = new QMap<QString,QPixmap>();
292 sortmeth = Name; 299 sortmeth = Name;
293 hidden.setAutoDelete(TRUE); 300 hidden.setAutoDelete(TRUE);
294 ike = FALSE; 301 ike = FALSE;
295 calculateGrid( Bottom ); 302 calculateGrid( Bottom );
296 connect(&m_eyeTimer,SIGNAL(timeout()),this,SLOT(stopEyeTimer())); 303 connect(&m_eyeTimer,SIGNAL(timeout()),this,SLOT(stopEyeTimer()));
297 Config config( "Launcher" ); 304 Config config( "Launcher" );
298 config.setGroup( "GUI" ); 305 config.setGroup( "GUI" );
299 setStaticBackgroundPicture( config.readBoolEntry( "StaticBackground", true ) ); 306 setStaticBackgroundPicture( config.readBoolEntry( "StaticBackground", true ) );
300} 307}
301 308
302LauncherIconView::~LauncherIconView() 309LauncherIconView::~LauncherIconView()
303{ 310{
304 odebug << "LauncherIconView::~LauncherIconView()" << oendl; 311 odebug << "LauncherIconView::~LauncherIconView()" << oendl;
305#if 0 // debuggery 312#if 0 // debuggery
306 QListIterator<AppLnk> it(hidden); 313 QListIterator<AppLnk> it(hidden);
307 AppLnk* l; 314 AppLnk* l;
308 while ((l=it.current())) { 315 while ((l=it.current())) {
309 ++it; 316 ++it;
310 //odebug << "" << l << ": hidden (should remove)" << oendl; 317 //odebug << "" << l << ": hidden (should remove)" << oendl;
311 } 318 }
312#endif 319#endif
313} 320}
314 321
315void LauncherIconView::unsetPalette() 322void LauncherIconView::unsetPalette()
316{ 323{
317 s_IgnoreNextPix = true; 324 s_IgnoreNextPix = true;
318 QIconView::unsetPalette(); 325 QIconView::unsetPalette();
319 s_IgnoreNextPix = false; 326 s_IgnoreNextPix = false;
320} 327}
321 328
322void LauncherIconView::setPalette(const QPalette & palette) 329void LauncherIconView::setPalette(const QPalette & palette)
323{ 330{
324 s_IgnoreNextPix = true; 331 s_IgnoreNextPix = true;
325 QIconView::setPalette(palette); 332 QIconView::setPalette(palette);
326 s_IgnoreNextPix = false; 333 s_IgnoreNextPix = false;
327} 334}
328 335
329void LauncherIconView::setStaticBackgroundPicture( bool enable ) 336void LauncherIconView::setStaticBackgroundPicture( bool enable )
330{ 337{
331 staticBackground = enable; 338 staticBackground = enable;
332 if ( staticBackground ) 339 if ( staticBackground )
333 { 340 {
334 setStaticBackground( true ); 341 setStaticBackground( true );
335 verticalScrollBar()->setTracking( false ); 342 verticalScrollBar()->setTracking( false );
336 } 343 }
337 else 344 else
338 { 345 {
339 setStaticBackground( false ); 346 setStaticBackground( false );
340 verticalScrollBar()->setTracking( true ); 347 verticalScrollBar()->setTracking( true );
341 } 348 }
342} 349}
343 350
344int LauncherIconView::compare(const AppLnk* a, const AppLnk* b) 351int LauncherIconView::compare(const AppLnk* a, const AppLnk* b)
345{ 352{
346 switch (sortmeth) { 353 switch (sortmeth) {
347 case Name: 354 case Name:
348 return a->name().lower().compare(b->name().lower()); 355 return a->name().lower().compare(b->name().lower());
349 case Date: { 356 case Date: {
350 QFileInfo fa(a->linkFileKnown() ? a->linkFile() : a->file()); 357 QFileInfo fa(a->linkFileKnown() ? a->linkFile() : a->file());
351 QFileInfo fb(b->linkFileKnown() ? b->linkFile() : b->file()); 358 QFileInfo fb(b->linkFileKnown() ? b->linkFile() : b->file());
352 return fa.lastModified().secsTo(fb.lastModified()); 359 return fa.lastModified().secsTo(fb.lastModified());
353 } 360 }
354 case Type: 361 case Type:
355 return a->type().compare(b->type()); 362 return a->type().compare(b->type());
356 } 363 }
357 return 0; 364 return 0;
358} 365}
359 366
360void LauncherIconView::setSortMethod( SortMethod m ) 367void LauncherIconView::setSortMethod( SortMethod m )
361{ 368{
362 if ( sortmeth != m ) { 369 if ( sortmeth != m ) {
363 sortmeth = m; 370 sortmeth = m;
364 sort(); 371 sort();
365 } 372 }
366} 373}
367 374
368void LauncherIconView::setCategoryFilter( int catfilter, bool resort ) 375void LauncherIconView::setCategoryFilter( int catfilter, bool resort )
369{ 376{
370 if ( catfilter == -2 ) 377 if ( catfilter == -2 )
371 cf = 0; 378 cf = 0;
372 else 379 else
373 cf = catfilter; 380 cf = catfilter;
374 hideOrShowItems(resort); 381 hideOrShowItems(resort);
375} 382}
376 383
377void LauncherIconView::setTypeFilter(const QString& typefilter, bool resort) 384void LauncherIconView::setTypeFilter(const QString& typefilter, bool resort)
378{ 385{
379 tf = QRegExp(typefilter,FALSE,TRUE); 386 tf = QRegExp(typefilter,FALSE,TRUE);
380 hideOrShowItems(resort); 387 hideOrShowItems(resort);
381} 388}
382 389
383void LauncherIconView::setItemTextPos( ItemTextPos pos ) 390void LauncherIconView::setItemTextPos( ItemTextPos pos )
384{ 391{
385 calculateGrid( pos ); 392 calculateGrid( pos );
386 QIconView::setItemTextPos( pos ); 393 QIconView::setItemTextPos( pos );
387} 394}
388 395
389void LauncherIconView::drawBackground( QPainter *p, const QRect &r ) 396void LauncherIconView::drawBackground( QPainter *p, const QRect &r )
390{ 397{
391 if ( bgPixmap.isNull() ) 398 if ( bgPixmap.isNull() )
392 { 399 {
393 p->fillRect( r, bgColor ); 400 p->fillRect( r, bgColor );
394 } 401 }
395 else 402 else
396 { 403 {
397 if ( staticBackground ) 404 if ( staticBackground )
398 { 405 {
399 p->drawTiledPixmap( r, bgPixmap, QPoint( r.x() % bgPixmap.width(), r.y() % bgPixmap.height() ) ); 406 p->drawTiledPixmap( r, bgPixmap, QPoint( r.x() % bgPixmap.width(), r.y() % bgPixmap.height() ) );
400 } 407 }
401 else 408 else
402 { 409 {
403 p->drawTiledPixmap( r, bgPixmap, QPoint( (r.x() + contentsX()) % bgPixmap.width(), 410 p->drawTiledPixmap( r, bgPixmap, QPoint( (r.x() + contentsX()) % bgPixmap.width(),
404 (r.y() + contentsY()) % bgPixmap.height() ) ); 411 (r.y() + contentsY()) % bgPixmap.height() ) );
405 } 412 }
406 } 413 }
407} 414}
408 415
409void LauncherIconView::addCatsAndMimes(AppLnk* app) 416void LauncherIconView::addCatsAndMimes(AppLnk* app)
410{ 417{
411 // QStringList c = app->categories(); 418 // QStringList c = app->categories();
412 // for (QStringList::ConstIterator cit=c.begin(); cit!=c.end(); ++cit) { 419 // for (QStringList::ConstIterator cit=c.begin(); cit!=c.end(); ++cit) {
413 // cats.replace(*cit,(void*)1); 420 // cats.replace(*cit,(void*)1);
414 // } 421 // }
415 QString maj=app->type(); 422 QString maj=app->type();
416 int sl=maj.find('/'); 423 int sl=maj.find('/');
417 if (sl>=0) { 424 if (sl>=0) {
418 QString k; 425 QString k;
419 k = maj.left(12) == "application/" ? maj : maj.left(sl); 426 k = maj.left(12) == "application/" ? maj : maj.left(sl);
420 mimes.replace(k,(void*)1); 427 mimes.replace(k,(void*)1);
421 } 428 }
422} 429}
423 430
424void LauncherIconView::setBusy(bool on) 431void LauncherIconView::setBusy(bool on)
425{ 432{
426#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY 433#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY
427 if ( busyPix.isNull() ) { 434 if ( busyPix.isNull() ) {
428 int size = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize(); 435 int size = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize();
429 busyPix.convertFromImage( Resource::loadImage( "busy" ).smoothScale( size * 16, size ) ); 436 busyPix.convertFromImage( OResource::loadImage( "busy", OResource::NoScale ).smoothScale( size * 16, size ) );
430 } 437 }
431#endif 438#endif
432 439
433 if ( on ) { 440 if ( on ) {
434 busyTimer = startTimer( 100 ); 441 busyTimer = startTimer( 100 );
435 } else { 442 } else {
436 if ( busyTimer ) { 443 if ( busyTimer ) {
437 killTimer( busyTimer ); 444 killTimer( busyTimer );
438 busyTimer = 0; 445 busyTimer = 0;
439 } 446 }
440 } 447 }
441 448
442 LauncherItem *c = on ? (LauncherItem*)currentItem() : 0; 449 LauncherItem *c = on ? (LauncherItem*)currentItem() : 0;
443 450
444 if ( bsy != c ) { 451 if ( bsy != c ) {
445 LauncherItem *oldBusy = bsy; 452 LauncherItem *oldBusy = bsy;
446 bsy = c; 453 bsy = c;
447 if ( oldBusy ) { 454 if ( oldBusy ) {
448 oldBusy->resetIcon(); 455 oldBusy->resetIcon();
449 } 456 }
450 if ( bsy ) { 457 if ( bsy ) {
451 bsy->setBusyIndicatorType( busyType ) ; 458 bsy->setBusyIndicatorType( busyType ) ;
452 bsy->animateIcon(); 459 bsy->animateIcon();
453 } 460 }
454 } 461 }
455} 462}
456 463
457void LauncherIconView::clear() 464void LauncherIconView::clear()
458{ 465{
459 mimes.clear(); 466 mimes.clear();
460 cats.clear(); 467 cats.clear();
461 QIconView::clear(); 468 QIconView::clear();
462 hidden.clear(); 469 hidden.clear();
463} 470}
464 471
465QStringList LauncherIconView::mimeTypes() const 472QStringList LauncherIconView::mimeTypes() const
466{ 473{
467 QStringList r; 474 QStringList r;
468 QDictIterator<void> it(mimes); 475 QDictIterator<void> it(mimes);
469 while (it.current()) { 476 while (it.current()) {
470 r.append(it.currentKey()); 477 r.append(it.currentKey());
471 ++it; 478 ++it;
472 } 479 }
473 r.sort(); 480 r.sort();
474 return r; 481 return r;
475} 482}
476 483
477LauncherItem*LauncherIconView::findDocItem(const QString&fname) 484LauncherItem*LauncherIconView::findDocItem(const QString&fname)
478{ 485{
479 LauncherItem* item = (LauncherItem*)firstItem(); 486 LauncherItem* item = (LauncherItem*)firstItem();
480 while (item) { 487 while (item) {
481 if (item->appLnk()->file()==fname) { 488 if (item->appLnk()->file()==fname) {
482 break; 489 break;
483 } 490 }
484 item = (LauncherItem*)item->nextItem(); 491 item = (LauncherItem*)item->nextItem();
485 } 492 }
486 return item; 493 return item;
487} 494}
488 495
489void LauncherIconView::setEyePixmap(const QPixmap&aPixmap,const QString&aFile,int width) 496void LauncherIconView::setEyePixmap(const QPixmap&aPixmap,const QString&aFile,int width)
490{ 497{
491 int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize(); 498 int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize();
492 if (s!=width) return; 499 if (s!=width) return;
493 LauncherItem*item = findDocItem(aFile); 500 LauncherItem*item = findDocItem(aFile);
494 if (!item||!item->isEyeImage()) return; 501 if (!item||!item->isEyeImage()) return;
495 (*sm_EyeCache)[aFile]=aPixmap; 502 (*sm_EyeCache)[aFile]=aPixmap;
496 item->setEyePixmap(aPixmap); 503 item->setEyePixmap(aPixmap);
497} 504}
498 505
499void LauncherIconView::checkCallback() 506void LauncherIconView::checkCallback()
500{ 507{
501 if (!m_EyeCallBack) { 508 if (!m_EyeCallBack) {
502 m_EyeCallBack = new LauncherThumbReceiver(); 509 m_EyeCallBack = new LauncherThumbReceiver();
503 connect(m_EyeCallBack,SIGNAL(sig_Thumbnail(const QPixmap&,const QString&,int)), 510 connect(m_EyeCallBack,SIGNAL(sig_Thumbnail(const QPixmap&,const QString&,int)),
504 this,SLOT(setEyePixmap(const QPixmap&,const QString&,int))); 511 this,SLOT(setEyePixmap(const QPixmap&,const QString&,int)));
505 m_eyeTimer.changeInterval(600000); 512 m_eyeTimer.changeInterval(600000);
506 } 513 }
507} 514}
508 515
509void LauncherIconView::addCheckItem(AppLnk* app) 516void LauncherIconView::addCheckItem(AppLnk* app)
510{ 517{
511 LauncherItem*item = new LauncherItem( this, app, bigIcns ); 518 LauncherItem*item = new LauncherItem( this, app, bigIcns );
512 if (item->isEyeImage()) { 519 if (item->isEyeImage()) {
513 checkCallback(); 520 checkCallback();
514 } 521 }
515} 522}
516 523
517void LauncherIconView::requestEyePix(const LauncherItem*item) 524void LauncherIconView::requestEyePix(const LauncherItem*item)
518{ 525{
519 if (!item) return; 526 if (!item) return;
520 if (item->isEyeImage()) { 527 if (item->isEyeImage()) {
521 checkCallback(); 528 checkCallback();
522 int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize(); 529 int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize();
523 m_EyeCallBack->requestThumb(item->appLnk()->file(),s,s); 530 m_EyeCallBack->requestThumb(item->appLnk()->file(),s,s);
524 } 531 }
525} 532}
526 533
527void LauncherIconView::stopEyeTimer() 534void LauncherIconView::stopEyeTimer()
528{ 535{
529 if (m_EyeCallBack) { 536 if (m_EyeCallBack) {
530 disconnect(m_EyeCallBack,SIGNAL(sig_Thumbnail(const QPixmap&,const QString&,int)), 537 disconnect(m_EyeCallBack,SIGNAL(sig_Thumbnail(const QPixmap&,const QString&,int)),
531 this,SLOT(setEyePixmap(const QPixmap&,const QString&,int))); 538 this,SLOT(setEyePixmap(const QPixmap&,const QString&,int)));
532 delete m_EyeCallBack; 539 delete m_EyeCallBack;
533 m_EyeCallBack=0; 540 m_EyeCallBack=0;
534 } 541 }
535 m_eyeTimer.stop(); 542 m_eyeTimer.stop();
536} 543}
537 544
538void LauncherIconView::updateCategoriesAndMimeTypes() 545void LauncherIconView::updateCategoriesAndMimeTypes()
539{ 546{
540 mimes.clear(); 547 mimes.clear();
541 cats.clear(); 548 cats.clear();
542 LauncherItem* item = (LauncherItem*)firstItem(); 549 LauncherItem* item = (LauncherItem*)firstItem();
543 while (item) { 550 while (item) {
544 addCatsAndMimes(item->appLnk()); 551 addCatsAndMimes(item->appLnk());
545 item = (LauncherItem*)item->nextItem(); 552 item = (LauncherItem*)item->nextItem();
546 } 553 }
547 QListIterator<AppLnk> it(hidden); 554 QListIterator<AppLnk> it(hidden);
548 AppLnk* l; 555 AppLnk* l;
549 while ((l=it.current())) { 556 while ((l=it.current())) {
550 addCatsAndMimes(l); 557 addCatsAndMimes(l);
551 ++it; 558 ++it;
552 } 559 }
553} 560}
554 561
555void LauncherIconView::hideOrShowItems(bool resort) 562void LauncherIconView::hideOrShowItems(bool resort)
556{ 563{
557 viewport()->setUpdatesEnabled( FALSE ); 564 viewport()->setUpdatesEnabled( FALSE );
558 hidden.setAutoDelete(FALSE); 565 hidden.setAutoDelete(FALSE);
559 QList<AppLnk> links=hidden; 566 QList<AppLnk> links=hidden;
560 hidden.clear(); 567 hidden.clear();
561 hidden.setAutoDelete(TRUE); 568 hidden.setAutoDelete(TRUE);
562 LauncherItem* item = (LauncherItem*)firstItem(); 569 LauncherItem* item = (LauncherItem*)firstItem();
563 while (item) { 570 while (item) {
564 links.append(item->takeAppLnk()); 571 links.append(item->takeAppLnk());
565 item = (LauncherItem*)item->nextItem(); 572 item = (LauncherItem*)item->nextItem();
566 } 573 }
567 clear(); 574 clear();
568 QListIterator<AppLnk> it(links); 575 QListIterator<AppLnk> it(links);
569 AppLnk* l; 576 AppLnk* l;
570 while ((l=it.current())) { 577 while ((l=it.current())) {
571 addItem(l,FALSE); 578 addItem(l,FALSE);
572 ++it; 579 ++it;
573 } 580 }
574 if ( resort && !autoArrange() ) 581 if ( resort && !autoArrange() )
575 sort(); 582 sort();
576 viewport()->setUpdatesEnabled( TRUE ); 583 viewport()->setUpdatesEnabled( TRUE );
577} 584}
578 585
579bool LauncherIconView::removeLink(const QString& linkfile,bool removeCache) 586bool LauncherIconView::removeLink(const QString& linkfile,bool removeCache)
580{ 587{
581 LauncherItem* item = (LauncherItem*)firstItem(); 588 LauncherItem* item = (LauncherItem*)firstItem();
582 AppLnk* l; 589 AppLnk* l;
583 bool did = FALSE; 590 bool did = FALSE;
584 DocLnk dl(linkfile); 591 DocLnk dl(linkfile);
585 while (item) { 592 while (item) {
586 l = item->appLnk(); 593 l = item->appLnk();
587 LauncherItem *nextItem = (LauncherItem *)item->nextItem(); 594 LauncherItem *nextItem = (LauncherItem *)item->nextItem();
588 if ( l->linkFileKnown() && l->linkFile() == linkfile || l->fileKnown() && 595 if ( l->linkFileKnown() && l->linkFile() == linkfile || l->fileKnown() &&
589 ( l->file() == linkfile || dl.isValid() && dl.file() == l->file() ) ) { 596 ( l->file() == linkfile || dl.isValid() && dl.file() == l->file() ) ) {
590 if (removeCache) sm_EyeCache->remove(l->file()); 597 if (removeCache) sm_EyeCache->remove(l->file());
591 delete item; 598 delete item;
592 did = TRUE; 599 did = TRUE;
593 } 600 }
594 item = nextItem; 601 item = nextItem;
595 } 602 }
596 QListIterator<AppLnk> it(hidden); 603 QListIterator<AppLnk> it(hidden);
597 while ((l=it.current())) { 604 while ((l=it.current())) {
598 ++it; 605 ++it;
599 if ( l->linkFileKnown() && l->linkFile() == linkfile 606 if ( l->linkFileKnown() && l->linkFile() == linkfile
600 || l->file() == linkfile 607 || l->file() == linkfile
601 || dl.isValid() && dl.file() == l->file() ) { 608 || dl.isValid() && dl.file() == l->file() ) {
602 hidden.removeRef(l); 609 hidden.removeRef(l);
603 did = TRUE; 610 did = TRUE;
604 } 611 }
605 } 612 }
606 return did; 613 return did;
607} 614}
608 615
609void LauncherIconView::addItem(AppLnk* app, bool resort) 616void LauncherIconView::addItem(AppLnk* app, bool resort)
610{ 617{
611 addCatsAndMimes(app); 618 addCatsAndMimes(app);
612 if ( (tf.isEmpty() || tf.match(app->type()) >= 0) 619 if ( (tf.isEmpty() || tf.match(app->type()) >= 0)
613 && (cf == 0 || app->categories().contains(cf) 620 && (cf == 0 || app->categories().contains(cf)
614 || cf == -1 && app->categories().count() == 0 ) ) { 621 || cf == -1 && app->categories().count() == 0 ) ) {
615 addCheckItem(app); 622 addCheckItem(app);
616 } else { 623 } else {
617 hidden.append(app); 624 hidden.append(app);
618 } 625 }
619 if ( resort ){ 626 if ( resort ){
620 sort(); 627 sort();
621 } 628 }
622} 629}
623 630
624void LauncherIconView::changeItem(const AppLnk&old,AppLnk*nlink) 631void LauncherIconView::changeItem(const AppLnk&old,AppLnk*nlink)
625{ 632{
626 QString oldfile = old.file(); 633 QString oldfile = old.file();
627 QString newfile = nlink->file(); 634 QString newfile = nlink->file();
628 635
629 if (newfile != oldfile) { 636 if (newfile != oldfile) {
630 QMap<QString,QPixmap>::Iterator it = sm_EyeCache->find(oldfile); 637 QMap<QString,QPixmap>::Iterator it = sm_EyeCache->find(oldfile);
631 if (it != sm_EyeCache->end()) { 638 if (it != sm_EyeCache->end()) {
632 (*sm_EyeCache)[newfile]=(*it); 639 (*sm_EyeCache)[newfile]=(*it);
633 } 640 }
634 removeLink(old.linkFile()); 641 removeLink(old.linkFile());
635 } else { 642 } else {
636 removeLink(old.linkFile(),false); 643 removeLink(old.linkFile(),false);
637 } 644 }
638 addItem(nlink,false); 645 addItem(nlink,false);
639} 646}
640 647
641void LauncherIconView::timerEvent( QTimerEvent *te ) 648void LauncherIconView::timerEvent( QTimerEvent *te )
642{ 649{
643 if ( te->timerId() == busyTimer ) { 650 if ( te->timerId() == busyTimer ) {
644 if ( bsy ) 651 if ( bsy )
645 bsy->animateIcon(); 652 bsy->animateIcon();
646 } else { 653 } else {
647 QIconView::timerEvent( te ); 654 QIconView::timerEvent( te );
648 } 655 }
649} 656}
650 657
651void LauncherIconView::setBigIcons( bool bi ) 658void LauncherIconView::setBigIcons( bool bi )
652{ 659{
653 sm_EyeCache->clear(); 660 sm_EyeCache->clear();
654 bigIcns = bi; 661 bigIcns = bi;
655#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY 662#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY
656 busyPix.resize(0,0); 663 busyPix.resize(0,0);
657#endif 664#endif
658} 665}
659 666
660QIconViewItem* LauncherIconView::busyItem() const 667QIconViewItem* LauncherIconView::busyItem() const
661{ 668{
662 return bsy; 669 return bsy;
663} 670}
664 671
665void LauncherIconView::setBusyIndicatorType ( BusyIndicatorType t ) { busyType = t; } 672void LauncherIconView::setBusyIndicatorType ( BusyIndicatorType t ) { busyType = t; }
666 673
667void LauncherIconView::calculateGrid( ItemTextPos pos ) 674void LauncherIconView::calculateGrid( ItemTextPos pos )
668{ 675{
669 int dw = QApplication::desktop()->width(); 676 int dw = QApplication::desktop()->width();
670 int viewerWidth = dw-style().scrollBarExtent().width(); 677 int viewerWidth = dw-style().scrollBarExtent().width();
671 if ( pos == Bottom ) { 678 if ( pos == Bottom ) {
672 if( !numColumns ) { 679 if( !numColumns ) {
673 if ( viewerWidth <= 200 ) numColumns = 2; 680 if ( viewerWidth <= 200 ) numColumns = 2;
674 else if ( viewerWidth >= 400 ) numColumns = viewerWidth/96; 681 else if ( viewerWidth >= 400 ) numColumns = viewerWidth/96;
675 else numColumns = 3; 682 else numColumns = 3;
676 } 683 }
677 setSpacing( 4 ); 684 setSpacing( 4 );
678 setGridX( (viewerWidth-(numColumns+1)*spacing())/numColumns ); 685 setGridX( (viewerWidth-(numColumns+1)*spacing())/numColumns );
679 setGridY( fontMetrics().height()*2+24 ); 686 setGridY( fontMetrics().height()*2+24 );
680 } else { 687 } else {
681 if( !numColumns ) { 688 if( !numColumns ) {
682 if ( viewerWidth < 150 ) numColumns = 1; 689 if ( viewerWidth < 150 ) numColumns = 1;
683 else if ( viewerWidth >= 400 ) numColumns = viewerWidth/150; 690 else if ( viewerWidth >= 400 ) numColumns = viewerWidth/150;
684 else numColumns = 2; 691 else numColumns = 2;
685 } 692 }
686 setSpacing( 2 ); 693 setSpacing( 2 );
687 setGridX( (viewerWidth-(numColumns+1)*spacing())/numColumns ); 694 setGridX( (viewerWidth-(numColumns+1)*spacing())/numColumns );
688 setGridY( fontMetrics().height()+2 ); 695 setGridY( fontMetrics().height()+2 );
689 } 696 }
690} 697}
691 698
692void LauncherIconView::styleChange( QStyle &old ) 699void LauncherIconView::styleChange( QStyle &old )
693{ 700{
694 QIconView::styleChange( old ); 701 QIconView::styleChange( old );
695 calculateGrid( itemTextPos() ); 702 calculateGrid( itemTextPos() );
696} 703}
697 704
698void LauncherIconView::keyPressEvent(QKeyEvent* e) 705void LauncherIconView::keyPressEvent(QKeyEvent* e)
699{ 706{
700 ike = TRUE; 707 ike = TRUE;
701 if ( e->key() == Key_F33 /* OK button */ || e->key() == Key_Space ) { 708 if ( e->key() == Key_F33 /* OK button */ || e->key() == Key_Space ) {
702 if ( (e->state() & ShiftButton) ) 709 if ( (e->state() & ShiftButton) )
703 emit mouseButtonPressed(ShiftButton, currentItem(), QPoint() ); 710 emit mouseButtonPressed(ShiftButton, currentItem(), QPoint() );
704 else 711 else
705 returnPressed(currentItem()); 712 returnPressed(currentItem());
706 } 713 }
707 714
708 QIconView::keyPressEvent(e); 715 QIconView::keyPressEvent(e);
709 ike = FALSE; 716 ike = FALSE;
710} 717}
711 718
712//=========================================================================== 719//===========================================================================
713// Implemantation of LauncherIconview end 720// Implemantation of LauncherIconview end
714//=========================================================================== 721//===========================================================================
715 722
716 723
717//=========================================================================== 724//===========================================================================
718LauncherView::LauncherView( QWidget* parent, const char* name, WFlags fl ) 725LauncherView::LauncherView( QWidget* parent, const char* name, WFlags fl )
719 : QVBox( parent, name, fl ) 726 : QVBox( parent, name, fl )
720{ 727{
721 catmb = 0; 728 catmb = 0;
722 icons = new LauncherIconView( this ); 729 icons = new LauncherIconView( this );
723 setFocusProxy(icons); 730 setFocusProxy(icons);
724 QPEApplication::setStylusOperation( icons->viewport(), QPEApplication::RightOnHold ); 731 QPEApplication::setStylusOperation( icons->viewport(), QPEApplication::RightOnHold );
725 732
726 icons->setItemsMovable( FALSE ); 733 icons->setItemsMovable( FALSE );
727 icons->setAutoArrange( TRUE ); 734 icons->setAutoArrange( TRUE );
728 icons->setSorting( TRUE ); 735 icons->setSorting( TRUE );
729 icons->setFrameStyle( QFrame::NoFrame ); 736 icons->setFrameStyle( QFrame::NoFrame );
730 icons->setMargin( 0 ); 737 icons->setMargin( 0 );
731 icons->setSelectionMode( QIconView::NoSelection ); 738 icons->setSelectionMode( QIconView::NoSelection );
732 icons->setBackgroundMode( PaletteBase ); 739 icons->setBackgroundMode( PaletteBase );
733 icons->setResizeMode( QIconView::Adjust ); 740 icons->setResizeMode( QIconView::Adjust );
734 vmode = (ViewMode)-1; 741 vmode = (ViewMode)-1;
735 setViewMode( Icon ); 742 setViewMode( Icon );
736 743
737 connect( icons, SIGNAL(mouseButtonClicked(int,QIconViewItem*,const QPoint&)), 744 connect( icons, SIGNAL(mouseButtonClicked(int,QIconViewItem*,const QPoint&)),
738 SLOT(itemClicked(int,QIconViewItem*)) ); 745 SLOT(itemClicked(int,QIconViewItem*)) );
739 connect( icons, SIGNAL(selectionChanged()), 746 connect( icons, SIGNAL(selectionChanged()),
740 SLOT(selectionChanged()) ); 747 SLOT(selectionChanged()) );
741 connect( icons, SIGNAL(returnPressed(QIconViewItem*)), 748 connect( icons, SIGNAL(returnPressed(QIconViewItem*)),
742 SLOT(returnPressed(QIconViewItem*)) ); 749 SLOT(returnPressed(QIconViewItem*)) );
743 connect( icons, SIGNAL(mouseButtonPressed(int,QIconViewItem*,const QPoint&)), 750 connect( icons, SIGNAL(mouseButtonPressed(int,QIconViewItem*,const QPoint&)),
744 SLOT(itemPressed(int,QIconViewItem*)) ); 751 SLOT(itemPressed(int,QIconViewItem*)) );
745 752
746 tools = 0; 753 tools = 0;
747 setBackgroundType( Ruled, QString::null ); 754 setBackgroundType( Ruled, QString::null );
748} 755}
749 756
750LauncherView::~LauncherView() 757LauncherView::~LauncherView()
751{ 758{
752 if ( bgCache && bgCache->contains( bgName ) ) 759 if ( bgCache && bgCache->contains( bgName ) )
753 (*bgCache)[bgName]->ref--; 760 (*bgCache)[bgName]->ref--;
754} 761}
755 762
756 763
757bool LauncherView::bsy=FALSE; 764bool LauncherView::bsy=FALSE;
758 765
759void LauncherView::setBusy(bool on) 766void LauncherView::setBusy(bool on)
760{ 767{
761 icons->setBusy(on); 768 icons->setBusy(on);
762} 769}
763 770
764void LauncherView::setBusyIndicatorType( const QString& type ) { 771void LauncherView::setBusyIndicatorType( const QString& type ) {
765 if ( type. lower ( ) == "animated" ) 772 if ( type. lower ( ) == "animated" )
766 icons->setBusyIndicatorType( BIT_Animated ) ; 773 icons->setBusyIndicatorType( BIT_Animated ) ;
767 else 774 else
768 icons->setBusyIndicatorType( BIT_Normal ) ; 775 icons->setBusyIndicatorType( BIT_Normal ) ;
769} 776}
770 777
771void LauncherView::hideIcons() 778void LauncherView::hideIcons()
772{ 779{
773 icons->hide(); 780 icons->hide();
774} 781}
775 782
776void LauncherView::setToolsEnabled(bool y) 783void LauncherView::setToolsEnabled(bool y)
777{ 784{
778 if ( !y != !tools ) { 785 if ( !y != !tools ) {
779 if ( y ) { 786 if ( y ) {
780 tools = new QHBox(this); 787 tools = new QHBox(this);
781 // Type filter 788 // Type filter
782 typemb = new QComboBox(tools); 789 typemb = new QComboBox(tools);
783 QSizePolicy p = typemb->sizePolicy(); 790 QSizePolicy p = typemb->sizePolicy();
784 p.setHorData(QSizePolicy::Expanding); 791 p.setHorData(QSizePolicy::Expanding);
785 typemb->setSizePolicy(p); 792 typemb->setSizePolicy(p);
786 // Category filter 793 // Category filter
787 updateTools(); 794 updateTools();
788 tools->show(); 795 tools->show();
789 } else { 796 } else {
790 delete tools; 797 delete tools;
791 tools = 0; 798 tools = 0;
792 } 799 }
793 } 800 }
794} 801}
795 802
796void LauncherView::updateTools() 803void LauncherView::updateTools()
797{ 804{
798 disconnect( typemb, SIGNAL(activated(int)), 805 disconnect( typemb, SIGNAL(activated(int)),
799 this, SLOT(showType(int)) ); 806 this, SLOT(showType(int)) );
800 if ( catmb ) { 807 if ( catmb ) {
801 disconnect( catmb, SIGNAL(signalSelected(int)),this,SLOT(showCategory(int))); 808 disconnect( catmb, SIGNAL(signalSelected(int)),this,SLOT(showCategory(int)));
802 } 809 }
803 810
804 // ### I want to remove this 811 // ### I want to remove this
805 icons->updateCategoriesAndMimeTypes(); 812 icons->updateCategoriesAndMimeTypes();
806 813
807 QString prev; 814 QString prev;
808 815
809 // Type filter 816 // Type filter
810 QStringList types; 817 QStringList types;
811 typelist = icons->mimeTypes(); 818 typelist = icons->mimeTypes();
812 for (QStringList::ConstIterator it = typelist.begin(); it!=typelist.end(); ++it) { 819 for (QStringList::ConstIterator it = typelist.begin(); it!=typelist.end(); ++it) {
813 QString t = *it; 820 QString t = *it;
814 if ( t.left(12) == "application/" ) { 821 if ( t.left(12) == "application/" ) {
815 MimeType mt(t); 822 MimeType mt(t);
816 const AppLnk* app = mt.application(); 823 const AppLnk* app = mt.application();
817 if ( app ) 824 if ( app )
818 t = app->name(); 825 t = app->name();
819 else 826 else
820 t = t.mid(12); 827 t = t.mid(12);
821 } else { 828 } else {
822 t[0] = t[0].upper(); 829 t[0] = t[0].upper();
823 } 830 }
824 types += t; 831 types += t;
825 } 832 }
826 types << tr("All types"); 833 types << tr("All types");
827 prev = typemb->currentText(); 834 prev = typemb->currentText();
828 typemb->clear(); 835 typemb->clear();
829 typemb->insertStringList(types); 836 typemb->insertStringList(types);
830 for (int i=0; i<typemb->count(); i++) { 837 for (int i=0; i<typemb->count(); i++) {
831 if ( typemb->text(i) == prev ) { 838 if ( typemb->text(i) == prev ) {
832 typemb->setCurrentItem(i); 839 typemb->setCurrentItem(i);
833 break; 840 break;
834 } 841 }
835 } 842 }
836 if ( prev.isNull() ) { 843 if ( prev.isNull() ) {
837 typemb->setCurrentItem(typemb->count()-1); 844 typemb->setCurrentItem(typemb->count()-1);
838 } 845 }
839 846
840 int pcat = catmb ? catmb->currentCategory() : -2; 847 int pcat = catmb ? catmb->currentCategory() : -2;
841 if ( !catmb ) { 848 if ( !catmb ) {
842 catmb = new CategorySelect(tools); 849 catmb = new CategorySelect(tools);
843 } else if (pcat!=-2) { 850 } else if (pcat!=-2) {
844 851
845 } 852 }
846 Categories cats( 0 ); 853 Categories cats( 0 );
847 cats.load( categoryFileName() ); 854 cats.load( categoryFileName() );
848 QArray<int> vl( 0 ); 855 QArray<int> vl( 0 );
849 catmb->setCategories( vl, "Document View", // No tr 856 catmb->setCategories( vl, "Document View", // No tr
850 tr("Document View") ); 857 tr("Document View") );
851 catmb->setRemoveCategoryEdit( TRUE ); 858 catmb->setRemoveCategoryEdit( TRUE );
852 catmb->setAllCategories( TRUE ); 859 catmb->setAllCategories( TRUE );
853 catmb->setCurrentCategory(pcat); 860 catmb->setCurrentCategory(pcat);
854 861
855 // if type has changed we need to redisplay 862 // if type has changed we need to redisplay
856 if ( typemb->currentText() != prev ) 863 if ( typemb->currentText() != prev )
857 showType( typemb->currentItem() ); 864 showType( typemb->currentItem() );
858 865
859 connect(typemb, SIGNAL(activated(int)), this, SLOT(showType(int))); 866 connect(typemb, SIGNAL(activated(int)), this, SLOT(showType(int)));
860 connect(catmb, SIGNAL(signalSelected(int)), this, SLOT(showCategory(int))); 867 connect(catmb, SIGNAL(signalSelected(int)), this, SLOT(showCategory(int)));
861} 868}
862 869
863void LauncherView::sortBy(int s) 870void LauncherView::sortBy(int s)
864{ 871{
865 icons->setSortMethod((LauncherIconView::SortMethod)s); 872 icons->setSortMethod((LauncherIconView::SortMethod)s);
866} 873}
867 874
868void LauncherView::showType(int t) 875void LauncherView::showType(int t)
869{ 876{
870 if ( t >= (int)typelist.count() ) { 877 if ( t >= (int)typelist.count() ) {
871 icons->setTypeFilter("",TRUE); 878 icons->setTypeFilter("",TRUE);
872 } else { 879 } else {
873 QString ty = typelist[t]; 880 QString ty = typelist[t];
874 if ( !ty.contains('/') ) 881 if ( !ty.contains('/') )
875 ty += "/*"; 882 ty += "/*";
876 icons->setTypeFilter(ty,TRUE); 883 icons->setTypeFilter(ty,TRUE);
877 } 884 }
878} 885}
879 886
880void LauncherView::showCategory( int c ) 887void LauncherView::showCategory( int c )
881{ 888{
882 icons->setCategoryFilter( c, TRUE ); 889 icons->setCategoryFilter( c, TRUE );
883} 890}
884 891
885void LauncherView::setViewMode( ViewMode m ) 892void LauncherView::setViewMode( ViewMode m )
886{ 893{
887 odebug << "LauncherView::setViewMode( ViewMode m )" << oendl; 894 odebug << "LauncherView::setViewMode( ViewMode m )" << oendl;
888 if ( vmode != m ) { 895 if ( vmode != m ) {
889 bool bigIcons = m == Icon; 896 bool bigIcons = m == Icon;
890 icons->viewport()->setUpdatesEnabled( FALSE ); 897 icons->viewport()->setUpdatesEnabled( FALSE );
891 icons->setBigIcons( bigIcons ); 898 icons->setBigIcons( bigIcons );
892 switch ( m ) { 899 switch ( m ) {
893 case List: 900 case List:
894 icons->setItemTextPos( QIconView::Right ); 901 icons->setItemTextPos( QIconView::Right );
895 break; 902 break;
896 case Icon: 903 case Icon:
897 icons->setItemTextPos( QIconView::Bottom ); 904 icons->setItemTextPos( QIconView::Bottom );
898 break; 905 break;
899 } 906 }
900 icons->hideOrShowItems( FALSE ); 907 icons->hideOrShowItems( FALSE );
901 icons->viewport()->setUpdatesEnabled( TRUE ); 908 icons->viewport()->setUpdatesEnabled( TRUE );
902 vmode = m; 909 vmode = m;
903 } 910 }
904} 911}
905 912
906// 913//
907// User images may require scaling. 914// User images may require scaling.
908// 915//
909QImage LauncherView::loadBackgroundImage(QString &bgName) 916QImage LauncherView::loadBackgroundImage(QString &bgName)
910{ 917{
911 QImageIO imgio; 918 QImageIO imgio;
912 QSize ds = qApp->desktop()->size(); // should be launcher, not desktop 919 QSize ds = qApp->desktop()->size(); // should be launcher, not desktop
913 bool further_scaling = TRUE; 920 bool further_scaling = TRUE;
914 921
915 imgio.setFileName( bgName ); 922 imgio.setFileName( bgName );
916 imgio.setParameters("GetHeaderInformation"); 923 imgio.setParameters("GetHeaderInformation");
917 924
918 if (imgio.read() == FALSE) { 925 if (imgio.read() == FALSE) {
919 return imgio.image(); 926 return imgio.image();
920 } 927 }
921 928
922 if (imgio.image().width() < ds.width() && 929 if (imgio.image().width() < ds.width() &&
923 imgio.image().height() < ds.height()) { 930 imgio.image().height() < ds.height()) {
924 further_scaling = FALSE; 931 further_scaling = FALSE;
925 } 932 }
926 933
927 if (!imgio.image().bits()) { 934 if (!imgio.image().bits()) {
928 // 935 //
929 // Scale and load. Note we don't scale up. 936 // Scale and load. Note we don't scale up.
930 // 937 //
931 QString param( "Scale( %1, %2, ScaleMin )" ); // No tr 938 QString param( "Scale( %1, %2, ScaleMin )" ); // No tr
932 imgio.setParameters(further_scaling ? 939 imgio.setParameters(further_scaling ?
933 param.arg(ds.width()).arg(ds.height()).latin1() : 940 param.arg(ds.width()).arg(ds.height()).latin1() :
934 ""); 941 "");
935 imgio.read(); 942 imgio.read();
936 } else { 943 } else {
937 if (further_scaling) { 944 if (further_scaling) {
938 int t1 = imgio.image().width() * ds.height(); 945 int t1 = imgio.image().width() * ds.height();
939 int t2 = imgio.image().height() * ds.width(); 946 int t2 = imgio.image().height() * ds.width();
940 int dsth = ds.height(); 947 int dsth = ds.height();
941 int dstw = ds.width(); 948 int dstw = ds.width();
942 949
943 if (t1 > t2) { 950 if (t1 > t2) {
944 dsth = t2 / imgio.image().width(); 951 dsth = t2 / imgio.image().width();
945 } else { 952 } else {
946 dstw = t1 / imgio.image().height(); 953 dstw = t1 / imgio.image().height();
947 } 954 }
948 955
949 // 956 //
950 // Loader didn't scale for us. Do it manually. 957 // Loader didn't scale for us. Do it manually.
951 // 958 //
952 return imgio.image().smoothScale(dstw, dsth); 959 return imgio.image().smoothScale(dstw, dsth);
953 } 960 }
954 } 961 }
955 962
956 return imgio.image(); 963 return imgio.image();
957} 964}
958 965
959void LauncherView::setBackgroundType( BackgroundType t, const QString &val ) 966void LauncherView::setBackgroundType( BackgroundType t, const QString &val )
960{ 967{
961 if ( !bgCache ) { 968 if ( !bgCache ) {
962 bgCache = new QMap<QString,BgPixmap*>; 969 bgCache = new QMap<QString,BgPixmap*>;
963 qAddPostRoutine( cleanup_cache ); 970 qAddPostRoutine( cleanup_cache );
964 } 971 }
965 972
966 if ( bgCache->contains( bgName ) ) 973 if ( bgCache->contains( bgName ) )
967 (*bgCache)[bgName]->ref--; 974 (*bgCache)[bgName]->ref--;
968 bgName = ""; 975 bgName = "";
969 976
970 QPixmap bg; 977 QPixmap bg;
971 978
972 switch ( t ) { 979 switch ( t ) {
973 case Ruled: { 980 case Ruled: {
974 bgName = QString("Ruled_%1").arg(colorGroup().background().name()); // No tr 981 bgName = QString("Ruled_%1").arg(colorGroup().background().name()); // No tr
975 if ( bgCache->contains( bgName ) ) { 982 if ( bgCache->contains( bgName ) ) {
976 (*bgCache)[bgName]->ref++; 983 (*bgCache)[bgName]->ref++;
977 bg = (*bgCache)[bgName]->pm; 984 bg = (*bgCache)[bgName]->pm;
978 } else { 985 } else {
979 bg.resize( width(), 9 ); 986 bg.resize( width(), 9 );
980 QPainter painter( &bg ); 987 QPainter painter( &bg );
981 for ( int i = 0; i < 3; i++ ) { 988 for ( int i = 0; i < 3; i++ ) {
982 painter.setPen( white ); 989 painter.setPen( white );
983 painter.drawLine( 0, i*3, width()-1, i*3 ); 990 painter.drawLine( 0, i*3, width()-1, i*3 );
984 painter.drawLine( 0, i*3+1, width()-1, i*3+1 ); 991 painter.drawLine( 0, i*3+1, width()-1, i*3+1 );
985 painter.setPen( colorGroup().background().light(105) ); 992 painter.setPen( colorGroup().background().light(105) );
986 painter.drawLine( 0, i*3+2, width()-1, i*3+2 ); 993 painter.drawLine( 0, i*3+2, width()-1, i*3+2 );
987 } 994 }
988 painter.end(); 995 painter.end();
989 bgCache->insert( bgName, new BgPixmap(bg) ); 996 bgCache->insert( bgName, new BgPixmap(bg) );
990 } 997 }
991 break; 998 break;
992 } 999 }
993 1000
994 case Image: 1001 case Image:
995 if (!val.isEmpty()) { 1002 if (!val.isEmpty()) {
996 bgName = val; 1003 bgName = val;
997 if ( bgCache->contains( bgName ) ) { 1004 if ( bgCache->contains( bgName ) ) {
998 (*bgCache)[bgName]->ref++; 1005 (*bgCache)[bgName]->ref++;
999 bg = (*bgCache)[bgName]->pm; 1006 bg = (*bgCache)[bgName]->pm;
1000 } else { 1007 } else {
1001 QString imgFile = bgName; 1008 QString imgFile = bgName;
1002 bool tile = FALSE; 1009 bool tile = FALSE;
1003 if ( imgFile[0]!='/' || !QFile::exists(imgFile) ) { 1010 if ( imgFile[0]!='/' || !QFile::exists(imgFile) ) {
1004 imgFile = Resource::findPixmap( imgFile ); 1011 imgFile = OResource::findPixmap( imgFile );
1005 tile = TRUE; 1012 tile = TRUE;
1006 } 1013 }
1007 QImage img = loadBackgroundImage(imgFile); 1014 QImage img = loadBackgroundImage(imgFile);
1008 1015
1009 1016
1010 if ( img.depth() == 1 ) 1017 if ( img.depth() == 1 )
1011 img = img.convertDepth(8); 1018 img = img.convertDepth(8);
1012 img.setAlphaBuffer(FALSE); 1019 img.setAlphaBuffer(FALSE);
1013 bg.convertFromImage(img); 1020 bg.convertFromImage(img);
1014 bgCache->insert( bgName, new BgPixmap(bg) ); 1021 bgCache->insert( bgName, new BgPixmap(bg) );
1015 } 1022 }
1016 } 1023 }
1017 break; 1024 break;
1018 1025
1019 case SolidColor: 1026 case SolidColor:
1020 default: 1027 default:
1021 break; 1028 break;
1022 } 1029 }
1023 1030
1024 const QObjectList *list = queryList( "QWidget", 0, FALSE ); 1031 const QObjectList *list = queryList( "QWidget", 0, FALSE );
1025 QObject *obj; 1032 QObject *obj;
1026 for ( QObjectListIt it( *list ); (obj=it.current()); ++it ) { 1033 for ( QObjectListIt it( *list ); (obj=it.current()); ++it ) {
1027 if ( obj->isWidgetType() ) { 1034 if ( obj->isWidgetType() ) {
1028 QWidget *w = (QWidget*)obj; 1035 QWidget *w = (QWidget*)obj;
1029 w->setBackgroundPixmap( bg ); 1036 w->setBackgroundPixmap( bg );
1030 if ( bgName.isEmpty() ) { 1037 if ( bgName.isEmpty() ) {
1031 // Solid Color 1038 // Solid Color
1032 if ( val.isEmpty() ) 1039 if ( val.isEmpty() )
1033 w->setBackgroundColor( colorGroup().base() ); 1040 w->setBackgroundColor( colorGroup().base() );
1034 else 1041 else
1035 w->setBackgroundColor( val ); 1042 w->setBackgroundColor( val );
1036 } else { 1043 } else {
1037 // Ruled or Image pixmap 1044 // Ruled or Image pixmap
1038 w->setBackgroundOrigin( ParentOrigin ); 1045 w->setBackgroundOrigin( ParentOrigin );
1039 } 1046 }
1040 } 1047 }
1041 } 1048 }
1042 delete list; 1049 delete list;
1043 1050
1044 bgType = t; 1051 bgType = t;
1045 icons->viewport()->update(); 1052 icons->viewport()->update();
1046 1053
1047 QTimer::singleShot( 1000, this, SLOT(flushBgCache()) ); 1054 QTimer::singleShot( 1000, this, SLOT(flushBgCache()) );
1048} 1055}
1049 1056
1050void LauncherView::setColNumber( int num ) 1057void LauncherView::setColNumber( int num )
1051{ 1058{
1052 icons->setColNumber( num ); 1059 icons->setColNumber( num );
1053} 1060}
1054 1061
1055void LauncherIconView::setColNumber( int num ) 1062void LauncherIconView::setColNumber( int num )
1056{ 1063{
1057 numColumns = num; 1064 numColumns = num;
1058 calculateGrid( Bottom ); 1065 calculateGrid( Bottom );
1059} 1066}
1060 1067
1061void LauncherView::setTextColor( const QColor &tc ) 1068void LauncherView::setTextColor( const QColor &tc )
1062{ 1069{
1063 textCol = tc; 1070 textCol = tc;
1064 QColorGroup cg = icons->colorGroup(); 1071 QColorGroup cg = icons->colorGroup();
1065 cg.setColor( QColorGroup::Text, tc ); 1072 cg.setColor( QColorGroup::Text, tc );
1066 icons->setPalette( QPalette(cg,cg,cg) ); 1073 icons->setPalette( QPalette(cg,cg,cg) );
1067 icons->viewport()->update(); 1074 icons->viewport()->update();
1068} 1075}
1069 1076
1070void LauncherView::setViewFont( const QFont &f ) 1077void LauncherView::setViewFont( const QFont &f )
1071{ 1078{
1072 icons->setFont( f ); 1079 icons->setFont( f );
1073 icons->hideOrShowItems( FALSE ); 1080 icons->hideOrShowItems( FALSE );
1074} 1081}
1075 1082
1076void LauncherView::clearViewFont() 1083void LauncherView::clearViewFont()
1077{ 1084{
1078 icons->unsetFont(); 1085 icons->unsetFont();
1079 icons->hideOrShowItems( FALSE ); 1086 icons->hideOrShowItems( FALSE );
1080} 1087}
1081 1088
1082void LauncherView::resizeEvent(QResizeEvent *e) 1089void LauncherView::resizeEvent(QResizeEvent *e)
1083{ 1090{
1084// qDebug("LauncherView resize event"); 1091// qDebug("LauncherView resize event");
1085 QVBox::resizeEvent( e ); 1092 QVBox::resizeEvent( e );
1086// commented out for launcherview and qt/e 2.3.8 problems, probably needs real fixing somewhere... 1093// commented out for launcherview and qt/e 2.3.8 problems, probably needs real fixing somewhere...
1087// if ( e->size().width() != e->oldSize().width() ) 1094// if ( e->size().width() != e->oldSize().width() )
1088 sort(); 1095 sort();
1089} 1096}
1090 1097
1091void LauncherView::selectionChanged() 1098void LauncherView::selectionChanged()
1092{ 1099{
1093 QIconViewItem* item = icons->currentItem(); 1100 QIconViewItem* item = icons->currentItem();
1094 if ( item && item->isSelected() ) { 1101 if ( item && item->isSelected() ) {
1095 AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); 1102 AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
1096 if ( icons->inKeyEvent() ) // not for mouse press 1103 if ( icons->inKeyEvent() ) // not for mouse press
1097 emit clicked( appLnk ); 1104 emit clicked( appLnk );
1098 item->setSelected(FALSE); 1105 item->setSelected(FALSE);
1099 } 1106 }
1100} 1107}
1101 1108
1102void LauncherView::returnPressed( QIconViewItem *item ) 1109void LauncherView::returnPressed( QIconViewItem *item )
1103{ 1110{
1104 if ( item ) { 1111 if ( item ) {
1105 AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); 1112 AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
1106 emit clicked( appLnk ); 1113 emit clicked( appLnk );
1107 } 1114 }
1108} 1115}
1109 1116
1110void LauncherView::itemClicked( int btn, QIconViewItem *item ) 1117void LauncherView::itemClicked( int btn, QIconViewItem *item )
1111{ 1118{
1112 if ( item ) { 1119 if ( item ) {
1113 AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); 1120 AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
1114 if ( btn == LeftButton ) { 1121 if ( btn == LeftButton ) {
1115 // Make sure it's the item we execute that gets highlighted 1122 // Make sure it's the item we execute that gets highlighted
1116 icons->setCurrentItem( item ); 1123 icons->setCurrentItem( item );
1117 emit clicked( appLnk ); 1124 emit clicked( appLnk );
1118 } 1125 }
1119 item->setSelected(FALSE); 1126 item->setSelected(FALSE);
1120 } 1127 }
1121} 1128}
1122 1129
1123void LauncherView::itemPressed( int btn, QIconViewItem *item ) 1130void LauncherView::itemPressed( int btn, QIconViewItem *item )
1124{ 1131{
1125 if ( item ) { 1132 if ( item ) {
1126 AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); 1133 AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
1127 if ( btn == RightButton ) 1134 if ( btn == RightButton )
1128 emit rightPressed( appLnk ); 1135 emit rightPressed( appLnk );
1129 else if ( btn == ShiftButton ) 1136 else if ( btn == ShiftButton )
1130 emit rightPressed( appLnk ); 1137 emit rightPressed( appLnk );
1131 item->setSelected(FALSE); 1138 item->setSelected(FALSE);
1132 } 1139 }
1133} 1140}
1134 1141
1135void LauncherView::removeAllItems() 1142void LauncherView::removeAllItems()
1136{ 1143{
1137 odebug << "LauncherView::removeAllItems()" << oendl; 1144 odebug << "LauncherView::removeAllItems()" << oendl;
1138 if (LauncherIconView::sm_EyeCache) LauncherIconView::sm_EyeCache->clear(); 1145 if (LauncherIconView::sm_EyeCache) LauncherIconView::sm_EyeCache->clear();
1139 icons->clear(); 1146 icons->clear();
1140} 1147}
1141 1148
1142bool LauncherView::removeLink(const QString& linkfile) 1149bool LauncherView::removeLink(const QString& linkfile)
1143{ 1150{
1144 return icons->removeLink(linkfile); 1151 return icons->removeLink(linkfile);
1145} 1152}
1146 1153
1147void LauncherView::addItem(AppLnk* app, bool resort) 1154void LauncherView::addItem(AppLnk* app, bool resort)
1148{ 1155{
1149 icons->addItem(app,resort); 1156 icons->addItem(app,resort);
1150} 1157}
1151 1158
1152void LauncherView::changeItem(const AppLnk&old,AppLnk*nlink) 1159void LauncherView::changeItem(const AppLnk&old,AppLnk*nlink)
1153{ 1160{
1154 icons->changeItem(old,nlink); 1161 icons->changeItem(old,nlink);
1155} 1162}
1156 1163
1157void LauncherView::setSortEnabled( bool v ) 1164void LauncherView::setSortEnabled( bool v )
1158{ 1165{
1159 icons->setSorting( v ); 1166 icons->setSorting( v );
1160 if ( v ) 1167 if ( v )
1161 sort(); 1168 sort();
1162} 1169}
1163 1170
1164void LauncherView::setUpdatesEnabled( bool u ) 1171void LauncherView::setUpdatesEnabled( bool u )
1165{ 1172{
1166 icons->setUpdatesEnabled( u ); 1173 icons->setUpdatesEnabled( u );
1167} 1174}
1168 1175
1169void LauncherView::sort() 1176void LauncherView::sort()
1170{ 1177{
1171 icons->sort(); 1178 icons->sort();
1172} 1179}
1173 1180
1174void LauncherView::paletteChange( const QPalette &p ) 1181void LauncherView::paletteChange( const QPalette &p )
1175{ 1182{
1176 icons->unsetPalette(); 1183 icons->unsetPalette();
1177 QVBox::paletteChange( p ); 1184 QVBox::paletteChange( p );
1178 if ( bgType == Ruled ) 1185 if ( bgType == Ruled )
1179 setBackgroundType( Ruled, QString::null ); 1186 setBackgroundType( Ruled, QString::null );
1180 QColorGroup cg = icons->colorGroup(); 1187 QColorGroup cg = icons->colorGroup();
1181 cg.setColor( QColorGroup::Text, textCol ); 1188 cg.setColor( QColorGroup::Text, textCol );
1182 icons->setPalette( QPalette(cg,cg,cg) ); 1189 icons->setPalette( QPalette(cg,cg,cg) );
1183} 1190}
1184 1191
1185void LauncherView::fontChanged(const QFont&) 1192void LauncherView::fontChanged(const QFont&)
1186{ 1193{
1187 odebug << "LauncherView::fontChanged()" << oendl; 1194 odebug << "LauncherView::fontChanged()" << oendl;
1188 icons->hideOrShowItems( FALSE ); 1195 icons->hideOrShowItems( FALSE );
1189} 1196}
1190 1197
1191void LauncherView::relayout(void) 1198void LauncherView::relayout(void)
1192{ 1199{
1193 icons->hideOrShowItems(FALSE); 1200 icons->hideOrShowItems(FALSE);
1194} 1201}
1195 1202
1196void LauncherView::flushBgCache() 1203void LauncherView::flushBgCache()
1197{ 1204{
1198 if ( !bgCache ) 1205 if ( !bgCache )
1199 return; 1206 return;
1200 // remove unreferenced backgrounds. 1207 // remove unreferenced backgrounds.
1201 QMap<QString,BgPixmap*>::Iterator it = bgCache->begin(); 1208 QMap<QString,BgPixmap*>::Iterator it = bgCache->begin();
1202 while ( it != bgCache->end() ) { 1209 while ( it != bgCache->end() ) {
1203 QMap<QString,BgPixmap*>::Iterator curr = it; 1210 QMap<QString,BgPixmap*>::Iterator curr = it;
1204 ++it; 1211 ++it;
1205 if ( (*curr)->ref == 0 ) { 1212 if ( (*curr)->ref == 0 ) {
1206 delete (*curr); 1213 delete (*curr);
1207 bgCache->remove( curr ); 1214 bgCache->remove( curr );
1208 } 1215 }
1209 } 1216 }
1210} 1217}
1211 1218
1212/* 1219/*
1213 * Launcherthumbnail handling for image files 1220 * Launcherthumbnail handling for image files
1214 */ 1221 */
1215 1222
1216/* special image handling - based on opie eye */ 1223/* special image handling - based on opie eye */
1217QDataStream &operator>>( QDataStream& s, PixmapInfo& inf ) { 1224QDataStream &operator>>( QDataStream& s, PixmapInfo& inf ) {
1218 s >> inf.file >> inf.pixmap >> inf.width >> inf.height; 1225 s >> inf.file >> inf.pixmap >> inf.width >> inf.height;
1219 return s; 1226 return s;
1220} 1227}
1221 1228
1222QDataStream &operator<<( QDataStream& s, const PixmapInfo& inf) { 1229QDataStream &operator<<( QDataStream& s, const PixmapInfo& inf) {
1223 return s << inf.file << inf.width << inf.height; 1230 return s << inf.file << inf.width << inf.height;
1224} 1231}
1225 1232
1226LauncherThumbReceiver::LauncherThumbReceiver() 1233LauncherThumbReceiver::LauncherThumbReceiver()
1227 :QObject(),requestTimer(this) 1234 :QObject(),requestTimer(this)
1228{ 1235{
1229 1236
1230 connect(&requestTimer,SIGNAL(timeout()),SLOT(sendRequest())); 1237 connect(&requestTimer,SIGNAL(timeout()),SLOT(sendRequest()));
1231 QCopChannel * chan = new QCopChannel( "QPE/opie-eye",this ); 1238 QCopChannel * chan = new QCopChannel( "QPE/opie-eye",this );
1232 connect(chan, SIGNAL(received(const QCString&,const QByteArray&)), 1239 connect(chan, SIGNAL(received(const QCString&,const QByteArray&)),
1233 this, SLOT(recieve(const QCString&,const QByteArray&)) ); 1240 this, SLOT(recieve(const QCString&,const QByteArray&)) );
1234 1241
1235 { 1242 {
1236 QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); 1243 QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" );
1237 } 1244 }
1238} 1245}
1239 1246
1240LauncherThumbReceiver::~LauncherThumbReceiver() 1247LauncherThumbReceiver::~LauncherThumbReceiver()
1241{ 1248{
1242 { 1249 {
1243 QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); 1250 QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" );
1244 } 1251 }
1245} 1252}
1246 1253
1247void LauncherThumbReceiver::recieve( const QCString&str, const QByteArray&at ) 1254void LauncherThumbReceiver::recieve( const QCString&str, const QByteArray&at )
1248{ 1255{
1249 PixmapInfos pixinfos; 1256 PixmapInfos pixinfos;
1250 QDataStream stream( at, IO_ReadOnly ); 1257 QDataStream stream( at, IO_ReadOnly );
1251 1258
1252 /* we are just interested in thumbmails */ 1259 /* we are just interested in thumbmails */
1253 if ( str == "pixmapsHandled(PixmapList)" ) 1260 if ( str == "pixmapsHandled(PixmapList)" )
1254 stream >> pixinfos; 1261 stream >> pixinfos;
1255 1262
1256 for ( PixmapInfos::Iterator it = pixinfos.begin(); it != pixinfos.end(); ++it ) { 1263 for ( PixmapInfos::Iterator it = pixinfos.begin(); it != pixinfos.end(); ++it ) {
1257 emit sig_Thumbnail((*it).pixmap,(*it).file,(*it).width); 1264 emit sig_Thumbnail((*it).pixmap,(*it).file,(*it).width);
1258 } 1265 }
1259} 1266}
1260 1267
1261void LauncherThumbReceiver::requestThumb(const QString&file,int width,int height) 1268void LauncherThumbReceiver::requestThumb(const QString&file,int width,int height)
1262{ 1269{
1263 PixmapInfo rItem; 1270 PixmapInfo rItem;
1264 rItem.file = file; 1271 rItem.file = file;
1265 rItem.width = width; 1272 rItem.width = width;
1266 rItem.height = height; 1273 rItem.height = height;
1267 m_inThumbNail.append(rItem); 1274 m_inThumbNail.append(rItem);
1268 if (!requestTimer.isActive()) { 1275 if (!requestTimer.isActive()) {
1269 requestTimer.start(100,true); 1276 requestTimer.start(100,true);
1270 } 1277 }
1271} 1278}
1272 1279
1273void LauncherThumbReceiver::sendRequest() 1280void LauncherThumbReceiver::sendRequest()
1274{ 1281{
1275 if (m_inThumbNail.count()>0) { 1282 if (m_inThumbNail.count()>0) {
1276 QCopEnvelope env("QPE/opie-eye_slave", "pixmapInfos(PixmapInfos)" ); 1283 QCopEnvelope env("QPE/opie-eye_slave", "pixmapInfos(PixmapInfos)" );
1277 env << m_inThumbNail; 1284 env << m_inThumbNail;
1278 m_inThumbNail.clear(); 1285 m_inThumbNail.clear();
1279 } 1286 }
1280} 1287}
diff --git a/core/launcher/startmenu.cpp b/core/launcher/startmenu.cpp
index ce7840e..24a9d7e 100644
--- a/core/launcher/startmenu.cpp
+++ b/core/launcher/startmenu.cpp
@@ -1,401 +1,396 @@
1/********************************************************************** 1/*
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2                 This file is part of the Opie Project
3** 3 =. (C) 2000-2002 Trolltech AS
4** This file is part of the Qtopia Environment. 4 .=l. (C) 2002-2005 The Opie Team <opie-devel@handhelds.org>
5** 5           .>+-=
6** This file may be distributed and/or modified under the terms of the 6 _;:,     .>    :=|. This program is free software; you can
7** GNU General Public License version 2 as published by the Free Software 7.> <`_,   >  .   <= redistribute it and/or modify it under
8** Foundation and appearing in the file LICENSE.GPL included in the 8 :`=1 )Y*s>-.--   : the terms of the GNU Library General Public
9** packaging of this file. 9.="- .-=="i,     .._ License as published by the Free Software
10** 10 - .   .-<_>     .<> Foundation; version 2 of the License.
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11     ._= =}       :
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12    .%`+i>       _;_.
13** 13    .i_,=:_.      -<s. This program is distributed in the hope that
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15** 15 : ..    .:,     . . . without even the implied warranty of
16** Contact info@trolltech.com if any conditions of this licensing are 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17** not clear to you. 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
18** 18..}^=.=       =       ; Library General Public License for more
19**********************************************************************/ 19++=   -.     .`     .: details.
20 20 :     =  ...= . :.=-
21 -.   .:....=;==+<; You should have received a copy of the GNU
22  -_. . .   )=.  = Library General Public License along with
23    --        :-=` this library; see the file COPYING.LIB.
24 If not, write to the Free Software Foundation,
25 Inc., 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA.
27*/
21// TODO. During startup 28// TODO. During startup
22// Launcher::typeAdded 29// Launcher::typeAdded
23// is called for each new tab and calls then each time the refresh of startmenu 30// is called for each new tab and calls then each time the refresh of startmenu
24// suboptimal 31// suboptimal
25 32
26#define INCLUDE_MENUITEM_DEF 33#define INCLUDE_MENUITEM_DEF
27 34
28#include "startmenu.h" 35#include "startmenu.h"
29 36
37/* OPIE */
38#include <opie2/oresource.h>
39using namespace Opie::Core;
30#include <qtopia/qpeapplication.h> 40#include <qtopia/qpeapplication.h>
31#include <qtopia/config.h> 41#include <qtopia/config.h>
32#include <qtopia/resource.h>
33#include <qtopia/mimetype.h> 42#include <qtopia/mimetype.h>
34#include <qtopia/qlibrary.h> 43#include <qtopia/qlibrary.h>
35 44
36//#include <qpainter.h>
37
38//#include <stdlib.h>
39
40
41#define APPLNK_ID_OFFSET 250 45#define APPLNK_ID_OFFSET 250
42#define NO_ID -1 46#define NO_ID -1
43 47
44 48
45void StartPopupMenu::keyPressEvent( QKeyEvent *e ) 49void StartPopupMenu::keyPressEvent( QKeyEvent *e )
46{ 50{
47 if ( e->key() == Key_F33 || e->key() == Key_Space ) { 51 if ( e->key() == Key_F33 || e->key() == Key_Space ) {
48 // "OK" button, little hacky 52 // "OK" button, little hacky
49 QKeyEvent ke(QEvent::KeyPress, Key_Enter, 13, 0); 53 QKeyEvent ke(QEvent::KeyPress, Key_Enter, 13, 0);
50 QPopupMenu::keyPressEvent( &ke ); 54 QPopupMenu::keyPressEvent( &ke );
51 } else { 55 } else {
52 QPopupMenu::keyPressEvent( e ); 56 QPopupMenu::keyPressEvent( e );
53 } 57 }
54} 58}
55 59
56//--------------------------------------------------------------------------- 60//---------------------------------------------------------------------------
57 61
58StartMenu::StartMenu(QWidget *parent) : QLabel( parent ) 62StartMenu::StartMenu(QWidget *parent) : QLabel( parent )
59{ 63{
60 startButtonPixmap = "go"; // No tr 64 startButtonPixmap = "go"; // No tr
61 65
62 int sz = AppLnk::smallIconSize()+3; 66 int sz = AppLnk::smallIconSize()+3;
63 QPixmap pm; 67 QPixmap pm;
64 pm.convertFromImage(Resource::loadImage( startButtonPixmap).smoothScale( sz,sz) ); 68 pm.convertFromImage(OResource::loadImage( startButtonPixmap, OResource::NoScale ).smoothScale( sz,sz) );
65 setPixmap(pm); 69 setPixmap(pm);
66 setFocusPolicy( NoFocus ); 70 setFocusPolicy( NoFocus );
67 71
68 useWidePopupMenu = true; 72 useWidePopupMenu = true;
69 launchMenu = 0; 73 launchMenu = 0;
70 currentItem = 0; 74 currentItem = 0;
71 refreshMenu(); 75 refreshMenu();
72} 76}
73 77
74 78
75void StartMenu::mousePressEvent( QMouseEvent * ) 79void StartMenu::mousePressEvent( QMouseEvent * )
76{ 80{
77 launch(); 81 launch();
78} 82}
79 83
80 84
81StartMenu::~StartMenu() 85StartMenu::~StartMenu()
82{ 86{
83 clearApplets(); 87 clearApplets();
84} 88}
85 89
86void StartMenu::createMenu() 90void StartMenu::createMenu()
87{ 91{
88 clearApplets(); 92 clearApplets();
89 delete launchMenu; 93 delete launchMenu;
90 94
91 launchMenu = new StartPopupMenu( this ); 95 launchMenu = new StartPopupMenu( this );
92 loadMenu( launchMenu ); 96 loadMenu( launchMenu );
93 loadApplets(); 97 loadApplets();
94 98
95 bool result = currentItem || menuApplets.count(); 99 bool result = currentItem || menuApplets.count();
96 if ( result ) 100 if ( result )
97 connect( launchMenu, SIGNAL(activated(int)), SLOT(itemSelected(int)) ); 101 connect( launchMenu, SIGNAL(activated(int)), SLOT(itemSelected(int)) );
98} 102}
99 103
100void StartMenu::refreshMenu() 104void StartMenu::refreshMenu()
101{ 105{
102 Config cfg( "StartMenu" ); 106 Config cfg( "StartMenu" );
103 cfg.setGroup( "Menu" ); 107 cfg.setGroup( "Menu" );
104 bool ltabs = cfg.readBoolEntry( "LauncherTabs", TRUE ); 108 bool ltabs = cfg.readBoolEntry( "LauncherTabs", TRUE );
105 bool lot = cfg.readBoolEntry( "LauncherOther", TRUE ); 109 bool lot = cfg.readBoolEntry( "LauncherOther", TRUE );
106 useWidePopupMenu = cfg.readBoolEntry( "LauncherSubPopup", TRUE ); 110 useWidePopupMenu = cfg.readBoolEntry( "LauncherSubPopup", TRUE );
107 111
108 if ( launchMenu && !(ltabs || lot) ) return; // nothing to do 112 if ( launchMenu && !(ltabs || lot) ) return; // nothing to do
109 113
110 createMenu(); 114 createMenu();
111} 115}
112 116
113void StartMenu::itemSelected( int id ) 117void StartMenu::itemSelected( int id )
114{ 118{
115 if ( id == NO_ID ) return; 119 if ( id == NO_ID ) return;
116 120
117 if ( id < 0 ) { 121 if ( id < 0 ) {
118 MenuApplet *applet = menuApplets.find( id ); 122 MenuApplet *applet = menuApplets.find( id );
119 if ( applet ) { 123 if ( applet ) {
120 applet->iface->activated(); 124 applet->iface->activated();
121 } 125 }
122 } else if ( id >= APPLNK_ID_OFFSET ) { 126 } else if ( id >= APPLNK_ID_OFFSET ) {
123 AppLnk * appLnk = appLnks.find( id ); 127 AppLnk * appLnk = appLnks.find( id );
124 if ( appLnk ) { 128 if ( appLnk ) {
125 appLnk->execute(); 129 appLnk->execute();
126 } 130 }
127 } else { 131 } else {
128 QString *tabName = tabNames.find( id ); 132 QString *tabName = tabNames.find( id );
129 if ( tabName ) { 133 if ( tabName ) {
130 emit tabSelected( *tabName ); 134 emit tabSelected( *tabName );
131 } 135 }
132 } 136 }
133} 137}
134 138
135void StartMenu::createAppEntry( QPopupMenu *menu, QDir dir, QString file ) 139void StartMenu::createAppEntry( QPopupMenu *menu, QDir dir, QString file )
136{ 140{
137 if ( file.right(8) == ".desktop" ) { 141 if ( file.right(8) == ".desktop" ) {
138 AppLnk* applnk = new AppLnk( dir.path() + "/" + file ); 142 AppLnk* applnk = new AppLnk( dir.path() + "/" + file );
139 if ( !applnk->isValid() ) { 143 if ( !applnk->isValid() ) {
140 delete applnk; 144 delete applnk;
141 return; 145 return;
142 } 146 }
143 147
144 if ( applnk->type() == "Separator" ) { // No tr 148 if ( applnk->type() == "Separator" ) { // No tr
145 menu->insertSeparator(); 149 menu->insertSeparator();
146 delete applnk; 150 delete applnk;
147 } else { 151 } else {
148 QPixmap test; 152 QPixmap pixmap = OResource::loadPixmap( applnk->icon(), OResource::SmallIcon );
149 QImage img = Resource::loadImage( applnk->icon() );
150 if(!img.isNull() )
151 test.convertFromImage(
152 img.smoothScale(
153 AppLnk::smallIconSize(), AppLnk::smallIconSize() ), 0 );
154
155 // Insert items ordered lexically 153 // Insert items ordered lexically
156 int current, left = 0, right = currentItem; 154 int current, left = 0, right = currentItem;
157 while( left != right ) { 155 while( left != right ) {
158 current = ( left + right ) / 2; 156 current = ( left + right ) / 2;
159 if ( menu->text(menu->idAt( ( current ) ) ) < applnk->name() ) 157 if ( menu->text(menu->idAt( ( current ) ) ) < applnk->name() )
160 left = ++current; 158 left = ++current;
161 else 159 else
162 right = current; 160 right = current;
163 } 161 }
164 162
165 menu->insertItem( test, applnk->name(), 163 menu->insertItem( pixmap, applnk->name(),
166 currentItem + APPLNK_ID_OFFSET, current ); 164 currentItem + APPLNK_ID_OFFSET, current );
167 appLnks.insert( currentItem + APPLNK_ID_OFFSET, applnk ); 165 appLnks.insert( currentItem + APPLNK_ID_OFFSET, applnk );
168 currentItem++; 166 currentItem++;
169 } 167 }
170 } 168 }
171 169
172} 170}
173 171
174void StartMenu::createDirEntry( QPopupMenu *menu, QDir dir, QString file, bool lot ) 172void StartMenu::createDirEntry( QPopupMenu *menu, QDir dir, QString file, bool lot )
175{ 173{
176 // do some sanity checks and collect information 174 // do some sanity checks and collect information
177 175
178 if ( file == "." || file == ".." ) return; 176 if ( file == "." || file == ".." ) return;
179 177
180 Config cfg( dir.path() + "/" + file + "/.directory", Config::File ); 178 Config cfg( dir.path() + "/" + file + "/.directory", Config::File );
181 if ( !cfg.isValid() ) return; 179 if ( !cfg.isValid() ) return;
182 180
183 QString name = cfg.readEntry( "Name" ); 181 QString name = cfg.readEntry( "Name" );
184 QString icon = cfg.readEntry( "Icon" ); 182 QString icon = cfg.readEntry( "Icon" );
185 if ( !name || !icon ) return; 183 if ( !name || !icon ) return;
186 184
187 QDir subdir = QDir( dir ); 185 QDir subdir = QDir( dir );
188 subdir.cd( file ); 186 subdir.cd( file );
189 subdir.setFilter( QDir::Files ); 187 subdir.setFilter( QDir::Files );
190 subdir.setNameFilter( "*.desktop" ); 188 subdir.setNameFilter( "*.desktop" );
191 // we don' t show the menu if there are no entries 189 // we don' t show the menu if there are no entries
192 // perhaps one should check if there exist subsubdirs with entries... 190 // perhaps one should check if there exist subsubdirs with entries...
193 if ( subdir.entryList().isEmpty() ) return; 191 if ( subdir.entryList().isEmpty() ) return;
194 192
195 // checks were ok 193 // checks were ok
196 194
197 QPixmap test; 195 QPixmap pixmap = OResource::loadPixmap( icon, OResource::SmallIcon );
198 test.convertFromImage( Resource::loadImage( icon ).smoothScale(
199 AppLnk::smallIconSize(), AppLnk::smallIconSize() ), 0 );
200
201 if ( useWidePopupMenu ) { 196 if ( useWidePopupMenu ) {
202 // generate submenu 197 // generate submenu
203 QPopupMenu *submenu = new QPopupMenu( menu ); 198 QPopupMenu *submenu = new QPopupMenu( menu );
204 connect( submenu, SIGNAL(activated(int)), SLOT(itemSelected(int)) ); 199 connect( submenu, SIGNAL(activated(int)), SLOT(itemSelected(int)) );
205 menu->insertItem( test, name, submenu, NO_ID ); 200 menu->insertItem( pixmap, name, submenu, NO_ID );
206 201
207 // ltabs is true cause else we wouldn't stuck around.. 202 // ltabs is true cause else we wouldn't stuck around..
208 createMenuEntries( submenu, subdir, true, lot ); 203 createMenuEntries( submenu, subdir, true, lot );
209 } else { 204 } else {
210 // no submenus - just bring corresponding tab to front 205 // no submenus - just bring corresponding tab to front
211 menu->insertItem( test, name, currentItem ); 206 menu->insertItem( pixmap, name, currentItem );
212 tabNames.insert( currentItem, new QString( file ) ); 207 tabNames.insert( currentItem, new QString( file ) );
213 currentItem++; 208 currentItem++;
214 } 209 }
215} 210}
216 211
217void StartMenu::createMenuEntries( QPopupMenu *menu, QDir dir, bool ltabs, bool lot ) 212void StartMenu::createMenuEntries( QPopupMenu *menu, QDir dir, bool ltabs, bool lot )
218{ 213{
219 if ( lot ) { 214 if ( lot ) {
220 dir.setFilter( QDir::Files ); 215 dir.setFilter( QDir::Files );
221 dir.setNameFilter( "*.desktop" ); 216 dir.setNameFilter( "*.desktop" );
222 QStringList files = dir.entryList(); 217 QStringList files = dir.entryList();
223 files.sort(); 218 files.sort();
224 219
225 for ( QStringList::Iterator it = files.begin(); it != files.end(); it++ ) { 220 for ( QStringList::Iterator it = files.begin(); it != files.end(); it++ ) {
226 createAppEntry( menu, dir, *it ); 221 createAppEntry( menu, dir, *it );
227 } 222 }
228 } 223 }
229 if ( ltabs ) { 224 if ( ltabs ) {
230 dir.setNameFilter( "*" ); 225 dir.setNameFilter( "*" );
231 dir.setFilter( QDir::Dirs ); 226 dir.setFilter( QDir::Dirs );
232 QStringList dirs = dir.entryList(); 227 QStringList dirs = dir.entryList();
233 dirs.sort(); 228 dirs.sort();
234 229
235 for ( QStringList::Iterator it = dirs.begin(); it != dirs.end(); it++ ) { 230 for ( QStringList::Iterator it = dirs.begin(); it != dirs.end(); it++ ) {
236 createDirEntry( menu, dir, *it, lot ); 231 createDirEntry( menu, dir, *it, lot );
237 } 232 }
238 } 233 }
239} 234}
240 235
241bool StartMenu::loadMenu( QPopupMenu *menu ) 236bool StartMenu::loadMenu( QPopupMenu *menu )
242{ 237{
243 Config cfg("StartMenu"); 238 Config cfg("StartMenu");
244 cfg.setGroup("Menu"); 239 cfg.setGroup("Menu");
245 240
246 bool ltabs = cfg.readBoolEntry("LauncherTabs", TRUE); 241 bool ltabs = cfg.readBoolEntry("LauncherTabs", TRUE);
247 bool lot = cfg.readBoolEntry("LauncherOther", TRUE); 242 bool lot = cfg.readBoolEntry("LauncherOther", TRUE);
248 useWidePopupMenu = cfg.readBoolEntry( "LauncherSubPopup", TRUE ); 243 useWidePopupMenu = cfg.readBoolEntry( "LauncherSubPopup", TRUE );
249 bool sepfirst = !ltabs && !lot; 244 bool sepfirst = !ltabs && !lot;
250 245
251 currentItem = 0; 246 currentItem = 0;
252 launchMenu->clear(); 247 launchMenu->clear();
253 248
254 appLnks.setAutoDelete( true ); 249 appLnks.setAutoDelete( true );
255 tabNames.setAutoDelete( true ); 250 tabNames.setAutoDelete( true );
256 appLnks.clear(); 251 appLnks.clear();
257 tabNames.clear(); 252 tabNames.clear();
258 appLnks.setAutoDelete( false ); 253 appLnks.setAutoDelete( false );
259 tabNames.setAutoDelete( false ); 254 tabNames.setAutoDelete( false );
260 255
261 QDir dir( MimeType::appsFolderName(), QString::null, QDir::Name ); 256 QDir dir( MimeType::appsFolderName(), QString::null, QDir::Name );
262 createMenuEntries( menu, dir, ltabs, lot ); 257 createMenuEntries( menu, dir, ltabs, lot );
263 258
264 if ( !menu->count() ) sepfirst = TRUE; 259 if ( !menu->count() ) sepfirst = TRUE;
265 260
266 launchMenu->setName( sepfirst ? "accessories" : "accessories_need_sep" ); // No tr 261 launchMenu->setName( sepfirst ? "accessories" : "accessories_need_sep" ); // No tr
267 262
268 return currentItem; 263 return currentItem;
269} 264}
270 265
271 266
272void StartMenu::launch() 267void StartMenu::launch()
273{ 268{
274 int y = mapToGlobal( QPoint() ).y() - launchMenu->sizeHint().height(); 269 int y = mapToGlobal( QPoint() ).y() - launchMenu->sizeHint().height();
275 270
276 if ( launchMenu->isVisible() ) 271 if ( launchMenu->isVisible() )
277 launchMenu->hide(); 272 launchMenu->hide();
278 else 273 else
279 launchMenu->popup( QPoint( 1, y ) ); 274 launchMenu->popup( QPoint( 1, y ) );
280} 275}
281 276
282 277
283 278
284 279
285static int compareAppletPositions(const void *b, const void *a) 280static int compareAppletPositions(const void *b, const void *a)
286{ 281{
287 const MenuApplet* aa = *(const MenuApplet**)a; 282 const MenuApplet* aa = *(const MenuApplet**)a;
288 const MenuApplet* ab = *(const MenuApplet**)b; 283 const MenuApplet* ab = *(const MenuApplet**)b;
289 int d = aa->iface->position() - ab->iface->position(); 284 int d = aa->iface->position() - ab->iface->position();
290 if ( d ) return d; 285 if ( d ) return d;
291 return QString::compare(aa->library->library(),ab->library->library()); 286 return QString::compare(aa->library->library(),ab->library->library());
292} 287}
293 288
294void StartMenu::clearApplets() 289void StartMenu::clearApplets()
295{ 290{
296 if ( launchMenu ) 291 if ( launchMenu )
297 launchMenu-> hide(); 292 launchMenu-> hide();
298 293
299 for ( QIntDictIterator<MenuApplet> it( menuApplets ); it.current(); ++it ) { 294 for ( QIntDictIterator<MenuApplet> it( menuApplets ); it.current(); ++it ) {
300 MenuApplet *applet = it.current(); 295 MenuApplet *applet = it.current();
301 if ( launchMenu ) { 296 if ( launchMenu ) {
302 launchMenu->removeItem( applet-> id ); 297 launchMenu->removeItem( applet-> id );
303 delete applet->popup; 298 delete applet->popup;
304 } 299 }
305 300
306 applet->iface->release(); 301 applet->iface->release();
307 applet->library->unload(); 302 applet->library->unload();
308 delete applet-> library; 303 delete applet-> library;
309 } 304 }
310 menuApplets.clear(); 305 menuApplets.clear();
311} 306}
312 307
313 308
314 309
315 310
316void StartMenu::loadApplets() 311void StartMenu::loadApplets()
317{ 312{
318 Config cfg( "StartMenu" ); 313 Config cfg( "StartMenu" );
319 cfg.setGroup( "Applets" ); 314 cfg.setGroup( "Applets" );
320 315
321 // SafeMode causes too much problems, so we disable it for now -- 316 // SafeMode causes too much problems, so we disable it for now --
322 // maybe we should reenable it for OPIE 1.0 - sandman 26.09.02 317 // maybe we should reenable it for OPIE 1.0 - sandman 26.09.02
323 // removed in the remerge PluginManager could handle it 318 // removed in the remerge PluginManager could handle it
324 // we don't currently use it -zecke 319 // we don't currently use it -zecke
325 320
326 QStringList exclude = cfg.readListEntry( "ExcludeApplets", ',' ); 321 QStringList exclude = cfg.readListEntry( "ExcludeApplets", ',' );
327 322
328 QString lang = getenv( "LANG" ); 323 QString lang = getenv( "LANG" );
329 QString path = QPEApplication::qpeDir() + "plugins/applets"; 324 QString path = QPEApplication::qpeDir() + "plugins/applets";
330 QDir dir( path, "lib*.so" ); 325 QDir dir( path, "lib*.so" );
331 QStringList list = dir.entryList(); 326 QStringList list = dir.entryList();
332 QStringList::Iterator it; 327 QStringList::Iterator it;
333 int napplets = 0; 328 int napplets = 0;
334 MenuApplet* *xapplets = new MenuApplet*[list.count()]; 329 MenuApplet* *xapplets = new MenuApplet*[list.count()];
335 for ( it = list.begin(); it != list.end(); ++it ) { 330 for ( it = list.begin(); it != list.end(); ++it ) {
336 if ( exclude.find( *it ) != exclude.end() ) 331 if ( exclude.find( *it ) != exclude.end() )
337 continue; 332 continue;
338 MenuAppletInterface *iface = 0; 333 MenuAppletInterface *iface = 0;
339 QLibrary *lib = new QLibrary( path + "/" + *it ); 334 QLibrary *lib = new QLibrary( path + "/" + *it );
340 if (( lib->queryInterface( IID_MenuApplet, (QUnknownInterface**)&iface ) == QS_OK ) && iface ) { 335 if (( lib->queryInterface( IID_MenuApplet, (QUnknownInterface**)&iface ) == QS_OK ) && iface ) {
341 MenuApplet *applet = new MenuApplet; 336 MenuApplet *applet = new MenuApplet;
342 xapplets[napplets++] = applet; 337 xapplets[napplets++] = applet;
343 applet->library = lib; 338 applet->library = lib;
344 applet->iface = iface; 339 applet->iface = iface;
345 340
346 QTranslator *trans = new QTranslator(qApp); 341 QTranslator *trans = new QTranslator(qApp);
347 QString type = (*it).left( (*it).find(".") ); 342 QString type = (*it).left( (*it).find(".") );
348 QString tfn = QPEApplication::qpeDir()+"i18n/"+lang+"/"+type+".qm"; 343 QString tfn = QPEApplication::qpeDir()+"i18n/"+lang+"/"+type+".qm";
349 if ( trans->load( tfn )) 344 if ( trans->load( tfn ))
350 qApp->installTranslator( trans ); 345 qApp->installTranslator( trans );
351 else 346 else
352 delete trans; 347 delete trans;
353 } else { 348 } else {
354 exclude += *it; 349 exclude += *it;
355 delete lib; 350 delete lib;
356 } 351 }
357 } 352 }
358 cfg.writeEntry( "ExcludeApplets", exclude, ',' ); 353 cfg.writeEntry( "ExcludeApplets", exclude, ',' );
359 qsort(xapplets, napplets, sizeof(menuApplets[0]), compareAppletPositions); 354 qsort(xapplets, napplets, sizeof(menuApplets[0]), compareAppletPositions);
360 355
361 356
362 while ( napplets-- ) { 357 while ( napplets-- ) {
363 MenuApplet *applet = xapplets[napplets]; 358 MenuApplet *applet = xapplets[napplets];
364 applet->popup = applet->iface->popup( this ); 359 applet->popup = applet->iface->popup( this );
365 360
366 // menuApplets got an id < -1 361 // menuApplets got an id < -1
367 menuApplets.insert( -( currentItem + 2 ), new MenuApplet( *applet ) ); 362 menuApplets.insert( -( currentItem + 2 ), new MenuApplet( *applet ) );
368 currentItem++; 363 currentItem++;
369 } 364 }
370 delete [] xapplets; 365 delete [] xapplets;
371 366
372 addApplets( launchMenu ); 367 addApplets( launchMenu );
373} 368}
374 369
375 370
376/* 371/*
377 * Launcher calls loadMenu too often fix that 372 * Launcher calls loadMenu too often fix that
378 */ 373 */
379void StartMenu::addApplets(QPopupMenu* pop) { 374void StartMenu::addApplets(QPopupMenu* pop) {
380 QIntDict<MenuApplet> dict; 375 QIntDict<MenuApplet> dict;
381 if( pop-> count ( )) 376 if( pop-> count ( ))
382 pop-> insertSeparator ( ); 377 pop-> insertSeparator ( );
383 378
384 for ( QIntDictIterator<MenuApplet> it( menuApplets ); it.current(); ++it ) { 379 for ( QIntDictIterator<MenuApplet> it( menuApplets ); it.current(); ++it ) {
385 MenuApplet *applet = it.current(); 380 MenuApplet *applet = it.current();
386 if ( applet->popup ) 381 if ( applet->popup )
387 applet->id = pop->insertItem( applet->iface->icon(), 382 applet->id = pop->insertItem( applet->iface->icon(),
388 applet->iface->text(), applet->popup ); 383 applet->iface->text(), applet->popup );
389 else 384 else
390 applet->id = pop->insertItem( applet->iface->icon(), 385 applet->id = pop->insertItem( applet->iface->icon(),
391 applet->iface->text() ); 386 applet->iface->text() );
392 387
393 388
394 dict.insert( applet->id, new MenuApplet( *applet ) ); 389 dict.insert( applet->id, new MenuApplet( *applet ) );
395 } 390 }
396 /* need to update the key */ 391 /* need to update the key */
397 menuApplets.setAutoDelete( true ); 392 menuApplets.setAutoDelete( true );
398 menuApplets.clear(); 393 menuApplets.clear();
399 menuApplets.setAutoDelete( false ); 394 menuApplets.setAutoDelete( false );
400 menuApplets = dict; 395 menuApplets = dict;
401} 396}
diff --git a/core/launcher/syncdialog.cpp b/core/launcher/syncdialog.cpp
index 4a2b8ff..d90b2ea 100644
--- a/core/launcher/syncdialog.cpp
+++ b/core/launcher/syncdialog.cpp
@@ -1,183 +1,192 @@
1/********************************************************************** 1/*
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2                 This file is part of the Opie Project
3** 3 =. (C) 2000-2002 Trolltech AS
4** This file is part of the Qtopia Environment. 4 .=l. (C) 2002-2005 The Opie Team <opie-devel@handhelds.org>
5** 5           .>+-=
6** This file may be distributed and/or modified under the terms of the 6 _;:,     .>    :=|. This program is free software; you can
7** GNU General Public License version 2 as published by the Free Software 7.> <`_,   >  .   <= redistribute it and/or modify it under
8** Foundation and appearing in the file LICENSE.GPL included in the 8 :`=1 )Y*s>-.--   : the terms of the GNU Library General Public
9** packaging of this file. 9.="- .-=="i,     .._ License as published by the Free Software
10** 10 - .   .-<_>     .<> Foundation; version 2 of the License.
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11     ._= =}       :
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12    .%`+i>       _;_.
13** 13    .i_,=:_.      -<s. This program is distributed in the hope that
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15** 15 : ..    .:,     . . . without even the implied warranty of
16** Contact info@trolltech.com if any conditions of this licensing are 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17** not clear to you. 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
18** 18..}^=.=       =       ; Library General Public License for more
19**********************************************************************/ 19++=   -.     .`     .: details.
20 20 :     =  ...= . :.=-
21 -.   .:....=;==+<; You should have received a copy of the GNU
22  -_. . .   )=.  = Library General Public License along with
23    --        :-=` this library; see the file COPYING.LIB.
24 If not, write to the Free Software Foundation,
25 Inc., 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA.
27*/
21#include "syncdialog.h" 28#include "syncdialog.h"
22 29
23#include <qtopia/resource.h> 30/* OPIE */
31#include <opie2/oresource.h>
32using namespace Opie::Core;
24 33
34/* QT */
25#include <qpainter.h> 35#include <qpainter.h>
26#include <qapplication.h> 36#include <qapplication.h>
27#include <qpushbutton.h> 37#include <qpushbutton.h>
28#include <qfile.h> 38#include <qfile.h>
29 39
30
31SyncDialog::SyncDialog( QWidget *parent, const QString &w ) 40SyncDialog::SyncDialog( QWidget *parent, const QString &w )
32 : QDialog( parent, "SyncDialog", FALSE, WStyle_Tool | WStyle_Customize | 41 : QDialog( parent, "SyncDialog", FALSE, WStyle_Tool | WStyle_Customize |
33 WStyle_StaysOnTop ), what(w), nextPt(0), rev(FALSE), hideDot(TRUE) 42 WStyle_StaysOnTop ), what(w), nextPt(0), rev(FALSE), hideDot(TRUE)
34{ 43{
35 QFont f( font() ); 44 QFont f( font() );
36 f.setPointSize( 16 ); 45 f.setPointSize( 16 );
37 setFont(f); 46 setFont(f);
38 47
39 loadPath(); 48 loadPath();
40 49
41 QSize ds = qApp->desktop()->size(); 50 QSize ds = qApp->desktop()->size();
42 setGeometry( 0, 0, ds.width(), ds.height() ); 51 setGeometry( 0, 0, ds.width(), ds.height() );
43 img = Resource::loadImage( "SyncScreen" ); 52 img = OResource::loadImage( "SyncScreen", OResource::NoScale );
44 if ( img.width() > ds.width() || img.height() > ds.height() ) { 53 if ( img.width() > ds.width() || img.height() > ds.height() ) {
45 path = scalePath( path, ds.width(), img.width(), ds.height(), img.height() ); 54 path = scalePath( path, ds.width(), img.width(), ds.height(), img.height() );
46 img = img.smoothScale( ds.width(), ds.height() ); 55 img = img.smoothScale( ds.width(), ds.height() );
47 } 56 }
48 dot = Resource::loadImage( "syncdot" ); 57 dot = OResource::loadImage( "syncdot", OResource::NoScale );
49 setBackgroundColor( white ); 58 setBackgroundColor( white );
50 59
51 QPushButton *pb = new QPushButton( tr("Abort"), this, "CancelSync" ); 60 QPushButton *pb = new QPushButton( tr("Abort"), this, "CancelSync" );
52 QSize bs = pb->sizeHint(); 61 QSize bs = pb->sizeHint();
53 bs.rwidth() += 10; 62 bs.rwidth() += 10;
54 bs.rheight() += 5; 63 bs.rheight() += 5;
55 pb->setGeometry( (ds.width()-bs.width())/2, 4*ds.height()/5, 64 pb->setGeometry( (ds.width()-bs.width())/2, 4*ds.height()/5,
56 bs.width(), bs.height() ); 65 bs.width(), bs.height() );
57 connect( pb, SIGNAL(clicked()), this, SIGNAL(cancel()) ); 66 connect( pb, SIGNAL(clicked()), this, SIGNAL(cancel()) );
58 67
59 if ( path.count() >= 2 ) { 68 if ( path.count() >= 2 ) {
60 path = generatePath( path, 8 ); 69 path = generatePath( path, 8 );
61 startTimer( 200 ); 70 startTimer( 200 );
62 } 71 }
63} 72}
64 73
65void SyncDialog::paintEvent( QPaintEvent *pe ) 74void SyncDialog::paintEvent( QPaintEvent *pe )
66{ 75{
67 QPainter p(this ); 76 QPainter p(this );
68 p.setClipRect( pe->rect() ); 77 p.setClipRect( pe->rect() );
69 int ox = (width() - img.width())/2; 78 int ox = (width() - img.width())/2;
70 int oy = (height() - img.height())/2; 79 int oy = (height() - img.height())/2;
71 80
72 QRect ir = QRect(ox, oy, img.width(), img.height()) & pe->rect(); 81 QRect ir = QRect(ox, oy, img.width(), img.height()) & pe->rect();
73 82
74 if ( ir.isValid() ) 83 if ( ir.isValid() )
75 p.drawImage( ir.x(), ir.y(), img, ir.x()-ox, ir.y()-oy, ir.width(), ir.height() ); 84 p.drawImage( ir.x(), ir.y(), img, ir.x()-ox, ir.y()-oy, ir.width(), ir.height() );
76 85
77 QString syncMsg = tr("Syncing:"); 86 QString syncMsg = tr("Syncing:");
78 p.setPen( black ); 87 p.setPen( black );
79 QRect r( 0, 0, width()/2-5, QMAX(oy,80) ); 88 QRect r( 0, 0, width()/2-5, QMAX(oy,80) );
80 p.drawText( r, AlignRight | AlignVCenter, syncMsg ); 89 p.drawText( r, AlignRight | AlignVCenter, syncMsg );
81 r.moveBy( width()/2, 0 ); 90 r.moveBy( width()/2, 0 );
82 QFont f( font() ); 91 QFont f( font() );
83 f.setWeight( QFont::Bold ); 92 f.setWeight( QFont::Bold );
84 p.setFont( f ); 93 p.setFont( f );
85 p.drawText( r, AlignLeft | AlignVCenter, what ); 94 p.drawText( r, AlignLeft | AlignVCenter, what );
86 95
87 if ( !hideDot ) 96 if ( !hideDot )
88 p.drawImage( ox+path[nextPt].x()-dot.width()/2, oy+path[nextPt].y()-dot.height()/2, dot ); 97 p.drawImage( ox+path[nextPt].x()-dot.width()/2, oy+path[nextPt].y()-dot.height()/2, dot );
89} 98}
90 99
91void SyncDialog::timerEvent( QTimerEvent * ) 100void SyncDialog::timerEvent( QTimerEvent * )
92{ 101{
93 int ox = (width() - img.width())/2; 102 int ox = (width() - img.width())/2;
94 int oy = (height() - img.height())/2; 103 int oy = (height() - img.height())/2;
95 int oldPt = nextPt; 104 int oldPt = nextPt;
96 105
97 if ( !rev ) { 106 if ( !rev ) {
98 nextPt++; 107 nextPt++;
99 if ( nextPt == (int)path.count() ) { 108 if ( nextPt == (int)path.count() ) {
100 nextPt -= 2; 109 nextPt -= 2;
101 rev = TRUE; 110 rev = TRUE;
102 } 111 }
103 } else { 112 } else {
104 nextPt--; 113 nextPt--;
105 if ( nextPt < 0 ) { 114 if ( nextPt < 0 ) {
106 nextPt = 1; 115 nextPt = 1;
107 rev = FALSE; 116 rev = FALSE;
108 } 117 }
109 } 118 }
110 119
111 hideDot = FALSE; 120 hideDot = FALSE;
112 repaint( ox+path[nextPt].x()-dot.width()/2, oy+path[nextPt].y()-dot.height()/2, 121 repaint( ox+path[nextPt].x()-dot.width()/2, oy+path[nextPt].y()-dot.height()/2,
113 dot.width(), dot.height() ); 122 dot.width(), dot.height() );
114 hideDot = TRUE; 123 hideDot = TRUE;
115 repaint( ox+path[oldPt].x()-dot.width()/2, oy+path[oldPt].y()-dot.height()/2, 124 repaint( ox+path[oldPt].x()-dot.width()/2, oy+path[oldPt].y()-dot.height()/2,
116 dot.width(), dot.height() ); 125 dot.width(), dot.height() );
117} 126}
118 127
119void SyncDialog::loadPath() 128void SyncDialog::loadPath()
120{ 129{
121 QString pfile = Resource::findPixmap( "syncdot" ); 130 QString pfile = OResource::findPixmap( "syncdot" );
122 if ( pfile.isEmpty() ) 131 if ( pfile.isEmpty() )
123 return; 132 return;
124 int dp = pfile.findRev('.'); 133 int dp = pfile.findRev('.');
125 pfile.replace( dp, pfile.length()-dp, ".path" ); 134 pfile.replace( dp, pfile.length()-dp, ".path" );
126 135
127 int count = 0; 136 int count = 0;
128 QFile file( pfile ); 137 QFile file( pfile );
129 if ( file.open( IO_ReadOnly ) ) { 138 if ( file.open( IO_ReadOnly ) ) {
130 QString line; 139 QString line;
131 while ( file.readLine( line, 256 ) > 0 ) { 140 while ( file.readLine( line, 256 ) > 0 ) {
132 int x, y; 141 int x, y;
133 if ( sscanf( line.latin1(), "%d %d", &x, &y ) == 2 ) { 142 if ( sscanf( line.latin1(), "%d %d", &x, &y ) == 2 ) {
134 path.resize( count+1 ); 143 path.resize( count+1 );
135 path[count++] = QPoint(x, y); 144 path[count++] = QPoint(x, y);
136 } 145 }
137 } 146 }
138 } 147 }
139} 148}
140 149
141QPointArray SyncDialog::scalePath( const QPointArray &pa, int xn, int xd, int yn, int yd ) 150QPointArray SyncDialog::scalePath( const QPointArray &pa, int xn, int xd, int yn, int yd )
142{ 151{
143 QPointArray sa( pa.size() ); 152 QPointArray sa( pa.size() );
144 153
145 for ( unsigned i = 0; i < pa.count(); i++ ) { 154 for ( unsigned i = 0; i < pa.count(); i++ ) {
146 int x = xn * pa[int(i)].x() / xd; 155 int x = xn * pa[int(i)].x() / xd;
147 int y = yn * pa[int(i)].y() / yd; 156 int y = yn * pa[int(i)].y() / yd;
148 sa[int(i)] = QPoint( x, y ); 157 sa[int(i)] = QPoint( x, y );
149 } 158 }
150 159
151 return sa; 160 return sa;
152} 161}
153 162
154QPointArray SyncDialog::generatePath( const QPointArray &pa, int dist ) 163QPointArray SyncDialog::generatePath( const QPointArray &pa, int dist )
155{ 164{
156 if ( pa.count() < 2 ) 165 if ( pa.count() < 2 )
157 return pa; 166 return pa;
158 167
159 QPointArray fa; 168 QPointArray fa;
160 int count = 0; 169 int count = 0;
161 fa.resize( count+1 ); 170 fa.resize( count+1 );
162 fa[count++] = pa[0]; 171 fa[count++] = pa[0];
163 for ( unsigned i = 0; i < pa.count()-1; i++ ) { 172 for ( unsigned i = 0; i < pa.count()-1; i++ ) {
164 int x1 = pa[int(i)].x(); 173 int x1 = pa[int(i)].x();
165 int y1 = pa[int(i)].y(); 174 int y1 = pa[int(i)].y();
166 int x2 = pa[int(i+1)].x(); 175 int x2 = pa[int(i+1)].x();
167 int y2 = pa[int(i+1)].y(); 176 int y2 = pa[int(i+1)].y();
168 int dx = x2 - x1; 177 int dx = x2 - x1;
169 int dy = y2 - y1; 178 int dy = y2 - y1;
170 int pts = (QMAX(QABS(dx),QABS(dy)) + dist/2 )/dist; 179 int pts = (QMAX(QABS(dx),QABS(dy)) + dist/2 )/dist;
171 for ( int j = 1; j < pts; j++ ) { 180 for ( int j = 1; j < pts; j++ ) {
172 int x = j * dx / pts; 181 int x = j * dx / pts;
173 int y = j * dy / pts; 182 int y = j * dy / pts;
174 fa.resize( count+1 ); 183 fa.resize( count+1 );
175 fa[count++] = pa[int(i)] + QPoint( x, y ); 184 fa[count++] = pa[int(i)] + QPoint( x, y );
176 } 185 }
177 fa.resize( count+1 ); 186 fa.resize( count+1 );
178 fa[count++] = pa[int(i+1)]; 187 fa[count++] = pa[int(i+1)];
179 } 188 }
180 189
181 return fa; 190 return fa;
182} 191}
183 192
diff --git a/core/launcher/taskbar.cpp b/core/launcher/taskbar.cpp
index 7cbfe13..1356c77 100644
--- a/core/launcher/taskbar.cpp
+++ b/core/launcher/taskbar.cpp
@@ -1,385 +1,393 @@
1/********************************************************************** 1/*
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2                 This file is part of the Opie Project
3** 3 =. (C) 2000-2002 Trolltech AS
4** This file is part of the Qtopia Environment. 4 .=l. (C) 2002-2005 The Opie Team <opie-devel@handhelds.org>
5** 5           .>+-=
6** This file may be distributed and/or modified under the terms of the 6 _;:,     .>    :=|. This program is free software; you can
7** GNU General Public License version 2 as published by the Free Software 7.> <`_,   >  .   <= redistribute it and/or modify it under
8** Foundation and appearing in the file LICENSE.GPL included in the 8 :`=1 )Y*s>-.--   : the terms of the GNU Library General Public
9** packaging of this file. 9.="- .-=="i,     .._ License as published by the Free Software
10** 10 - .   .-<_>     .<> Foundation; version 2 of the License.
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11     ._= =}       :
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12    .%`+i>       _;_.
13** 13    .i_,=:_.      -<s. This program is distributed in the hope that
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15** 15 : ..    .:,     . . . without even the implied warranty of
16** Contact info@trolltech.com if any conditions of this licensing are 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17** not clear to you. 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
18** 18..}^=.=       =       ; Library General Public License for more
19**********************************************************************/ 19++=   -.     .`     .: details.
20 20 :     =  ...= . :.=-
21 -.   .:....=;==+<; You should have received a copy of the GNU
22  -_. . .   )=.  = Library General Public License along with
23    --        :-=` this library; see the file COPYING.LIB.
24 If not, write to the Free Software Foundation,
25 Inc., 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA.
27*/
21#include "startmenu.h" 28#include "startmenu.h"
22#include "inputmethods.h" 29#include "inputmethods.h"
23#include "runningappbar.h" 30#include "runningappbar.h"
24#include "systray.h" 31#include "systray.h"
25#include "wait.h" 32#include "wait.h"
26#include "appicons.h" 33#include "appicons.h"
27 34
28#include "taskbar.h" 35#include "taskbar.h"
29#include "server.h" 36#include "server.h"
30 37
31/* OPIE */ 38/* OPIE */
32#include <opie2/odebug.h> 39#include <opie2/odebug.h>
40#include <opie2/oresource.h>
33#include <qtopia/config.h> 41#include <qtopia/config.h>
34#include <qtopia/qpeapplication.h> 42#include <qtopia/qpeapplication.h>
35#ifdef QWS 43#ifdef QWS
36#include <qtopia/qcopenvelope_qws.h> 44#include <qtopia/qcopenvelope_qws.h>
37#endif 45#endif
38#include <qtopia/global.h> 46#include <qtopia/global.h>
39using namespace Opie::Core; 47using namespace Opie::Core;
40 48
41/* QT */ 49/* QT */
42#include <qlabel.h> 50#include <qlabel.h>
43#include <qlayout.h> 51#include <qlayout.h>
44#include <qtimer.h> 52#include <qtimer.h>
45#ifdef QWS 53#ifdef QWS
46#include <qwindowsystem_qws.h> 54#include <qwindowsystem_qws.h>
47#endif 55#endif
48#include <qwidgetstack.h> 56#include <qwidgetstack.h>
49 57
50#if defined( Q_WS_QWS ) 58#if defined( Q_WS_QWS )
51#include <qwsdisplay_qws.h> 59#include <qwsdisplay_qws.h>
52#include <qgfx_qws.h> 60#include <qgfx_qws.h>
53#endif 61#endif
54 62
55 63
56static bool initNumLock() 64static bool initNumLock()
57{ 65{
58#ifdef QPE_INITIAL_NUMLOCK_STATE 66#ifdef QPE_INITIAL_NUMLOCK_STATE
59 QPE_INITIAL_NUMLOCK_STATE 67 QPE_INITIAL_NUMLOCK_STATE
60#endif 68#endif
61 return FALSE; 69 return FALSE;
62} 70}
63 71
64//--------------------------------------------------------------------------- 72//---------------------------------------------------------------------------
65 73
66class SafeMode : public QWidget 74class SafeMode : public QWidget
67{ 75{
68 Q_OBJECT 76 Q_OBJECT
69public: 77public:
70 SafeMode( QWidget *parent ) : QWidget( parent ), menu(0) 78 SafeMode( QWidget *parent ) : QWidget( parent ), menu(0)
71 { 79 {
72 message = tr("Safe Mode"); 80 message = tr("Safe Mode");
73 QFont f( font() ); 81 QFont f( font() );
74 f.setWeight( QFont::Bold ); 82 f.setWeight( QFont::Bold );
75 setFont( f ); 83 setFont( f );
76 } 84 }
77 85
78 void mousePressEvent( QMouseEvent *); 86 void mousePressEvent( QMouseEvent *);
79 QSize sizeHint() const; 87 QSize sizeHint() const;
80 void paintEvent( QPaintEvent* ); 88 void paintEvent( QPaintEvent* );
81 89
82private slots: 90private slots:
83 void action(int i); 91 void action(int i);
84 92
85private: 93private:
86 QString message; 94 QString message;
87 QPopupMenu *menu; 95 QPopupMenu *menu;
88}; 96};
89 97
90void SafeMode::mousePressEvent( QMouseEvent *) 98void SafeMode::mousePressEvent( QMouseEvent *)
91{ 99{
92 if ( !menu ) { 100 if ( !menu ) {
93 menu = new QPopupMenu(this); 101 menu = new QPopupMenu(this);
94 menu->insertItem( tr("Plugin Manager..."), 0 ); 102 menu->insertItem( tr("Plugin Manager..."), 0 );
95 menu->insertItem( tr("Restart Qtopia"), 1 ); 103 menu->insertItem( tr("Restart Qtopia"), 1 );
96 menu->insertItem( tr("Help..."), 2 ); 104 menu->insertItem( tr("Help..."), 2 );
97 connect(menu, SIGNAL(activated(int)), this, SLOT(action(int))); 105 connect(menu, SIGNAL(activated(int)), this, SLOT(action(int)));
98 } 106 }
99 QPoint curPos = mapToGlobal( QPoint(0,0) ); 107 QPoint curPos = mapToGlobal( QPoint(0,0) );
100 QSize sh = menu->sizeHint(); 108 QSize sh = menu->sizeHint();
101 menu->popup( curPos-QPoint((sh.width()-width())/2,sh.height()) ); 109 menu->popup( curPos-QPoint((sh.width()-width())/2,sh.height()) );
102} 110}
103 111
104void SafeMode::action(int i) 112void SafeMode::action(int i)
105{ 113{
106 switch (i) { 114 switch (i) {
107 case 0: 115 case 0:
108 Global::execute( "pluginmanager" ); 116 Global::execute( "pluginmanager" );
109 break; 117 break;
110 case 1: 118 case 1:
111 Global::restart(); 119 Global::restart();
112 break; 120 break;
113 case 2: 121 case 2:
114 Global::execute( "helpbrowser", "safemode.html" ); 122 Global::execute( "helpbrowser", "safemode.html" );
115 break; 123 break;
116 } 124 }
117} 125}
118 126
119QSize SafeMode::sizeHint() const 127QSize SafeMode::sizeHint() const
120{ 128{
121 QFontMetrics fm = fontMetrics(); 129 QFontMetrics fm = fontMetrics();
122 130
123 return QSize( fm.width(message), fm.height() ); 131 return QSize( fm.width(message), fm.height() );
124} 132}
125 133
126void SafeMode::paintEvent( QPaintEvent* ) 134void SafeMode::paintEvent( QPaintEvent* )
127{ 135{
128 QPainter p(this); 136 QPainter p(this);
129 p.drawText( rect(), AlignCenter, message ); 137 p.drawText( rect(), AlignCenter, message );
130} 138}
131 139
132//--------------------------------------------------------------------------- 140//---------------------------------------------------------------------------
133 141
134class LockKeyState : public QWidget 142class LockKeyState : public QWidget
135{ 143{
136public: 144public:
137 LockKeyState( QWidget *parent ) : 145 LockKeyState( QWidget *parent ) :
138 QWidget(parent), 146 QWidget(parent),
139 nl(initNumLock()), cl(FALSE) 147 nl(initNumLock()), cl(FALSE)
140 { 148 {
141 nl_pm = Resource::loadPixmap("numlock"); 149 nl_pm = OResource::loadPixmap("numlock", OResource::NoScale);
142 cl_pm = Resource::loadPixmap("capslock"); 150 cl_pm = OResource::loadPixmap("capslock", OResource::NoScale);
143 } 151 }
144 QSize sizeHint() const 152 QSize sizeHint() const
145 { 153 {
146 return QSize(nl_pm.width()+2,nl_pm.width()+nl_pm.height()+1); 154 return QSize(nl_pm.width()+2,nl_pm.width()+nl_pm.height()+1);
147 } 155 }
148 void toggleNumLockState() 156 void toggleNumLockState()
149 { 157 {
150 nl = !nl; repaint(); 158 nl = !nl; repaint();
151 } 159 }
152 void toggleCapsLockState() 160 void toggleCapsLockState()
153 { 161 {
154 cl = !cl; repaint(); 162 cl = !cl; repaint();
155 } 163 }
156 void paintEvent( QPaintEvent * ) 164 void paintEvent( QPaintEvent * )
157 { 165 {
158 int y = (height()-sizeHint().height())/2; 166 int y = (height()-sizeHint().height())/2;
159 QPainter p(this); 167 QPainter p(this);
160 if ( nl ) 168 if ( nl )
161 p.drawPixmap(1,y,nl_pm); 169 p.drawPixmap(1,y,nl_pm);
162 if ( cl ) 170 if ( cl )
163 p.drawPixmap(1,y+nl_pm.height()+1,cl_pm); 171 p.drawPixmap(1,y+nl_pm.height()+1,cl_pm);
164 } 172 }
165private: 173private:
166 QPixmap nl_pm, cl_pm; 174 QPixmap nl_pm, cl_pm;
167 bool nl, cl; 175 bool nl, cl;
168}; 176};
169 177
170//--------------------------------------------------------------------------- 178//---------------------------------------------------------------------------
171 179
172TaskBar::~TaskBar() 180TaskBar::~TaskBar()
173{ 181{
174} 182}
175 183
176 184
177TaskBar::TaskBar() : QHBox(0, 0, WStyle_Customize | WStyle_Tool | WStyle_StaysOnTop | WGroupLeader) 185TaskBar::TaskBar() : QHBox(0, 0, WStyle_Customize | WStyle_Tool | WStyle_StaysOnTop | WGroupLeader)
178{ 186{
179 /* Read InputMethod Config */ 187 /* Read InputMethod Config */
180 readConfig(); 188 readConfig();
181 189
182 sm = new StartMenu( this ); 190 sm = new StartMenu( this );
183 connect( sm, SIGNAL(tabSelected(const QString&)), this, 191 connect( sm, SIGNAL(tabSelected(const QString&)), this,
184 SIGNAL(tabSelected(const QString&)) ); 192 SIGNAL(tabSelected(const QString&)) );
185 193
186 inputMethods = new InputMethods( this ); 194 inputMethods = new InputMethods( this );
187 connect( inputMethods, SIGNAL(inputToggled(bool)), 195 connect( inputMethods, SIGNAL(inputToggled(bool)),
188 this, SLOT(calcMaxWindowRect()) ); 196 this, SLOT(calcMaxWindowRect()) );
189 197
190 stack = new QWidgetStack( this ); 198 stack = new QWidgetStack( this );
191 stack->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) ); 199 stack->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) );
192 label = new QLabel(stack); 200 label = new QLabel(stack);
193 201
194 runningAppBar = new RunningAppBar(stack); 202 runningAppBar = new RunningAppBar(stack);
195 stack->raiseWidget(runningAppBar); 203 stack->raiseWidget(runningAppBar);
196 204
197 waitIcon = new Wait( this ); 205 waitIcon = new Wait( this );
198 (void) new AppIcons( this ); 206 (void) new AppIcons( this );
199 207
200 sysTray = new SysTray( this ); 208 sysTray = new SysTray( this );
201 209
202 /* ### FIXME plugin loader and safe mode */ 210 /* ### FIXME plugin loader and safe mode */
203#if 0 211#if 0
204 if (PluginLoader::inSafeMode()) 212 if (PluginLoader::inSafeMode())
205 (void)new SafeMode( this ); 213 (void)new SafeMode( this );
206#endif 214#endif
207 215
208 // ## make customizable in some way? 216 // ## make customizable in some way?
209#ifdef OPIE_TASKBAR_LOCK_KEY_STATE 217#ifdef OPIE_TASKBAR_LOCK_KEY_STATE
210 lockState = new LockKeyState( this ); 218 lockState = new LockKeyState( this );
211#else 219#else
212 lockState = 0; 220 lockState = 0;
213#endif 221#endif
214 222
215#if defined(Q_WS_QWS) 223#if defined(Q_WS_QWS)
216#if !defined(QT_NO_COP) 224#if !defined(QT_NO_COP)
217 QCopChannel *channel = new QCopChannel( "QPE/TaskBar", this ); 225 QCopChannel *channel = new QCopChannel( "QPE/TaskBar", this );
218 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), 226 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)),
219 this, SLOT(receive(const QCString&,const QByteArray&)) ); 227 this, SLOT(receive(const QCString&,const QByteArray&)) );
220#endif 228#endif
221#endif 229#endif
222 waitTimer = new QTimer( this ); 230 waitTimer = new QTimer( this );
223 connect( waitTimer, SIGNAL( timeout() ), this, SLOT( stopWait() ) ); 231 connect( waitTimer, SIGNAL( timeout() ), this, SLOT( stopWait() ) );
224 clearer = new QTimer( this ); 232 clearer = new QTimer( this );
225 QObject::connect(clearer, SIGNAL(timeout()), SLOT(clearStatusBar())); 233 QObject::connect(clearer, SIGNAL(timeout()), SLOT(clearStatusBar()));
226 234
227 connect( qApp, SIGNAL(symbol()), this, SLOT(toggleSymbolInput()) ); 235 connect( qApp, SIGNAL(symbol()), this, SLOT(toggleSymbolInput()) );
228 connect( qApp, SIGNAL(numLockStateToggle()), this, SLOT(toggleNumLockState()) ); 236 connect( qApp, SIGNAL(numLockStateToggle()), this, SLOT(toggleNumLockState()) );
229 connect( qApp, SIGNAL(capsLockStateToggle()), this, SLOT(toggleCapsLockState()) ); 237 connect( qApp, SIGNAL(capsLockStateToggle()), this, SLOT(toggleCapsLockState()) );
230} 238}
231 239
232void TaskBar::setStatusMessage( const QString &text ) 240void TaskBar::setStatusMessage( const QString &text )
233{ 241{
234 if ( !text.isEmpty() ) { 242 if ( !text.isEmpty() ) {
235 label->setText( text ); 243 label->setText( text );
236 stack->raiseWidget( label ); 244 stack->raiseWidget( label );
237 if ( sysTray && ( label->fontMetrics().width( text ) > label->width() ) ) 245 if ( sysTray && ( label->fontMetrics().width( text ) > label->width() ) )
238 sysTray->hide(); 246 sysTray->hide();
239 clearer->start( 3000, TRUE ); 247 clearer->start( 3000, TRUE );
240 } else { 248 } else {
241 clearStatusBar(); 249 clearStatusBar();
242 } 250 }
243} 251}
244 252
245void TaskBar::clearStatusBar() 253void TaskBar::clearStatusBar()
246{ 254{
247 label->clear(); 255 label->clear();
248 stack->raiseWidget(runningAppBar); 256 stack->raiseWidget(runningAppBar);
249 if ( sysTray ) 257 if ( sysTray )
250 sysTray->show(); 258 sysTray->show();
251 // stack->raiseWidget( mru ); 259 // stack->raiseWidget( mru );
252} 260}
253 261
254void TaskBar::startWait() 262void TaskBar::startWait()
255{ 263{
256 waitIcon->setWaiting( true ); 264 waitIcon->setWaiting( true );
257 // a catchall stop after 10 seconds... 265 // a catchall stop after 10 seconds...
258 waitTimer->start( 10 * 1000, true ); 266 waitTimer->start( 10 * 1000, true );
259} 267}
260 268
261void TaskBar::stopWait(const QString&) 269void TaskBar::stopWait(const QString&)
262{ 270{
263 waitTimer->stop(); 271 waitTimer->stop();
264 waitIcon->setWaiting( false ); 272 waitIcon->setWaiting( false );
265} 273}
266 274
267void TaskBar::stopWait() 275void TaskBar::stopWait()
268{ 276{
269 waitTimer->stop(); 277 waitTimer->stop();
270 waitIcon->setWaiting( false ); 278 waitIcon->setWaiting( false );
271} 279}
272 280
273/* 281/*
274 * This resizeEvent will be captured by 282 * This resizeEvent will be captured by
275 * the ServerInterface and it'll layout 283 * the ServerInterface and it'll layout
276 * and calc rect. Now if we go from bigger 284 * and calc rect. Now if we go from bigger
277 * to smaller screen the SysTray is out of 285 * to smaller screen the SysTray is out of
278 * bounds and repaint() won't trigger an Event 286 * bounds and repaint() won't trigger an Event
279 */ 287 */
280void TaskBar::resizeEvent( QResizeEvent *e ) 288void TaskBar::resizeEvent( QResizeEvent *e )
281{ 289{
282 if ( sysTray ) 290 if ( sysTray )
283 sysTray->hide(); 291 sysTray->hide();
284 292
285 QHBox::resizeEvent( e ); 293 QHBox::resizeEvent( e );
286 294
287 if ( sysTray ) 295 if ( sysTray )
288 sysTray->show(); 296 sysTray->show();
289} 297}
290 298
291void TaskBar::styleChange( QStyle &s ) 299void TaskBar::styleChange( QStyle &s )
292{ 300{
293 QHBox::styleChange( s ); 301 QHBox::styleChange( s );
294 calcMaxWindowRect(); 302 calcMaxWindowRect();
295} 303}
296 304
297void TaskBar::calcMaxWindowRect() 305void TaskBar::calcMaxWindowRect()
298{ 306{
299 if ( resizeRunningApp ) 307 if ( resizeRunningApp )
300 { 308 {
301 #if defined(Q_WS_QWS) 309 #if defined(Q_WS_QWS)
302 QRect wr; 310 QRect wr;
303 int displayWidth = qApp->desktop()->width(); 311 int displayWidth = qApp->desktop()->width();
304 QRect ir = inputMethods->inputRect(); 312 QRect ir = inputMethods->inputRect();
305 if ( ir.isValid() ) { 313 if ( ir.isValid() ) {
306 wr.setCoords( 0, 0, displayWidth-1, ir.top()-1 ); 314 wr.setCoords( 0, 0, displayWidth-1, ir.top()-1 );
307 } else { 315 } else {
308 wr.setCoords( 0, 0, displayWidth-1, y()-1 ); 316 wr.setCoords( 0, 0, displayWidth-1, y()-1 );
309 } 317 }
310 #if QT_VERSION < 0x030000 318 #if QT_VERSION < 0x030000
311 QWSServer::setMaxWindowRect( qt_screen->mapToDevice(wr,QSize(qt_screen->width(),qt_screen->height())) ); 319 QWSServer::setMaxWindowRect( qt_screen->mapToDevice(wr,QSize(qt_screen->width(),qt_screen->height())) );
312 #else 320 #else
313 QWSServer::setMaxWindowRect( wr ); 321 QWSServer::setMaxWindowRect( wr );
314 #endif 322 #endif
315 #endif 323 #endif
316 } 324 }
317} 325}
318 326
319void TaskBar::receive( const QCString &msg, const QByteArray &data ) 327void TaskBar::receive( const QCString &msg, const QByteArray &data )
320{ 328{
321 QDataStream stream( data, IO_ReadOnly ); 329 QDataStream stream( data, IO_ReadOnly );
322 if ( msg == "message(QString)" ) { 330 if ( msg == "message(QString)" ) {
323 QString text; 331 QString text;
324 stream >> text; 332 stream >> text;
325 setStatusMessage( text ); 333 setStatusMessage( text );
326 } else if ( msg == "hideInputMethod()" ) { 334 } else if ( msg == "hideInputMethod()" ) {
327 inputMethods->hideInputMethod(); 335 inputMethods->hideInputMethod();
328 } else if ( msg == "showInputMethod()" ) { 336 } else if ( msg == "showInputMethod()" ) {
329 inputMethods->showInputMethod(); 337 inputMethods->showInputMethod();
330 } else if ( msg == "showInputMethod(QString)" ) { 338 } else if ( msg == "showInputMethod(QString)" ) {
331 QString name; 339 QString name;
332 stream >> name; 340 stream >> name;
333 inputMethods->showInputMethod(name); 341 inputMethods->showInputMethod(name);
334 } else if ( msg == "reloadInputMethods()" ) { 342 } else if ( msg == "reloadInputMethods()" ) {
335 readConfig(); 343 readConfig();
336 inputMethods->readConfig(); 344 inputMethods->readConfig();
337 inputMethods->loadInputMethods(); 345 inputMethods->loadInputMethods();
338 } else if ( msg == "reloadApplets()" ) { 346 } else if ( msg == "reloadApplets()" ) {
339 sysTray->clearApplets(); 347 sysTray->clearApplets();
340 sm->createMenu(); 348 sm->createMenu();
341 sysTray->addApplets(); 349 sysTray->addApplets();
342 }else if ( msg == "toggleMenu()" ) { 350 }else if ( msg == "toggleMenu()" ) {
343 if ( sm-> launchMenu-> isVisible() ) 351 if ( sm-> launchMenu-> isVisible() )
344 sm-> launch(); 352 sm-> launch();
345 else 353 else
346 QCopEnvelope e( "QPE/System", "toggleApplicationMenu()" ); 354 QCopEnvelope e( "QPE/System", "toggleApplicationMenu()" );
347 }else if ( msg == "toggleStartMenu()" ) 355 }else if ( msg == "toggleStartMenu()" )
348 sm->launch(); 356 sm->launch();
349} 357}
350 358
351void TaskBar::setApplicationState( const QString &name, ServerInterface::ApplicationState state ) 359void TaskBar::setApplicationState( const QString &name, ServerInterface::ApplicationState state )
352{ 360{
353 if ( state == ServerInterface::Launching ) 361 if ( state == ServerInterface::Launching )
354 runningAppBar->applicationLaunched( name ); 362 runningAppBar->applicationLaunched( name );
355 else if ( state == ServerInterface::Terminated ) 363 else if ( state == ServerInterface::Terminated )
356 runningAppBar->applicationTerminated( name ); 364 runningAppBar->applicationTerminated( name );
357} 365}
358 366
359void TaskBar::toggleNumLockState() 367void TaskBar::toggleNumLockState()
360{ 368{
361 if ( lockState ) lockState->toggleNumLockState(); 369 if ( lockState ) lockState->toggleNumLockState();
362} 370}
363 371
364void TaskBar::toggleCapsLockState() 372void TaskBar::toggleCapsLockState()
365{ 373{
366 if ( lockState ) lockState->toggleCapsLockState(); 374 if ( lockState ) lockState->toggleCapsLockState();
367} 375}
368 376
369void TaskBar::toggleSymbolInput() 377void TaskBar::toggleSymbolInput()
370{ 378{
371 QString unicodeInput = qApp->translate( "InputMethods", "Unicode" ); 379 QString unicodeInput = qApp->translate( "InputMethods", "Unicode" );
372 if ( inputMethods->currentShown() == unicodeInput ) { 380 if ( inputMethods->currentShown() == unicodeInput ) {
373 inputMethods->hideInputMethod(); 381 inputMethods->hideInputMethod();
374 } else { 382 } else {
375 inputMethods->showInputMethod( unicodeInput ); 383 inputMethods->showInputMethod( unicodeInput );
376 } 384 }
377} 385}
378 386
379void TaskBar::readConfig() { 387void TaskBar::readConfig() {
380 Config cfg( "Launcher" ); 388 Config cfg( "Launcher" );
381 cfg.setGroup( "InputMethods" ); 389 cfg.setGroup( "InputMethods" );
382 resizeRunningApp = cfg.readBoolEntry( "Resize", true ); 390 resizeRunningApp = cfg.readBoolEntry( "Resize", true );
383} 391}
384 392
385#include "taskbar.moc" 393#include "taskbar.moc"
diff --git a/core/launcher/wait.cpp b/core/launcher/wait.cpp
index 523819d..f872218 100644
--- a/core/launcher/wait.cpp
+++ b/core/launcher/wait.cpp
@@ -1,81 +1,87 @@
1/********************************************************************** 1/*
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2                 This file is part of the Opie Project
3** 3 =. (C) 2000-2002 Trolltech AS
4** This file is part of the Qtopia Environment. 4 .=l. (C) 2002-2005 The Opie Team <opie-devel@handhelds.org>
5** 5           .>+-=
6** This file may be distributed and/or modified under the terms of the 6 _;:,     .>    :=|. This program is free software; you can
7** GNU General Public License version 2 as published by the Free Software 7.> <`_,   >  .   <= redistribute it and/or modify it under
8** Foundation and appearing in the file LICENSE.GPL included in the 8 :`=1 )Y*s>-.--   : the terms of the GNU Library General Public
9** packaging of this file. 9.="- .-=="i,     .._ License as published by the Free Software
10** 10 - .   .-<_>     .<> Foundation; version 2 of the License.
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11     ._= =}       :
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12    .%`+i>       _;_.
13** 13    .i_,=:_.      -<s. This program is distributed in the hope that
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15** 15 : ..    .:,     . . . without even the implied warranty of
16** Contact info@trolltech.com if any conditions of this licensing are 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17** not clear to you. 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
18** 18..}^=.=       =       ; Library General Public License for more
19**********************************************************************/ 19++=   -.     .`     .: details.
20 20 :     =  ...= . :.=-
21 -.   .:....=;==+<; You should have received a copy of the GNU
22  -_. . .   )=.  = Library General Public License along with
23    --        :-=` this library; see the file COPYING.LIB.
24 If not, write to the Free Software Foundation,
25 Inc., 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA.
27*/
21#include "wait.h" 28#include "wait.h"
22 29
23#include <opie2/owait.h> 30#include <opie2/owait.h>
31#include <opie2/oresource.h>
32using namespace Opie::Core;
24 33
25#include <qtopia/config.h> 34#include <qtopia/config.h>
26#include <qtopia/applnk.h> 35#include <qtopia/applnk.h>
27 36
28Wait *lastWaitObject = NULL; 37Wait *lastWaitObject = NULL;
29 38
30 39
31using namespace Opie::Ui; 40using namespace Opie::Ui;
32Wait::Wait( QWidget *parent ) : QWidget( parent ), 41Wait::Wait( QWidget *parent ) : QWidget( parent ),
33 waiting( FALSE ) 42 waiting( FALSE )
34{ 43{
35 44
36 QSize size( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); 45 QSize size( AppLnk::smallIconSize(), AppLnk::smallIconSize() );
37 setFixedSize( size ); 46 setFixedSize( size );
38 47 pm = OResource::loadPixmap( "wait", OResource::SmallIcon );
39 QImage img = Resource::loadImage( "wait" );
40 img = img.smoothScale( size.width(), size.height() );
41 pm.convertFromImage( img );
42 48
43 lastWaitObject = this; 49 lastWaitObject = this;
44 m_centralWait = new OWait( 0l ); 50 m_centralWait = new OWait( 0l );
45 m_centralWait->hide(); 51 m_centralWait->hide();
46 hide(); 52 hide();
47} 53}
48 54
49 55
50Wait *Wait::getWaitObject() 56Wait *Wait::getWaitObject()
51{ 57{
52 return lastWaitObject; 58 return lastWaitObject;
53} 59}
54 60
55 61
56void Wait::setWaiting( bool w ) 62void Wait::setWaiting( bool w )
57{ 63{
58 Config cfg ( "Launcher" ); 64 Config cfg ( "Launcher" );
59 cfg.setGroup("GUI"); 65 cfg.setGroup("GUI");
60 66
61 67
62 waiting = w; 68 waiting = w;
63 if ( w ) { 69 if ( w ) {
64 if ( cfg. readBoolEntry( "BigBusy" ) ) 70 if ( cfg. readBoolEntry( "BigBusy" ) )
65 m_centralWait->show(); 71 m_centralWait->show();
66 else 72 else
67 show(); 73 show();
68 }else{ 74 }else{
69 m_centralWait->hide(); 75 m_centralWait->hide();
70 hide(); 76 hide();
71 } 77 }
72} 78}
73 79
74 80
75void Wait::paintEvent( QPaintEvent * ) 81void Wait::paintEvent( QPaintEvent * )
76{ 82{
77 QPainter p( this ); 83 QPainter p( this );
78 p.drawPixmap( 0, 0, pm ); 84 p.drawPixmap( 0, 0, pm );
79} 85}
80 86
81 87