summaryrefslogtreecommitdiff
path: root/core/launcher/launcher.cpp
Unidiff
Diffstat (limited to 'core/launcher/launcher.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/launcher.cpp43
1 files changed, 25 insertions, 18 deletions
diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp
index 5ec1cf8..ccc2114 100644
--- a/core/launcher/launcher.cpp
+++ b/core/launcher/launcher.cpp
@@ -56,49 +56,49 @@
56#include <qwidgetstack.h> 56#include <qwidgetstack.h>
57#include <qregexp.h> 57#include <qregexp.h>
58#include <qmessagebox.h> 58#include <qmessagebox.h>
59#include <qframe.h> 59#include <qframe.h>
60#include <qpainter.h> 60#include <qpainter.h>
61#include <qlabel.h> 61#include <qlabel.h>
62#include <qtextstream.h> 62#include <qtextstream.h>
63#include <qpopupmenu.h> 63#include <qpopupmenu.h>
64 64
65/* STD */ 65/* STD */
66#include <stdlib.h> 66#include <stdlib.h>
67#include <assert.h> 67#include <assert.h>
68#if defined(_OS_LINUX_) || defined(Q_OS_LINUX) 68#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
69#include <unistd.h> 69#include <unistd.h>
70#include <stdio.h> 70#include <stdio.h>
71#include <sys/vfs.h> 71#include <sys/vfs.h>
72#include <mntent.h> 72#include <mntent.h>
73#endif 73#endif
74 74
75 75
76static bool isVisibleWindow( int ); 76static bool isVisibleWindow( int );
77//=========================================================================== 77//===========================================================================
78 78
79LauncherTabWidget::LauncherTabWidget( Launcher* parent ) : 79LauncherTabWidget::LauncherTabWidget( Launcher* parent ) :
80 QVBox( parent ), docview( 0 ) 80 QVBox( parent ), docview( 0 ),docTabEnabled(true),m_DocumentTabId(0)
81{ 81{
82 docLoadingWidgetEnabled = false; 82 docLoadingWidgetEnabled = false;
83 docLoadingWidget = 0; 83 docLoadingWidget = 0;
84 docLoadingWidgetProgress = 0; 84 docLoadingWidgetProgress = 0;
85 launcher = parent; 85 launcher = parent;
86 categoryBar = new LauncherTabBar( this ); 86 categoryBar = new LauncherTabBar( this );
87 QPalette pal = categoryBar->palette(); 87 QPalette pal = categoryBar->palette();
88 pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); 88 pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) );
89 pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); 89 pal.setColor( QColorGroup::Background, pal.active().background().light(110) );
90 categoryBar->setPalette( pal ); 90 categoryBar->setPalette( pal );
91 stack = new QWidgetStack(this); 91 stack = new QWidgetStack(this);
92 connect( categoryBar, SIGNAL(selected(int)), this, SLOT(raiseTabWidget()) ); 92 connect( categoryBar, SIGNAL(selected(int)), this, SLOT(raiseTabWidget()) );
93 categoryBar->show(); 93 categoryBar->show();
94 stack->show(); 94 stack->show();
95 95
96#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 96#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
97 QCopChannel *channel = new QCopChannel( "QPE/Launcher", this ); 97 QCopChannel *channel = new QCopChannel( "QPE/Launcher", this );
98 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), 98 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)),
99 this, SLOT(launcherMessage(const QCString&,const QByteArray&)) ); 99 this, SLOT(launcherMessage(const QCString&,const QByteArray&)) );
100 connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), 100 connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)),
101 this, SLOT(appMessage(const QCString&,const QByteArray&))); 101 this, SLOT(appMessage(const QCString&,const QByteArray&)));
102#endif 102#endif
103 103
104 createDocLoadingWidget(); 104 createDocLoadingWidget();
@@ -107,174 +107,177 @@ LauncherTabWidget::LauncherTabWidget( Launcher* parent ) :
107void LauncherTabWidget::createDocLoadingWidget() 107void LauncherTabWidget::createDocLoadingWidget()
108{ 108{
109 // Construct the 'doc loading widget' shown when finding documents 109 // Construct the 'doc loading widget' shown when finding documents
110 110
111 // ### LauncherView class needs changing to be more generic so 111 // ### LauncherView class needs changing to be more generic so
112 // this widget can change its background similar to the iconviews 112 // this widget can change its background similar to the iconviews
113 // so the background for this matches 113 // so the background for this matches
114 docLoadingWidget = new LauncherView( stack ); 114 docLoadingWidget = new LauncherView( stack );
115 docLoadingWidget->hideIcons(); 115 docLoadingWidget->hideIcons();
116 QVBox *docLoadingVBox = new QVBox( docLoadingWidget ); 116 QVBox *docLoadingVBox = new QVBox( docLoadingWidget );
117 117
118 docLoadingVBox->setSpacing( 20 ); 118 docLoadingVBox->setSpacing( 20 );
119 docLoadingVBox->setMargin( 10 ); 119 docLoadingVBox->setMargin( 10 );
120 120
121 QWidget *space1 = new QWidget( docLoadingVBox ); 121 QWidget *space1 = new QWidget( docLoadingVBox );
122 docLoadingVBox->setStretchFactor( space1, 1 ); 122 docLoadingVBox->setStretchFactor( space1, 1 );
123 123
124 QLabel *waitPixmap = new QLabel( docLoadingVBox ); 124 QLabel *waitPixmap = new QLabel( docLoadingVBox );
125 waitPixmap->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, waitPixmap->sizePolicy().hasHeightForWidth() ) ); 125 waitPixmap->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, waitPixmap->sizePolicy().hasHeightForWidth() ) );
126 waitPixmap->setPixmap( Resource::loadPixmap( "bigwait" ) ); 126 waitPixmap->setPixmap( Resource::loadPixmap( "bigwait" ) );
127 waitPixmap->setAlignment( int( QLabel::AlignCenter ) ); 127 waitPixmap->setAlignment( int( QLabel::AlignCenter ) );
128 128
129 Config cfg( "Launcher" ); 129 Config cfg( "Launcher" );
130 cfg.setGroup( "DocTab" ); 130 cfg.setGroup( "DocTab" );
131 bool docTabEnabled = cfg.readBoolEntry( "Enable", true ); 131 docTabEnabled = cfg.readBoolEntry( "Enable", true );
132 132
133 QLabel *textLabel = new QLabel( docLoadingVBox ); 133 QLabel *textLabel = new QLabel( docLoadingVBox );
134 textLabel->setAlignment( int( QLabel::AlignCenter ) ); 134 textLabel->setAlignment( int( QLabel::AlignCenter ) );
135 docLoadingWidgetProgress = new QProgressBar( docLoadingVBox ); 135 docLoadingWidgetProgress = new QProgressBar( docLoadingVBox );
136 docLoadingWidgetProgress->setProgress( 0 ); 136 docLoadingWidgetProgress->setProgress( 0 );
137 docLoadingWidgetProgress->setCenterIndicator( TRUE ); 137 docLoadingWidgetProgress->setCenterIndicator( TRUE );
138 docLoadingWidgetProgress->setBackgroundMode( NoBackground ); // No flicker 138 docLoadingWidgetProgress->setBackgroundMode( NoBackground ); // No flicker
139 setProgressStyle(); 139 setProgressStyle();
140 140
141 if ( docTabEnabled ) 141 if ( docTabEnabled )
142 { 142 {
143 textLabel->setText( tr( "<b>Finding Documents...</b>" ) ); 143 textLabel->setText( tr( "<b>Finding Documents...</b>" ) );
144 } 144 }
145 else 145 else
146 { 146 {
147 textLabel->setText( tr( "<b>The Documents Tab<p>has been disabled.<p>" 147 textLabel->setText( tr( "<b>The Documents Tab<p>has been disabled.<p>"
148 "Use Settings->Launcher->DocTab<p>to reenable it.</b></center>" ) ); 148 "Use Settings->Launcher->DocTab<p>to reenable it.</b></center>" ) );
149 docLoadingWidgetProgress->hide(); 149 docLoadingWidgetProgress->hide();
150 docLoadingWidgetEnabled = true; 150 docLoadingWidgetEnabled = true;
151 } 151 }
152 152
153 QWidget *space2 = new QWidget( docLoadingVBox ); 153 QWidget *space2 = new QWidget( docLoadingVBox );
154 docLoadingVBox->setStretchFactor( space2, 1 ); 154 docLoadingVBox->setStretchFactor( space2, 1 );
155 155
156 cfg.setGroup( "Tab Documents" ); // No tr 156 cfg.setGroup( "Tab Documents" ); // No tr
157 setTabViewAppearance( docLoadingWidget, cfg ); 157 setTabViewAppearance( docLoadingWidget, cfg );
158 158
159 stack->addWidget( docLoadingWidget, 0 ); 159 stack->addWidget( docLoadingWidget, 0 );
160} 160}
161 161
162void LauncherTabWidget::initLayout() 162void LauncherTabWidget::initLayout()
163{ 163{
164 layout()->activate(); 164 layout()->activate();
165 docView()->setFocus(); 165 docView()->setFocus();
166 categoryBar->showTab("Documents"); 166 categoryBar->showTab("Documents");
167} 167}
168 168
169void LauncherTabWidget::appMessage(const QCString& message, const QByteArray&) 169void LauncherTabWidget::appMessage(const QCString& message, const QByteArray&)
170{ 170{
171 if ( message == "nextView()" ) 171 if ( message == "nextView()" )
172 categoryBar->nextTab(); 172 categoryBar->nextTab();
173} 173}
174 174
175void LauncherTabWidget::raiseTabWidget() 175void LauncherTabWidget::raiseTabWidget()
176{ 176{
177 if ( categoryBar->currentView() == docView() 177 if ( categoryBar->currentView() == docView()
178 && docLoadingWidgetEnabled ) { 178 && docLoadingWidgetEnabled ) {
179 stack->raiseWidget( docLoadingWidget ); 179 stack->raiseWidget( docLoadingWidget );
180 docLoadingWidget->updateGeometry(); 180 docLoadingWidget->updateGeometry();
181 } else { 181 } else {
182 stack->raiseWidget( categoryBar->currentView() ); 182 stack->raiseWidget( categoryBar->currentView() );
183 } 183 }
184} 184}
185 185
186void LauncherTabWidget::tabProperties() 186void LauncherTabWidget::tabProperties()
187{ 187{
188 LauncherView *view = categoryBar->currentView(); 188 LauncherView *view = categoryBar->currentView();
189 QPopupMenu *m = new QPopupMenu( this ); 189 QPopupMenu *m = new QPopupMenu( this );
190 m->insertItem( tr("Icon View"), LauncherView::Icon ); 190 m->insertItem( tr("Icon View"), LauncherView::Icon );
191 m->insertItem( tr("List View"), LauncherView::List ); 191 m->insertItem( tr("List View"), LauncherView::List );
192 m->setItemChecked( (int)view->viewMode(), TRUE ); 192 m->setItemChecked( (int)view->viewMode(), TRUE );
193 int rv = m->exec( QCursor::pos() ); 193 int rv = m->exec( QCursor::pos() );
194 if ( rv >= 0 && rv != view->viewMode() ) { 194 if ( rv >= 0 && rv != view->viewMode() ) {
195 view->setViewMode( (LauncherView::ViewMode)rv ); 195 view->setViewMode( (LauncherView::ViewMode)rv );
196 } 196 }
197 197
198 delete m; 198 delete m;
199} 199}
200 200
201void LauncherTabWidget::deleteView( const QString& id ) 201void LauncherTabWidget::deleteView( const QString& id )
202{ 202{
203 LauncherTab *t = categoryBar->launcherTab(id); 203 LauncherTab *t = categoryBar->launcherTab(id);
204 if ( t ) { 204 if ( t ) {
205 stack->removeWidget( t->view ); 205 stack->removeWidget( t->view );
206 delete t->view; 206 delete t->view;
207 categoryBar->removeTab( t ); 207 categoryBar->removeTab( t );
208 } 208 }
209} 209}
210 210
211LauncherView* LauncherTabWidget::newView( const QString& id, const QPixmap& pm, const QString& label ) 211LauncherView* LauncherTabWidget::newView( const QString& id, const QPixmap& pm, const QString& label )
212{ 212{
213 LauncherView* view = new LauncherView( stack ); 213 LauncherView* view = new LauncherView( stack );
214 connect( view, SIGNAL(clicked(const AppLnk*)), 214 connect( view, SIGNAL(clicked(const AppLnk*)),
215 this, SIGNAL(clicked(const AppLnk*))); 215 this, SIGNAL(clicked(const AppLnk*)));
216 connect( view, SIGNAL(rightPressed(AppLnk*)), 216 connect( view, SIGNAL(rightPressed(AppLnk*)),
217 this, SIGNAL(rightPressed(AppLnk*))); 217 this, SIGNAL(rightPressed(AppLnk*)));
218 218
219
219 int n = categoryBar->count(); 220 int n = categoryBar->count();
221
220 stack->addWidget( view, n ); 222 stack->addWidget( view, n );
221 223
222 LauncherTab *tab = new LauncherTab( id, view, pm, label ); 224 LauncherTab *tab = new LauncherTab( id, view, pm, label );
223 categoryBar->insertTab( tab, n-1 ); 225 categoryBar->insertTab( tab, n-1 );
224 226 if ( id == "Documents" ) {
225 if ( id == "Documents" ) 227 docview = view;
226 docview = view; 228 m_DocumentTabId = n;
229 }
227 230
228 odebug << "inserting " << id << " at " << n-1 << "" << oendl; 231 odebug << "inserting " << id << " at " << n-1 << "" << oendl;
229 232
230 Config cfg("Launcher"); 233 Config cfg("Launcher");
231 setTabAppearance( tab, cfg ); 234 setTabAppearance( tab, cfg );
232 235
233 cfg.setGroup( "GUI" ); 236 cfg.setGroup( "GUI" );
234 view->setBusyIndicatorType( cfg.readEntry( "BusyType", QString::null ) ); 237 view->setBusyIndicatorType( cfg.readEntry( "BusyType", QString::null ) );
235 238
236 return view; 239 return view;
237} 240}
238 241
239LauncherView *LauncherTabWidget::view( const QString &id ) 242LauncherView *LauncherTabWidget::view( const QString &id )
240{ 243{
241 LauncherTab *t = categoryBar->launcherTab(id); 244 LauncherTab *t = categoryBar->launcherTab(id);
242 if ( !t ) 245 if ( !t )
243 return 0; 246 return 0;
244 return t->view; 247 return t->view;
245} 248}
246 249
247LauncherView *LauncherTabWidget::docView() 250LauncherView *LauncherTabWidget::docView()
248{ 251{
249 return docview; 252 return docview;
250} 253}
251 254
252void LauncherTabWidget::setLoadingWidgetEnabled( bool v ) 255void LauncherTabWidget::setLoadingWidgetEnabled( bool v )
253{ 256{
254 if ( v != docLoadingWidgetEnabled && docLoadingWidget ) { 257 if ( v != docLoadingWidgetEnabled && docLoadingWidget ) {
255 docLoadingWidgetEnabled = v; 258 docLoadingWidgetEnabled = v;
256 raiseTabWidget(); 259 raiseTabWidget();
257 } 260 }
258} 261}
259 262
260void LauncherTabWidget::setLoadingProgress( int percent ) 263void LauncherTabWidget::setLoadingProgress( int percent )
261{ 264{
262 docLoadingWidgetProgress->setProgress( (percent / 4) * 4 ); 265 docLoadingWidgetProgress->setProgress( (percent / 4) * 4 );
263} 266}
264 267
265// ### this function could more to LauncherView 268// ### this function could more to LauncherView
266void LauncherTabWidget::setTabViewAppearance( LauncherView *v, Config &cfg ) 269void LauncherTabWidget::setTabViewAppearance( LauncherView *v, Config &cfg )
267{ 270{
268 // View 271 // View
269 QString view = cfg.readEntry( "View", "Icon" ); 272 QString view = cfg.readEntry( "View", "Icon" );
270 if ( view == "List" ) // No tr 273 if ( view == "List" ) // No tr
271 v->setViewMode( LauncherView::List ); 274 v->setViewMode( LauncherView::List );
272 QString bgType = cfg.readEntry( "BackgroundType", "Image" ); 275 QString bgType = cfg.readEntry( "BackgroundType", "Image" );
273 if ( bgType == "Image" ) { // No tr 276 if ( bgType == "Image" ) { // No tr
274 QString pm = cfg.readEntry( "BackgroundImage", "launcher/opie-background" ); 277 QString pm = cfg.readEntry( "BackgroundImage", "launcher/opie-background" );
275 v->setBackgroundType( LauncherView::Image, pm ); 278 v->setBackgroundType( LauncherView::Image, pm );
276 } else if ( bgType == "SolidColor" ) { 279 } else if ( bgType == "SolidColor" ) {
277 QString c = cfg.readEntry( "BackgroundColor" ); 280 QString c = cfg.readEntry( "BackgroundColor" );
278 v->setBackgroundType( LauncherView::SolidColor, c ); 281 v->setBackgroundType( LauncherView::SolidColor, c );
279 } else { 282 } else {
280 v->setBackgroundType( LauncherView::Ruled, QString::null ); 283 v->setBackgroundType( LauncherView::Ruled, QString::null );
@@ -583,49 +586,48 @@ void Launcher::select( const AppLnk *appLnk )
583 tr("<p>No application is defined for this document." 586 tr("<p>No application is defined for this document."
584 "<p>Type is %1.").arg(appLnk->type()), tr("OK"), tr("View as text"), 0, 0, 1); 587 "<p>Type is %1.").arg(appLnk->type()), tr("OK"), tr("View as text"), 0, 0, 1);
585 588
586 /* ### Fixme */ 589 /* ### Fixme */
587 if ( i == 1 ) 590 if ( i == 1 )
588 Global::execute("textedit",appLnk->file()); 591 Global::execute("textedit",appLnk->file());
589 592
590 return; 593 return;
591 } 594 }
592 tabs->setBusy(TRUE); 595 tabs->setBusy(TRUE);
593 emit executing( appLnk ); 596 emit executing( appLnk );
594 appLnk->execute(); 597 appLnk->execute();
595 } 598 }
596} 599}
597 600
598void Launcher::properties( AppLnk *appLnk ) 601void Launcher::properties( AppLnk *appLnk )
599{ 602{
600 if ( appLnk->type() == "Folder" ) { // No tr 603 if ( appLnk->type() == "Folder" ) { // No tr
601 // Not supported: flat is simpler for the user 604 // Not supported: flat is simpler for the user
602 } else { 605 } else {
603/* ### libqtopia FIXME also moving docLnks... */ 606/* ### libqtopia FIXME also moving docLnks... */
604 LnkProperties prop(appLnk,0 ); 607 LnkProperties prop(appLnk,0 );
605 608
606 if (QPEApplication::execDialog( &prop )==QDialog::Accepted && tabs->currentView()==tabs->docView()) { 609 if (QPEApplication::execDialog( &prop )==QDialog::Accepted && tabs->currentView()==tabs->docView()) {
607 tabs->docView()->updateTools();
608 } 610 }
609 } 611 }
610} 612}
611 613
612void Launcher::storageChanged( const QList<FileSystem> & ) 614void Launcher::storageChanged( const QList<FileSystem> & )
613{ 615{
614 // ### update combo boxes if we had a combo box for the storage type 616 // ### update combo boxes if we had a combo box for the storage type
615} 617}
616 618
617void Launcher::systemMessage( const QCString &msg, const QByteArray &data) 619void Launcher::systemMessage( const QCString &msg, const QByteArray &data)
618{ 620{
619 QDataStream stream( data, IO_ReadOnly ); 621 QDataStream stream( data, IO_ReadOnly );
620 if ( msg == "busy()" ) { 622 if ( msg == "busy()" ) {
621 tb->startWait(); 623 tb->startWait();
622 } else if ( msg == "notBusy(QString)" ) { 624 } else if ( msg == "notBusy(QString)" ) {
623 QString app; 625 QString app;
624 stream >> app; 626 stream >> app;
625 tabs->setBusy(FALSE); 627 tabs->setBusy(FALSE);
626 tb->stopWait(app); 628 tb->stopWait(app);
627 } else if (msg == "applyStyle()") { 629 } else if (msg == "applyStyle()") {
628 tabs->currentView()->relayout(); 630 tabs->currentView()->relayout();
629 } 631 }
630} 632}
631 633
@@ -700,50 +702,55 @@ void Launcher::aboutToAddBegin()
700 702
701void Launcher::aboutToAddEnd() 703void Launcher::aboutToAddEnd()
702{ 704{
703 tabs->docView()->setUpdatesEnabled( true ); 705 tabs->docView()->setUpdatesEnabled( true );
704} 706}
705 707
706void Launcher::showLoadingDocs() 708void Launcher::showLoadingDocs()
707{ 709{
708 tabs->docView()->hide(); 710 tabs->docView()->hide();
709} 711}
710 712
711void Launcher::showDocTab() 713void Launcher::showDocTab()
712{ 714{
713 if ( tabs->categoryBar->currentView() == tabs->docView() ) 715 if ( tabs->categoryBar->currentView() == tabs->docView() )
714 tabs->docView()->show(); 716 tabs->docView()->show();
715} 717}
716 718
717void Launcher::documentRemoved( const DocLnk& doc ) 719void Launcher::documentRemoved( const DocLnk& doc )
718{ 720{
719 tabs->docView()->removeLink( doc.linkFile() ); 721 tabs->docView()->removeLink( doc.linkFile() );
720} 722}
721 723
722void Launcher::documentChanged( const DocLnk& oldDoc, const DocLnk& newDoc ) 724void Launcher::documentChanged( const DocLnk& oldDoc, const DocLnk& newDoc )
723{ 725{
726#if 0
724 documentRemoved( oldDoc ); 727 documentRemoved( oldDoc );
725 documentAdded( newDoc ); 728 documentAdded( newDoc );
729// tabs->docView()->updateTools();
730#else
731 tabs->docView()->changeItem(oldDoc,new DocLnk(newDoc));
732#endif
726} 733}
727 734
728void Launcher::allDocumentsRemoved() 735void Launcher::allDocumentsRemoved()
729{ 736{
730 tabs->docView()->removeAllItems(); 737 tabs->docView()->removeAllItems();
731} 738}
732 739
733void Launcher::applicationStateChanged( const QString& name, ApplicationState state ) 740void Launcher::applicationStateChanged( const QString& name, ApplicationState state )
734{ 741{
735 tb->setApplicationState( name, state ); 742 tb->setApplicationState( name, state );
736} 743}
737 744
738void Launcher::applicationScanningProgress( int percent ) 745void Launcher::applicationScanningProgress( int percent )
739{ 746{
740 switch ( percent ) { 747 switch ( percent ) {
741 case 0: { 748 case 0: {
742 for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) { 749 for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) {
743 tabs->view( (*it) )->setUpdatesEnabled( FALSE ); 750 tabs->view( (*it) )->setUpdatesEnabled( FALSE );
744 tabs->view( (*it) )->setSortEnabled( FALSE ); 751 tabs->view( (*it) )->setSortEnabled( FALSE );
745 } 752 }
746 break; 753 break;
747 } 754 }
748 case 100: { 755 case 100: {
749 for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) { 756 for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) {