-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathMacUnifiedToolBar.h
138 lines (81 loc) · 3.13 KB
/
MacUnifiedToolBar.h
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#ifndef UNIFIEDTOOLBAR_H
#define UNIFIEDTOOLBAR_H
#include <QToolBar>
#include "cpp_utilities.h"
#define _UNIFIED_TOOLBAR_MAC_10_10 1 //2015.12.3 Mac-10.10 style toolbar?
///////////////////////////////////////////////////////////
class _CActionList : public std::vector<QAction*>{
protected:
bool m_bVisible;
public:
_CActionList() : m_bVisible(true){return;}
bool isVisible(){return m_bVisible;}
void setVisible(bool bVisible){m_bVisible= bVisible;}
};
///////////////////////////////////////////////////////////
#if _UNIFIED_TOOLBAR_MAC_10_10
class QToolButton;
class QHBoxLayout;
///////////////////////////////////////////////////////////
class _CToolItemsGroup : public QWidget{
Q_OBJECT
protected:
QString m_sGroupName;
QHBoxLayout * m_pLayoutToolItems;
QList<QWidget*> m_vToolItems;
QString m_sQssForToolButton;
public:
_CToolItemsGroup(const QString& sGroupName = "", QWidget* parent = NULL);
void addAction(QAction* pAction);
void addWidget(QWidget* pWidget);
// void addSeparator();
public:
virtual bool eventFilter(QObject* o, QEvent* e);
protected slots:
void onToggleToolButtonChecked(bool bChk);
};
////////////////////////////////////////////////////
class QUnifiedToolBar : public QToolBar{
protected:
_CPairVector<QString, QAction*> m_mToolItemsGroups;
_CPairVector<QString, QAction*> m_mSpacerBeforeGroup;
protected:
void addSpacer(const QString& sGroupName);
_CToolItemsGroup* toolItemGroupOf(const QString& sGroupName);
void dockFirstToolbar();
public:
QUnifiedToolBar(QWidget* parent = NULL);
virtual ~QUnifiedToolBar();
QStringList groups();
void addWidget(const QString& sGroupName, QWidget* pWidget);
void addAction(const QString& sGroupName, QAction* pAction);
void addSeparator(const QString& sGroupName);
bool isGroupVisible(const QString& sGroupName);
void setGroupVisible(const QString& sGroupName, bool bVisible);
// void setActionAlignment(QAction* pAction, Qt::Alignment nAlign);
// void setWidgetAlignment(QWidget* pWidget, Qt::Alignment nAlign);
};
#else
class QUnifiedToolBar : public QToolBar{
protected:
_CPairVector<QString, _CActionList*> m_mActionGroups;
//2015.1.25 Set to false to pause refreshing toolbar when add action/widget(for efficiency), and when set to true, it will cause refreshing
bool m_bPauseRefresh;
protected:
void updateToolBar();
public:
QUnifiedToolBar(QWidget* parent = NULL);
virtual ~QUnifiedToolBar();
void pauseRefreshToolbar(){m_bPauseRefresh = true;}
void resumeRefreshToolbar(){m_bPauseRefresh = false;}
QStringList groups();
void addWidget(const QString& sGroupName, QWidget* pWidget);
void addAction(const QString& sGroupName, QAction* pAction);
void addSeparator(const QString& sGroupName);
bool isGroupVisible(const QString& sGroupName);
void setGroupVisible(const QString& sGroupName, bool bVisible);
// void setActionAlignment(QAction* pAction, Qt::Alignment nAlign);
// void setWidgetAlignment(QWidget* pWidget, Qt::Alignment nAlign);
};
#endif
#endif // UNIFIEDTOOLBAR_H