Hi guys,
review board is not feeling well (upgrading i suppose?) so posting it here
anyways, with this patch could be possible to use Plasma::TabBar like a 
QStackedWidget, i think it makes sense since it has already the double use of 
a tabbar and a tabwidget, so it would be one thing to rule them all...
Index: tabbar.h
===================================================================
--- tabbar.h	(revision 917950)
+++ tabbar.h	(working copy)
@@ -51,6 +51,7 @@
     Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex)
     Q_PROPERTY(int count READ count)
     Q_PROPERTY(QString styleSheet READ styleSheet WRITE setStyleSheet)
+    Q_PROPERTY(bool tabBarShown READ isTabBarShown WRITE setTabBarShown)
 
 public:
     /**
@@ -158,6 +159,20 @@
     QIcon tabIcon(int index) const;
 
     /**
+     * shows or hides the tabbar, used if you just want to display the
+     * pages, when the tabbar doesn't have content pages at all this
+     * function has no effect
+     *
+     * @arg show true if we want to show the tabbar
+     */
+     void setTabBarShown(bool show);
+
+     /**
+      * @return true if the tabbar is shown
+      */
+     bool isTabBarShown() const;
+
+    /**
      * Sets the stylesheet used to control the visual display of this TabBar
      *
      * @arg stylesheet a CSS string
Index: tabbar.cpp
===================================================================
--- tabbar.cpp	(revision 917950)
+++ tabbar.cpp	(working copy)
@@ -71,7 +71,7 @@
         : q(parent),
           tabProxy(0),
           currentIndex(0),
-          isTabWidget(true),
+          tabWidgetMode(true),
           oldPage(0),
           newPage(0),
           oldPageAnimId(-1),
@@ -94,7 +94,7 @@
     QGraphicsLinearLayout *tabWidgetLayout;
     QGraphicsLinearLayout *tabBarLayout;
     int currentIndex;
-    bool isTabWidget;
+    bool tabWidgetMode;
 
     QGraphicsWidget *oldPage;
     QGraphicsWidget *newPage;
@@ -113,7 +113,7 @@
         }
     }
 
-    if (tabWidget != isTabWidget) {
+    if (tabWidget != tabWidgetMode) {
         if (tabWidget) {
             mainLayout->removeAt(0);
             tabBarLayout->insertItem(1, tabProxy);
@@ -125,7 +125,12 @@
         }
     }
 
-    isTabWidget = tabWidget;
+    //always show the tabbar
+    if (!tabWidget) {
+        q->setTabBarShown(true);
+    }
+
+    tabWidgetMode = tabWidget;
 }
 
 void TabBarPrivate::slidingCompleted(QGraphicsItem *item)
@@ -270,7 +275,7 @@
 
 void TabBar::resizeEvent(QGraphicsSceneResizeEvent * event)
 {
-    if (!d->isTabWidget) {
+    if (!d->tabWidgetMode) {
         d->tabProxy->setMinimumSize(event->newSize().toSize());
     } else {
         d->tabProxy->native->setMinimumSize(QSize(0,0));
@@ -405,6 +410,26 @@
     return d->tabProxy->native->tabIcon(index);
 }
 
+void TabBar::setTabBarShown(bool show)
+{
+    if (!show && !d->tabWidgetMode) {
+        return;
+    }
+
+    if (!show && d->tabProxy->isVisible()) {
+        d->tabProxy->hide();
+        d->tabBarLayout->removeItem(d->tabProxy);
+    } else if (show && !d->tabProxy->isVisible()) {
+        d->tabProxy->show();
+        d->tabBarLayout->insertItem(0, d->tabProxy);
+    }
+}
+
+bool TabBar::isTabBarShown() const
+{
+    return d->tabProxy->isVisible();
+}
+
 void TabBar::setStyleSheet(const QString &stylesheet)
 {
     d->tabProxy->native->setStyleSheet(stylesheet);
_______________________________________________
Plasma-devel mailing list
Plasma-devel@kde.org
https://mail.kde.org/mailman/listinfo/plasma-devel

Reply via email to