-
Notifications
You must be signed in to change notification settings - Fork 0
/
ttabwidget.hpp
29 lines (23 loc) · 1.18 KB
/
ttabwidget.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#pragma once
#include <QTabWidget>
#include <QTabBar>
#include <QVector>
class TTabWidget : public QTabWidget
{ //vertical, can temporarily hide tabs. unreserves tabbar space when not visible
public:
TTabWidget(QWidget *parent = 0) : QTabWidget(parent), tabBarAutoHide(true), doing_stuff(false) { tabBar()->hide(); }
bool isTabVisible(int idx) const;
void setTabVisible(int idx, bool visible); //index, including hidden
void setAutoHide(bool on) { tabBarAutoHide = on; if (!on) tabBar()->show(); else if (count() <= 1) tabBar()->hide(); }
int totalCount() const { return count() + hidden_idx.size(); }
QSize minimumSizeHint() const { return QTabWidget::minimumSizeHint() - QSize(0, tabBar()->isVisibleTo((QWidget *)this) ? 0 : tabBar()->sizeHint().height()); }
QSize sizeHint() const { return QTabWidget::sizeHint() - QSize(0, tabBar()->isVisibleTo((QWidget *)this) ? 0 : tabBar()->sizeHint().height()); }
protected:
void tabInserted(int index);
void tabRemoved(int index);
bool tabBarAutoHide;
bool doing_stuff;
QVector<int> hidden_idx;
QVector<QWidget *> hidden_wid;
QVector<QPair<QIcon, QString> > hidden_data;
};