void MainWindow::setWidgetsVisible(bool makeVisible) { // state flags static bool bookmarksToolBarFlag; static bool historyPanelFlag; static bool bookmarksPanelFlag; KToolBar *mainBar = toolBar("mainToolBar"); KToolBar *bookBar = toolBar("bookmarksToolBar"); if (!makeVisible) { // save current state, if in windowed mode if (!isFullScreen()) { bookmarksToolBarFlag = bookBar->isHidden(); historyPanelFlag = m_historyPanel->isHidden(); bookmarksPanelFlag = m_bookmarksPanel->isHidden(); } bookBar->hide(); m_view->setTabBarHidden(true); m_historyPanel->hide(); m_bookmarksPanel->hide(); // hide main toolbar mainBar->hide(); } else { // show main toolbar mainBar->show(); m_view->setTabBarHidden(false); // restore state of windowed mode if (!bookmarksToolBarFlag) bookBar->show(); if (!historyPanelFlag) m_historyPanel->show(); if (!bookmarksPanelFlag) m_bookmarksPanel->show(); } }
void MainWindow::selectPlugin( Kontact::Plugin *plugin ) { if ( !plugin ) return; if ( plugin->isRunningStandalone() ) { statusBar()->message( i18n( "Application is running standalone. Foregrounding..." ), 1000 ); mSidePane->indicateForegrunding( plugin ); plugin->bringToForeground(); return; } KApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) ); KParts::Part *part = plugin->part(); if ( !part ) { KApplication::restoreOverrideCursor(); KMessageBox::error( this, i18n( "Cannot load part for %1." ) .arg( plugin->title() ) + "\n" + lastErrorMessage() ); plugin->setDisabled( true ); mSidePane->updatePlugins(); return; } // store old focus widget QWidget *focusWidget = kapp->focusWidget(); if ( mCurrentPlugin && focusWidget ) { // save the focus widget only when it belongs to the activated part QWidget *parent = focusWidget->parentWidget(); while ( parent ) { if ( parent == mCurrentPlugin->part()->widget() ) mFocusWidgets.insert( mCurrentPlugin->identifier(), QGuardedPtr<QWidget>( focusWidget ) ); parent = parent->parentWidget(); } } if ( mSidePane ) mSidePane->selectPlugin( plugin ); plugin->select(); mPartManager->setActivePart( part ); QWidget *view = part->widget(); Q_ASSERT( view ); if ( view ) { mPartsStack->raiseWidget( view ); view->show(); if ( mFocusWidgets.contains( plugin->identifier() ) ) { focusWidget = mFocusWidgets[ plugin->identifier() ]; if ( focusWidget ) focusWidget->setFocus(); } else view->setFocus(); mCurrentPlugin = plugin; KAction *newAction = plugin->newActions()->first(); KAction *syncAction = plugin->syncActions()->first(); createGUI( plugin->part() ); KToolBar* navigatorToolBar = findToolBar( "navigatorToolBar" ); // Let the navigator toolbar be always the last one, if it's in the top dockwindow if ( navigatorToolBar && !navigatorToolBar->isHidden() && navigatorToolBar->barPos() == KToolBar::Top ) { topDock()->moveDockWindow( navigatorToolBar, -1 ); } setCaption( i18n( "Plugin dependent window title" ,"%1 - Kontact" ).arg( plugin->title() ) ); if ( newAction ) { mNewActions->setIcon( newAction->icon() ); mNewActions->setText( newAction->text() ); } else { // we'll use the action of the first plugin which offers one PluginList::Iterator it; for ( it = mPlugins.begin(); it != mPlugins.end(); ++it ) { newAction = (*it)->newActions()->first(); if ( newAction ) { mNewActions->setIcon( newAction->icon() ); mNewActions->setText( newAction->text() ); break; } } } if ( mSyncActionsEnabled ) { if ( syncAction ) { mSyncActions->setIcon( syncAction->icon() ); mSyncActions->setText( syncAction->text() ); } else { // we'll use the action of the first plugin which offers one PluginList::Iterator it; for ( it = mPlugins.begin(); it != mPlugins.end(); ++it ) { syncAction = (*it)->syncActions()->first(); if ( syncAction ) { mSyncActions->setIcon( syncAction->icon() ); mSyncActions->setText( syncAction->text() ); break; } } } } } QStringList invisibleActions = plugin->invisibleToolbarActions(); QStringList::ConstIterator it; for ( it = invisibleActions.begin(); it != invisibleActions.end(); ++it ) { KAction *action = part->actionCollection()->action( (*it).latin1() ); if ( action ) { QPtrListIterator<KToolBar> it( toolBarIterator() ); for ( ; it.current() ; ++it ) { action->unplug( it.current() ); } } } KApplication::restoreOverrideCursor(); }