diff options
author | Andrea Diamantini <adjam7@gmail.com> | 2012-11-26 17:20:15 +0100 |
---|---|---|
committer | Andrea Diamantini <adjam7@gmail.com> | 2012-12-10 02:48:06 +0100 |
commit | 9bf2bbe9bb14425ef228c8e1689bbd14935cac48 (patch) | |
tree | db8ff5863de372d77090a877bb7a0589a01eb1d7 /src/tabwindow | |
parent | Add an home page tab when rekonq is started with some pinned tabs (diff) | |
download | rekonq-9bf2bbe9bb14425ef228c8e1689bbd14935cac48.tar.xz |
Fix tabs moves when some of them are pinned
Diffstat (limited to 'src/tabwindow')
-rw-r--r-- | src/tabwindow/tabbar.cpp | 60 | ||||
-rw-r--r-- | src/tabwindow/tabbar.h | 5 | ||||
-rw-r--r-- | src/tabwindow/tabwindow.cpp | 4 |
3 files changed, 68 insertions, 1 deletions
diff --git a/src/tabwindow/tabbar.cpp b/src/tabwindow/tabbar.cpp index 70dcd3b1..aaf18dc7 100644 --- a/src/tabwindow/tabbar.cpp +++ b/src/tabwindow/tabbar.cpp @@ -333,10 +333,35 @@ void TabBar::removeAnimation(int index) } +void TabBar::tabInserted(int index) +{ + // Find the available index to move + int availableIndex = index; + for (int i = index; i < count(); i++) + { + if (tabData(i).toBool()) + { + availableIndex++; + break; + } + } + + if (index < availableIndex) + { + TabWindow *w = qobject_cast<TabWindow *>(parent()); + w->moveTab(index, availableIndex); + } + + KTabBar::tabInserted(index); +} + + void TabBar::tabRemoved(int index) { hideTabPreview(); removeAnimation(index); + + KTabBar::tabRemoved(index); } @@ -396,6 +421,41 @@ void TabBar::mousePressEvent(QMouseEvent *event) } +void TabBar::mouseReleaseEvent(QMouseEvent *event) +{ + // count pinned tabs + int pinnedTabs = 0; + for(int i = 0; i < count(); i++) + { + if (tabData(i).toBool()) + pinnedTabs++; + } + + // fix unpinned ones + for(int i = 0; i < pinnedTabs; i++) + { + if (!tabData(i).toBool()) + { + TabWindow *w = qobject_cast<TabWindow *>(parent()); + w->moveTab(i, pinnedTabs); + w->setCurrentIndex(pinnedTabs); + } + } + + // fix pinned ones + for (int i = pinnedTabs; i < count(); i++) + { + if (tabData(i).toBool()) + { + TabWindow *w = qobject_cast<TabWindow *>(parent()); + w->moveTab(i, pinnedTabs - 1); + w->setCurrentIndex(pinnedTabs - 1); + } + } + KTabBar::mouseReleaseEvent(event); +} + + void TabBar::tabLayoutChange() { KTabBar::tabLayoutChange(); diff --git a/src/tabwindow/tabbar.h b/src/tabwindow/tabbar.h index 292f3d6d..b325eab8 100644 --- a/src/tabwindow/tabbar.h +++ b/src/tabwindow/tabbar.h @@ -60,8 +60,11 @@ protected: virtual void mouseMoveEvent(QMouseEvent *event); virtual void leaveEvent(QEvent *event); virtual void mousePressEvent(QMouseEvent *event); + virtual void mouseReleaseEvent(QMouseEvent *event); + virtual void tabInserted(int index); virtual void tabRemoved(int index); + virtual void tabLayoutChange(); Q_SIGNALS: @@ -89,7 +92,7 @@ private Q_SLOTS: void showTabPreview(); void hideTabPreview(); - + private: // highlightAnimation TabHighlightEffect *m_tabHighlightEffect; diff --git a/src/tabwindow/tabwindow.cpp b/src/tabwindow/tabwindow.cpp index 4925f8d9..60a9a0eb 100644 --- a/src/tabwindow/tabwindow.cpp +++ b/src/tabwindow/tabwindow.cpp @@ -369,6 +369,10 @@ void TabWindow::tabLoadStarted() if (!tabBar()->tabData(index).toBool()) tabBar()->setTabText(index, i18n("Loading...")); + else + { + tabBar()->tabButton(index, QTabBar::RightSide)->hide(); // NOTE: not really good this, but..."Repetita iuvant"!!! + } } } |