author | mickeyl <mickeyl> | 2003-11-20 01:31:27 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-11-20 01:31:27 (UTC) |
commit | ae9e1ed9cc9e65c1ffb28f3b75ff499e18c6b31a (patch) (side-by-side diff) | |
tree | eb25cce124b37363bbd3b7b757d2c92dc94bee19 | |
parent | d8c2766507a807c72a350bf73c2908e4fa021262 (diff) | |
download | opie-ae9e1ed9cc9e65c1ffb28f3b75ff499e18c6b31a.zip opie-ae9e1ed9cc9e65c1ffb28f3b75ff499e18c6b31a.tar.gz opie-ae9e1ed9cc9e65c1ffb28f3b75ff499e18c6b31a.tar.bz2 |
rework optional doc-tab patch to be less intrusive and more sane
-rw-r--r-- | core/launcher/documentlist.cpp | 22 | ||||
-rw-r--r-- | core/launcher/launcher.cpp | 16 | ||||
-rw-r--r-- | core/launcher/launcher.h | 2 |
3 files changed, 15 insertions, 25 deletions
diff --git a/core/launcher/documentlist.cpp b/core/launcher/documentlist.cpp index dcea4b9..1a7de33 100644 --- a/core/launcher/documentlist.cpp +++ b/core/launcher/documentlist.cpp @@ -51,120 +51,110 @@ AppLnkSet *DocumentList::appLnkSet = 0; static const int MAX_SEARCH_DEPTH = 10; class DocumentListPrivate : public QObject { Q_OBJECT public: DocumentListPrivate( ServerInterface *gui ); ~DocumentListPrivate(); void initialize(); const QString nextFile(); const DocLnk *iterate(); bool store( DocLnk* dl ); void estimatedPercentScanned(); DocLnkSet dls; QDict<void> reference; QDictIterator<void> *dit; enum { Find, RemoveKnownFiles, MakeUnknownFiles, Done } state; QStringList docPaths; unsigned int docPathsSearched; int searchDepth; QDir *listDirs[MAX_SEARCH_DEPTH]; const QFileInfoList *lists[MAX_SEARCH_DEPTH]; unsigned int listPositions[MAX_SEARCH_DEPTH]; StorageInfo *storage; int tid; ServerInterface *serverGui; bool needToSendAllDocLinks; bool sendAppLnks; bool sendDocLnks; bool scanDocs; }; DocumentList::DocumentList( ServerInterface *serverGui, bool scanDocs, QObject *parent, const char *name ) : QObject( parent, name ) { appLnkSet = new AppLnkSet( MimeType::appsFolderName() ); d = new DocumentListPrivate( serverGui ); - d->scanDocs = scanDocs; d->needToSendAllDocLinks = false; + Config cfg( "Launcher" ); + cfg.setGroup( "DocTab" ); + d->scanDocs = cfg.readBoolEntry( "Enable", true ); + qDebug( "DocumentList::DocumentList() : scanDocs = %d", d->scanDocs ); + QTimer::singleShot( 10, this, SLOT( startInitialScan() ) ); } void DocumentList::startInitialScan() { reloadAppLnks(); - - Config cfg( "Launcher" ); - cfg.setGroup( "DocTab" ); - bool docTabEnabled = cfg.readBoolEntry( "Enable", true ); - if ( docTabEnabled ) - reloadDocLnks(); - else - { - if ( d->sendDocLnks && d->serverGui ) - { - d->serverGui->documentScanningProgress( 0 ); - d->serverGui->allDocumentsRemoved(); - } - } - + reloadDocLnks(); } DocumentList::~DocumentList() { delete appLnkSet; delete d; } void DocumentList::add( const DocLnk& doc ) { if ( d->serverGui && QFile::exists( doc.file() ) ) d->serverGui->documentAdded( doc ); } void DocumentList::start() { resume(); } void DocumentList::pause() { //qDebug("pause %i", d->tid); killTimer( d->tid ); d->tid = 0; } void DocumentList::resume() { if ( d->tid == 0 ) { d->tid = startTimer( 0 ); //qDebug("resumed %i", d->tid); } } /* void DocumentList::resend() { // Re-emits all the added items to the list (firstly letting everyone know to // clear what they have as it is being sent again) pause(); emit allRemoved(); QTimer::singleShot( 5, this, SLOT( resendWorker() ) ); } diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp index b312672..344cd46 100644 --- a/core/launcher/launcher.cpp +++ b/core/launcher/launcher.cpp @@ -107,96 +107,97 @@ LauncherTabWidget::LauncherTabWidget( Launcher* parent ) : #endif createDocLoadingWidget(); } void LauncherTabWidget::createDocLoadingWidget() { // Construct the 'doc loading widget' shown when finding documents // ### LauncherView class needs changing to be more generic so // this widget can change its background similar to the iconviews // so the background for this matches docLoadingWidget = new LauncherView( stack ); docLoadingWidget->hideIcons(); QVBox *docLoadingVBox = new QVBox( docLoadingWidget ); docLoadingVBox->setSpacing( 20 ); docLoadingVBox->setMargin( 10 ); QWidget *space1 = new QWidget( docLoadingVBox ); docLoadingVBox->setStretchFactor( space1, 1 ); QLabel *waitPixmap = new QLabel( docLoadingVBox ); waitPixmap->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, waitPixmap->sizePolicy().hasHeightForWidth() ) ); waitPixmap->setPixmap( Resource::loadPixmap( "bigwait" ) ); waitPixmap->setAlignment( int( QLabel::AlignCenter ) ); Config cfg( "Launcher" ); cfg.setGroup( "DocTab" ); bool docTabEnabled = cfg.readBoolEntry( "Enable", true ); QLabel *textLabel = new QLabel( docLoadingVBox ); textLabel->setAlignment( int( QLabel::AlignCenter ) ); docLoadingWidgetProgress = new QProgressBar( docLoadingVBox ); docLoadingWidgetProgress->setProgress( 0 ); docLoadingWidgetProgress->setCenterIndicator( TRUE ); docLoadingWidgetProgress->setBackgroundMode( NoBackground ); // No flicker setProgressStyle(); if ( docTabEnabled ) { textLabel->setText( tr( "<b>Finding Documents...</b>" ) ); } else { textLabel->setText( tr( "<b>The Documents Tab<p>has been disabled.<p>" "Use Settings->Launcher->DocTab<p>to reenable it.</b></center>" ) ); docLoadingWidgetProgress->hide(); + docLoadingWidgetEnabled = true; } QWidget *space2 = new QWidget( docLoadingVBox ); docLoadingVBox->setStretchFactor( space2, 1 ); cfg.setGroup( "Tab Documents" ); // No tr setTabViewAppearance( docLoadingWidget, cfg ); stack->addWidget( docLoadingWidget, 0 ); } void LauncherTabWidget::initLayout() { layout()->activate(); docView()->setFocus(); categoryBar->showTab("Documents"); } void LauncherTabWidget::appMessage(const QCString& message, const QByteArray&) { if ( message == "nextView()" ) categoryBar->nextTab(); } void LauncherTabWidget::raiseTabWidget() { if ( categoryBar->currentView() == docView() && docLoadingWidgetEnabled ) { stack->raiseWidget( docLoadingWidget ); docLoadingWidget->updateGeometry(); } else { stack->raiseWidget( categoryBar->currentView() ); } } void LauncherTabWidget::tabProperties() { LauncherView *view = categoryBar->currentView(); QPopupMenu *m = new QPopupMenu( this ); m->insertItem( tr("Icon View"), LauncherView::Icon ); m->insertItem( tr("List View"), LauncherView::List ); m->setItemChecked( (int)view->viewMode(), TRUE ); int rv = m->exec( QCursor::pos() ); if ( rv >= 0 && rv != view->viewMode() ) { view->setViewMode( (LauncherView::ViewMode)rv ); } delete m; @@ -456,96 +457,103 @@ void Launcher::createGUI() tb = new TaskBar; tabs = new LauncherTabWidget( this ); setCentralWidget( tabs ); ServerInterface::dockWidget( tb, ServerInterface::Bottom ); tb->show(); qApp->installEventFilter( this ); connect( qApp, SIGNAL(symbol()), this, SLOT(toggleSymbolInput()) ); connect( qApp, SIGNAL(numLockStateToggle()), this, SLOT(toggleNumLockState()) ); connect( qApp, SIGNAL(capsLockStateToggle()), this, SLOT(toggleCapsLockState()) ); connect( tb, SIGNAL(tabSelected(const QString&)), this, SLOT(showTab(const QString&)) ); connect( tabs, SIGNAL(selected(const QString&)), this, SLOT(viewSelected(const QString&)) ); connect( tabs, SIGNAL(clicked(const AppLnk*)), this, SLOT(select(const AppLnk*))); connect( tabs, SIGNAL(rightPressed(AppLnk*)), this, SLOT(properties(AppLnk*))); #if defined(Q_WS_QWS) && !defined(QT_NO_COP) QCopChannel* sysChannel = new QCopChannel( "QPE/System", this ); connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)), this, SLOT(systemMessage( const QCString &, const QByteArray &)) ); #endif // all documents QImage img( Resource::loadImage( "DocsIcon" ) ); QPixmap pm; pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); // It could add this itself if it handles docs tabs->newView("Documents", pm, tr("Documents") )->setToolsEnabled( TRUE ); QTimer::singleShot( 0, tabs, SLOT( initLayout() ) ); qApp->setMainWidget( this ); QTimer::singleShot( 500, this, SLOT( makeVisible() ) ); } Launcher::~Launcher() { if ( tb ) destroyGUI(); } + bool Launcher::requiresDocuments() const + { + Config cfg( "Launcher" ); + cfg.setGroup( "DocTab" ); + return cfg.readBoolEntry( "Enable", true ); +} + void Launcher::makeVisible() { showMaximized(); } void Launcher::destroyGUI() { delete tb; tb = 0; delete tabs; tabs =0; } bool Launcher::eventFilter( QObject*, QEvent *ev ) { #ifdef QT_QWS_CUSTOM if ( ev->type() == QEvent::KeyPress ) { QKeyEvent *ke = (QKeyEvent *)ev; if ( ke->key() == Qt::Key_F11 ) { // menu key QWidget *active = qApp->activeWindow(); if ( active && active->isPopup() ) active->close(); else { Global::terminateBuiltin("calibrate"); // No tr tb->launchStartMenu(); } return TRUE; } } #else Q_UNUSED(ev); #endif return FALSE; } void Launcher::toggleSymbolInput() { tb->toggleSymbolInput(); } void Launcher::toggleNumLockState() { tb->toggleNumLockState(); } void Launcher::toggleCapsLockState() { tb->toggleCapsLockState(); @@ -704,77 +712,69 @@ void Launcher::showDocTab() tabs->docView()->show(); } void Launcher::documentRemoved( const DocLnk& doc ) { tabs->docView()->removeLink( doc.linkFile() ); } void Launcher::documentChanged( const DocLnk& oldDoc, const DocLnk& newDoc ) { documentRemoved( oldDoc ); documentAdded( newDoc ); } void Launcher::allDocumentsRemoved() { tabs->docView()->removeAllItems(); } void Launcher::applicationStateChanged( const QString& name, ApplicationState state ) { tb->setApplicationState( name, state ); } void Launcher::applicationScanningProgress( int percent ) { switch ( percent ) { case 0: { for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) { tabs->view( (*it) )->setUpdatesEnabled( FALSE ); tabs->view( (*it) )->setSortEnabled( FALSE ); } break; } case 100: { for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) { tabs->view( (*it) )->setUpdatesEnabled( TRUE ); tabs->view( (*it) )->setSortEnabled( TRUE ); } break; } default: break; } } void Launcher::documentScanningProgress( int percent ) { - if ( !docTabEnabled ) - { - qDebug( "Launcher: document tab disabled!" ); - tabs->setLoadingProgress( 100 ); - tabs->setLoadingWidgetEnabled( TRUE ); - return; - } - switch ( percent ) { case 0: { tabs->setLoadingProgress( 0 ); tabs->setLoadingWidgetEnabled( TRUE ); tabs->docView()->setUpdatesEnabled( FALSE ); tabs->docView()->setSortEnabled( FALSE ); break; } case 100: { tabs->docView()->updateTools(); tabs->docView()->setSortEnabled( TRUE ); tabs->docView()->setUpdatesEnabled( TRUE ); tabs->setLoadingWidgetEnabled( FALSE ); break; } default: tabs->setLoadingProgress( percent ); break; } } diff --git a/core/launcher/launcher.h b/core/launcher/launcher.h index 1d046ee..4f3ff8c 100644 --- a/core/launcher/launcher.h +++ b/core/launcher/launcher.h @@ -71,87 +71,87 @@ signals: protected slots: void raiseTabWidget(); void tabProperties(); void initLayout(); private slots: void launcherMessage( const QCString &, const QByteArray &); void appMessage( const QCString &, const QByteArray &); void setProgressStyle(); protected: void paletteChange( const QPalette &p ); void styleChange( QStyle & ); private: Launcher *launcher; LauncherView *docview; QWidgetStack *stack; LauncherView *docLoadingWidget; QProgressBar *docLoadingWidgetProgress; bool docLoadingWidgetEnabled; }; class Launcher : public QMainWindow, public ServerInterface { Q_OBJECT public: Launcher(); ~Launcher(); // implementing ServerInterface void createGUI(); void destroyGUI(); void typeAdded( const QString& type, const QString& name, const QPixmap& pixmap, const QPixmap& bgPixmap ); void typeRemoved( const QString& type ); void applicationAdded( const QString& type, const AppLnk& doc ); void applicationRemoved( const QString& type, const AppLnk& doc ); void allApplicationsRemoved(); void applicationStateChanged( const QString& name, ApplicationState state ); void documentAdded( const DocLnk& doc ); void documentRemoved( const DocLnk& doc ); void allDocumentsRemoved(); void documentChanged( const DocLnk& oldDoc, const DocLnk& newDoc ); void storageChanged( const QList<FileSystem> & ); void applicationScanningProgress( int percent ); void documentScanningProgress( int percent ); bool requiresApplications() const { return TRUE; } - bool requiresDocuments() const { return TRUE; } + bool requiresDocuments() const; void showLoadingDocs(); void showDocTab(); QStringList idList() const { return ids; } public slots: void viewSelected(const QString&); void showTab(const QString&); void select( const AppLnk * ); void properties( AppLnk * ); void makeVisible(); signals: void executing( const AppLnk * ); private slots: void systemMessage( const QCString &, const QByteArray &); void toggleSymbolInput(); void toggleNumLockState(); void toggleCapsLockState(); protected: bool eventFilter( QObject *o, QEvent *ev ); private: void updateApps(); void loadDocs(); void updateDocs(); void updateTabs(); LauncherTabWidget *tabs; QStringList ids; TaskBar *tb; bool docTabEnabled; }; #endif // LAUNCHERVIEW_H |