@@ -127,27 +127,6 @@ void AutoHideSideBarPrivate::handleViewportEvent(QEvent* e)
127127 }
128128 break ;
129129
130- case QEvent::Resize:
131- if (_this->tabCount ())
132- {
133- auto ev = static_cast <QResizeEvent*>(e);
134- auto Tab = _this->tabAt (0 );
135- int Size = isHorizontal () ? ev->size ().height () : ev->size ().width ();
136- int TabSize = isHorizontal () ? Tab->size ().height () : Tab->size ().width ();
137- // If the size of the side bar is less than the size of the first tab
138- // then there are no visible tabs in this side bar. This check will
139- // fail if someone will force a very big border via CSS!!
140- if (Size < TabSize)
141- {
142- _this->hide ();
143- }
144- }
145- else
146- {
147- _this->hide ();
148- }
149- break ;
150-
151130 default :
152131 break ;
153132 }
@@ -288,20 +267,33 @@ void CAutoHideSideBar::removeTab(CAutoHideTab* SideTab)
288267// ============================================================================
289268bool CAutoHideSideBar::eventFilter (QObject *watched, QEvent *event)
290269{
291- if (event->type () != QEvent::ShowToParent)
270+ auto Tab = qobject_cast<CAutoHideTab*>(watched);
271+ if (!Tab)
292272 {
293273 return false ;
294274 }
295275
296- // As soon as on tab is shown, we need to show the side tab bar
297- auto Tab = qobject_cast<CAutoHideTab*>(watched);
298- if (Tab)
276+ switch (event->type ())
299277 {
300- show ();
278+ case QEvent::ShowToParent:
279+ show ();
280+ break ;
281+
282+ case QEvent::Hide:
283+ if (!hasVisibleTabs ())
284+ {
285+ hide ();
286+ }
287+ break ;
288+
289+ default :
290+ break ;
301291 }
292+
302293 return false ;
303294}
304295
296+
305297// ============================================================================
306298Qt::Orientation CAutoHideSideBar::orientation () const
307299{
@@ -323,6 +315,37 @@ int CAutoHideSideBar::tabCount() const
323315}
324316
325317
318+ // ============================================================================
319+ int CAutoHideSideBar::visibleTabCount () const
320+ {
321+ int count = 0 ;
322+ for (auto i = 0 ; i < tabCount (); i++)
323+ {
324+ if (tabAt (i)->isVisible ())
325+ {
326+ count++;
327+ }
328+ }
329+
330+ return count;
331+ }
332+
333+
334+ // ============================================================================
335+ bool CAutoHideSideBar::hasVisibleTabs () const
336+ {
337+ for (auto i = 0 ; i < tabCount (); i++)
338+ {
339+ if (tabAt (i)->isVisible ())
340+ {
341+ return true ;
342+ }
343+ }
344+
345+ return false ;
346+ }
347+
348+
326349// ============================================================================
327350SideBarLocation CAutoHideSideBar::sideBarLocation () const
328351{
0 commit comments