[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [calligra] sheets/part: Fix up resizing behaviour for the sheet selector widget
From:       Tomas Mecir <mecirt () gmail ! com>
Date:       2016-12-03 19:59:38
Message-ID: E1cDGTC-0000S5-If () code ! kde ! org
[Download RAW message or body]

Git commit 7558620e887ad44049798cab022f2d346f19b8d9 by Tomas Mecir.
Committed on 03/12/2016 at 19:59.
Pushed by mecir into branch 'master'.

Fix up resizing behaviour for the sheet selector widget

M  +8    -1    sheets/part/TabBar.cpp
M  +1    -0    sheets/part/View.cpp

https://commits.kde.org/calligra/7558620e887ad44049798cab022f2d346f19b8d9

diff --git a/sheets/part/TabBar.cpp b/sheets/part/TabBar.cpp
index 677fc27..989d4e5 100644
--- a/sheets/part/TabBar.cpp
+++ b/sheets/part/TabBar.cpp
@@ -39,6 +39,7 @@
 #include <QWidget>
 #include <QWheelEvent>
 #include <QFontDatabase>
+#include <QDebug>
 
 // TODO
 // improvement possibilities
@@ -236,6 +237,7 @@ void TabBarPrivate::layoutTabs()
                 break;
             }
     }
+    tabbar->updateGeometry();
 }
 
 int TabBarPrivate::tabAt(const QPoint& pos)
@@ -367,6 +369,7 @@ TabBar::TabBar(QWidget* parent, const char* /*name*/)
     d->wheelDelta = 0;
     d->autoScroll = false;
     d->offset = 64;
+    setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
 
     // initialize the scroll buttons
     d->scrollFirstButton = new QToolButton(this);
@@ -687,7 +690,11 @@ void TabBar::resizeEvent(QResizeEvent*)
 
 QSize TabBar::sizeHint() const
 {
-    return QSize(40, style()->pixelMetric(QStyle::PM_ScrollBarExtent));
+    int h = style()->pixelMetric(QStyle::PM_ScrollBarExtent);
+    int w = 5 * h;  // we have 4 buttons, the 5 is to give some free space too
+    if (d->tabRects.size()) w += d->tabRects[d->tabRects.size() - 1].right();
+
+    return QSize(w, h);
 }
 
 void TabBar::renameTab(const QString& old_name, const QString& new_name)
diff --git a/sheets/part/View.cpp b/sheets/part/View.cpp
index 3f7b707..72fc266 100644
--- a/sheets/part/View.cpp
+++ b/sheets/part/View.cpp
@@ -771,6 +771,7 @@ void View::initView()
     d->tabScrollBarLayout = new QGridLayout(bottomPart);
     d->tabScrollBarLayout->setMargin(0);
     d->tabScrollBarLayout->setSpacing(0);
+    d->tabScrollBarLayout->setColumnStretch(1, 1);
     d->tabBar = new TabBar(0);
     d->tabScrollBarLayout->addWidget(d->tabBar, 0, 0);
     d->horzScrollBar = new QScrollBar(0);
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic