summaryrefslogtreecommitdiff
authorsandman <sandman>2002-09-27 00:57:22 (UTC)
committer sandman <sandman>2002-09-27 00:57:22 (UTC)
commit6ac98209a82c5aa24ab09faf79525cd9aa5a8a1d (patch) (unidiff)
tree5a81f96aa27867e6ce30c1fe81b5004d73299cf7
parent82012ba8a063b729dec92db60c939834530a9fa4 (diff)
downloadopie-6ac98209a82c5aa24ab09faf79525cd9aa5a8a1d.zip
opie-6ac98209a82c5aa24ab09faf79525cd9aa5a8a1d.tar.gz
opie-6ac98209a82c5aa24ab09faf79525cd9aa5a8a1d.tar.bz2
- fixed the default bg type
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/launcher.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp
index dc81c9e..1bd1156 100644
--- a/core/launcher/launcher.cpp
+++ b/core/launcher/launcher.cpp
@@ -1,780 +1,780 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21// WARNING: Do *NOT* define this yourself. The SL5xxx from SHARP does NOT 21// WARNING: Do *NOT* define this yourself. The SL5xxx from SHARP does NOT
22// have this class. 22// have this class.
23#define QTOPIA_INTERNAL_FSLP 23#define QTOPIA_INTERNAL_FSLP
24 24
25#ifdef QWS 25#ifdef QWS
26#include <qpe/qcopenvelope_qws.h> 26#include <qpe/qcopenvelope_qws.h>
27#endif 27#endif
28#include <qpe/resource.h> 28#include <qpe/resource.h>
29#include <qpe/applnk.h> 29#include <qpe/applnk.h>
30#include <qpe/config.h> 30#include <qpe/config.h>
31#include <qpe/global.h> 31#include <qpe/global.h>
32#include <qpe/qpeapplication.h> 32#include <qpe/qpeapplication.h>
33#include <qpe/mimetype.h> 33#include <qpe/mimetype.h>
34#include <qpe/storage.h> 34#include <qpe/storage.h>
35#include <qpe/palmtoprecord.h> 35#include <qpe/palmtoprecord.h>
36 36
37#include <qpe/version.h> 37#include <qpe/version.h>
38 38
39#include <qdir.h> 39#include <qdir.h>
40#ifdef QWS 40#ifdef QWS
41#include <qwindowsystem_qws.h> 41#include <qwindowsystem_qws.h>
42#endif 42#endif
43#include <qtimer.h> 43#include <qtimer.h>
44#include <qcombobox.h> 44#include <qcombobox.h>
45#include <qvbox.h> 45#include <qvbox.h>
46#include <qlayout.h> 46#include <qlayout.h>
47#include <qstyle.h> 47#include <qstyle.h>
48#include <qpushbutton.h> 48#include <qpushbutton.h>
49#include <qtabbar.h> 49#include <qtabbar.h>
50#include <qwidgetstack.h> 50#include <qwidgetstack.h>
51#include <qlayout.h> 51#include <qlayout.h>
52#include <qregexp.h> 52#include <qregexp.h>
53#include <qmessagebox.h> 53#include <qmessagebox.h>
54#include <qframe.h> 54#include <qframe.h>
55#include <qpainter.h> 55#include <qpainter.h>
56#include <qlabel.h> 56#include <qlabel.h>
57#include <qtextstream.h> 57#include <qtextstream.h>
58#include <qpopupmenu.h> 58#include <qpopupmenu.h>
59 59
60#include "launcherview.h" 60#include "launcherview.h"
61#include "launcher.h" 61#include "launcher.h"
62#include "syncdialog.h" 62#include "syncdialog.h"
63#include "desktop.h" 63#include "desktop.h"
64#include <qpe/lnkproperties.h> 64#include <qpe/lnkproperties.h>
65//#include "mrulist.h" 65//#include "mrulist.h"
66#include "qrsync.h" 66#include "qrsync.h"
67#include <stdlib.h> 67#include <stdlib.h>
68#include <unistd.h> 68#include <unistd.h>
69 69
70#if defined(_OS_LINUX_) || defined(Q_OS_LINUX) 70#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
71#include <stdio.h> 71#include <stdio.h>
72#include <sys/vfs.h> 72#include <sys/vfs.h>
73#include <mntent.h> 73#include <mntent.h>
74#endif 74#endif
75 75
76#include <qpe/storage.h> 76#include <qpe/storage.h>
77#include "mediummountgui.h" 77#include "mediummountgui.h"
78 78
79namespace { 79namespace {
80 QStringList configToMime( Config *cfg ){ 80 QStringList configToMime( Config *cfg ){
81 QStringList mimes; 81 QStringList mimes;
82 bool tmpMime = true; 82 bool tmpMime = true;
83 cfg->setGroup("mimetypes" ); 83 cfg->setGroup("mimetypes" );
84 tmpMime = cfg->readBoolEntry("all" ,true); 84 tmpMime = cfg->readBoolEntry("all" ,true);
85 if( tmpMime ){ 85 if( tmpMime ){
86 mimes << QString::null; 86 mimes << QString::null;
87 return mimes; 87 return mimes;
88 }else{ 88 }else{
89 tmpMime = cfg->readBoolEntry("audio", true ); 89 tmpMime = cfg->readBoolEntry("audio", true );
90 if(tmpMime ) 90 if(tmpMime )
91 mimes.append("audio/*" ); 91 mimes.append("audio/*" );
92 92
93 tmpMime = cfg->readBoolEntry("image", true ); 93 tmpMime = cfg->readBoolEntry("image", true );
94 if(tmpMime ) 94 if(tmpMime )
95 mimes.append("image/*" ); 95 mimes.append("image/*" );
96 96
97 tmpMime = cfg->readBoolEntry("text", true ); 97 tmpMime = cfg->readBoolEntry("text", true );
98 if(tmpMime ) 98 if(tmpMime )
99 mimes.append("text/*"); 99 mimes.append("text/*");
100 100
101 tmpMime = cfg->readBoolEntry("video", true ); 101 tmpMime = cfg->readBoolEntry("video", true );
102 if(tmpMime ) 102 if(tmpMime )
103 mimes.append("video/*" ); 103 mimes.append("video/*" );
104 } 104 }
105 return mimes; 105 return mimes;
106 } 106 }
107 107
108} 108}
109 109
110 110
111 111
112//#define SHOW_ALL 112//#define SHOW_ALL
113 113
114class CategoryTab : public QTab 114class CategoryTab : public QTab
115{ 115{
116public: 116public:
117 CategoryTab( const QIconSet &icon, const QString &text=QString::null ) 117 CategoryTab( const QIconSet &icon, const QString &text=QString::null )
118 : QTab( icon, text ) 118 : QTab( icon, text )
119 { 119 {
120 } 120 }
121 121
122 QColor bgColor; 122 QColor bgColor;
123 QColor fgColor; 123 QColor fgColor;
124}; 124};
125 125
126//=========================================================================== 126//===========================================================================
127 127
128CategoryTabWidget::CategoryTabWidget( QWidget* parent ) : 128CategoryTabWidget::CategoryTabWidget( QWidget* parent ) :
129 QVBox( parent ) 129 QVBox( parent )
130{ 130{
131 categoryBar = 0; 131 categoryBar = 0;
132 stack = 0; 132 stack = 0;
133} 133}
134 134
135void CategoryTabWidget::prevTab() 135void CategoryTabWidget::prevTab()
136{ 136{
137 if ( categoryBar ) { 137 if ( categoryBar ) {
138 int n = categoryBar->count(); 138 int n = categoryBar->count();
139 int tab = categoryBar->currentTab(); 139 int tab = categoryBar->currentTab();
140 if ( tab >= 0 ) 140 if ( tab >= 0 )
141 categoryBar->setCurrentTab( (tab - 1 + n)%n ); 141 categoryBar->setCurrentTab( (tab - 1 + n)%n );
142 } 142 }
143} 143}
144 144
145void CategoryTabWidget::nextTab() 145void CategoryTabWidget::nextTab()
146{ 146{
147 if ( categoryBar ) { 147 if ( categoryBar ) {
148 int n = categoryBar->count(); 148 int n = categoryBar->count();
149 int tab = categoryBar->currentTab(); 149 int tab = categoryBar->currentTab();
150 categoryBar->setCurrentTab( (tab + 1)%n ); 150 categoryBar->setCurrentTab( (tab + 1)%n );
151 } 151 }
152} 152}
153 153
154void CategoryTabWidget::addItem( const QString& linkfile ) 154void CategoryTabWidget::addItem( const QString& linkfile )
155{ 155{
156 int i=0; 156 int i=0;
157 AppLnk *app = new AppLnk(linkfile); 157 AppLnk *app = new AppLnk(linkfile);
158 if ( !app->isValid() ) { 158 if ( !app->isValid() ) {
159 delete app; 159 delete app;
160 app=0; 160 app=0;
161 } 161 }
162 if ( !app || !app->file().isEmpty() ) { 162 if ( !app || !app->file().isEmpty() ) {
163 // A document 163 // A document
164 delete app; 164 delete app;
165 app = new DocLnk(linkfile); 165 app = new DocLnk(linkfile);
166 if ( app->fileKnown() ) { 166 if ( app->fileKnown() ) {
167 ((LauncherView*)(stack->widget(ids.count()-1)))->addItem(app); 167 ((LauncherView*)(stack->widget(ids.count()-1)))->addItem(app);
168 } else { 168 } else {
169 ((LauncherView*)(stack->widget(ids.count()-1)))->sort(); 169 ((LauncherView*)(stack->widget(ids.count()-1)))->sort();
170 delete app; 170 delete app;
171 } 171 }
172 return; 172 return;
173 } 173 }
174 // An application 174 // An application
175 for ( QStringList::Iterator it=ids.begin(); it!=ids.end(); ++it) { 175 for ( QStringList::Iterator it=ids.begin(); it!=ids.end(); ++it) {
176 if ( !(*it).isEmpty() ) { 176 if ( !(*it).isEmpty() ) {
177 QRegExp tf(*it,FALSE,TRUE); 177 QRegExp tf(*it,FALSE,TRUE);
178 if ( tf.match(app->type()) >= 0 ) { 178 if ( tf.match(app->type()) >= 0 ) {
179 ((LauncherView*)stack->widget(i))->addItem(app); 179 ((LauncherView*)stack->widget(i))->addItem(app);
180 return; 180 return;
181 } 181 }
182 i++; 182 i++;
183 } 183 }
184 } 184 }
185 185
186 QCopEnvelope e("QPE/TaskBar","reloadApps()"); 186 QCopEnvelope e("QPE/TaskBar","reloadApps()");
187} 187}
188 188
189void CategoryTabWidget::initializeCategories(AppLnkSet* rootFolder, 189void CategoryTabWidget::initializeCategories(AppLnkSet* rootFolder,
190 AppLnkSet* docFolder, const QList<FileSystem> &fs) 190 AppLnkSet* docFolder, const QList<FileSystem> &fs)
191{ 191{
192 delete categoryBar; 192 delete categoryBar;
193 categoryBar = new CategoryTabBar( this ); 193 categoryBar = new CategoryTabBar( this );
194 QPalette pal = categoryBar->palette(); 194 QPalette pal = categoryBar->palette();
195 pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); 195 pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) );
196 pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); 196 pal.setColor( QColorGroup::Background, pal.active().background().light(110) );
197 categoryBar->setPalette( pal ); 197 categoryBar->setPalette( pal );
198 198
199 delete stack; 199 delete stack;
200 stack = new QWidgetStack(this); 200 stack = new QWidgetStack(this);
201 tabs=0; 201 tabs=0;
202 202
203 ids.clear(); 203 ids.clear();
204 204
205 Config cfg("Launcher"); 205 Config cfg("Launcher");
206 206
207 QStringList types = rootFolder->types(); 207 QStringList types = rootFolder->types();
208 for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) { 208 for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) {
209 if ( !(*it).isEmpty() ) { 209 if ( !(*it).isEmpty() ) {
210 (void)newView(*it,rootFolder->typePixmap(*it),rootFolder->typeName(*it)); 210 (void)newView(*it,rootFolder->typePixmap(*it),rootFolder->typeName(*it));
211 setTabAppearance( *it, cfg ); 211 setTabAppearance( *it, cfg );
212 } 212 }
213 } 213 }
214 QListIterator<AppLnk> it( rootFolder->children() ); 214 QListIterator<AppLnk> it( rootFolder->children() );
215 AppLnk* l; 215 AppLnk* l;
216 while ( (l=it.current()) ) { 216 while ( (l=it.current()) ) {
217 if ( l->type() == "Separator" ) { // No tr 217 if ( l->type() == "Separator" ) { // No tr
218 rootFolder->remove(l); 218 rootFolder->remove(l);
219 delete l; 219 delete l;
220 } else { 220 } else {
221 int i=0; 221 int i=0;
222 for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) { 222 for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) {
223 if ( *it == l->type() ) 223 if ( *it == l->type() )
224 ((LauncherView*)stack->widget(i))->addItem(l,FALSE); 224 ((LauncherView*)stack->widget(i))->addItem(l,FALSE);
225 i++; 225 i++;
226 } 226 }
227 } 227 }
228 ++it; 228 ++it;
229 } 229 }
230 rootFolder->detachChildren(); 230 rootFolder->detachChildren();
231 for (int i=0; i<tabs; i++) 231 for (int i=0; i<tabs; i++)
232 ((LauncherView*)stack->widget(i))->sort(); 232 ((LauncherView*)stack->widget(i))->sort();
233 233
234 // all documents 234 // all documents
235 QImage img( Resource::loadImage( "DocsIcon" ) ); 235 QImage img( Resource::loadImage( "DocsIcon" ) );
236 QPixmap pm; 236 QPixmap pm;
237 pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); 237 pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() );
238 docview = newView( "Documents", // No tr 238 docview = newView( "Documents", // No tr
239 pm, tr("Documents")); 239 pm, tr("Documents"));
240 docview->populate( docFolder, QString::null ); 240 docview->populate( docFolder, QString::null );
241 docFolder->detachChildren(); 241 docFolder->detachChildren();
242 docview->setFileSystems(fs); 242 docview->setFileSystems(fs);
243 docview->setToolsEnabled(TRUE); 243 docview->setToolsEnabled(TRUE);
244 setTabAppearance( "Documents", cfg ); // No tr 244 setTabAppearance( "Documents", cfg ); // No tr
245 245
246 connect( categoryBar, SIGNAL(selected(int)), stack, SLOT(raiseWidget(int)) ); 246 connect( categoryBar, SIGNAL(selected(int)), stack, SLOT(raiseWidget(int)) );
247 247
248 ((LauncherView*)stack->widget(0))->setFocus(); 248 ((LauncherView*)stack->widget(0))->setFocus();
249 249
250 categoryBar->show(); 250 categoryBar->show();
251 stack->show(); 251 stack->show();
252} 252}
253 253
254void CategoryTabWidget::setTabAppearance( const QString &id, Config &cfg ) 254void CategoryTabWidget::setTabAppearance( const QString &id, Config &cfg )
255{ 255{
256 QString grp( "Tab %1" ); // No tr 256 QString grp( "Tab %1" ); // No tr
257 cfg.setGroup( grp.arg(id) ); 257 cfg.setGroup( grp.arg(id) );
258 LauncherView *v = view( id ); 258 LauncherView *v = view( id );
259 int idx = ids.findIndex( id ); 259 int idx = ids.findIndex( id );
260 CategoryTab *tab = (CategoryTab *)categoryBar->tab( idx ); 260 CategoryTab *tab = (CategoryTab *)categoryBar->tab( idx );
261 261
262 // View 262 // View
263 QString view = cfg.readEntry( "View", "Icon" ); 263 QString view = cfg.readEntry( "View", "Icon" );
264 if ( view == "List" ) // No tr 264 if ( view == "List" ) // No tr
265 v->setViewMode( LauncherView::List ); 265 v->setViewMode( LauncherView::List );
266 QString bgType = cfg.readEntry( "BackgroundType", "Ruled" ); 266 QString bgType = cfg.readEntry( "BackgroundType", "Image" );
267 if ( bgType == "Image" ) { // No tr 267 if ( bgType == "Image" ) { // No tr
268 QString pm = cfg.readEntry( "BackgroundImage", "wallpaper/marble" ); 268 QString pm = cfg.readEntry( "BackgroundImage", "launcher/opie-background" );
269 v->setBackgroundType( LauncherView::Image, pm ); 269 v->setBackgroundType( LauncherView::Image, pm );
270 } else if ( bgType == "SolidColor" ) { 270 } else if ( bgType == "SolidColor" ) {
271 QString c = cfg.readEntry( "BackgroundColor" ); 271 QString c = cfg.readEntry( "BackgroundColor" );
272 v->setBackgroundType( LauncherView::SolidColor, c ); 272 v->setBackgroundType( LauncherView::SolidColor, c );
273 } 273 }
274 QString textCol = cfg.readEntry( "TextColor" ); 274 QString textCol = cfg.readEntry( "TextColor" );
275 if ( textCol.isEmpty() ) 275 if ( textCol.isEmpty() )
276 v->setTextColor( QColor() ); 276 v->setTextColor( QColor() );
277 else 277 else
278 v->setTextColor( QColor(textCol) ); 278 v->setTextColor( QColor(textCol) );
279 QStringList font = cfg.readListEntry( "Font", ',' ); 279 QStringList font = cfg.readListEntry( "Font", ',' );
280 if ( font.count() == 4 ) 280 if ( font.count() == 4 )
281 v->setViewFont( QFont(font[0], font[1].toInt(), font[2].toInt(), font[3].toInt()!=0) ); 281 v->setViewFont( QFont(font[0], font[1].toInt(), font[2].toInt(), font[3].toInt()!=0) );
282 282
283 // Tabs 283 // Tabs
284 QString tabCol = cfg.readEntry( "TabColor" ); 284 QString tabCol = cfg.readEntry( "TabColor" );
285 if ( tabCol.isEmpty() ) 285 if ( tabCol.isEmpty() )
286 tab->bgColor = QColor(); 286 tab->bgColor = QColor();
287 else 287 else
288 tab->bgColor = QColor(tabCol); 288 tab->bgColor = QColor(tabCol);
289 QString tabTextCol = cfg.readEntry( "TabTextColor" ); 289 QString tabTextCol = cfg.readEntry( "TabTextColor" );
290 if ( tabTextCol.isEmpty() ) 290 if ( tabTextCol.isEmpty() )
291 tab->fgColor = QColor(); 291 tab->fgColor = QColor();
292 else 292 else
293 tab->fgColor = QColor(tabTextCol); 293 tab->fgColor = QColor(tabTextCol);
294} 294}
295 295
296void CategoryTabWidget::updateDocs(AppLnkSet* docFolder, const QList<FileSystem> &fs) 296void CategoryTabWidget::updateDocs(AppLnkSet* docFolder, const QList<FileSystem> &fs)
297{ 297{
298 docview->populate( docFolder, QString::null ); 298 docview->populate( docFolder, QString::null );
299 docFolder->detachChildren(); 299 docFolder->detachChildren();
300 docview->setFileSystems(fs); 300 docview->setFileSystems(fs);
301 docview->updateTools(); 301 docview->updateTools();
302} 302}
303 303
304void CategoryTabWidget::tabProperties() 304void CategoryTabWidget::tabProperties()
305{ 305{
306 LauncherView *view = (LauncherView*)stack->widget( categoryBar->currentTab() ); 306 LauncherView *view = (LauncherView*)stack->widget( categoryBar->currentTab() );
307 QPopupMenu *m = new QPopupMenu( this ); 307 QPopupMenu *m = new QPopupMenu( this );
308 m->insertItem( tr("Icon View"), LauncherView::Icon ); 308 m->insertItem( tr("Icon View"), LauncherView::Icon );
309 m->insertItem( tr("List View"), LauncherView::List ); 309 m->insertItem( tr("List View"), LauncherView::List );
310 m->setItemChecked( (int)view->viewMode(), TRUE ); 310 m->setItemChecked( (int)view->viewMode(), TRUE );
311 int rv = m->exec( QCursor::pos() ); 311 int rv = m->exec( QCursor::pos() );
312 if ( rv >= 0 && rv != view->viewMode() ) { 312 if ( rv >= 0 && rv != view->viewMode() ) {
313 view->setViewMode( (LauncherView::ViewMode)rv ); 313 view->setViewMode( (LauncherView::ViewMode)rv );
314 } 314 }
315 315
316 delete m; 316 delete m;
317} 317}
318 318
319QString CategoryTabWidget::getAllDocLinkInfo() const 319QString CategoryTabWidget::getAllDocLinkInfo() const
320{ 320{
321 return docview->getAllDocLinkInfo(); 321 return docview->getAllDocLinkInfo();
322} 322}
323 323
324LauncherView* CategoryTabWidget::newView( const QString& id, const QPixmap& pm, const QString& label ) 324LauncherView* CategoryTabWidget::newView( const QString& id, const QPixmap& pm, const QString& label )
325{ 325{
326 LauncherView* view = new LauncherView( stack ); 326 LauncherView* view = new LauncherView( stack );
327 connect( view, SIGNAL(clicked(const AppLnk*)), 327 connect( view, SIGNAL(clicked(const AppLnk*)),
328 this, SIGNAL(clicked(const AppLnk*))); 328 this, SIGNAL(clicked(const AppLnk*)));
329 connect( view, SIGNAL(rightPressed(AppLnk*)), 329 connect( view, SIGNAL(rightPressed(AppLnk*)),
330 this, SIGNAL(rightPressed(AppLnk*))); 330 this, SIGNAL(rightPressed(AppLnk*)));
331 ids.append(id); 331 ids.append(id);
332 categoryBar->addTab( new CategoryTab( pm, label ) ); 332 categoryBar->addTab( new CategoryTab( pm, label ) );
333 stack->addWidget( view, tabs++ ); 333 stack->addWidget( view, tabs++ );
334 return view; 334 return view;
335} 335}
336 336
337void CategoryTabWidget::updateLink(const QString& linkfile) 337void CategoryTabWidget::updateLink(const QString& linkfile)
338{ 338{
339 int i=0; 339 int i=0;
340 LauncherView* view; 340 LauncherView* view;
341 while ((view = (LauncherView*)stack->widget(i++))) { 341 while ((view = (LauncherView*)stack->widget(i++))) {
342 if ( view->removeLink(linkfile) ) 342 if ( view->removeLink(linkfile) )
343 break; 343 break;
344 } 344 }
345 addItem(linkfile); 345 addItem(linkfile);
346 docview->updateTools(); 346 docview->updateTools();
347} 347}
348 348
349void CategoryTabWidget::paletteChange( const QPalette &p ) 349void CategoryTabWidget::paletteChange( const QPalette &p )
350{ 350{
351 QVBox::paletteChange( p ); 351 QVBox::paletteChange( p );
352 QPalette pal = palette(); 352 QPalette pal = palette();
353 pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); 353 pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) );
354 pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); 354 pal.setColor( QColorGroup::Background, pal.active().background().light(110) );
355 categoryBar->setPalette( pal ); 355 categoryBar->setPalette( pal );
356 categoryBar->update(); 356 categoryBar->update();
357} 357}
358 358
359void CategoryTabWidget::setBusy(bool on) 359void CategoryTabWidget::setBusy(bool on)
360{ 360{
361 if ( on ) 361 if ( on )
362 ((LauncherView*)stack->visibleWidget())->setBusy(TRUE); 362 ((LauncherView*)stack->visibleWidget())->setBusy(TRUE);
363 else 363 else
364 for (int i=0; i<tabs; i++) 364 for (int i=0; i<tabs; i++)
365 ((LauncherView*)stack->widget(i))->setBusy(FALSE); 365 ((LauncherView*)stack->widget(i))->setBusy(FALSE);
366} 366}
367 367
368LauncherView *CategoryTabWidget::view( const QString &id ) 368LauncherView *CategoryTabWidget::view( const QString &id )
369{ 369{
370 int idx = ids.findIndex( id ); 370 int idx = ids.findIndex( id );
371 return (LauncherView *)stack->widget(idx); 371 return (LauncherView *)stack->widget(idx);
372} 372}
373 373
374//=========================================================================== 374//===========================================================================
375 375
376CategoryTabBar::CategoryTabBar( QWidget *parent, const char *name ) 376CategoryTabBar::CategoryTabBar( QWidget *parent, const char *name )
377 : QTabBar( parent, name ) 377 : QTabBar( parent, name )
378{ 378{
379 setFocusPolicy( NoFocus ); 379 setFocusPolicy( NoFocus );
380 connect( this, SIGNAL( selected(int) ), this, SLOT( layoutTabs() ) ); 380 connect( this, SIGNAL( selected(int) ), this, SLOT( layoutTabs() ) );
381} 381}
382 382
383CategoryTabBar::~CategoryTabBar() 383CategoryTabBar::~CategoryTabBar()
384{ 384{
385} 385}
386 386
387void CategoryTabBar::layoutTabs() 387void CategoryTabBar::layoutTabs()
388{ 388{
389 if ( !count() ) 389 if ( !count() )
390 return; 390 return;
391 391
392// int percentFalloffTable[] = { 100, 70, 40, 12, 6, 3, 1, 0 }; 392// int percentFalloffTable[] = { 100, 70, 40, 12, 6, 3, 1, 0 };
393 int available = width()-1; 393 int available = width()-1;
394 QFontMetrics fm = fontMetrics(); 394 QFontMetrics fm = fontMetrics();
395 int hiddenTabWidth = -7; 395 int hiddenTabWidth = -7;
396 int middleTab = currentTab(); 396 int middleTab = currentTab();
397 int hframe, vframe, overlap; 397 int hframe, vframe, overlap;
398 style().tabbarMetrics( this, hframe, vframe, overlap ); 398 style().tabbarMetrics( this, hframe, vframe, overlap );
399 int x = 0; 399 int x = 0;
400 QRect r; 400 QRect r;
401 QTab *t; 401 QTab *t;
402 int required = 0; 402 int required = 0;
403 int eventabwidth = (width()-1)/count(); 403 int eventabwidth = (width()-1)/count();
404 enum Mode { HideBackText, Pack, Even } mode=Even; 404 enum Mode { HideBackText, Pack, Even } mode=Even;
405 for ( int i = 0; i < count(); i++ ) { 405 for ( int i = 0; i < count(); i++ ) {
406 t = tab(i); 406 t = tab(i);
407 int iw = fm.width( t->text() ) + hframe - overlap; 407 int iw = fm.width( t->text() ) + hframe - overlap;
408 if ( i != middleTab ) { 408 if ( i != middleTab ) {
409 available -= hiddenTabWidth + hframe - overlap; 409 available -= hiddenTabWidth + hframe - overlap;
410 if ( t->iconSet() != 0 ) 410 if ( t->iconSet() != 0 )
411 available -= t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); 411 available -= t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width();
412 } 412 }
413 if ( t->iconSet() != 0 ) 413 if ( t->iconSet() != 0 )
414 iw += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); 414 iw += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width();
415 required += iw; 415 required += iw;
416 // As space gets tight, packed looks better than even. "10" must be at least 0. 416 // As space gets tight, packed looks better than even. "10" must be at least 0.
417 if ( iw >= eventabwidth-10 ) 417 if ( iw >= eventabwidth-10 )
418 mode = Pack; 418 mode = Pack;
419 } 419 }
420 if ( mode == Pack && required > width()-1 ) 420 if ( mode == Pack && required > width()-1 )
421 mode = HideBackText; 421 mode = HideBackText;
422 for ( int i = 0; i < count(); i++ ) { 422 for ( int i = 0; i < count(); i++ ) {
423 t = tab(i); 423 t = tab(i);
424 if ( mode != HideBackText ) { 424 if ( mode != HideBackText ) {
425 int w = fm.width( t->text() ); 425 int w = fm.width( t->text() );
426 int ih = 0; 426 int ih = 0;
427 if ( t->iconSet() != 0 ) { 427 if ( t->iconSet() != 0 ) {
428 w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); 428 w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width();
429 ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); 429 ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height();
430 } 430 }
431 int h = QMAX( fm.height(), ih ); 431 int h = QMAX( fm.height(), ih );
432 h = QMAX( h, QApplication::globalStrut().height() ); 432 h = QMAX( h, QApplication::globalStrut().height() );
433 433
434 h += vframe; 434 h += vframe;
435 w += hframe; 435 w += hframe;
436 436
437 QRect tr(x, 0, 437 QRect tr(x, 0,
438 mode == Even ? eventabwidth : w * (width()-1)/required, h); 438 mode == Even ? eventabwidth : w * (width()-1)/required, h);
439 t->setRect(tr); 439 t->setRect(tr);
440 x += tr.width() - overlap; 440 x += tr.width() - overlap;
441 r = r.unite(tr); 441 r = r.unite(tr);
442 } else if ( i != middleTab ) { 442 } else if ( i != middleTab ) {
443 int w = hiddenTabWidth; 443 int w = hiddenTabWidth;
444 int ih = 0; 444 int ih = 0;
445 if ( t->iconSet() != 0 ) { 445 if ( t->iconSet() != 0 ) {
446 w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); 446 w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width();
447 ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); 447 ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height();
448 } 448 }
449 int h = QMAX( fm.height(), ih ); 449 int h = QMAX( fm.height(), ih );
450 h = QMAX( h, QApplication::globalStrut().height() ); 450 h = QMAX( h, QApplication::globalStrut().height() );
451 451
452 h += vframe; 452 h += vframe;
453 w += hframe; 453 w += hframe;
454 454
455 t->setRect( QRect(x, 0, w, h) ); 455 t->setRect( QRect(x, 0, w, h) );
456 x += t->rect().width() - overlap; 456 x += t->rect().width() - overlap;
457 r = r.unite( t->rect() ); 457 r = r.unite( t->rect() );
458 } else { 458 } else {
459 int ih = 0; 459 int ih = 0;
460 if ( t->iconSet() != 0 ) { 460 if ( t->iconSet() != 0 ) {
461 ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); 461 ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height();
462 } 462 }
463 int h = QMAX( fm.height(), ih ); 463 int h = QMAX( fm.height(), ih );
464 h = QMAX( h, QApplication::globalStrut().height() ); 464 h = QMAX( h, QApplication::globalStrut().height() );
465 465
466 h += vframe; 466 h += vframe;
467 467
468 t->setRect( QRect(x, 0, available, h) ); 468 t->setRect( QRect(x, 0, available, h) );
469 x += t->rect().width() - overlap; 469 x += t->rect().width() - overlap;
470 r = r.unite( t->rect() ); 470 r = r.unite( t->rect() );
471 } 471 }
472 } 472 }
473 473
474 QRect rr = tab(count()-1)->rect(); 474 QRect rr = tab(count()-1)->rect();
475 rr.setRight(width()-1); 475 rr.setRight(width()-1);
476 tab(count()-1)->setRect( rr ); 476 tab(count()-1)->setRect( rr );
477 477
478 for ( t = tabList()->first(); t; t = tabList()->next() ) { 478 for ( t = tabList()->first(); t; t = tabList()->next() ) {
479 QRect tr = t->rect(); 479 QRect tr = t->rect();
480 tr.setHeight( r.height() ); 480 tr.setHeight( r.height() );
481 t->setRect( tr ); 481 t->setRect( tr );
482 } 482 }
483 483
484 update(); 484 update();
485} 485}
486 486
487 487
488void CategoryTabBar::paint( QPainter * p, QTab * t, bool selected ) const 488void CategoryTabBar::paint( QPainter * p, QTab * t, bool selected ) const
489{ 489{
490 CategoryTabBar *that = (CategoryTabBar *) this; 490 CategoryTabBar *that = (CategoryTabBar *) this;
491 CategoryTab *ct = (CategoryTab *)t; 491 CategoryTab *ct = (CategoryTab *)t;
492 QPalette pal = palette(); 492 QPalette pal = palette();
493 bool setPal = FALSE; 493 bool setPal = FALSE;
494 if ( ct->bgColor.isValid() ) { 494 if ( ct->bgColor.isValid() ) {
495 pal.setColor( QPalette::Active, QColorGroup::Background, ct->bgColor ); 495 pal.setColor( QPalette::Active, QColorGroup::Background, ct->bgColor );
496 pal.setColor( QPalette::Active, QColorGroup::Button, ct->bgColor ); 496 pal.setColor( QPalette::Active, QColorGroup::Button, ct->bgColor );
497 pal.setColor( QPalette::Inactive, QColorGroup::Background, ct->bgColor ); 497 pal.setColor( QPalette::Inactive, QColorGroup::Background, ct->bgColor );
498 pal.setColor( QPalette::Inactive, QColorGroup::Button, ct->bgColor ); 498 pal.setColor( QPalette::Inactive, QColorGroup::Button, ct->bgColor );
499 that->setUpdatesEnabled( FALSE ); 499 that->setUpdatesEnabled( FALSE );
500 that->setPalette( pal ); 500 that->setPalette( pal );
501 setPal = TRUE; 501 setPal = TRUE;
502 } 502 }
503#if QT_VERSION >= 300 503#if QT_VERSION >= 300
504 QStyle::SFlags flags = QStyle::Style_Default; 504 QStyle::SFlags flags = QStyle::Style_Default;
505 if ( selected ) 505 if ( selected )
506 flags |= QStyle::Style_Selected; 506 flags |= QStyle::Style_Selected;
507 style().drawControl( QStyle::CE_TabBarTab, p, this, t->rect(), 507 style().drawControl( QStyle::CE_TabBarTab, p, this, t->rect(),
508 colorGroup(), flags, QStyleOption(t) ); 508 colorGroup(), flags, QStyleOption(t) );
509#else 509#else
510 style().drawTab( p, this, t, selected ); 510 style().drawTab( p, this, t, selected );
511#endif 511#endif
512 512
513 QRect r( t->rect() ); 513 QRect r( t->rect() );
514 QFont f( font() ); 514 QFont f( font() );
515 if ( selected ) 515 if ( selected )
516 f.setBold( TRUE ); 516 f.setBold( TRUE );
517 p->setFont( f ); 517 p->setFont( f );
518 518
519 if ( ct->fgColor.isValid() ) { 519 if ( ct->fgColor.isValid() ) {
520 pal.setColor( QPalette::Active, QColorGroup::Foreground, ct->fgColor ); 520 pal.setColor( QPalette::Active, QColorGroup::Foreground, ct->fgColor );
521 pal.setColor( QPalette::Inactive, QColorGroup::Foreground, ct->fgColor ); 521 pal.setColor( QPalette::Inactive, QColorGroup::Foreground, ct->fgColor );
522 that->setUpdatesEnabled( FALSE ); 522 that->setUpdatesEnabled( FALSE );
523 that->setPalette( pal ); 523 that->setPalette( pal );
524 setPal = TRUE; 524 setPal = TRUE;
525 } 525 }
526 int iw = 0; 526 int iw = 0;
527 int ih = 0; 527 int ih = 0;
528 if ( t->iconSet() != 0 ) { 528 if ( t->iconSet() != 0 ) {
529 iw = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width() + 2; 529 iw = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width() + 2;
530 ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); 530 ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height();
531 } 531 }
532 int w = iw + p->fontMetrics().width( t->text() ) + 4; 532 int w = iw + p->fontMetrics().width( t->text() ) + 4;
533 int h = QMAX(p->fontMetrics().height() + 4, ih ); 533 int h = QMAX(p->fontMetrics().height() + 4, ih );
534 paintLabel( p, QRect( r.left() + (r.width()-w)/2 - 3, 534 paintLabel( p, QRect( r.left() + (r.width()-w)/2 - 3,
535 r.top() + (r.height()-h)/2, w, h ), t, 535 r.top() + (r.height()-h)/2, w, h ), t,
536#if QT_VERSION >= 300 536#if QT_VERSION >= 300
537 t->identifier() == keyboardFocusTab() 537 t->identifier() == keyboardFocusTab()
538#else 538#else
539 t->identitifer() == keyboardFocusTab() 539 t->identitifer() == keyboardFocusTab()
540#endif 540#endif
541 ); 541 );
542 if ( setPal ) { 542 if ( setPal ) {
543 that->unsetPalette(); 543 that->unsetPalette();
544 that->setUpdatesEnabled( TRUE ); 544 that->setUpdatesEnabled( TRUE );
545 } 545 }
546} 546}
547 547
548 548
549void CategoryTabBar::paintLabel( QPainter* p, const QRect&, 549void CategoryTabBar::paintLabel( QPainter* p, const QRect&,
550 QTab* t, bool has_focus ) const 550 QTab* t, bool has_focus ) const
551{ 551{
552 QRect r = t->rect(); 552 QRect r = t->rect();
553 // if ( t->id != currentTab() ) 553 // if ( t->id != currentTab() )
554 //r.moveBy( 1, 1 ); 554 //r.moveBy( 1, 1 );
555 // 555 //
556 if ( t->iconSet() ) { 556 if ( t->iconSet() ) {
557 // the tab has an iconset, draw it in the right mode 557 // the tab has an iconset, draw it in the right mode
558 QIconSet::Mode mode = (t->isEnabled() && isEnabled()) ? QIconSet::Normal : QIconSet::Disabled; 558 QIconSet::Mode mode = (t->isEnabled() && isEnabled()) ? QIconSet::Normal : QIconSet::Disabled;
559 if ( mode == QIconSet::Normal && has_focus ) 559 if ( mode == QIconSet::Normal && has_focus )
560 mode = QIconSet::Active; 560 mode = QIconSet::Active;
561 QPixmap pixmap = t->iconSet()->pixmap( QIconSet::Small, mode ); 561 QPixmap pixmap = t->iconSet()->pixmap( QIconSet::Small, mode );
562 int pixw = pixmap.width(); 562 int pixw = pixmap.width();
563 int pixh = pixmap.height(); 563 int pixh = pixmap.height();
564 p->drawPixmap( r.left() + 6, r.center().y() - pixh / 2 + 1, pixmap ); 564 p->drawPixmap( r.left() + 6, r.center().y() - pixh / 2 + 1, pixmap );
565 r.setLeft( r.left() + pixw + 5 ); 565 r.setLeft( r.left() + pixw + 5 );
566 } 566 }
567 567
568 QRect tr = r; 568 QRect tr = r;
569 569
570 if ( r.width() < 20 ) 570 if ( r.width() < 20 )
571 return; 571 return;
572 572
573 if ( t->isEnabled() && isEnabled() ) { 573 if ( t->isEnabled() && isEnabled() ) {
574#if defined(_WS_WIN32_) 574#if defined(_WS_WIN32_)
575 if ( colorGroup().brush( QColorGroup::Button ) == colorGroup().brush( QColorGroup::Background ) ) 575 if ( colorGroup().brush( QColorGroup::Button ) == colorGroup().brush( QColorGroup::Background ) )
576 p->setPen( colorGroup().buttonText() ); 576 p->setPen( colorGroup().buttonText() );
577 else 577 else
578 p->setPen( colorGroup().foreground() ); 578 p->setPen( colorGroup().foreground() );
579#else 579#else
580 p->setPen( colorGroup().foreground() ); 580 p->setPen( colorGroup().foreground() );
581#endif 581#endif
582 p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); 582 p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() );
583 } else { 583 } else {
584 p->setPen( palette().disabled().foreground() ); 584 p->setPen( palette().disabled().foreground() );
585 p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); 585 p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() );
586 } 586 }
587} 587}
588 588
589//--------------------------------------------------------------------------- 589//---------------------------------------------------------------------------
590 590
591Launcher::Launcher( QWidget* parent, const char* name, WFlags fl ) 591Launcher::Launcher( QWidget* parent, const char* name, WFlags fl )
592 : QMainWindow( parent, name, fl ) 592 : QMainWindow( parent, name, fl )
593{ 593{
594 setCaption( tr("Launcher") ); 594 setCaption( tr("Launcher") );
595 595
596 syncDialog = 0; 596 syncDialog = 0;
597 597
598 // we have a pretty good idea how big we'll be 598 // we have a pretty good idea how big we'll be
599 setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() ); 599 setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() );
600 600
601 tabs = 0; 601 tabs = 0;
602 rootFolder = 0; 602 rootFolder = 0;
603 docsFolder = 0; 603 docsFolder = 0;
604 604
605 int stamp = uidgen.generate(); // this is our timestamp to see which devices we know 605 int stamp = uidgen.generate(); // this is our timestamp to see which devices we know
606 //uidgen.store( stamp ); 606 //uidgen.store( stamp );
607 m_timeStamp = QString::number( stamp ); 607 m_timeStamp = QString::number( stamp );
608 608
609 tabs = new CategoryTabWidget( this ); 609 tabs = new CategoryTabWidget( this );
610 tabs->setMaximumWidth( qApp->desktop()->width() ); 610 tabs->setMaximumWidth( qApp->desktop()->width() );
611 setCentralWidget( tabs ); 611 setCentralWidget( tabs );
612 612
613 connect( tabs, SIGNAL(selected(const QString&)), 613 connect( tabs, SIGNAL(selected(const QString&)),
614 this, SLOT(viewSelected(const QString&)) ); 614 this, SLOT(viewSelected(const QString&)) );
615 connect( tabs, SIGNAL(clicked(const AppLnk*)), 615 connect( tabs, SIGNAL(clicked(const AppLnk*)),
616 this, SLOT(select(const AppLnk*))); 616 this, SLOT(select(const AppLnk*)));
617 connect( tabs, SIGNAL(rightPressed(AppLnk*)), 617 connect( tabs, SIGNAL(rightPressed(AppLnk*)),
618 this, SLOT(properties(AppLnk*))); 618 this, SLOT(properties(AppLnk*)));
619 619
620#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 620#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
621 QCopChannel* sysChannel = new QCopChannel( "QPE/System", this ); 621 QCopChannel* sysChannel = new QCopChannel( "QPE/System", this );
622 connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)), 622 connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)),
623 this, SLOT(systemMessage( const QCString &, const QByteArray &)) ); 623 this, SLOT(systemMessage( const QCString &, const QByteArray &)) );
624 QCopChannel *channel = new QCopChannel( "QPE/Launcher", this ); 624 QCopChannel *channel = new QCopChannel( "QPE/Launcher", this );
625 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 625 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
626 this, SLOT(launcherMessage(const QCString&, const QByteArray&)) ); 626 this, SLOT(launcherMessage(const QCString&, const QByteArray&)) );
627#endif 627#endif
628 628
629 storage = new StorageInfo( this ); 629 storage = new StorageInfo( this );
630 connect( storage, SIGNAL( disksChanged() ), SLOT( storageChanged() ) ); 630 connect( storage, SIGNAL( disksChanged() ), SLOT( storageChanged() ) );
631 631
632 updateTabs(); 632 updateTabs();
633 633
634 preloadApps(); 634 preloadApps();
635 635
636 in_lnk_props = FALSE; 636 in_lnk_props = FALSE;
637 got_lnk_change = FALSE; 637 got_lnk_change = FALSE;
638} 638}
639 639
640Launcher::~Launcher() 640Launcher::~Launcher()
641{ 641{
642 delete rootFolder; 642 delete rootFolder;
643 delete docsFolder; 643 delete docsFolder;
644} 644}
645 645
646static bool isVisibleWindow(int wid) 646static bool isVisibleWindow(int wid)
647{ 647{
648#ifdef QWS 648#ifdef QWS
649 const QList<QWSWindow> &list = qwsServer->clientWindows(); 649 const QList<QWSWindow> &list = qwsServer->clientWindows();
650 QWSWindow* w; 650 QWSWindow* w;
651 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { 651 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) {
652 if ( w->winId() == wid ) 652 if ( w->winId() == wid )
653 return !w->isFullyObscured(); 653 return !w->isFullyObscured();
654 } 654 }
655#endif 655#endif
656 return FALSE; 656 return FALSE;
657} 657}
658 658
659void Launcher::showMaximized() 659void Launcher::showMaximized()
660{ 660{
661 if ( isVisibleWindow( winId() ) ) 661 if ( isVisibleWindow( winId() ) )
662 doMaximize(); 662 doMaximize();
663 else 663 else
664 QTimer::singleShot( 20, this, SLOT(doMaximize()) ); 664 QTimer::singleShot( 20, this, SLOT(doMaximize()) );
665} 665}
666 666
667void Launcher::doMaximize() 667void Launcher::doMaximize()
668{ 668{
669 QMainWindow::showMaximized(); 669 QMainWindow::showMaximized();
670} 670}
671 671
672void Launcher::updateMimeTypes() 672void Launcher::updateMimeTypes()
673{ 673{
674 MimeType::clear(); 674 MimeType::clear();
675 updateMimeTypes(rootFolder); 675 updateMimeTypes(rootFolder);
676} 676}
677 677
678void Launcher::updateMimeTypes(AppLnkSet* folder) 678void Launcher::updateMimeTypes(AppLnkSet* folder)
679{ 679{
680 for ( QListIterator<AppLnk> it( folder->children() ); it.current(); ++it ) { 680 for ( QListIterator<AppLnk> it( folder->children() ); it.current(); ++it ) {
681 AppLnk *app = it.current(); 681 AppLnk *app = it.current();
682 if ( app->type() == "Folder" ) // No tr 682 if ( app->type() == "Folder" ) // No tr
683 updateMimeTypes((AppLnkSet *)app); 683 updateMimeTypes((AppLnkSet *)app);
684 else { 684 else {
685 MimeType::registerApp(*app); 685 MimeType::registerApp(*app);
686 } 686 }
687 } 687 }
688} 688}
689 689
690/** This is a HACK.... 690/** This is a HACK....
691 * Reason: scanning huge mediums, microdirvers for examples 691 * Reason: scanning huge mediums, microdirvers for examples
692 * consomes time. To avoid that we invented the MediumMountCheck 692 * consomes time. To avoid that we invented the MediumMountCheck
693 * 693 *
694 * a) the user globally disabled medium checking. We can ignore 694 * a) the user globally disabled medium checking. We can ignore
695 * all removable medium 695 * all removable medium
696 * b) the user enabled medium checking globally and we need to use this mimefilter 696 * b) the user enabled medium checking globally and we need to use this mimefilter
697 * c) the user enabled medium checking on a per medium bases 697 * c) the user enabled medium checking on a per medium bases
698 * c1) we already checked and its not ask again turns 698 * c1) we already checked and its not ask again turns
699 * c2) we need to ask and then apply the mimefilter 699 * c2) we need to ask and then apply the mimefilter
700 */ 700 */
701void Launcher::loadDocs() // ok here comes a hack belonging to Global:: 701void Launcher::loadDocs() // ok here comes a hack belonging to Global::
702{ 702{
703 delete docsFolder; 703 delete docsFolder;
704 docsFolder = new DocLnkSet; 704 docsFolder = new DocLnkSet;
705 705
706 DocLnkSet *tmp = 0; 706 DocLnkSet *tmp = 0;
707 QString home = QString(getenv("HOME")) + "/Documents"; 707 QString home = QString(getenv("HOME")) + "/Documents";
708 tmp = new DocLnkSet( home , QString::null); 708 tmp = new DocLnkSet( home , QString::null);
709 docsFolder->appendFrom( *tmp ); 709 docsFolder->appendFrom( *tmp );
710 delete tmp; 710 delete tmp;
711 711
712 // RAM documents 712 // RAM documents
713 StorageInfo storage; 713 StorageInfo storage;
714 const QList<FileSystem> &fileSystems = storage.fileSystems(); 714 const QList<FileSystem> &fileSystems = storage.fileSystems();
715 QListIterator<FileSystem> it ( fileSystems ); 715 QListIterator<FileSystem> it ( fileSystems );
716 716
717 for ( ; it.current(); ++it ) { 717 for ( ; it.current(); ++it ) {
718 if ( (*it)->disk() == "/dev/mtdblock6" || (*it)->disk() == "tmpfs" ) { 718 if ( (*it)->disk() == "/dev/mtdblock6" || (*it)->disk() == "tmpfs" ) {
719 tmp = new DocLnkSet( (*it)->path(), QString::null ); 719 tmp = new DocLnkSet( (*it)->path(), QString::null );
720 docsFolder->appendFrom( *tmp ); 720 docsFolder->appendFrom( *tmp );
721 delete tmp; 721 delete tmp;
722 } 722 }
723 } 723 }
724 724
725 Config mediumCfg( "medium"); 725 Config mediumCfg( "medium");
726 mediumCfg.setGroup("main"); 726 mediumCfg.setGroup("main");
727 // a) -zecke we don't want to check 727 // a) -zecke we don't want to check
728 if(!mediumCfg.readBoolEntry("use", true ) ) 728 if(!mediumCfg.readBoolEntry("use", true ) )
729 return; 729 return;
730 730
731 // find out wich filesystems are new in this round 731 // find out wich filesystems are new in this round
732 // We will do this by having a timestamp inside each mountpoint 732 // We will do this by having a timestamp inside each mountpoint
733 // if the current timestamp doesn't match this is a new file system and 733 // if the current timestamp doesn't match this is a new file system and
734 // come up with our MediumMountGui :) let the hacking begin 734 // come up with our MediumMountGui :) let the hacking begin
735 int stamp = uidgen.generate(); 735 int stamp = uidgen.generate();
736 736
737 QString newStamp = QString::number( stamp ); // generates newtime Stamp 737 QString newStamp = QString::number( stamp ); // generates newtime Stamp
738 738
739 // b) 739 // b)
740 if( mediumCfg.readBoolEntry("global", true ) ){ 740 if( mediumCfg.readBoolEntry("global", true ) ){
741 QString mime = configToMime(&mediumCfg).join(";"); 741 QString mime = configToMime(&mediumCfg).join(";");
742 for( it.toFirst(); it.current(); ++it ){ 742 for( it.toFirst(); it.current(); ++it ){
743 if( (*it)->isRemovable() ){ 743 if( (*it)->isRemovable() ){
744 tmp = new DocLnkSet( (*it)->path(), mime ); 744 tmp = new DocLnkSet( (*it)->path(), mime );
745 docsFolder->appendFrom( *tmp ); 745 docsFolder->appendFrom( *tmp );
746 delete tmp; 746 delete tmp;
747 } 747 }
748 } // done 748 } // done
749 return; // save the else 749 return; // save the else
750 } 750 }
751 // c) zecke 751 // c) zecke
752 for ( it.toFirst(); it.current(); ++it ) { 752 for ( it.toFirst(); it.current(); ++it ) {
753 if ( (*it)->isRemovable() ) { // let's find out if we should search on it 753 if ( (*it)->isRemovable() ) { // let's find out if we should search on it
754 Config cfg( (*it)->path() + "/.opiestorage.cf", Config::File); 754 Config cfg( (*it)->path() + "/.opiestorage.cf", Config::File);
755 cfg.setGroup("main"); 755 cfg.setGroup("main");
756 QString stamp = cfg.readEntry("timestamp", QDateTime::currentDateTime().toString() ); 756 QString stamp = cfg.readEntry("timestamp", QDateTime::currentDateTime().toString() );
757 /** This medium is uptodate 757 /** This medium is uptodate
758 */ 758 */
759 if( stamp == m_timeStamp ){ // ok we know this card 759 if( stamp == m_timeStamp ){ // ok we know this card
760 cfg.writeEntry("timestamp", newStamp ); //just write a new timestamp 760 cfg.writeEntry("timestamp", newStamp ); //just write a new timestamp
761 // we need to scan the list now. Hopefully the cache will be there 761 // we need to scan the list now. Hopefully the cache will be there
762 // read the mimetypes from the config and search for documents 762 // read the mimetypes from the config and search for documents
763 QStringList mimetypes = configToMime( &cfg); 763 QStringList mimetypes = configToMime( &cfg);
764 tmp = new DocLnkSet( (*it)->path(), mimetypes.join(";") ); 764 tmp = new DocLnkSet( (*it)->path(), mimetypes.join(";") );
765 docsFolder->appendFrom( *tmp ); 765 docsFolder->appendFrom( *tmp );
766 delete tmp; 766 delete tmp;
767 767
768 }else{ // come up with the gui cause this a new card 768 }else{ // come up with the gui cause this a new card
769 MediumMountGui medium(&cfg, (*it)->path() ); 769 MediumMountGui medium(&cfg, (*it)->path() );
770 if( medium.check() ){ // we did not ask before or ask again is off 770 if( medium.check() ){ // we did not ask before or ask again is off
771 /** c2) */ 771 /** c2) */
772 if( medium.exec() ){ // he clicked yes so search it 772 if( medium.exec() ){ // he clicked yes so search it
773 // speicher 773 // speicher
774 //cfg.read(); // cause of a race we need to reread - fixed 774 //cfg.read(); // cause of a race we need to reread - fixed
775 cfg.setGroup("main"); 775 cfg.setGroup("main");
776 cfg.writeEntry("timestamp", newStamp ); 776 cfg.writeEntry("timestamp", newStamp );
777 cfg.write(); 777 cfg.write();
778 tmp = new DocLnkSet( (*it)->path(), medium.mimeTypes().join(";" ) ); 778 tmp = new DocLnkSet( (*it)->path(), medium.mimeTypes().join(";" ) );
779 docsFolder->appendFrom( *tmp ); 779 docsFolder->appendFrom( *tmp );
780 delete tmp; 780 delete tmp;