diff --git a/src/DockAreaTabBar.cpp b/src/DockAreaTabBar.cpp index 4b71614..4f49b14 100644 --- a/src/DockAreaTabBar.cpp +++ b/src/DockAreaTabBar.cpp @@ -113,7 +113,7 @@ CDockAreaTabBar::CDockAreaTabBar(CDockAreaWidget* parent) : d(new DockAreaTabBarPrivate(this)) { d->DockArea = parent; - setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Ignored); + setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); setFrameStyle(QFrame::NoFrame); setWidgetResizable(true); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); @@ -565,6 +565,23 @@ bool CDockAreaTabBar::isTabOpen(int Index) const return !tab(Index)->isHidden(); } + +//=========================================================================== +QSize CDockAreaTabBar::minimumSizeHint() const +{ + QSize Size = sizeHint(); + Size.setWidth(Super::minimumSizeHint().width());// this defines the minimum width of a dock area + return Size; +} + +//=========================================================================== +QSize CDockAreaTabBar::sizeHint() const +{ + QSize Size = Super::sizeHint(); + Size.setHeight(d->TabsContainerWidget->sizeHint().height()); + return Size; +} + } // namespace ads //--------------------------------------------------------------------------- diff --git a/src/DockAreaTabBar.h b/src/DockAreaTabBar.h index d769be1..44c6912 100644 --- a/src/DockAreaTabBar.h +++ b/src/DockAreaTabBar.h @@ -156,6 +156,21 @@ public: */ bool isTabOpen(int Index) const; + /** + * Overrides the minimumSizeHint() function of QScrollArea + * The minimumSizeHint() is bigger than the sizeHint () for the scroll + * area because even if the scrollbars are invisible, the required speace + * is reserved in the minimumSizeHint(). This override simply returns + * sizeHint(); + */ + virtual QSize minimumSizeHint() const override; + + /** + * The function provides a sizeHint that matches the height of the + * internal viewport. + */ + virtual QSize sizeHint() const override; + public slots: /** * This property sets the index of the tab bar's visible tab diff --git a/src/DockAreaTitleBar.cpp b/src/DockAreaTitleBar.cpp index 4553938..1192d63 100644 --- a/src/DockAreaTitleBar.cpp +++ b/src/DockAreaTitleBar.cpp @@ -130,6 +130,7 @@ DockAreaTitleBarPrivate::DockAreaTitleBarPrivate(CDockAreaTitleBar* _public) : //============================================================================ void DockAreaTitleBarPrivate::createButtons() { + QSizePolicy ButtonSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); // Tabs menu button TabsMenuButton = new tTileBarButton(); TabsMenuButton->setObjectName("tabsMenuButton"); @@ -145,7 +146,7 @@ void DockAreaTitleBarPrivate::createButtons() #ifndef QT_NO_TOOLTIP TabsMenuButton->setToolTip(QObject::tr("List all tabs")); #endif - TabsMenuButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); + TabsMenuButton->setSizePolicy(ButtonSizePolicy); TopLayout->addWidget(TabsMenuButton, 0); _this->connect(TabsMenuButton->menu(), SIGNAL(triggered(QAction*)), SLOT(onTabsMenuActionTriggered(QAction*))); @@ -159,7 +160,7 @@ void DockAreaTitleBarPrivate::createButtons() UndockButton->setToolTip(QObject::tr("Detach Group")); #endif setTitleBarButtonIcon(UndockButton, QStyle::SP_TitleBarNormalButton); - UndockButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); + UndockButton->setSizePolicy(ButtonSizePolicy); TopLayout->addWidget(UndockButton, 0); _this->connect(UndockButton, SIGNAL(clicked()), SLOT(onUndockButtonClicked())); @@ -179,7 +180,7 @@ void DockAreaTitleBarPrivate::createButtons() CloseButton->setToolTip(QObject::tr("Close Group")); } #endif - CloseButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); + CloseButton->setSizePolicy(ButtonSizePolicy); CloseButton->setIconSize(QSize(16, 16)); if (testConfigFlag(CDockManager::DockAreaHasCloseButton)) {