summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/sessionmanager.cpp3
-rw-r--r--src/tabwindow/tabbar.cpp60
-rw-r--r--src/tabwindow/tabbar.h5
-rw-r--r--src/tabwindow/tabwindow.cpp4
4 files changed, 70 insertions, 2 deletions
diff --git a/src/sessionmanager.cpp b/src/sessionmanager.cpp
index 4903360c..08f576a4 100644
--- a/src/sessionmanager.cpp
+++ b/src/sessionmanager.cpp
@@ -109,7 +109,8 @@ int loadTabs(TabWindow *tw, QDomElement & window, bool useFirstTab, bool justThe
if (tabIsPinned)
{
tw->tabBar()->setTabData(tabNo, true);
- tw->tabBar()->tabButton(tabNo, QTabBar::RightSide)->hide(); // NOTE: this is not good here: where is its proper place?
+ if (tw->tabBar()->tabButton(tabNo, QTabBar::RightSide))
+ tw->tabBar()->tabButton(tabNo, QTabBar::RightSide)->hide(); // NOTE: this is not good here: where is its proper place?
}
}
}
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"!!!
+ }
}
}