summaryrefslogtreecommitdiff
path: root/core/launcher/launcher.cpp
Unidiff
Diffstat (limited to 'core/launcher/launcher.cpp') (more/less context) (show whitespace changes)
-rw-r--r--core/launcher/launcher.cpp37
1 files changed, 17 insertions, 20 deletions
diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp
index 5d0c778..bf2287d 100644
--- a/core/launcher/launcher.cpp
+++ b/core/launcher/launcher.cpp
@@ -1,101 +1,98 @@
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#include "startmenu.h"
22#include "taskbar.h"
23#include "serverinterface.h"
24#include "launcherview.h"
25#include "launcher.h"
26#include "server.h"
27
28/* OPIE */
29#include <opie2/odebug.h>
21#include <qtopia/global.h> 30#include <qtopia/global.h>
22#ifdef Q_WS_QWS 31#ifdef Q_WS_QWS
23#include <qtopia/qcopenvelope_qws.h> 32#include <qtopia/qcopenvelope_qws.h>
24#endif 33#endif
25#include <qtopia/resource.h> 34#include <qtopia/resource.h>
26#include <qtopia/applnk.h> 35#include <qtopia/applnk.h>
27#include <qtopia/config.h> 36#include <qtopia/config.h>
28#include <qtopia/qpeapplication.h> 37#include <qtopia/qpeapplication.h>
29#include <qtopia/mimetype.h> 38#include <qtopia/mimetype.h>
30#include <qtopia/private/categories.h> 39#include <qtopia/private/categories.h>
31//#include <qtopia/custom.h> 40#define QTOPIA_INTERNAL_FSLP
41#include <qtopia/lnkproperties.h>
32 42
43/* QT */
33#include <qdir.h> 44#include <qdir.h>
34#ifdef Q_WS_QWS 45#ifdef Q_WS_QWS
46#include <qkeyboard_qws.h>
35#include <qwindowsystem_qws.h> 47#include <qwindowsystem_qws.h>
36#endif 48#endif
37#include <qtimer.h> 49#include <qtimer.h>
38#include <qcombobox.h> 50#include <qcombobox.h>
39#include <qvbox.h> 51#include <qvbox.h>
40#include <qlayout.h> 52#include <qlayout.h>
41#include <qstyle.h> 53#include <qstyle.h>
42#include <qpushbutton.h> 54#include <qpushbutton.h>
43#include <qtabbar.h> 55#include <qtabbar.h>
44#include <qwidgetstack.h> 56#include <qwidgetstack.h>
45#include <qregexp.h> 57#include <qregexp.h>
46#include <qmessagebox.h> 58#include <qmessagebox.h>
47#include <qframe.h> 59#include <qframe.h>
48#include <qpainter.h> 60#include <qpainter.h>
49#include <qlabel.h> 61#include <qlabel.h>
50#include <qtextstream.h> 62#include <qtextstream.h>
51#include <qpopupmenu.h> 63#include <qpopupmenu.h>
52 64
53#include "startmenu.h" 65/* STD */
54#include "taskbar.h"
55
56#include "serverinterface.h"
57#include "launcherview.h"
58#include "launcher.h"
59#include "server.h"
60
61#define QTOPIA_INTERNAL_FSLP
62#include <qtopia/lnkproperties.h>
63#include <stdlib.h> 66#include <stdlib.h>
64#include <assert.h> 67#include <assert.h>
65
66#if defined(_OS_LINUX_) || defined(Q_OS_LINUX) 68#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
67#include <unistd.h> 69#include <unistd.h>
68#include <stdio.h> 70#include <stdio.h>
69#include <sys/vfs.h> 71#include <sys/vfs.h>
70#include <mntent.h> 72#include <mntent.h>
71#endif 73#endif
72 74
73#ifdef Q_WS_QWS
74#include <qkeyboard_qws.h>
75#include <qpe/lnkproperties.h>
76#endif
77
78 75
79static bool isVisibleWindow( int ); 76static bool isVisibleWindow( int );
80//=========================================================================== 77//===========================================================================
81 78
82LauncherTabWidget::LauncherTabWidget( Launcher* parent ) : 79LauncherTabWidget::LauncherTabWidget( Launcher* parent ) :
83 QVBox( parent ), docview( 0 ) 80 QVBox( parent ), docview( 0 )
84{ 81{
85 docLoadingWidgetEnabled = false; 82 docLoadingWidgetEnabled = false;
86 docLoadingWidget = 0; 83 docLoadingWidget = 0;
87 docLoadingWidgetProgress = 0; 84 docLoadingWidgetProgress = 0;
88 launcher = parent; 85 launcher = parent;
89 categoryBar = new LauncherTabBar( this ); 86 categoryBar = new LauncherTabBar( this );
90 QPalette pal = categoryBar->palette(); 87 QPalette pal = categoryBar->palette();
91 pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); 88 pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) );
92 pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); 89 pal.setColor( QColorGroup::Background, pal.active().background().light(110) );
93 categoryBar->setPalette( pal ); 90 categoryBar->setPalette( pal );
94 stack = new QWidgetStack(this); 91 stack = new QWidgetStack(this);
95 connect( categoryBar, SIGNAL(selected(int)), this, SLOT(raiseTabWidget()) ); 92 connect( categoryBar, SIGNAL(selected(int)), this, SLOT(raiseTabWidget()) );
96 categoryBar->show(); 93 categoryBar->show();
97 stack->show(); 94 stack->show();
98 95
99#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 96#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
100 QCopChannel *channel = new QCopChannel( "QPE/Launcher", this ); 97 QCopChannel *channel = new QCopChannel( "QPE/Launcher", this );
101 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), 98 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)),
@@ -207,49 +204,49 @@ void LauncherTabWidget::deleteView( const QString& id )
207 if ( t ) { 204 if ( t ) {
208 stack->removeWidget( t->view ); 205 stack->removeWidget( t->view );
209 delete t->view; 206 delete t->view;
210 categoryBar->removeTab( t ); 207 categoryBar->removeTab( t );
211 } 208 }
212} 209}
213 210
214LauncherView* LauncherTabWidget::newView( const QString& id, const QPixmap& pm, const QString& label ) 211LauncherView* LauncherTabWidget::newView( const QString& id, const QPixmap& pm, const QString& label )
215{ 212{
216 LauncherView* view = new LauncherView( stack ); 213 LauncherView* view = new LauncherView( stack );
217 connect( view, SIGNAL(clicked(const AppLnk*)), 214 connect( view, SIGNAL(clicked(const AppLnk*)),
218 this, SIGNAL(clicked(const AppLnk*))); 215 this, SIGNAL(clicked(const AppLnk*)));
219 connect( view, SIGNAL(rightPressed(AppLnk*)), 216 connect( view, SIGNAL(rightPressed(AppLnk*)),
220 this, SIGNAL(rightPressed(AppLnk*))); 217 this, SIGNAL(rightPressed(AppLnk*)));
221 218
222 int n = categoryBar->count(); 219 int n = categoryBar->count();
223 stack->addWidget( view, n ); 220 stack->addWidget( view, n );
224 221
225 LauncherTab *tab = new LauncherTab( id, view, pm, label ); 222 LauncherTab *tab = new LauncherTab( id, view, pm, label );
226 categoryBar->insertTab( tab, n-1 ); 223 categoryBar->insertTab( tab, n-1 );
227 224
228 if ( id == "Documents" ) 225 if ( id == "Documents" )
229 docview = view; 226 docview = view;
230 227
231 qDebug("inserting %s at %d", id.latin1(), n-1 ); 228 odebug << "inserting " << id << " at " << n-1 << "" << oendl;
232 229
233 Config cfg("Launcher"); 230 Config cfg("Launcher");
234 setTabAppearance( tab, cfg ); 231 setTabAppearance( tab, cfg );
235 232
236 cfg.setGroup( "GUI" ); 233 cfg.setGroup( "GUI" );
237 view->setBusyIndicatorType( cfg.readEntry( "BusyType", QString::null ) ); 234 view->setBusyIndicatorType( cfg.readEntry( "BusyType", QString::null ) );
238 235
239 return view; 236 return view;
240} 237}
241 238
242LauncherView *LauncherTabWidget::view( const QString &id ) 239LauncherView *LauncherTabWidget::view( const QString &id )
243{ 240{
244 LauncherTab *t = categoryBar->launcherTab(id); 241 LauncherTab *t = categoryBar->launcherTab(id);
245 if ( !t ) 242 if ( !t )
246 return 0; 243 return 0;
247 return t->view; 244 return t->view;
248} 245}
249 246
250LauncherView *LauncherTabWidget::docView() 247LauncherView *LauncherTabWidget::docView()
251{ 248{
252 return docview; 249 return docview;
253} 250}
254 251
255void LauncherTabWidget::setLoadingWidgetEnabled( bool v ) 252void LauncherTabWidget::setLoadingWidgetEnabled( bool v )
@@ -392,49 +389,49 @@ void LauncherTabWidget::launcherMessage( const QCString &msg, const QByteArray &
392 docLoadingWidget->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor ); 389 docLoadingWidget->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor );
393 } else if ( msg == "setTextColor(QString,QString)" ) { 390 } else if ( msg == "setTextColor(QString,QString)" ) {
394 QString id; 391 QString id;
395 stream >> id; 392 stream >> id;
396 QString color; 393 QString color;
397 stream >> color; 394 stream >> color;
398 if ( view(id) ) 395 if ( view(id) )
399 view(id)->setTextColor( QColor(color) ); 396 view(id)->setTextColor( QColor(color) );
400 if ( id == "Documents" ) 397 if ( id == "Documents" )
401 docLoadingWidget->setTextColor( QColor(color) ); 398 docLoadingWidget->setTextColor( QColor(color) );
402 } else if ( msg == "setFont(QString,QString,int,int,int)" ) { 399 } else if ( msg == "setFont(QString,QString,int,int,int)" ) {
403 QString id; 400 QString id;
404 stream >> id; 401 stream >> id;
405 QString fam; 402 QString fam;
406 stream >> fam; 403 stream >> fam;
407 int size; 404 int size;
408 stream >> size; 405 stream >> size;
409 int weight; 406 int weight;
410 stream >> weight; 407 stream >> weight;
411 int italic; 408 int italic;
412 stream >> italic; 409 stream >> italic;
413 if ( view(id) ) { 410 if ( view(id) ) {
414 if ( !fam.isEmpty() ) { 411 if ( !fam.isEmpty() ) {
415 view(id)->setViewFont( QFont(fam, size, weight, italic!=0) ); 412 view(id)->setViewFont( QFont(fam, size, weight, italic!=0) );
416 qDebug( "setFont: %s, %d, %d, %d", fam.latin1(), size, weight, italic ); 413 odebug << "setFont: " << fam << ", " << size << ", " << weight << ", " << italic << "" << oendl;
417 } else { 414 } else {
418 view(id)->clearViewFont(); 415 view(id)->clearViewFont();
419 } 416 }
420 } 417 }
421 }else if ( msg == "setBusyIndicatorType(QString)" ) { 418 }else if ( msg == "setBusyIndicatorType(QString)" ) {
422 QString type; 419 QString type;
423 stream >> type; 420 stream >> type;
424 setBusyIndicatorType( type ); 421 setBusyIndicatorType( type );
425 }else if ( msg == "home()" ) { 422 }else if ( msg == "home()" ) {
426 if ( isVisibleWindow( static_cast<QWidget*>(parent())->winId() ) ) { 423 if ( isVisibleWindow( static_cast<QWidget*>(parent())->winId() ) ) {
427 if (categoryBar) 424 if (categoryBar)
428 categoryBar->nextTab(); 425 categoryBar->nextTab();
429 }else 426 }else
430 static_cast<QWidget*>(parent())->raise(); 427 static_cast<QWidget*>(parent())->raise();
431 } 428 }
432} 429}
433 430
434 431
435 432
436//--------------------------------------------------------------------------- 433//---------------------------------------------------------------------------
437 434
438Launcher::Launcher() 435Launcher::Launcher()
439 : QMainWindow( 0, "PDA User Interface", QWidget::WStyle_Customize | QWidget::WGroupLeader ) 436 : QMainWindow( 0, "PDA User Interface", QWidget::WStyle_Customize | QWidget::WGroupLeader )
440{ 437{
@@ -663,49 +660,49 @@ void Launcher::typeRemoved( const QString& type )
663// tb->refreshStartMenu(); 660// tb->refreshStartMenu();
664} 661}
665 662
666void Launcher::applicationAdded( const QString& type, const AppLnk& app ) 663void Launcher::applicationAdded( const QString& type, const AppLnk& app )
667{ 664{
668 if ( app.type() == "Separator" ) // No tr 665 if ( app.type() == "Separator" ) // No tr
669 return; 666 return;
670 667
671 LauncherView *view = tabs->view( type ); 668 LauncherView *view = tabs->view( type );
672 if ( view ) 669 if ( view )
673 view->addItem( new AppLnk( app ), FALSE ); 670 view->addItem( new AppLnk( app ), FALSE );
674 else 671 else
675 qWarning("addAppLnk: No view for type %s. Can't add app %s!", 672 qWarning("addAppLnk: No view for type %s. Can't add app %s!",
676 type.latin1(),app.name().latin1() ); 673 type.latin1(),app.name().latin1() );
677 674
678 MimeType::registerApp( app ); 675 MimeType::registerApp( app );
679} 676}
680 677
681void Launcher::applicationRemoved( const QString& type, const AppLnk& app ) 678void Launcher::applicationRemoved( const QString& type, const AppLnk& app )
682{ 679{
683 LauncherView *view = tabs->view( type ); 680 LauncherView *view = tabs->view( type );
684 if ( view ) 681 if ( view )
685 view->removeLink( app.linkFile() ); 682 view->removeLink( app.linkFile() );
686 else 683 else
687 qWarning("removeAppLnk: No view for %s!", type.latin1() ); 684 owarn << "removeAppLnk: No view for " << type << "!" << oendl;
688} 685}
689 686
690void Launcher::allApplicationsRemoved() 687void Launcher::allApplicationsRemoved()
691{ 688{
692 MimeType::clear(); 689 MimeType::clear();
693 for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) 690 for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it)
694 tabs->view( (*it) )->removeAllItems(); 691 tabs->view( (*it) )->removeAllItems();
695} 692}
696 693
697void Launcher::documentAdded( const DocLnk& doc ) 694void Launcher::documentAdded( const DocLnk& doc )
698{ 695{
699 tabs->docView()->addItem( new DocLnk( doc ), FALSE ); 696 tabs->docView()->addItem( new DocLnk( doc ), FALSE );
700} 697}
701 698
702void Launcher::showLoadingDocs() 699void Launcher::showLoadingDocs()
703{ 700{
704 tabs->docView()->hide(); 701 tabs->docView()->hide();
705} 702}
706 703
707void Launcher::showDocTab() 704void Launcher::showDocTab()
708{ 705{
709 if ( tabs->categoryBar->currentView() == tabs->docView() ) 706 if ( tabs->categoryBar->currentView() == tabs->docView() )
710 tabs->docView()->show(); 707 tabs->docView()->show();
711} 708}