SARibbon 2.5.1
SARibbon wiki
载入中...
搜索中...
未找到
SARibbonCategory.h
1#ifndef SARIBBONCATEGORY_H
2#define SARIBBONCATEGORY_H
3#include "SARibbonGlobal.h"
4#include <QFrame>
5#include "SARibbonPanel.h"
6#include <QScopedPointer>
7#include <QPushButton>
8#include <QWheelEvent>
9
10class QAction;
11class QHBoxLayout;
12class QWheelEvent;
13class SARibbonBar;
15
65class SA_RIBBON_EXPORT SARibbonCategory : public QFrame
66{
67 Q_OBJECT
68 SA_RIBBON_DECLARE_PRIVATE(SARibbonCategory)
69 friend class SARibbonBar;
70 friend class SARibbonContextCategory;
71 Q_PROPERTY(bool isCanCustomize READ isCanCustomize WRITE setCanCustomize)
72 Q_PROPERTY(QString categoryName READ categoryName WRITE setCategoryName)
73public:
74 using FpPanelIterate = std::function< bool(SARibbonPanel*) >;
75
76public:
77 explicit SARibbonCategory(QWidget* p = nullptr);
78 explicit SARibbonCategory(const QString& name, QWidget* p = nullptr);
80
81 // Get the category name/获取Category名称
82 QString categoryName() const;
83
84 // Set the category name/设置Category名称
85 void setCategoryName(const QString& title);
86
87 // Get the panel layout mode/获取面板布局模式
88 SARibbonPanel::PanelLayoutMode panelLayoutMode() const;
89
90 // Set the panel layout mode/设置面板布局模式
91 void setPanelLayoutMode(SARibbonPanel::PanelLayoutMode m);
92
93 // Add a panel (panel)/添加面板(panel)
94 SARibbonPanel* addPanel(const QString& title);
95
96 // Add panel/添加panel
97 void addPanel(SARibbonPanel* panel);
98
99 // Qt Designer specific/Qt Designer专用
100 Q_INVOKABLE void addPanel(QWidget* panel);
101
102 // Create a new panel and insert it at the index position/新建一个panel,并插入到index位置
103 SARibbonPanel* insertPanel(const QString& title, int index);
104
105 // Find panel by name/通过名字查找panel
106 SARibbonPanel* panelByName(const QString& title) const;
107
108 // Find panel by ObjectName/通过ObjectName查找panel
109 SARibbonPanel* panelByObjectName(const QString& objname) const;
110
111 // Find panel by index, returns nullptr if the index is out of range/通过索引找到panel,如果超过索引范围,会返回nullptr
112 SARibbonPanel* panelByIndex(int index) const;
113
114 // Find the index corresponding to panel/查找panel对应的索引
115 int panelIndex(SARibbonPanel* p) const;
116
117 // Move a Panel from from index to to index/移动一个Panel从from index到to index
118 void movePanel(int from, int to);
119
120 // Detach panel from SARibbonCategory management/把panel脱离SARibbonCategory的管理
121 bool takePanel(SARibbonPanel* panel);
122
123 // Remove Panel, Category will directly recycle SARibbonPanel memory/移除Panel,Category会直接回收SARibbonPanel内存
124 bool removePanel(SARibbonPanel* panel);
125
126 // Remove panel/移除panel
127 bool removePanel(int index);
128
129 // Return all panels under Category/返回Category下的所有panel
130 QList< SARibbonPanel* > panelList() const;
131
132 // Returns true if it is a ContextCategory/如果是ContextCategory,此函数返回true
133 bool isContextCategory() const;
134
135 // Return the number of panels/返回panel的个数
136 int panelCount() const;
137
138 // Determine if customization is allowed/判断是否可以自定义
139 bool isCanCustomize() const;
140 // Set whether customization is allowed/设置是否可以自定义
141 void setCanCustomize(bool b);
142
143 // Height of panel title bar/panel标题栏的高度
144 int panelTitleHeight() const;
145 // Set the height of panel/设置panel的高度
146 void setPanelTitleHeight(int h);
147
148 // Whether the panel title bar is displayed/是否panel显示标题栏
149 bool isEnableShowPanelTitle() const;
150 // Set to display panel title/设置显示panel标题
151 void setEnableShowPanelTitle(bool on);
152
153 // Set the alignment of Category/设置Category的对齐方式
154 void setCategoryAlignment(SARibbonAlignment al);
155 // Category alignment/Category的对齐方式
156 SARibbonAlignment categoryAlignment() const;
157
158 // Set the spacing of panel/设置panel的spacing
159 void setPanelSpacing(int n);
160 // panel spacing/panel的spacing
161 int panelSpacing() const;
162
163 // Set the icon size of panel buttons, large action is not affected/设置panel按钮的icon尺寸,large action不受此尺寸影响
164 void setPanelToolButtonIconSize(const QSize& s);
165 // Icon size of panel buttons, large action is not affected/panel按钮的icon尺寸,large action不受此尺寸影响
166 QSize panelToolButtonIconSize() const;
167
168 // Get the corresponding ribbonbar, returns null if not managed by ribbonbar/获取对应的ribbonbar,如果没有加入ribbonbar的管理,此值为null
169 SARibbonBar* ribbonBar() const;
170
171 // Refresh the category layout, suitable for calling after changing the ribbon mode/刷新category的布局,适用于改变ribbon的模式之后调用
172 void updateItemGeometry();
173
174 // Set whether to use animation when scrolling/设置滚动时是否使用动画
175 void setUseAnimatingScroll(bool useAnimating);
176 // Whether to use animation when scrolling/滚动时是否使用动画
177 bool isUseAnimatingScroll() const;
178
179 // Set wheel scroll step (px)/设置滚轮滚动步长(px)
180 void setWheelScrollStep(int step);
181 // Wheel scroll step/滚轮的滚动步长
182 int wheelScrollStep() const;
183
184 // Set animation duration(ms)/设置动画持续时间(ms)
185 void setAnimationDuration(int duration);
186 // Animation duration(ms)/动画持续时间(ms)
187 int animationDuration() const;
188
189 // Determine whether the text of panel is allowed to wrap/判断panel的文字是否允许换行
190 bool isEnableWordWrap() const;
191
192 // Button maximum aspect ratio, this coefficient determines the maximum width of the button/按钮最大宽高比,这个系数决定按钮的最大宽度
193 qreal buttonMaximumAspectRatio() const;
194
195 // This function will iterate through all panels under Category and execute the function pointer/此函数会遍历Category下的所有panel,执行函数指针
196 bool iteratePanel(FpPanelIterate fp) const;
197
198 QSize sizeHint() const Q_DECL_OVERRIDE;
199Q_SIGNALS:
204 void categoryNameChanged(const QString& n);
205
210 void actionTriggered(QAction* action);
211
212protected:
213 virtual bool event(QEvent* e) override;
214 // 处理滚轮事件
215 void wheelEvent(QWheelEvent* event) override;
216 //
217 void changeEvent(QEvent* event) override;
218
219 // Mark this as a context label/标记这个是上下文标签
220 void markIsContextCategory(bool isContextCategory = true);
221
222 // Get SARibbonCategoryLayoutlayout/获取SARibbonCategoryLayoutlayout
223 SARibbonCategoryLayout* categoryLayout() const;
224
225 // Set whether the text of panel buttons is allowed to wrap/设置panel的按钮文字允许换行
226 void setEnableWordWrap(bool on);
227
228 // Set button maximum aspect ratio, this coefficient determines the maximum width of the button/设置按钮最大宽高比,这个系数决定按钮的最大宽度
229 void setButtonMaximumAspectRatio(qreal fac = 1.4);
230};
231
237class SA_RIBBON_EXPORT SARibbonCategoryScrollButton : public QToolButton
238{
239 Q_OBJECT
240public:
241 explicit SARibbonCategoryScrollButton(Qt::ArrowType arr, QWidget* p = nullptr);
243};
244
245#endif // SARIBBONCATEGORY_H
SARibbonBar继承于QMenuBar,在SARibbonMainWindow中直接替换了原来的QMenuBar
Definition SARibbonBar.h:94
The SARibbonCategoryLayout class
Definition SARibbonCategoryLayout.h:17
SARibbonCategory无法完全显示时,显示的调整按钮
Definition SARibbonCategory.h:238
Ribbon控件中的分类选项卡页面(Category)
Definition SARibbonCategory.h:66
void categoryNameChanged(const QString &n)
Category title changed signal/category标题发生了改变信号
void actionTriggered(QAction *action)
Refer to QToolBar::actionTriggered signal/参考QToolBar::actionTriggered的信号
管理上下文标签的类
Definition SARibbonContextCategory.h:11
panel页窗口,panel是ribbon的面板用于承放控件 / Ribbon panel container, used to hold controls
Definition SARibbonPanel.h:93
PanelLayoutMode
Layout mode for the panel / 面板的布局模式
Definition SARibbonPanel.h:109