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
@@ -68,25 +68,25 @@
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()) );
@@ -119,25 +119,25 @@ void LauncherTabWidget::createDocLoadingWidget()
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>" ) );
@@ -160,109 +160,112 @@ void LauncherTabWidget::createDocLoadingWidget()
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
@@ -595,25 +598,24 @@ void Launcher::select( const AppLnk *appLnk )
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 );
@@ -712,26 +714,31 @@ void 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