forked from Mudlet/Mudlet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTTabBar.h
More file actions
93 lines (82 loc) · 4.79 KB
/
TTabBar.h
File metadata and controls
93 lines (82 loc) · 4.79 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#ifndef TTABBAR_H
#define TTABBAR_H
/***************************************************************************
* Copyright (C) 2018 by Stephen Lyons - [email protected] *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "pre_guard.h"
#include <QProxyStyle>
#include <QSet>
#include <QString>
#include <QTabBar>
#include "post_guard.h"
class TStyle : public QProxyStyle
{
public:
TStyle(QTabBar * bar) : mpTabBar(bar) {}
~TStyle() {}
void drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = Q_NULLPTR) const;
void setTabBold(const QString& tabName, const bool state) { setNamedTabState(tabName, state, mBoldTabsSet); }
void setTabBold(const int index, const bool state) { setIndexedTabState(index, state, mBoldTabsSet); }
void setTabItalic(const QString& tabName, const bool state) { setNamedTabState(tabName, state, mItalicTabsSet); }
void setTabItalic(const int index, const bool state) { setIndexedTabState(index, state, mItalicTabsSet); }
void setTabUnderline(const QString& tabName, const bool state) {setNamedTabState(tabName, state, mUnderlineTabsSet); }
void setTabUnderline(const int index, const bool state) { setIndexedTabState(index, state, mUnderlineTabsSet); }
bool tabBold(const QString& tabName) const { return namedTabState(tabName, mBoldTabsSet); }
bool tabBold(const int index) const { return indexedTabState(index, mBoldTabsSet); }
bool tabItalic(const QString& tabName) const { return namedTabState(tabName, mItalicTabsSet); }
bool tabItalic(const int index) const { return indexedTabState(index, mItalicTabsSet); }
bool tabUnderline(const QString& tabName) const { return namedTabState(tabName, mUnderlineTabsSet); }
bool tabUnderline(const int index) const { return indexedTabState(index, mUnderlineTabsSet); }
private:
bool indexedTabState(int, const QSet<QString>&) const;
bool namedTabState(const QString&, const QSet<QString>&) const;
void setNamedTabState(const QString&, bool, QSet<QString>&);
void setIndexedTabState(int, bool, QSet<QString>&);
QTabBar * mpTabBar;
QSet<QString> mBoldTabsSet;
QSet<QString> mItalicTabsSet;
QSet<QString> mUnderlineTabsSet;
};
class TTabBar : public QTabBar
{
public:
TTabBar(QWidget * parent)
: QTabBar(parent)
, mStyle(qobject_cast<QTabBar*>(this))
{
setStyle(&mStyle);
}
~TTabBar() {}
QSize tabSizeHint(int index) const;
void setTabBold(const QString& tabName, const bool state) {mStyle.setTabBold(tabName, state); }
void setTabBold(const int index, const bool state) {mStyle.setTabBold(index, state); }
void setTabItalic(const QString& tabName, const bool state) {mStyle.setTabItalic(tabName, state); }
void setTabItalic(const int index, const bool state) {mStyle.setTabItalic(index, state); }
void setTabUnderline(const QString& tabName, const bool state) {mStyle.setTabUnderline(tabName, state); }
void setTabUnderline(const int index, const bool state) {mStyle.setTabUnderline(index, state); }
bool tabBold(const QString& tabName) const {return mStyle.tabBold(tabName);}
bool tabBold(const int index) const {return mStyle.tabBold(index);}
bool tabItalic(const QString& tabName) const {return mStyle.tabItalic(tabName);}
bool tabItalic(const int index) const {return mStyle.tabItalic(index);}
bool tabUnderline(const QString& tabName) const {return mStyle.tabUnderline(tabName);}
bool tabUnderline(const int index) const {return mStyle.tabUnderline(index);}
private:
// This instance of TStyle needs a pointer to a QTabBar on instantiation:
TStyle mStyle;
};
#endif // TTABBAR_H