SARibbon 2.5.2
SARibbon wiki
载入中...
搜索中...
未找到
SARibbonPanel.h
1#ifndef SARIBBONPANEL_H
2#define SARIBBONPANEL_H
3#include "SARibbonGlobal.h"
4#include "SARibbonPanelItem.h"
5#include "SARibbonToolButton.h"
6#include <QLayout>
7#include <QWidget>
8#include <QLabel>
9class SARibbonMenu;
10class SARibbonGallery;
11class QGridLayout;
15class SARibbonBar;
16
26class SA_RIBBON_EXPORT SARibbonPanelLabel : public QLabel
27{
28 Q_OBJECT
29public:
31 SARibbonPanelLabel(QWidget* parent = nullptr);
32};
33
99class SA_RIBBON_EXPORT SARibbonPanel : public QFrame
100{
101 Q_OBJECT
102 SA_RIBBON_DECLARE_PRIVATE(SARibbonPanel)
103 friend class SARibbonBar;
104 friend class SARibbonCategory;
105 friend class SARibbonCategoryPrivate;
106 friend class SARibbonCustomizeWidgetPrivate;
107 friend class SARibbonPanelLayout;
108 Q_PROPERTY(bool isCanCustomize READ isCanCustomize WRITE setCanCustomize)
109 Q_PROPERTY(bool isExpanding READ isExpanding WRITE setExpanding)
110 Q_PROPERTY(QString panelName READ panelName WRITE setPanelName)
111public:
116 {
127
138
156 SingleRowMode
157 };
158 Q_ENUM(PanelLayoutMode)
159public:
160 using FpRibbonToolButtonIterate = std::function< bool(SARibbonToolButton*) >;
161
162public:
164 explicit SARibbonPanel(QWidget* parent = nullptr);
166 explicit SARibbonPanel(const QString& name, QWidget* parent = nullptr);
168 ~SARibbonPanel() Q_DECL_OVERRIDE;
169 using QWidget::addAction;
170
172 void addAction(QAction* action, SARibbonPanelItem::RowProportion rowProportion);
174 void addAction(QAction* act,
175 QToolButton::ToolButtonPopupMode popMode,
176 SARibbonPanelItem::RowProportion rowProportion = SARibbonPanelItem::Large);
178 void addLargeAction(QAction* action);
180 void addMediumAction(QAction* action);
182 void addSmallAction(QAction* action);
183
185 void addSmallAction(QAction* action, QToolButton::ToolButtonPopupMode popMode);
187 void addLargeAction(QAction* action, QToolButton::ToolButtonPopupMode popMode);
189 void addMediumAction(QAction* action, QToolButton::ToolButtonPopupMode popMode);
191 QAction* addAction(const QString& text,
192 const QIcon& icon,
193 QToolButton::ToolButtonPopupMode popMode,
194 SARibbonPanelItem::RowProportion rowProportion = SARibbonPanelItem::Large);
195
197 void addMenu(QMenu* menu,
198 SARibbonPanelItem::RowProportion rowProportion,
199 QToolButton::ToolButtonPopupMode popMode = QToolButton::InstantPopup);
201 void addLargeMenu(QMenu* menu, QToolButton::ToolButtonPopupMode popMode = QToolButton::InstantPopup);
203 void addMediumMenu(QMenu* menu, QToolButton::ToolButtonPopupMode popMode = QToolButton::InstantPopup);
205 void addSmallMenu(QMenu* menu, QToolButton::ToolButtonPopupMode popMode = QToolButton::InstantPopup);
206
208 QAction* addWidget(QWidget* w, SARibbonPanelItem::RowProportion rowProportion);
209
211 QAction* addSmallWidget(QWidget* w);
212
214 QAction* addMediumWidget(QWidget* w);
215
217 QAction* addLargeWidget(QWidget* w);
218
220 SARibbonGallery* addGallery(bool expanding = true);
221
223 QAction* addSeparator();
224
226 SARibbonToolButton* actionToRibbonToolButton(QAction* action);
227
230 void setOptionAction(QAction* action);
231
233 bool isHaveOptionAction() const;
234
236 QList< SARibbonToolButton* > ribbonToolButtons() const;
237
239 PanelLayoutMode panelLayoutMode() const;
241 void setPanelLayoutMode(PanelLayoutMode mode);
242
244 void resetToolButtonSize();
245
247 bool isTwoRow() const;
248
250 void setExpanding(bool isExpanding = true);
252 bool isExpanding() const;
253
255 int titleHeight() const;
256
258 bool isEnableShowTitle() const;
259
261 int actionIndex(QAction* act) const;
262
264 void moveAction(int from, int to);
265
267 bool isCanCustomize() const;
269 void setCanCustomize(bool b);
270
272 QString panelName() const;
274 void setPanelName(const QString& title);
275
277 int largeButtonHeight() const;
278
280 const QList< SARibbonPanelItem* >& ribbonPanelItem() const;
281
283 SARibbonPanelLayout* panelLayout() const;
284
286 void updateItemGeometry();
287
289 SARibbonCategory* category() const;
290
292 SARibbonBar* ribbonBar() const;
293
295 int spacing() const;
296
298 void setToolButtonIconSize(const QSize& smallSize, const QSize& largeSize);
300 QPair< QSize, QSize > toolButtonIconSize() const;
301
303 void setLargeIconSize(const QSize& largeSize);
305 QSize largeIconSize() const;
306
308 void setSmallIconSize(const QSize& smallSize);
310 QSize smallIconSize() const;
311
313 SARibbonToolButton* lastAddActionButton();
314
316 SARibbonPanelLabel* titleLabel() const;
317
319 bool isEnableWordWrap() const;
320
322 void setEnableIconRightText(bool on);
324 bool isEnableIconRightText() const;
325
327 qreal buttonMaximumAspectRatio() const;
328
331 bool iterateButton(FpRibbonToolButtonIterate fp) const;
332
333public:
335 virtual QSize sizeHint() const Q_DECL_OVERRIDE;
337 virtual QSize minimumSizeHint() const Q_DECL_OVERRIDE;
338
339public:
341 static int panelHeightHint(const QFontMetrics& fm, PanelLayoutMode layMode, int panelTitleHeight);
343 static void setActionRowProportionProperty(QAction* action, SARibbonPanelItem::RowProportion rp);
345 static SARibbonPanelItem::RowProportion getActionRowProportionProperty(QAction* action);
347 static void setActionToolButtonPopupModeProperty(QAction* action, QToolButton::ToolButtonPopupMode popMode);
349 static QToolButton::ToolButtonPopupMode getActionToolButtonPopupModeProperty(QAction* action);
351 static void setActionToolButtonStyleProperty(QAction* action, Qt::ToolButtonStyle buttonStyle);
353 static Qt::ToolButtonStyle getActionToolButtonStyleProperty(QAction* action);
354
355Q_SIGNALS:
356
368 void actionTriggered(QAction* action);
369
381 void panelNameChanged(const QString& n);
382
383protected:
385 virtual void actionEvent(QActionEvent* e) Q_DECL_OVERRIDE;
387 virtual void changeEvent(QEvent* e) Q_DECL_OVERRIDE;
388
389protected:
390 // The following methods are for receiving parameters from the corresponding interfaces of SARibbonBar, users do not
391 // need to set them when operating SARibbonPanel When SARibbonPanel is set to SARibbonCategory, SARibbonCategory
392 // will resynchronize its own parameters to the panel Similarly, when SARibbonCategory is added to SARibbonBar,
393 // SARibbonBar will resynchronize its own parameters to the category
394
396 void setTitleHeight(int h);
397
399 void setSpacing(int n);
400
402 void setEnableShowTitle(bool on);
403
406 void setEnableWordWrap(bool on);
407
409 void setButtonMaximumAspectRatio(qreal fac = 1.4);
410};
411
412#endif // SARIBBONPANEL_H
Definition SARibbonBar.h:171
Definition SARibbonCategory.h:32
Definition SARibbonGallery.h:80
Definition SARibbonMenu.h:18
Definition SARibbonPanelItem.h:25
Definition SARibbonPanel.h:27
Definition SARibbonPanelLayout.h:25
Definition SARibbonPanelOptionButton.h:25
panel页窗口,panel是ribbon的面板用于承放控件 / Ribbon panel container, used to hold controls
Definition SARibbonPanel.h:100
PanelLayoutMode
Layout mode for the panel / 面板的布局模式
Definition SARibbonPanel.h:116
@ TwoRowMode
Two-row layout mode / 两行布局模式
Definition SARibbonPanel.h:137
@ ThreeRowMode
Three-row layout mode / 三行布局模式
Definition SARibbonPanel.h:126
Definition SARibbonToolButton.h:31