From 228bd405a579f1653462809dae12cb48f2df941c Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Thu, 29 Oct 2009 11:26:42 +0100 Subject: Fixing hide/show tab bar and flickering new tabs. That happened because of the code moving from mainview to tabbar (my fault) (tabbar cannot draw and be drawn..) --- src/tabbar.cpp | 58 ++-------------------------------------------------------- 1 file changed, 2 insertions(+), 56 deletions(-) (limited to 'src/tabbar.cpp') diff --git a/src/tabbar.cpp b/src/tabbar.cpp index 65a65f7e..b92c938a 100644 --- a/src/tabbar.cpp +++ b/src/tabbar.cpp @@ -64,7 +64,6 @@ TabBar::TabBar(MainView *parent) : KTabBar(parent) , m_parent(parent) - , m_addTabButton(new QToolButton(this)) , m_currentTabPreview(-1) { setElideMode(Qt::ElideRight); @@ -77,8 +76,6 @@ TabBar::TabBar(MainView *parent) connect(this, SIGNAL(contextMenu(int, const QPoint &)), this, SLOT(slotContextMenuRequested(int, const QPoint &))); connect(this, SIGNAL(emptyAreaContextMenu(const QPoint &)), this, SLOT(slotEmptyAreaContextMenu(const QPoint &))); - - QTimer::singleShot(0, this, SLOT(postLaunch())); } @@ -87,27 +84,9 @@ TabBar::~TabBar() } -void TabBar::postLaunch() -{ - // Find the correct MainWindow of this tab button - MainWindowList list = Application::instance()->mainWindowList(); - Q_FOREACH(QPointer w, list) - { - if (w->isAncestorOf(this)) - { - m_addTabButton->setDefaultAction(w->actionByName("new_tab")); - break; - } - } - - m_addTabButton->setAutoRaise(true); - m_addTabButton->setToolButtonStyle(Qt::ToolButtonIconOnly); -} - - QSize TabBar::tabSizeHint(int index) const { - int buttonSize = m_addTabButton->size().width(); + int buttonSize = m_parent->addTabButton()->size().width(); int tabBarWidth = m_parent->size().width() - buttonSize; int baseWidth = m_parent->sizeHint().width()/BASE_WIDTH_DIVISOR; int minWidth = m_parent->sizeHint().width()/MIN_WIDTH_DIVISOR; @@ -243,6 +222,7 @@ void TabBar::leaveEvent(QEvent *event) KTabBar::leaveEvent(event); } + void TabBar::mousePressEvent(QMouseEvent *event) { // just close tab on middle mouse click @@ -253,40 +233,6 @@ void TabBar::mousePressEvent(QMouseEvent *event) } -void TabBar::updateNewTabButton() -{ - static bool ButtonInCorner = false; - - int tabWidgetWidth = m_parent->frameSize().width(); - int tabBarWidth = tabSizeHint(0).width() * count(); - - if (tabBarWidth + m_addTabButton->width() > tabWidgetWidth) - { - if(ButtonInCorner) - return; - m_parent->setCornerWidget(m_addTabButton); - ButtonInCorner = true; - } - else - { - if(ButtonInCorner) - { - m_parent->setCornerWidget(0); - m_addTabButton->show(); - ButtonInCorner = false; - } - - int newPosX = tabWidgetWidth - m_addTabButton->width(); - int newPosY = height() - m_addTabButton->height(); - - if (tabBarWidth + m_addTabButton->width() < tabWidgetWidth) - newPosX = tabBarWidth; - - m_addTabButton->move(newPosX, newPosY); - } -} - - void TabBar::slotContextMenuRequested(int tab, const QPoint &pos) { m_actualIndex = tab; -- cgit v1.2.1