@@ -127,27 +127,6 @@ void AutoHideSideBarPrivate::handleViewportEvent(QEvent* e)
127
127
}
128
128
break ;
129
129
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
-
151
130
default :
152
131
break ;
153
132
}
@@ -288,20 +267,33 @@ void CAutoHideSideBar::removeTab(CAutoHideTab* SideTab)
288
267
// ============================================================================
289
268
bool CAutoHideSideBar::eventFilter (QObject *watched, QEvent *event)
290
269
{
291
- if (event->type () != QEvent::ShowToParent)
270
+ auto Tab = qobject_cast<CAutoHideTab*>(watched);
271
+ if (!Tab)
292
272
{
293
273
return false ;
294
274
}
295
275
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 ())
299
277
{
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 ;
301
291
}
292
+
302
293
return false ;
303
294
}
304
295
296
+
305
297
// ============================================================================
306
298
Qt::Orientation CAutoHideSideBar::orientation () const
307
299
{
@@ -323,6 +315,37 @@ int CAutoHideSideBar::tabCount() const
323
315
}
324
316
325
317
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
+
326
349
// ============================================================================
327
350
SideBarLocation CAutoHideSideBar::sideBarLocation () const
328
351
{
0 commit comments