summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/launcher.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp
index 98e7481..7887704 100644
--- a/core/launcher/launcher.cpp
+++ b/core/launcher/launcher.cpp
@@ -134,645 +134,648 @@ void LauncherTabWidget::createDocLoadingWidget()
134 Config cfg( "Launcher" ); 134 Config cfg( "Launcher" );
135 cfg.setGroup( "DocTab" ); 135 cfg.setGroup( "DocTab" );
136 bool docTabEnabled = cfg.readBoolEntry( "Enable", true ); 136 bool docTabEnabled = cfg.readBoolEntry( "Enable", true );
137 137
138 QLabel *textLabel = new QLabel( docLoadingVBox ); 138 QLabel *textLabel = new QLabel( docLoadingVBox );
139 textLabel->setAlignment( int( QLabel::AlignCenter ) ); 139 textLabel->setAlignment( int( QLabel::AlignCenter ) );
140 docLoadingWidgetProgress = new QProgressBar( docLoadingVBox ); 140 docLoadingWidgetProgress = new QProgressBar( docLoadingVBox );
141 docLoadingWidgetProgress->setProgress( 0 ); 141 docLoadingWidgetProgress->setProgress( 0 );
142 docLoadingWidgetProgress->setCenterIndicator( TRUE ); 142 docLoadingWidgetProgress->setCenterIndicator( TRUE );
143 docLoadingWidgetProgress->setBackgroundMode( NoBackground ); // No flicker 143 docLoadingWidgetProgress->setBackgroundMode( NoBackground ); // No flicker
144 setProgressStyle(); 144 setProgressStyle();
145 145
146 if ( docTabEnabled ) 146 if ( docTabEnabled )
147 { 147 {
148 textLabel->setText( tr( "<b>Finding Documents...</b>" ) ); 148 textLabel->setText( tr( "<b>Finding Documents...</b>" ) );
149 } 149 }
150 else 150 else
151 { 151 {
152 textLabel->setText( tr( "<b>The Documents Tab<p>has been disabled.<p>" 152 textLabel->setText( tr( "<b>The Documents Tab<p>has been disabled.<p>"
153 "Use Settings->Launcher->DocTab<p>to reenable it.</b></center>" ) ); 153 "Use Settings->Launcher->DocTab<p>to reenable it.</b></center>" ) );
154 docLoadingWidgetProgress->hide(); 154 docLoadingWidgetProgress->hide();
155 docLoadingWidgetEnabled = true; 155 docLoadingWidgetEnabled = true;
156 } 156 }
157 157
158 QWidget *space2 = new QWidget( docLoadingVBox ); 158 QWidget *space2 = new QWidget( docLoadingVBox );
159 docLoadingVBox->setStretchFactor( space2, 1 ); 159 docLoadingVBox->setStretchFactor( space2, 1 );
160 160
161 cfg.setGroup( "Tab Documents" ); // No tr 161 cfg.setGroup( "Tab Documents" ); // No tr
162 setTabViewAppearance( docLoadingWidget, cfg ); 162 setTabViewAppearance( docLoadingWidget, cfg );
163 163
164 stack->addWidget( docLoadingWidget, 0 ); 164 stack->addWidget( docLoadingWidget, 0 );
165} 165}
166 166
167void LauncherTabWidget::initLayout() 167void LauncherTabWidget::initLayout()
168{ 168{
169 layout()->activate(); 169 layout()->activate();
170 docView()->setFocus(); 170 docView()->setFocus();
171 categoryBar->showTab("Documents"); 171 categoryBar->showTab("Documents");
172} 172}
173 173
174void LauncherTabWidget::appMessage(const QCString& message, const QByteArray&) 174void LauncherTabWidget::appMessage(const QCString& message, const QByteArray&)
175{ 175{
176 if ( message == "nextView()" ) 176 if ( message == "nextView()" )
177 categoryBar->nextTab(); 177 categoryBar->nextTab();
178} 178}
179 179
180void LauncherTabWidget::raiseTabWidget() 180void LauncherTabWidget::raiseTabWidget()
181{ 181{
182 if ( categoryBar->currentView() == docView() 182 if ( categoryBar->currentView() == docView()
183 && docLoadingWidgetEnabled ) { 183 && docLoadingWidgetEnabled ) {
184 stack->raiseWidget( docLoadingWidget ); 184 stack->raiseWidget( docLoadingWidget );
185 docLoadingWidget->updateGeometry(); 185 docLoadingWidget->updateGeometry();
186 } else { 186 } else {
187 stack->raiseWidget( categoryBar->currentView() ); 187 stack->raiseWidget( categoryBar->currentView() );
188 } 188 }
189} 189}
190 190
191void LauncherTabWidget::tabProperties() 191void LauncherTabWidget::tabProperties()
192{ 192{
193 LauncherView *view = categoryBar->currentView(); 193 LauncherView *view = categoryBar->currentView();
194 QPopupMenu *m = new QPopupMenu( this ); 194 QPopupMenu *m = new QPopupMenu( this );
195 m->insertItem( tr("Icon View"), LauncherView::Icon ); 195 m->insertItem( tr("Icon View"), LauncherView::Icon );
196 m->insertItem( tr("List View"), LauncherView::List ); 196 m->insertItem( tr("List View"), LauncherView::List );
197 m->setItemChecked( (int)view->viewMode(), TRUE ); 197 m->setItemChecked( (int)view->viewMode(), TRUE );
198 int rv = m->exec( QCursor::pos() ); 198 int rv = m->exec( QCursor::pos() );
199 if ( rv >= 0 && rv != view->viewMode() ) { 199 if ( rv >= 0 && rv != view->viewMode() ) {
200 view->setViewMode( (LauncherView::ViewMode)rv ); 200 view->setViewMode( (LauncherView::ViewMode)rv );
201 } 201 }
202 202
203 delete m; 203 delete m;
204} 204}
205 205
206void LauncherTabWidget::deleteView( const QString& id ) 206void LauncherTabWidget::deleteView( const QString& id )
207{ 207{
208 LauncherTab *t = categoryBar->launcherTab(id); 208 LauncherTab *t = categoryBar->launcherTab(id);
209 if ( t ) { 209 if ( t ) {
210 stack->removeWidget( t->view ); 210 stack->removeWidget( t->view );
211 delete t->view; 211 delete t->view;
212 categoryBar->removeTab( t ); 212 categoryBar->removeTab( t );
213 } 213 }
214} 214}
215 215
216LauncherView* LauncherTabWidget::newView( const QString& id, const QPixmap& pm, const QString& label ) 216LauncherView* LauncherTabWidget::newView( const QString& id, const QPixmap& pm, const QString& label )
217{ 217{
218 LauncherView* view = new LauncherView( stack ); 218 LauncherView* view = new LauncherView( stack );
219 connect( view, SIGNAL(clicked(const AppLnk*)), 219 connect( view, SIGNAL(clicked(const AppLnk*)),
220 this, SIGNAL(clicked(const AppLnk*))); 220 this, SIGNAL(clicked(const AppLnk*)));
221 connect( view, SIGNAL(rightPressed(AppLnk*)), 221 connect( view, SIGNAL(rightPressed(AppLnk*)),
222 this, SIGNAL(rightPressed(AppLnk*))); 222 this, SIGNAL(rightPressed(AppLnk*)));
223 223
224 int n = categoryBar->count(); 224 int n = categoryBar->count();
225 stack->addWidget( view, n ); 225 stack->addWidget( view, n );
226 226
227 LauncherTab *tab = new LauncherTab( id, view, pm, label ); 227 LauncherTab *tab = new LauncherTab( id, view, pm, label );
228 categoryBar->insertTab( tab, n-1 ); 228 categoryBar->insertTab( tab, n-1 );
229 229
230 if ( id == "Documents" ) 230 if ( id == "Documents" )
231 docview = view; 231 docview = view;
232 232
233 qDebug("inserting %s at %d", id.latin1(), n-1 ); 233 qDebug("inserting %s at %d", id.latin1(), n-1 );
234 234
235 Config cfg("Launcher"); 235 Config cfg("Launcher");
236 setTabAppearance( tab, cfg ); 236 setTabAppearance( tab, cfg );
237 237
238 cfg.setGroup( "GUI" ); 238 cfg.setGroup( "GUI" );
239 view->setBusyIndicatorType( cfg.readEntry( "BusyType", QString::null ) ); 239 view->setBusyIndicatorType( cfg.readEntry( "BusyType", QString::null ) );
240 240
241 return view; 241 return view;
242} 242}
243 243
244LauncherView *LauncherTabWidget::view( const QString &id ) 244LauncherView *LauncherTabWidget::view( const QString &id )
245{ 245{
246 LauncherTab *t = categoryBar->launcherTab(id); 246 LauncherTab *t = categoryBar->launcherTab(id);
247 if ( !t ) 247 if ( !t )
248 return 0; 248 return 0;
249 return t->view; 249 return t->view;
250} 250}
251 251
252LauncherView *LauncherTabWidget::docView() 252LauncherView *LauncherTabWidget::docView()
253{ 253{
254 return docview; 254 return docview;
255} 255}
256 256
257void LauncherTabWidget::setLoadingWidgetEnabled( bool v ) 257void LauncherTabWidget::setLoadingWidgetEnabled( bool v )
258{ 258{
259 if ( v != docLoadingWidgetEnabled && docLoadingWidget ) { 259 if ( v != docLoadingWidgetEnabled && docLoadingWidget ) {
260 docLoadingWidgetEnabled = v; 260 docLoadingWidgetEnabled = v;
261 raiseTabWidget(); 261 raiseTabWidget();
262 } 262 }
263} 263}
264 264
265void LauncherTabWidget::setLoadingProgress( int percent ) 265void LauncherTabWidget::setLoadingProgress( int percent )
266{ 266{
267 docLoadingWidgetProgress->setProgress( (percent / 4) * 4 ); 267 docLoadingWidgetProgress->setProgress( (percent / 4) * 4 );
268} 268}
269 269
270// ### this function could more to LauncherView 270// ### this function could more to LauncherView
271void LauncherTabWidget::setTabViewAppearance( LauncherView *v, Config &cfg ) 271void LauncherTabWidget::setTabViewAppearance( LauncherView *v, Config &cfg )
272{ 272{
273 // View 273 // View
274 QString view = cfg.readEntry( "View", "Icon" ); 274 QString view = cfg.readEntry( "View", "Icon" );
275 if ( view == "List" ) // No tr 275 if ( view == "List" ) // No tr
276 v->setViewMode( LauncherView::List ); 276 v->setViewMode( LauncherView::List );
277 QString bgType = cfg.readEntry( "BackgroundType", "Image" ); 277 QString bgType = cfg.readEntry( "BackgroundType", "Image" );
278 if ( bgType == "Image" ) { // No tr 278 if ( bgType == "Image" ) { // No tr
279 QString pm = cfg.readEntry( "BackgroundImage", "launcher/opie-background" ); 279 QString pm = cfg.readEntry( "BackgroundImage", "launcher/opie-background" );
280 v->setBackgroundType( LauncherView::Image, pm ); 280 v->setBackgroundType( LauncherView::Image, pm );
281 } else if ( bgType == "SolidColor" ) { 281 } else if ( bgType == "SolidColor" ) {
282 QString c = cfg.readEntry( "BackgroundColor" ); 282 QString c = cfg.readEntry( "BackgroundColor" );
283 v->setBackgroundType( LauncherView::SolidColor, c ); 283 v->setBackgroundType( LauncherView::SolidColor, c );
284 } else { 284 } else {
285 v->setBackgroundType( LauncherView::Ruled, QString::null ); 285 v->setBackgroundType( LauncherView::Ruled, QString::null );
286 } 286 }
287 QString textCol = cfg.readEntry( "TextColor" ); 287 QString textCol = cfg.readEntry( "TextColor" );
288 if ( textCol.isEmpty() ) 288 if ( textCol.isEmpty() )
289 v->setTextColor( QColor() ); 289 v->setTextColor( QColor() );
290 else 290 else
291 v->setTextColor( QColor(textCol) ); 291 v->setTextColor( QColor(textCol) );
292// bool customFont = cfg.readBoolEntry( "CustomFont", FALSE ); 292// bool customFont = cfg.readBoolEntry( "CustomFont", FALSE );
293 293
294 294
295 QStringList font = cfg.readListEntry( "Font", ',' ); 295 QStringList font = cfg.readListEntry( "Font", ',' );
296 if ( font.count() == 4 ) 296 if ( font.count() == 4 )
297 v->setViewFont( QFont(font[0], font[1].toInt(), font[2].toInt(), font[3].toInt()!=0) ); 297 v->setViewFont( QFont(font[0], font[1].toInt(), font[2].toInt(), font[3].toInt()!=0) );
298 298
299 // ### FIXME TabColor TabTextColor 299 // ### FIXME TabColor TabTextColor
300 300
301} 301}
302 302
303// ### Could move to LauncherTab 303// ### Could move to LauncherTab
304void LauncherTabWidget::setTabAppearance( LauncherTab *tab, Config &cfg ) 304void LauncherTabWidget::setTabAppearance( LauncherTab *tab, Config &cfg )
305{ 305{
306 cfg.setGroup( QString( "Tab %1" ).arg(tab->type) ); // No tr 306 cfg.setGroup( QString( "Tab %1" ).arg(tab->type) ); // No tr
307 307
308 setTabViewAppearance( tab->view, cfg ); 308 setTabViewAppearance( tab->view, cfg );
309 309
310 // Tabs 310 // Tabs
311 QString tabCol = cfg.readEntry( "TabColor" ); 311 QString tabCol = cfg.readEntry( "TabColor" );
312 if ( tabCol.isEmpty() ) 312 if ( tabCol.isEmpty() )
313 tab->bgColor = QColor(); 313 tab->bgColor = QColor();
314 else 314 else
315 tab->bgColor = QColor(tabCol); 315 tab->bgColor = QColor(tabCol);
316 QString tabTextCol = cfg.readEntry( "TabTextColor" ); 316 QString tabTextCol = cfg.readEntry( "TabTextColor" );
317 if ( tabTextCol.isEmpty() ) 317 if ( tabTextCol.isEmpty() )
318 tab->fgColor = QColor(); 318 tab->fgColor = QColor();
319 else 319 else
320 tab->fgColor = QColor(tabTextCol); 320 tab->fgColor = QColor(tabTextCol);
321} 321}
322 322
323void LauncherTabWidget::paletteChange( const QPalette &p ) 323void LauncherTabWidget::paletteChange( const QPalette &p )
324{ 324{
325 QVBox::paletteChange( p ); 325 QVBox::paletteChange( p );
326 QPalette pal = palette(); 326 QPalette pal = palette();
327 pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); 327 pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) );
328 pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); 328 pal.setColor( QColorGroup::Background, pal.active().background().light(110) );
329 categoryBar->setPalette( pal ); 329 categoryBar->setPalette( pal );
330 categoryBar->update(); 330 categoryBar->update();
331} 331}
332 332
333void LauncherTabWidget::styleChange( QStyle & ) 333void LauncherTabWidget::styleChange( QStyle & )
334{ 334{
335 QTimer::singleShot( 0, this, SLOT(setProgressStyle()) ); 335 QTimer::singleShot( 0, this, SLOT(setProgressStyle()) );
336} 336}
337 337
338void LauncherTabWidget::setProgressStyle() 338void LauncherTabWidget::setProgressStyle()
339{ 339{
340 if (docLoadingWidgetProgress) { 340 if (docLoadingWidgetProgress) {
341 docLoadingWidgetProgress->setFrameShape( QProgressBar::Box ); 341 docLoadingWidgetProgress->setFrameShape( QProgressBar::Box );
342 docLoadingWidgetProgress->setFrameShadow( QProgressBar::Plain ); 342 docLoadingWidgetProgress->setFrameShadow( QProgressBar::Plain );
343 docLoadingWidgetProgress->setMargin( 1 ); 343 docLoadingWidgetProgress->setMargin( 1 );
344 docLoadingWidgetProgress->setLineWidth( 1 ); 344 docLoadingWidgetProgress->setLineWidth( 1 );
345 } 345 }
346} 346}
347 347
348void LauncherTabWidget::setBusy(bool on) 348void LauncherTabWidget::setBusy(bool on)
349{ 349{
350 if ( on ) 350 if ( on )
351 currentView()->setBusy(TRUE); 351 currentView()->setBusy(TRUE);
352 else { 352 else {
353 for ( int i = 0; i < categoryBar->count(); i++ ) { 353 for ( int i = 0; i < categoryBar->count(); i++ ) {
354 LauncherView *view = ((LauncherTab *)categoryBar->tab(i))->view; 354 LauncherView *view = ((LauncherTab *)categoryBar->tab(i))->view;
355 view->setBusy( FALSE ); 355 view->setBusy( FALSE );
356 } 356 }
357 } 357 }
358} 358}
359 359
360void LauncherTabWidget::setBusyIndicatorType( const QString& str ) { 360void LauncherTabWidget::setBusyIndicatorType( const QString& str ) {
361 for (int i = 0; i < categoryBar->count(); i++ ) { 361 for (int i = 0; i < categoryBar->count(); i++ ) {
362 LauncherView* view = static_cast<LauncherTab*>( categoryBar->tab(i) )->view; 362 LauncherView* view = static_cast<LauncherTab*>( categoryBar->tab(i) )->view;
363 view->setBusyIndicatorType( str ); 363 view->setBusyIndicatorType( str );
364 } 364 }
365} 365}
366 366
367LauncherView *LauncherTabWidget::currentView(void) 367LauncherView *LauncherTabWidget::currentView(void)
368{ 368{
369 return (LauncherView*)stack->visibleWidget(); 369 return (LauncherView*)stack->visibleWidget();
370} 370}
371 371
372 372
373 373
374void LauncherTabWidget::launcherMessage( const QCString &msg, const QByteArray &data) 374void LauncherTabWidget::launcherMessage( const QCString &msg, const QByteArray &data)
375{ 375{
376 QDataStream stream( data, IO_ReadOnly ); 376 QDataStream stream( data, IO_ReadOnly );
377 if ( msg == "setTabView(QString,int)" ) { 377 if ( msg == "setTabView(QString,int)" ) {
378 QString id; 378 QString id;
379 stream >> id; 379 stream >> id;
380 int mode; 380 int mode;
381 stream >> mode; 381 stream >> mode;
382 if ( view(id) ) 382 if ( view(id) )
383 view(id)->setViewMode( (LauncherView::ViewMode)mode ); 383 view(id)->setViewMode( (LauncherView::ViewMode)mode );
384 } else if ( msg == "setTabBackground(QString,int,QString)" ) { 384 } else if ( msg == "setTabBackground(QString,int,QString)" ) {
385 QString id; 385 QString id;
386 stream >> id; 386 stream >> id;
387 int mode; 387 int mode;
388 stream >> mode; 388 stream >> mode;
389 QString pixmapOrColor; 389 QString pixmapOrColor;
390 stream >> pixmapOrColor; 390 stream >> pixmapOrColor;
391 if ( view(id) ) 391 if ( view(id) )
392 view(id)->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor ); 392 view(id)->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor );
393 if ( id == "Documents" ) 393 if ( id == "Documents" )
394 docLoadingWidget->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor ); 394 docLoadingWidget->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor );
395 } else if ( msg == "setTextColor(QString,QString)" ) { 395 } else if ( msg == "setTextColor(QString,QString)" ) {
396 QString id; 396 QString id;
397 stream >> id; 397 stream >> id;
398 QString color; 398 QString color;
399 stream >> color; 399 stream >> color;
400 if ( view(id) ) 400 if ( view(id) )
401 view(id)->setTextColor( QColor(color) ); 401 view(id)->setTextColor( QColor(color) );
402 if ( id == "Documents" ) 402 if ( id == "Documents" )
403 docLoadingWidget->setTextColor( QColor(color) ); 403 docLoadingWidget->setTextColor( QColor(color) );
404 } else if ( msg == "setFont(QString,QString,int,int,int)" ) { 404 } else if ( msg == "setFont(QString,QString,int,int,int)" ) {
405 QString id; 405 QString id;
406 stream >> id; 406 stream >> id;
407 QString fam; 407 QString fam;
408 stream >> fam; 408 stream >> fam;
409 int size; 409 int size;
410 stream >> size; 410 stream >> size;
411 int weight; 411 int weight;
412 stream >> weight; 412 stream >> weight;
413 int italic; 413 int italic;
414 stream >> italic; 414 stream >> italic;
415 if ( view(id) ) { 415 if ( view(id) ) {
416 if ( !fam.isEmpty() ) { 416 if ( !fam.isEmpty() ) {
417 view(id)->setViewFont( QFont(fam, size, weight, italic!=0) ); 417 view(id)->setViewFont( QFont(fam, size, weight, italic!=0) );
418 qDebug( "setFont: %s, %d, %d, %d", fam.latin1(), size, weight, italic ); 418 qDebug( "setFont: %s, %d, %d, %d", fam.latin1(), size, weight, italic );
419 } else { 419 } else {
420 view(id)->clearViewFont(); 420 view(id)->clearViewFont();
421 } 421 }
422 } 422 }
423 }else if ( msg == "setBusyIndicatorType(QString)" ) { 423 }else if ( msg == "setBusyIndicatorType(QString)" ) {
424 QString type; 424 QString type;
425 stream >> type; 425 stream >> type;
426 setBusyIndicatorType( type ); 426 setBusyIndicatorType( type );
427 }else if ( msg == "home()" ) { 427 }else if ( msg == "home()" ) {
428 if ( isVisibleWindow( static_cast<QWidget*>(parent())->winId() ) ) { 428 if ( isVisibleWindow( static_cast<QWidget*>(parent())->winId() ) ) {
429 if (categoryBar) 429 if (categoryBar)
430 categoryBar->nextTab(); 430 categoryBar->nextTab();
431 }else 431 }else
432 static_cast<QWidget*>(parent())->raise(); 432 static_cast<QWidget*>(parent())->raise();
433 } 433 }
434} 434}
435 435
436 436
437 437
438//--------------------------------------------------------------------------- 438//---------------------------------------------------------------------------
439 439
440Launcher::Launcher() 440Launcher::Launcher()
441 : QMainWindow( 0, "PDA User Interface", QWidget::WStyle_Customize | QWidget::WGroupLeader ) 441 : QMainWindow( 0, "PDA User Interface", QWidget::WStyle_Customize | QWidget::WGroupLeader )
442{ 442{
443 tabs = 0; 443 tabs = 0;
444 tb = 0; 444 tb = 0;
445 Config cfg( "Launcher" ); 445 Config cfg( "Launcher" );
446 cfg.setGroup( "DocTab" ); 446 cfg.setGroup( "DocTab" );
447 docTabEnabled = cfg.readBoolEntry( "Enable", true ); 447 docTabEnabled = cfg.readBoolEntry( "Enable", true );
448} 448}
449 449
450void Launcher::createGUI() 450void Launcher::createGUI()
451{ 451{
452 setCaption( tr("Launcher") ); 452 setCaption( tr("Launcher") );
453 453
454 // we have a pretty good idea how big we'll be 454 // we have a pretty good idea how big we'll be
455 setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() ); 455 setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() );
456 456
457 tb = new TaskBar; 457 tb = new TaskBar;
458 tabs = new LauncherTabWidget( this ); 458 tabs = new LauncherTabWidget( this );
459 setCentralWidget( tabs ); 459 setCentralWidget( tabs );
460 460
461 ServerInterface::dockWidget( tb, ServerInterface::Bottom ); 461 ServerInterface::dockWidget( tb, ServerInterface::Bottom );
462 tb->show(); 462 tb->show();
463 463
464 qApp->installEventFilter( this ); 464 qApp->installEventFilter( this );
465 465
466 466
467 connect( qApp, SIGNAL(symbol()), this, SLOT(toggleSymbolInput()) ); 467 connect( qApp, SIGNAL(symbol()), this, SLOT(toggleSymbolInput()) );
468 connect( qApp, SIGNAL(numLockStateToggle()), this, SLOT(toggleNumLockState()) ); 468 connect( qApp, SIGNAL(numLockStateToggle()), this, SLOT(toggleNumLockState()) );
469 connect( qApp, SIGNAL(capsLockStateToggle()), this, SLOT(toggleCapsLockState()) ); 469 connect( qApp, SIGNAL(capsLockStateToggle()), this, SLOT(toggleCapsLockState()) );
470 470
471 connect( tb, SIGNAL(tabSelected(const QString&)), 471 connect( tb, SIGNAL(tabSelected(const QString&)),
472 this, SLOT(showTab(const QString&)) ); 472 this, SLOT(showTab(const QString&)) );
473 connect( tabs, SIGNAL(selected(const QString&)), 473 connect( tabs, SIGNAL(selected(const QString&)),
474 this, SLOT(viewSelected(const QString&)) ); 474 this, SLOT(viewSelected(const QString&)) );
475 connect( tabs, SIGNAL(clicked(const AppLnk*)), 475 connect( tabs, SIGNAL(clicked(const AppLnk*)),
476 this, SLOT(select(const AppLnk*))); 476 this, SLOT(select(const AppLnk*)));
477 connect( tabs, SIGNAL(rightPressed(AppLnk*)), 477 connect( tabs, SIGNAL(rightPressed(AppLnk*)),
478 this, SLOT(properties(AppLnk*))); 478 this, SLOT(properties(AppLnk*)));
479 479
480#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 480#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
481 QCopChannel* sysChannel = new QCopChannel( "QPE/System", this ); 481 QCopChannel* sysChannel = new QCopChannel( "QPE/System", this );
482 connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)), 482 connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)),
483 this, SLOT(systemMessage( const QCString &, const QByteArray &)) ); 483 this, SLOT(systemMessage( const QCString &, const QByteArray &)) );
484#endif 484#endif
485 485
486 // all documents 486 // all documents
487 QImage img( Resource::loadImage( "DocsIcon" ) ); 487 QImage img( Resource::loadImage( "DocsIcon" ) );
488 QPixmap pm; 488 QPixmap pm;
489 pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); 489 pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() );
490 // It could add this itself if it handles docs 490 // It could add this itself if it handles docs
491 491
492 tabs->newView("Documents", pm, tr("Documents") )->setToolsEnabled( TRUE ); 492 tabs->newView("Documents", pm, tr("Documents") )->setToolsEnabled( TRUE );
493 493
494 QTimer::singleShot( 0, tabs, SLOT( initLayout() ) ); 494 QTimer::singleShot( 0, tabs, SLOT( initLayout() ) );
495 qApp->setMainWidget( this ); 495 qApp->setMainWidget( this );
496 QTimer::singleShot( 500, this, SLOT( makeVisible() ) ); 496 QTimer::singleShot( 500, this, SLOT( makeVisible() ) );
497} 497}
498 498
499Launcher::~Launcher() 499Launcher::~Launcher()
500{ 500{
501 if ( tb ) 501 if ( tb )
502 destroyGUI(); 502 destroyGUI();
503} 503}
504 504
505 bool Launcher::requiresDocuments() const 505 bool Launcher::requiresDocuments() const
506 { 506 {
507 Config cfg( "Launcher" ); 507 Config cfg( "Launcher" );
508 cfg.setGroup( "DocTab" ); 508 cfg.setGroup( "DocTab" );
509 return cfg.readBoolEntry( "Enable", true ); 509 return cfg.readBoolEntry( "Enable", true );
510} 510}
511 511
512void Launcher::makeVisible() 512void Launcher::makeVisible()
513{ 513{
514 showMaximized(); 514 showMaximized();
515} 515}
516 516
517void Launcher::destroyGUI() 517void Launcher::destroyGUI()
518{ 518{
519 delete tb; 519 delete tb;
520 tb = 0; 520 tb = 0;
521 delete tabs; 521 delete tabs;
522 tabs =0; 522 tabs =0;
523} 523}
524 524
525bool Launcher::eventFilter( QObject*, QEvent *ev ) 525bool Launcher::eventFilter( QObject*, QEvent *ev )
526{ 526{
527#ifdef QT_QWS_CUSTOM 527#ifdef QT_QWS_CUSTOM
528 if ( ev->type() == QEvent::KeyPress ) { 528 if ( ev->type() == QEvent::KeyPress ) {
529 QKeyEvent *ke = (QKeyEvent *)ev; 529 QKeyEvent *ke = (QKeyEvent *)ev;
530 if ( ke->key() == Qt::Key_F11 ) { // menu key 530 if ( ke->key() == Qt::Key_F11 ) { // menu key
531 QWidget *active = qApp->activeWindow(); 531 QWidget *active = qApp->activeWindow();
532 if ( active && active->isPopup() ) 532 if ( active && active->isPopup() )
533 active->close(); 533 active->close();
534 else { 534 else {
535 Global::terminateBuiltin("calibrate"); // No tr 535 Global::terminateBuiltin("calibrate"); // No tr
536 tb->launchStartMenu(); 536 tb->launchStartMenu();
537 } 537 }
538 return TRUE; 538 return TRUE;
539 } 539 }
540 } 540 }
541#else 541#else
542 Q_UNUSED(ev); 542 Q_UNUSED(ev);
543#endif 543#endif
544 return FALSE; 544 return FALSE;
545} 545}
546 546
547void Launcher::toggleSymbolInput() 547void Launcher::toggleSymbolInput()
548{ 548{
549 tb->toggleSymbolInput(); 549 tb->toggleSymbolInput();
550} 550}
551 551
552void Launcher::toggleNumLockState() 552void Launcher::toggleNumLockState()
553{ 553{
554 tb->toggleNumLockState(); 554 tb->toggleNumLockState();
555} 555}
556 556
557void Launcher::toggleCapsLockState() 557void Launcher::toggleCapsLockState()
558{ 558{
559 tb->toggleCapsLockState(); 559 tb->toggleCapsLockState();
560} 560}
561 561
562static bool isVisibleWindow(int wid) 562static bool isVisibleWindow(int wid)
563{ 563{
564#ifdef Q_WS_QWS 564#ifdef Q_WS_QWS
565 const QList<QWSWindow> &list = qwsServer->clientWindows(); 565 const QList<QWSWindow> &list = qwsServer->clientWindows();
566 QWSWindow* w; 566 QWSWindow* w;
567 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { 567 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) {
568 if ( w->winId() == wid ) 568 if ( w->winId() == wid )
569 return !w->isFullyObscured(); 569 return !w->isFullyObscured();
570 } 570 }
571#endif 571#endif
572 return FALSE; 572 return FALSE;
573} 573}
574 574
575void Launcher::viewSelected(const QString& s) 575void Launcher::viewSelected(const QString& s)
576{ 576{
577 setCaption( s + tr(" - Launcher") ); 577 setCaption( s + tr(" - Launcher") );
578} 578}
579 579
580void Launcher::showTab(const QString& id) 580void Launcher::showTab(const QString& id)
581{ 581{
582 tabs->categoryBar->showTab(id); 582 tabs->categoryBar->showTab(id);
583 raise(); 583 raise();
584} 584}
585 585
586void Launcher::select( const AppLnk *appLnk ) 586void Launcher::select( const AppLnk *appLnk )
587{ 587{
588 if ( appLnk->type() == "Folder" ) { // No tr 588 if ( appLnk->type() == "Folder" ) { // No tr
589 // Not supported: flat is simpler for the user 589 // Not supported: flat is simpler for the user
590 } else { 590 } else {
591 if ( appLnk->exec().isNull() ) { 591 if ( appLnk->exec().isNull() ) {
592 int i = QMessageBox::information(this,tr("No application"), 592 int i = QMessageBox::information(this,tr("No application"),
593 tr("<p>No application is defined for this document." 593 tr("<p>No application is defined for this document."
594 "<p>Type is %1.").arg(appLnk->type()), tr("OK"), tr("View as text"), 0, 0, 1); 594 "<p>Type is %1.").arg(appLnk->type()), tr("OK"), tr("View as text"), 0, 0, 1);
595 595
596 /* ### Fixme */ 596 /* ### Fixme */
597 if ( i == 1 ) 597 if ( i == 1 )
598 Global::execute("textedit",appLnk->file()); 598 Global::execute("textedit",appLnk->file());
599 599
600 return; 600 return;
601 } 601 }
602 tabs->setBusy(TRUE); 602 tabs->setBusy(TRUE);
603 emit executing( appLnk ); 603 emit executing( appLnk );
604 appLnk->execute(); 604 appLnk->execute();
605 } 605 }
606} 606}
607 607
608void Launcher::properties( AppLnk *appLnk ) 608void Launcher::properties( AppLnk *appLnk )
609{ 609{
610 if ( appLnk->type() == "Folder" ) { // No tr 610 if ( appLnk->type() == "Folder" ) { // No tr
611 // Not supported: flat is simpler for the user 611 // Not supported: flat is simpler for the user
612 } else { 612 } else {
613/* ### libqtopia FIXME also moving docLnks... */ 613/* ### libqtopia FIXME also moving docLnks... */
614 LnkProperties prop(appLnk,0 ); 614 LnkProperties prop(appLnk,0 );
615 615
616 QPEApplication::execDialog( &prop ); 616 QPEApplication::execDialog( &prop );
617 } 617 }
618} 618}
619 619
620void Launcher::storageChanged( const QList<FileSystem> &fs ) 620void Launcher::storageChanged( const QList<FileSystem> &fs )
621{ 621{
622 // ### update combo boxes if we had a combo box for the storage type 622 // ### update combo boxes if we had a combo box for the storage type
623} 623}
624 624
625void Launcher::systemMessage( const QCString &msg, const QByteArray &data) 625void Launcher::systemMessage( const QCString &msg, const QByteArray &data)
626{ 626{
627 QDataStream stream( data, IO_ReadOnly ); 627 QDataStream stream( data, IO_ReadOnly );
628 if ( msg == "busy()" ) { 628 if ( msg == "busy()" ) {
629 tb->startWait(); 629 tb->startWait();
630 } else if ( msg == "notBusy(QString)" ) { 630 } else if ( msg == "notBusy(QString)" ) {
631 QString app; 631 QString app;
632 stream >> app; 632 stream >> app;
633 tabs->setBusy(FALSE); 633 tabs->setBusy(FALSE);
634 tb->stopWait(app); 634 tb->stopWait(app);
635 } else if (msg == "applyStyle()") { 635 } else if (msg == "applyStyle()") {
636 tabs->currentView()->relayout(); 636 tabs->currentView()->relayout();
637 } 637 }
638} 638}
639 639
640// These are the update functions from the server 640// These are the update functions from the server
641void Launcher::typeAdded( const QString& type, const QString& name, 641void Launcher::typeAdded( const QString& type, const QString& name,
642 const QPixmap& pixmap, const QPixmap& ) 642 const QPixmap& pixmap, const QPixmap& )
643{ 643{
644 tabs->newView( type, pixmap, name ); 644 tabs->newView( type, pixmap, name );
645 ids.append( type ); 645 ids.append( type );
646 tb->refreshStartMenu(); 646 /* this will be called in applicationScanningProgress with value 100! */
647// tb->refreshStartMenu();
647 648
648 static bool first = TRUE; 649 static bool first = TRUE;
649 if ( first ) { 650 if ( first ) {
650 first = FALSE; 651 first = FALSE;
651 tabs->categoryBar->showTab(type); 652 tabs->categoryBar->showTab(type);
652 } 653 }
653 654
654 tabs->view( type )->setUpdatesEnabled( FALSE ); 655 tabs->view( type )->setUpdatesEnabled( FALSE );
655 tabs->view( type )->setSortEnabled( FALSE ); 656 tabs->view( type )->setSortEnabled( FALSE );
656} 657}
657 658
658void Launcher::typeRemoved( const QString& type ) 659void Launcher::typeRemoved( const QString& type )
659{ 660{
660 tabs->view( type )->removeAllItems(); 661 tabs->view( type )->removeAllItems();
661 tabs->deleteView( type ); 662 tabs->deleteView( type );
662 ids.remove( type ); 663 ids.remove( type );
663 tb->refreshStartMenu(); 664 /* this will be called in applicationScanningProgress with value 100! */
665// tb->refreshStartMenu();
664} 666}
665 667
666void Launcher::applicationAdded( const QString& type, const AppLnk& app ) 668void Launcher::applicationAdded( const QString& type, const AppLnk& app )
667{ 669{
668 if ( app.type() == "Separator" ) // No tr 670 if ( app.type() == "Separator" ) // No tr
669 return; 671 return;
670 672
671 LauncherView *view = tabs->view( type ); 673 LauncherView *view = tabs->view( type );
672 if ( view ) 674 if ( view )
673 view->addItem( new AppLnk( app ), FALSE ); 675 view->addItem( new AppLnk( app ), FALSE );
674 else 676 else
675 qWarning("addAppLnk: No view for type %s. Can't add app %s!", 677 qWarning("addAppLnk: No view for type %s. Can't add app %s!",
676 type.latin1(),app.name().latin1() ); 678 type.latin1(),app.name().latin1() );
677 679
678 MimeType::registerApp( app ); 680 MimeType::registerApp( app );
679} 681}
680 682
681void Launcher::applicationRemoved( const QString& type, const AppLnk& app ) 683void Launcher::applicationRemoved( const QString& type, const AppLnk& app )
682{ 684{
683 LauncherView *view = tabs->view( type ); 685 LauncherView *view = tabs->view( type );
684 if ( view ) 686 if ( view )
685 view->removeLink( app.linkFile() ); 687 view->removeLink( app.linkFile() );
686 else 688 else
687 qWarning("removeAppLnk: No view for %s!", type.latin1() ); 689 qWarning("removeAppLnk: No view for %s!", type.latin1() );
688} 690}
689 691
690void Launcher::allApplicationsRemoved() 692void Launcher::allApplicationsRemoved()
691{ 693{
692 MimeType::clear(); 694 MimeType::clear();
693 for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) 695 for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it)
694 tabs->view( (*it) )->removeAllItems(); 696 tabs->view( (*it) )->removeAllItems();
695} 697}
696 698
697void Launcher::documentAdded( const DocLnk& doc ) 699void Launcher::documentAdded( const DocLnk& doc )
698{ 700{
699 tabs->docView()->addItem( new DocLnk( doc ), FALSE ); 701 tabs->docView()->addItem( new DocLnk( doc ), FALSE );
700} 702}
701 703
702void Launcher::showLoadingDocs() 704void Launcher::showLoadingDocs()
703{ 705{
704 tabs->docView()->hide(); 706 tabs->docView()->hide();
705} 707}
706 708
707void Launcher::showDocTab() 709void Launcher::showDocTab()
708{ 710{
709 if ( tabs->categoryBar->currentView() == tabs->docView() ) 711 if ( tabs->categoryBar->currentView() == tabs->docView() )
710 tabs->docView()->show(); 712 tabs->docView()->show();
711} 713}
712 714
713void Launcher::documentRemoved( const DocLnk& doc ) 715void Launcher::documentRemoved( const DocLnk& doc )
714{ 716{
715 tabs->docView()->removeLink( doc.linkFile() ); 717 tabs->docView()->removeLink( doc.linkFile() );
716} 718}
717 719
718void Launcher::documentChanged( const DocLnk& oldDoc, const DocLnk& newDoc ) 720void Launcher::documentChanged( const DocLnk& oldDoc, const DocLnk& newDoc )
719{ 721{
720 documentRemoved( oldDoc ); 722 documentRemoved( oldDoc );
721 documentAdded( newDoc ); 723 documentAdded( newDoc );
722} 724}
723 725
724void Launcher::allDocumentsRemoved() 726void Launcher::allDocumentsRemoved()
725{ 727{
726 tabs->docView()->removeAllItems(); 728 tabs->docView()->removeAllItems();
727} 729}
728 730
729void Launcher::applicationStateChanged( const QString& name, ApplicationState state ) 731void Launcher::applicationStateChanged( const QString& name, ApplicationState state )
730{ 732{
731 tb->setApplicationState( name, state ); 733 tb->setApplicationState( name, state );
732} 734}
733 735
734void Launcher::applicationScanningProgress( int percent ) 736void Launcher::applicationScanningProgress( int percent )
735{ 737{
736 switch ( percent ) { 738 switch ( percent ) {
737 case 0: { 739 case 0: {
738 for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) { 740 for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) {
739 tabs->view( (*it) )->setUpdatesEnabled( FALSE ); 741 tabs->view( (*it) )->setUpdatesEnabled( FALSE );
740 tabs->view( (*it) )->setSortEnabled( FALSE ); 742 tabs->view( (*it) )->setSortEnabled( FALSE );
741 } 743 }
742 break; 744 break;
743 } 745 }
744 case 100: { 746 case 100: {
745 for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) { 747 for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) {
746 tabs->view( (*it) )->setUpdatesEnabled( TRUE ); 748 tabs->view( (*it) )->setUpdatesEnabled( TRUE );
747 tabs->view( (*it) )->setSortEnabled( TRUE ); 749 tabs->view( (*it) )->setSortEnabled( TRUE );
748 } 750 }
749 break; 751 break;
750 } 752 }
751 default: 753 default:
752 break; 754 break;
753 } 755 }
754} 756}
755 757
756void Launcher::documentScanningProgress( int percent ) 758void Launcher::documentScanningProgress( int percent )
757{ 759{
758 switch ( percent ) { 760 switch ( percent ) {
759 case 0: { 761 case 0: {
760 tabs->setLoadingProgress( 0 ); 762 tabs->setLoadingProgress( 0 );
761 tabs->setLoadingWidgetEnabled( TRUE ); 763 tabs->setLoadingWidgetEnabled( TRUE );
762 tabs->docView()->setUpdatesEnabled( FALSE ); 764 tabs->docView()->setUpdatesEnabled( FALSE );
763 tabs->docView()->setSortEnabled( FALSE ); 765 tabs->docView()->setSortEnabled( FALSE );
764 break; 766 break;
765 } 767 }
766 case 100: { 768 case 100: {
767 tabs->docView()->updateTools(); 769 tabs->docView()->updateTools();
768 tabs->docView()->setSortEnabled( TRUE ); 770 tabs->docView()->setSortEnabled( TRUE );
769 tabs->docView()->setUpdatesEnabled( TRUE ); 771 tabs->docView()->setUpdatesEnabled( TRUE );
770 tabs->setLoadingWidgetEnabled( FALSE ); 772 tabs->setLoadingWidgetEnabled( FALSE );
773 tb->refreshStartMenu();
771 break; 774 break;
772 } 775 }
773 default: 776 default:
774 tabs->setLoadingProgress( percent ); 777 tabs->setLoadingProgress( percent );
775 break; 778 break;
776 } 779 }
777} 780}
778 781