mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-11-15 13:15:43 +08:00
Fixed #653 - DisablingTabTextEliding not letting DockAreaDynamicTabsMenuButtonVisibility to function and program crashes
This commit is contained in:
parent
1c41cbff82
commit
cea1327dac
@ -548,6 +548,13 @@ int CDockAreaTabBar::tabInsertIndexAt(const QPoint& Pos) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
bool CDockAreaTabBar::areTabsOverflowing() const
|
||||||
|
{
|
||||||
|
return d->TabsContainerWidget->width() > width();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace ads
|
} // namespace ads
|
||||||
|
|
||||||
|
|
||||||
|
@ -153,6 +153,12 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual QSize sizeHint() const override;
|
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:
|
public Q_SLOTS:
|
||||||
/**
|
/**
|
||||||
* This property sets the index of the tab bar's visible tab
|
* This property sets the index of the tab bar's visible tab
|
||||||
|
@ -377,27 +377,48 @@ CDockAreaTabBar* CDockAreaTitleBar::tabBar() const
|
|||||||
return d->TabBar;
|
return d->TabBar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
void CDockAreaTitleBar::resizeEvent(QResizeEvent *event)
|
||||||
|
{
|
||||||
|
Super::resizeEvent(event);
|
||||||
|
if (CDockManager::testConfigFlag(CDockManager::DockAreaDynamicTabsMenuButtonVisibility)
|
||||||
|
&& CDockManager::testConfigFlag(CDockManager::DisableTabTextEliding))
|
||||||
|
{
|
||||||
|
markTabsMenuOutdated();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void CDockAreaTitleBar::markTabsMenuOutdated()
|
void CDockAreaTitleBar::markTabsMenuOutdated()
|
||||||
{
|
{
|
||||||
if(DockAreaTitleBarPrivate::testConfigFlag(CDockManager::DockAreaDynamicTabsMenuButtonVisibility))
|
if (CDockManager::testConfigFlag(CDockManager::DockAreaDynamicTabsMenuButtonVisibility))
|
||||||
{
|
{
|
||||||
bool hasElidedTabTitle = false;
|
bool TabsMenuButtonVisible = false;
|
||||||
for (int i = 0; i < d->TabBar->count(); ++i)
|
if (CDockManager::testConfigFlag(CDockManager::DisableTabTextEliding))
|
||||||
{
|
{
|
||||||
if (!d->TabBar->isTabOpen(i))
|
TabsMenuButtonVisible = d->TabBar->areTabsOverflowing();
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
CDockWidgetTab* Tab = d->TabBar->tab(i);
|
|
||||||
if(Tab->isTitleElided())
|
|
||||||
{
|
|
||||||
hasElidedTabTitle = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
bool visible = (hasElidedTabTitle && (d->TabBar->count() > 1));
|
else
|
||||||
QMetaObject::invokeMethod(d->TabsMenuButton, "setVisible", Qt::QueuedConnection, Q_ARG(bool, visible));
|
{
|
||||||
|
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;
|
d->MenuOutdated = true;
|
||||||
}
|
}
|
||||||
|
@ -152,6 +152,11 @@ protected:
|
|||||||
*/
|
*/
|
||||||
virtual void contextMenuEvent(QContextMenuEvent *event) override;
|
virtual void contextMenuEvent(QContextMenuEvent *event) override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle resize events
|
||||||
|
*/
|
||||||
|
virtual void resizeEvent(QResizeEvent *event) override;
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
/**
|
/**
|
||||||
* Call this slot to tell the title bar that it should update the tabs menu
|
* Call this slot to tell the title bar that it should update the tabs menu
|
||||||
|
Loading…
Reference in New Issue
Block a user