SARibbon 2.5.2
SARibbon wiki
载入中...
搜索中...
未找到
SARibbonGallery.h
1#ifndef SARIBBONGALLERY_H
2#define SARIBBONGALLERY_H
3#include "SARibbonGlobal.h"
4#include <QFrame>
5#include <QToolButton>
6#include <QScrollArea>
7#include "SARibbonGalleryGroup.h"
8class QLabel;
9class QVBoxLayout;
10class QSizeGrip;
11class QShowEvent;
12class QHideEvent;
14
18class SA_RIBBON_EXPORT SARibbonGalleryButton : public QToolButton
19{
20 Q_OBJECT
21public:
22 explicit SARibbonGalleryButton(QWidget* parent = nullptr);
24};
25
47class SA_RIBBON_EXPORT SARibbonGallery : public QFrame
48{
49 Q_OBJECT
50 SA_RIBBON_DECLARE_PRIVATE(SARibbonGallery)
51public:
52 explicit SARibbonGallery(QWidget* parent = nullptr);
53 virtual ~SARibbonGallery();
54 // 添加一个GalleryGroup
55 SARibbonGalleryGroup* addGalleryGroup();
56 // 添加一个GalleryGroup
57 void addGalleryGroup(SARibbonGalleryGroup* group);
58 // 快速添加一组actions
59 SARibbonGalleryGroup* addCategoryActions(const QString& title, QList< QAction* > actions);
60 // 设置当前显示的SARibbonGalleryGroup
61 void setCurrentViewGroup(SARibbonGalleryGroup* group);
62 // 获取当前显示的SARibbonGalleryGroup
63 SARibbonGalleryGroup* currentViewGroup() const;
64 // 获取弹出窗口指针
65 SARibbonGalleryViewport* getPopupViewPort() const;
66
67public:
68 // 设置最右边三个控制按钮的最大宽度(默认15)
69 static void setGalleryButtonMaximumWidth(int w);
70Q_SIGNALS:
76 void triggered(QAction* action);
82 void hovered(QAction* action);
83
84public Q_SLOTS:
85 // 上翻页
86 virtual void pageUp();
87 // 下翻页
88 virtual void pageDown();
89 // 显示更多触发,默认弹出内部管理的SARibbonGalleryViewport,用户可重载此函数实现自定义的弹出
90 virtual void showMoreDetail();
91protected Q_SLOTS:
92 void onItemClicked(const QModelIndex& index);
93 virtual void onTriggered(QAction* action);
94
95private:
96 SARibbonGalleryViewport* ensureGetPopupViewPort();
97
98protected:
99 void resizeEvent(QResizeEvent* event) override;
100};
101
105class SARibbonGalleryViewport : public QScrollArea
106{
107 Q_OBJECT
108public:
109 explicit SARibbonGalleryViewport(QWidget* parent);
110 // 添加窗口不带标题
111 void addWidget(QWidget* w);
112 // 添加窗口,带标题
113 void addWidget(QWidget* w, const QString& title);
114 // 通过SARibbonGalleryGroup获取对应的标题,用户可以通过此函数设置QLabel的属性
115 QLabel* titleLabel(QWidget* w);
116 // 移除窗口
117 void removeWidget(QWidget* w);
118 // 获取此窗口下所有的SARibbonGalleryGroup
119 QList< SARibbonGalleryGroup* > galleryGroupList() const;
120 // 获取gallery的高度
121 int galleryHeight() const;
122 // 根据宽度计算高度推荐值
123 int heightHintForWidth(int w) const;
124public Q_SLOTS:
125 void onTitleChanged(QWidget* w, const QString& title);
126
127protected: // 新增
128 bool eventFilter(QObject* o, QEvent* e) override;
129 void showEvent(QShowEvent* e) override;
130 void hideEvent(QHideEvent* e) override;
131 void resizeEvent(QResizeEvent* e) override;
132
133private:
134 QWidget* m_contentWidget { nullptr };
135 QVBoxLayout* m_layout;
136 QMap< QWidget*, QLabel* > m_widgetToTitleLabel;
137 QSizeGrip* m_sizeGrip;
138};
139
140#endif // SARIBBONGALLERY_H
针对SARibbonGallery控件的按钮
Definition SARibbonGallery.h:19
Gallery的组
Definition SARibbonGalleryGroup.h:60
SARibbonGallery的Viewport class
Definition SARibbonGallery.h:106
void addWidget(QWidget *w)
添加窗口不带标题
Definition SARibbonGallery.cpp:178
QLabel * titleLabel(QWidget *w)
通过SARibbonGalleryGroup获取对应的标题,用户可以通过此函数设置QLabel的属性
Definition SARibbonGallery.cpp:227
int heightHintForWidth(int w) const
根据宽度计算高度推荐值
Definition SARibbonGallery.cpp:276
void removeWidget(QWidget *w)
移除窗口
Definition SARibbonGallery.cpp:236
void onTitleChanged(QWidget *w, const QString &title)
widget的标题改变
Definition SARibbonGallery.cpp:302
Gallery控件
Definition SARibbonGallery.h:48
void hovered(QAction *action)
转发管理的SARibbonGalleryGroup::hovered
void triggered(QAction *action)
转发管理的SARibbonGalleryGroup::triggered 所有加入SARibbonGallery的action都会被一个QActionGroup管理,...