Skip to content

Commit cea1327

Browse files
Fixed #653 - DisablingTabTextEliding not letting DockAreaDynamicTabsMenuButtonVisibility to function and program crashes
1 parent 1c41cbf commit cea1327

File tree

4 files changed

+52
-13
lines changed

4 files changed

+52
-13
lines changed

src/DockAreaTabBar.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,13 @@ int CDockAreaTabBar::tabInsertIndexAt(const QPoint& Pos) const
548548
}
549549
}
550550

551+
552+
//===========================================================================
553+
bool CDockAreaTabBar::areTabsOverflowing() const
554+
{
555+
return d->TabsContainerWidget->width() > width();
556+
}
557+
551558
} // namespace ads
552559

553560

src/DockAreaTabBar.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,12 @@ private Q_SLOTS:
153153
*/
154154
virtual QSize sizeHint() const override;
155155

156+
/**
157+
* This function returns true, if the tabs need more space than the size
158+
* of the tab bar.
159+
*/
160+
bool areTabsOverflowing() const;
161+
156162
public Q_SLOTS:
157163
/**
158164
* This property sets the index of the tab bar's visible tab

src/DockAreaTitleBar.cpp

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -377,27 +377,48 @@ CDockAreaTabBar* CDockAreaTitleBar::tabBar() const
377377
return d->TabBar;
378378
}
379379

380+
381+
//============================================================================
382+
void CDockAreaTitleBar::resizeEvent(QResizeEvent *event)
383+
{
384+
Super::resizeEvent(event);
385+
if (CDockManager::testConfigFlag(CDockManager::DockAreaDynamicTabsMenuButtonVisibility)
386+
&& CDockManager::testConfigFlag(CDockManager::DisableTabTextEliding))
387+
{
388+
markTabsMenuOutdated();
389+
}
390+
}
391+
392+
380393
//============================================================================
381394
void CDockAreaTitleBar::markTabsMenuOutdated()
382395
{
383-
if(DockAreaTitleBarPrivate::testConfigFlag(CDockManager::DockAreaDynamicTabsMenuButtonVisibility))
396+
if (CDockManager::testConfigFlag(CDockManager::DockAreaDynamicTabsMenuButtonVisibility))
384397
{
385-
bool hasElidedTabTitle = false;
386-
for (int i = 0; i < d->TabBar->count(); ++i)
398+
bool TabsMenuButtonVisible = false;
399+
if (CDockManager::testConfigFlag(CDockManager::DisableTabTextEliding))
387400
{
388-
if (!d->TabBar->isTabOpen(i))
389-
{
390-
continue;
391-
}
392-
CDockWidgetTab* Tab = d->TabBar->tab(i);
393-
if(Tab->isTitleElided())
401+
TabsMenuButtonVisible = d->TabBar->areTabsOverflowing();
402+
}
403+
else
404+
{
405+
bool hasElidedTabTitle = false;
406+
for (int i = 0; i < d->TabBar->count(); ++i)
394407
{
395-
hasElidedTabTitle = true;
396-
break;
408+
if (!d->TabBar->isTabOpen(i))
409+
{
410+
continue;
411+
}
412+
CDockWidgetTab* Tab = d->TabBar->tab(i);
413+
if(Tab->isTitleElided())
414+
{
415+
hasElidedTabTitle = true;
416+
break;
417+
}
397418
}
419+
TabsMenuButtonVisible = (hasElidedTabTitle && (d->TabBar->count() > 1));
398420
}
399-
bool visible = (hasElidedTabTitle && (d->TabBar->count() > 1));
400-
QMetaObject::invokeMethod(d->TabsMenuButton, "setVisible", Qt::QueuedConnection, Q_ARG(bool, visible));
421+
QMetaObject::invokeMethod(d->TabsMenuButton, "setVisible", Qt::QueuedConnection, Q_ARG(bool, TabsMenuButtonVisible));
401422
}
402423
d->MenuOutdated = true;
403424
}

src/DockAreaTitleBar.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,11 @@ private Q_SLOTS:
152152
*/
153153
virtual void contextMenuEvent(QContextMenuEvent *event) override;
154154

155+
/**
156+
* Handle resize events
157+
*/
158+
virtual void resizeEvent(QResizeEvent *event) override;
159+
155160
public Q_SLOTS:
156161
/**
157162
* Call this slot to tell the title bar that it should update the tabs menu

0 commit comments

Comments
 (0)