Commit 3b39ad08 authored by Zack Rusin's avatar Zack Rusin
Browse files

Fixing flicker on initial showing of the tabbar.

CCMAIL: 58040@bugs.kde.org

svn path=/trunk/kdebase/konqueror/; revision=323560
parent f40b6c05
......@@ -1119,8 +1119,6 @@ void KonqMainWindow::slotCreateNewWindow( const KURL &url, const KParts::URLArgs
// activate the view _now_ in order to make the menuBar() hide call work
if ( part ) {
mainWindow->viewManager()->setActivePart( part, true );
if ( dynamic_cast<KonqFrameTabs*>(mainWindow->viewManager()->docContainer()) )
mainWindow->viewManager()->revertDocContainer();
}
QString profileName = QString::fromLatin1( url.isLocalFile() ? "konqueror/profiles/filemanagement" : "konqueror/profiles/webbrowsing" );
......
......@@ -53,7 +53,7 @@
KonqFrameTabs::KonqFrameTabs(QWidget* parent, KonqFrameContainerBase* parentContainer,
KonqViewManager* viewManager, const char * name)
: KTabWidget(parent, name), m_rightWidget(0)
: KTabWidget(parent, name), m_rightWidget(0), m_leftWidget(0), m_alwaysTabBar(false)
{
//kdDebug(1202) << "KonqFrameTabs::KonqFrameTabs()" << endl;
......@@ -141,13 +141,13 @@ KonqFrameTabs::KonqFrameTabs(QWidget* parent, KonqFrameContainerBase* parentCont
m_pViewManager->mainWindow(), SLOT( slotRemoveTabPopup() ) );
if ( config->readBoolEntry( "AddTabButton", true ) ) {
QToolButton * leftWidget = new QToolButton( this );
connect( leftWidget, SIGNAL( clicked() ),
m_leftWidget = new QToolButton( this );
connect( m_leftWidget, SIGNAL( clicked() ),
m_pViewManager->mainWindow(), SLOT( slotAddTab() ) );
leftWidget->setIconSet( SmallIcon( "tab_new" ) );
leftWidget->adjustSize();
QToolTip::add(leftWidget, i18n("Open a new tab"));
setCornerWidget( leftWidget, TopLeft );
m_leftWidget->setIconSet( SmallIcon( "tab_new" ) );
m_leftWidget->adjustSize();
QToolTip::add(m_leftWidget, i18n("Open a new tab"));
setCornerWidget( m_leftWidget, TopLeft );
}
if ( config->readBoolEntry( "CloseTabButton", true ) ) {
m_rightWidget = new QToolButton( this );
......@@ -374,6 +374,7 @@ void KonqFrameTabs::insertChildFrame( KonqFrameBase* frame, int index )
if (frame)
{
//kdDebug(1202) << "Adding frame" << endl;
bool showTabBar = (count() == 1);
insertTab(frame->widget(),"", index);
frame->setParentContainer(this);
if (index == -1) m_pChildFrameList->append(frame);
......@@ -385,6 +386,10 @@ void KonqFrameTabs::insertChildFrame( KonqFrameBase* frame, int index )
activeChildView->setCaption( activeChildView->caption() );
activeChildView->setTabIcon( activeChildView->url().url() );
}
if (showTabBar)
this->showTabBar();
else if ( count() == 1 )
this->hideTabBar();//the first frame inserted (initialization)
}
else
kdWarning(1202) << "KonqFrameTabs " << this << ": insertChildFrame(0L) !" << endl;
......@@ -398,6 +403,8 @@ void KonqFrameTabs::removeChildFrame( KonqFrameBase * frame )
m_pChildFrameList->remove(frame);
if (m_rightWidget)
m_rightWidget->setEnabled( m_pChildFrameList->count()>1 );
if (count() == 1)
hideTabBar();
}
else
kdWarning(1202) << "KonqFrameTabs " << this << ": removeChildFrame(0L) !" << endl;
......@@ -571,4 +578,33 @@ void KonqFrameTabs::slotInitiateDrag( QWidget *w )
}
}
void KonqFrameTabs::hideTabBar()
{
if ( !m_alwaysTabBar ) {
m_leftWidget->hide();
m_rightWidget->hide();
tabBar()->hide();
}
}
void KonqFrameTabs::showTabBar()
{
tabBar()->show();
m_leftWidget->show();
m_rightWidget->show();
}
void KonqFrameTabs::setAlwaysTabbedMode( bool enable )
{
bool update = ( enable != m_alwaysTabBar );
m_alwaysTabBar = enable;
if ( update ) {
if ( m_alwaysTabBar )
showTabBar();
else
hideTabBar();
}
}
#include "konq_tabs.moc"
......@@ -89,6 +89,7 @@ public:
public slots:
void slotCurrentChanged( QWidget* newPage );
void setAlwaysTabbedMode( bool );
signals:
void ctrlTabPressed();
......@@ -99,6 +100,8 @@ protected:
uint tabBarWidthForMaxChars( uint );
void refreshSubPopupMenuTab();
void hideTabBar();
void showTabBar();
QPtrList<KonqFrameBase>* m_pChildFrameList;
......@@ -113,14 +116,17 @@ private slots:
void slotReceivedDropEvent( QDropEvent* );
void slotInitiateDrag( QWidget * );
void slotReceivedDropEvent( QWidget *, QDropEvent * );
void slotSubPopupMenuTabActivated( int);
void slotSubPopupMenuTabActivated( int );
private:
KonqViewManager* m_pViewManager;
QPopupMenu* m_pPopupMenu;
QPopupMenu * m_pSubPopupMenuTab;
uint m_CurrentMaxLength, m_maxLength, m_minLength;
QToolButton* m_rightWidget;
QToolButton* m_leftWidget;
bool m_permanentCloseButtons;
bool m_alwaysTabBar;
};
#endif
......@@ -77,8 +77,10 @@ KonqView* KonqViewManager::Initialize( const QString &serviceType, const QString
KConfig *config = KGlobal::config();
KConfigGroupSaver cs( config, QString::fromLatin1("FMSettings") );
if ( config->readBoolEntry( "AlwaysTabbedMode", false ) )
convertDocContainer();
static_cast<KonqFrameTabs*>( m_pDocContainer )->setAlwaysTabbedMode(
config->readBoolEntry( "AlwaysTabbedMode", false ) );
m_pDocContainer->widget()->show();
return childView;
......@@ -305,60 +307,6 @@ void KonqViewManager::convertDocContainer()
m_pDocContainer = newContainer;
}
void KonqViewManager::revertDocContainer()
{
// If the tab container is left with only one tab after the removal,
// destroy it and put its lone child frame in its place
KonqFrameTabs* tabContainer = static_cast<KonqFrameTabs*>(m_pDocContainer);
KonqFrameContainerBase* parentContainer = tabContainer->parentContainer();
kdDebug(1202) << "parentContainer=" << parentContainer << endl;
if (parentContainer == 0L) return;
bool moveNewContainer = false;
QValueList<int> splitterSizes;
if (parentContainer->frameType()=="Container") {
moveNewContainer = (static_cast<KonqFrameContainer*>(parentContainer)->idAfter( tabContainer ) != 0);
splitterSizes = static_cast<KonqFrameContainer*>(parentContainer)->sizes();
}
KonqFrameBase* otherFrame = tabContainer->childFrameList()->first();
kdDebug(1202) << "otherFrame=" << otherFrame << endl;
if (otherFrame == 0L ) return;
parentContainer->widget()->setUpdatesEnabled( false );
QPoint pos = otherFrame->widget()->pos();
otherFrame->reparentFrame( m_pMainWindow, pos );
tabContainer->removeChildFrame( otherFrame );
parentContainer->removeChildFrame( tabContainer );
delete tabContainer;
otherFrame->reparentFrame( parentContainer->widget(), pos );
parentContainer->insertChildFrame( otherFrame );
if ( moveNewContainer ) {
static_cast<KonqFrameContainer*>(parentContainer)->moveToFirst( otherFrame->widget() );
static_cast<KonqFrameContainer*>(parentContainer)->swapChildren();
}
if (parentContainer->frameType()=="Container")
static_cast<KonqFrameContainer*>(parentContainer)->setSizes( splitterSizes );
otherFrame->widget()->show();
parentContainer->widget()->setUpdatesEnabled( true );
parentContainer->setActiveChild( otherFrame );
parentContainer->activateChild();
m_pDocContainer = otherFrame;
}
KonqView* KonqViewManager::addTab(const QString &serviceType, const QString &serviceName, bool passiveMode, bool openAfterCurrentPage )
{
#ifdef DEBUG_VIEWMGR
......@@ -592,13 +540,6 @@ void KonqViewManager::removeTab( KonqFrameBase* tab )
tabContainer->slotCurrentChanged(tabContainer->currentPage());
if (tabContainer->count() == 1) {
KConfig *config = KGlobal::config();
KConfigGroupSaver cs( config, QString::fromLatin1("FMSettings") );
if ( !( config->readBoolEntry( "AlwaysTabbedMode", false ) ) )
revertDocContainer();
}
#ifdef DEBUG_VIEWMGR
m_pMainWindow->dumpViewList();
printFullHierarchy( m_pMainWindow );
......@@ -1160,7 +1101,7 @@ void KonqViewManager::loadViewProfile( KConfig &cfg, const QString & filename,
"LoadProfileTabsConfirm" ) == KMessageBox::Cancel )
return;
}
KonqView *originalView = m_pMainWindow->currentView();
QPtrList<KonqFrameBase> frameList = *tabContainer->childFrameList();
QPtrListIterator<KonqFrameBase> it( frameList );
......@@ -1193,7 +1134,7 @@ void KonqViewManager::loadViewProfile( KConfig &cfg, const QString & filename,
return;
}
}
KConfig *config = KGlobal::config();
KConfigGroupSaver cs( config, QString::fromLatin1("FMSettings") );
bool alwaysTabbedMode = config->readBoolEntry( "AlwaysTabbedMode", false );
......@@ -1217,7 +1158,7 @@ void KonqViewManager::loadViewProfile( KConfig &cfg, const QString & filename,
}
//kdDebug(1202) << "KonqViewManager::loadViewProfile : loading RootItem " << rootItem << endl;
if ( alwaysTabbedMode && rootItem == "empty" )
if ( rootItem == "empty" )
{
cfg.writeEntry( "View0_ServiceType", "text/html" );
cfg.writeEntry( "View0_ServiceName", "html" );
......@@ -1246,9 +1187,11 @@ void KonqViewManager::loadViewProfile( KConfig &cfg, const QString & filename,
m_pMainWindow->action( "clear_location" )->activate();
}
if ( alwaysTabbedMode && m_pDocContainer->frameType() != "Tabs")
if ( m_pDocContainer->frameType() != "Tabs")
convertDocContainer();
static_cast<KonqFrameTabs*>( m_pDocContainer )->setAlwaysTabbedMode( alwaysTabbedMode );
// Set an active part first so that we open the URL in the current view
// (to set the location bar correctly and asap)
KonqView *nextChildView = 0L;
......
......@@ -90,10 +90,6 @@ public:
*/
void convertDocContainer();
/**
* Reverts a Tab docContainer into a View
*/
void revertDocContainer();
/**
* Adds a tab to m_pMainContainer
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment