diff --git a/src/DockAreaTabBar.cpp b/src/DockAreaTabBar.cpp index 39b2901..81307d0 100644 --- a/src/DockAreaTabBar.cpp +++ b/src/DockAreaTabBar.cpp @@ -548,6 +548,13 @@ int CDockAreaTabBar::tabInsertIndexAt(const QPoint& Pos) const } } + +//=========================================================================== +bool CDockAreaTabBar::areTabsOverflowing() const +{ + return d->TabsContainerWidget->width() > width(); +} + } // namespace ads diff --git a/src/DockAreaTabBar.h b/src/DockAreaTabBar.h index 1eec312..2d57009 100644 --- a/src/DockAreaTabBar.h +++ b/src/DockAreaTabBar.h @@ -153,6 +153,12 @@ public: */ virtual QSize sizeHint() const override; + /** + * This function returns true, if the tabs need more space than the size + * of the tab bar. + */ + bool areTabsOverflowing() const; + public Q_SLOTS: /** * This property sets the index of the tab bar's visible tab diff --git a/src/DockAreaTitleBar.cpp b/src/DockAreaTitleBar.cpp index b3f42f9..32a1d1a 100644 --- a/src/DockAreaTitleBar.cpp +++ b/src/DockAreaTitleBar.cpp @@ -377,27 +377,48 @@ CDockAreaTabBar* CDockAreaTitleBar::tabBar() const return d->TabBar; } + +//============================================================================ +void CDockAreaTitleBar::resizeEvent(QResizeEvent *event) +{ + Super::resizeEvent(event); + if (CDockManager::testConfigFlag(CDockManager::DockAreaDynamicTabsMenuButtonVisibility) + && CDockManager::testConfigFlag(CDockManager::DisableTabTextEliding)) + { + markTabsMenuOutdated(); + } +} + + //============================================================================ void CDockAreaTitleBar::markTabsMenuOutdated() { - if(DockAreaTitleBarPrivate::testConfigFlag(CDockManager::DockAreaDynamicTabsMenuButtonVisibility)) + if (CDockManager::testConfigFlag(CDockManager::DockAreaDynamicTabsMenuButtonVisibility)) { - bool hasElidedTabTitle = false; - for (int i = 0; i < d->TabBar->count(); ++i) + bool TabsMenuButtonVisible = false; + if (CDockManager::testConfigFlag(CDockManager::DisableTabTextEliding)) { - if (!d->TabBar->isTabOpen(i)) - { - continue; - } - CDockWidgetTab* Tab = d->TabBar->tab(i); - if(Tab->isTitleElided()) - { - hasElidedTabTitle = true; - break; - } + TabsMenuButtonVisible = d->TabBar->areTabsOverflowing(); } - bool visible = (hasElidedTabTitle && (d->TabBar->count() > 1)); - QMetaObject::invokeMethod(d->TabsMenuButton, "setVisible", Qt::QueuedConnection, Q_ARG(bool, visible)); + else + { + bool hasElidedTabTitle = false; + for (int i = 0; i < d->TabBar->count(); ++i) + { + if (!d->TabBar->isTabOpen(i)) + { + continue; + } + CDockWidgetTab* Tab = d->TabBar->tab(i); + if(Tab->isTitleElided()) + { + hasElidedTabTitle = true; + break; + } + } + TabsMenuButtonVisible = (hasElidedTabTitle && (d->TabBar->count() > 1)); + } + QMetaObject::invokeMethod(d->TabsMenuButton, "setVisible", Qt::QueuedConnection, Q_ARG(bool, TabsMenuButtonVisible)); } d->MenuOutdated = true; } diff --git a/src/DockAreaTitleBar.h b/src/DockAreaTitleBar.h index f4179d9..6f07eea 100644 --- a/src/DockAreaTitleBar.h +++ b/src/DockAreaTitleBar.h @@ -152,6 +152,11 @@ protected: */ virtual void contextMenuEvent(QContextMenuEvent *event) override; + /** + * Handle resize events + */ + virtual void resizeEvent(QResizeEvent *event) override; + public Q_SLOTS: /** * Call this slot to tell the title bar that it should update the tabs menu