Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sometimes sidebar visibility state is incorrect #524

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 23 additions & 25 deletions src/AutoHideSideBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -288,14 +267,18 @@ void CAutoHideSideBar::removeTab(CAutoHideTab* SideTab)
//============================================================================
bool CAutoHideSideBar::eventFilter(QObject *watched, QEvent *event)
{
if (event->type() != QEvent::ShowToParent)
// As soon as a tab is hidden, we need to check if the side tab should be hidden
auto Tab = qobject_cast<CAutoHideTab*>(watched);
if (Tab && event->type() == QEvent::Hide)
{
return false;
if (visibleTabCount() == 0)
{
hide();
}
}

// As soon as on tab is shown, we need to show the side tab bar
auto Tab = qobject_cast<CAutoHideTab*>(watched);
if (Tab)
if (Tab && event->type() == QEvent::ShowToParent)
{
show();
}
Expand Down Expand Up @@ -323,6 +306,21 @@ 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;
}


//============================================================================
SideBarLocation CAutoHideSideBar::sideBarLocation() const
{
Expand Down
5 changes: 5 additions & 0 deletions src/AutoHideSideBar.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ class ADS_EXPORT CAutoHideSideBar : public QScrollArea
*/
int tabCount() const;

/*
* Gets the count of visible tab widgets
*/
int visibleTabCount() const;

/**
* Getter for side tab bar area property
*/
Expand Down