mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-12-25 07:31:33 +08:00
Fixed issue #524: Sometimes sidebar visibility state is incorrect
This commit is contained in:
parent
5517822008
commit
27edfe63ee
@ -734,7 +734,7 @@ CMainWindow::CMainWindow(QWidget *parent) :
|
||||
CDockManager::setConfigFlag(CDockManager::FocusHighlighting, true);
|
||||
|
||||
// uncomment if you would like to enable dock widget auto hiding
|
||||
CDockManager::setAutoHideConfigFlags({CDockManager::DefaultAutoHideConfig | CDockManager::AutoHideCloseButtonCollapsesDock});
|
||||
CDockManager::setAutoHideConfigFlags({CDockManager::DefaultAutoHideConfig});
|
||||
|
||||
// uncomment if you would like to enable an equal distribution of the
|
||||
// available size of a splitter to all contained dock widgets
|
||||
|
@ -127,27 +127,6 @@ void AutoHideSideBarPrivate::handleViewportEvent(QEvent* e)
|
||||
}
|
||||
break;
|
||||
|
||||
case QEvent::Resize:
|
||||
if (_this->tabCount())
|
||||
{
|
||||
auto ev = static_cast<QResizeEvent*>(e);
|
||||
auto Tab = _this->tabAt(0);
|
||||
int Size = isHorizontal() ? ev->size().height() : ev->size().width();
|
||||
int TabSize = isHorizontal() ? Tab->size().height() : Tab->size().width();
|
||||
// If the size of the side bar is less than the size of the first tab
|
||||
// then there are no visible tabs in this side bar. This check will
|
||||
// fail if someone will force a very big border via CSS!!
|
||||
if (Size < TabSize)
|
||||
{
|
||||
_this->hide();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_this->hide();
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -288,20 +267,33 @@ void CAutoHideSideBar::removeTab(CAutoHideTab* SideTab)
|
||||
//============================================================================
|
||||
bool CAutoHideSideBar::eventFilter(QObject *watched, QEvent *event)
|
||||
{
|
||||
if (event->type() != QEvent::ShowToParent)
|
||||
auto Tab = qobject_cast<CAutoHideTab*>(watched);
|
||||
if (!Tab)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// As soon as on tab is shown, we need to show the side tab bar
|
||||
auto Tab = qobject_cast<CAutoHideTab*>(watched);
|
||||
if (Tab)
|
||||
switch (event->type())
|
||||
{
|
||||
show();
|
||||
case QEvent::ShowToParent:
|
||||
show();
|
||||
break;
|
||||
|
||||
case QEvent::Hide:
|
||||
if (!hasVisibleTabs())
|
||||
{
|
||||
hide();
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
Qt::Orientation CAutoHideSideBar::orientation() const
|
||||
{
|
||||
@ -323,6 +315,37 @@ int CAutoHideSideBar::tabCount() const
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
int CAutoHideSideBar::visibleTabCount() const
|
||||
{
|
||||
int count = 0;
|
||||
for (auto i = 0; i < tabCount(); i++)
|
||||
{
|
||||
if (tabAt(i)->isVisible())
|
||||
{
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
bool CAutoHideSideBar::hasVisibleTabs() const
|
||||
{
|
||||
for (auto i = 0; i < tabCount(); i++)
|
||||
{
|
||||
if (tabAt(i)->isVisible())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//============================================================================
|
||||
SideBarLocation CAutoHideSideBar::sideBarLocation() const
|
||||
{
|
||||
|
@ -134,6 +134,19 @@ public:
|
||||
*/
|
||||
int tabCount() const;
|
||||
|
||||
/**
|
||||
* Returns the number of visible tabs
|
||||
*/
|
||||
int visibleTabCount() const;
|
||||
|
||||
/**
|
||||
* Returns true, if the sidebar contains visible tabs.
|
||||
* The function returns as soon as it finds the first visible tab.
|
||||
* That means, if you just want to find out if theee are visible tabs
|
||||
* then this function is quicker than visibleTabCount()
|
||||
*/
|
||||
bool hasVisibleTabs() const;
|
||||
|
||||
/**
|
||||
* Getter for side tab bar area property
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user