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
24class SA_RIBBON_EXPORT SARibbonGalleryButton : public QToolButton
25{
26 Q_OBJECT
27public:
28 explicit SARibbonGalleryButton(QWidget* parent = nullptr);
30};
31
79class SA_RIBBON_EXPORT SARibbonGallery : public QFrame
80{
81 Q_OBJECT
82 SA_RIBBON_DECLARE_PRIVATE(SARibbonGallery)
83public:
85 explicit SARibbonGallery(QWidget* parent = nullptr);
87 virtual ~SARibbonGallery();
89 SARibbonGalleryGroup* addGalleryGroup();
91 void addGalleryGroup(SARibbonGalleryGroup* group);
93 SARibbonGalleryGroup* addCategoryActions(const QString& title, QList< QAction* > actions);
95 void setCurrentViewGroup(SARibbonGalleryGroup* group);
97 SARibbonGalleryGroup* currentViewGroup() const;
99 SARibbonGalleryViewport* getPopupViewPort() const;
100
101public:
103 static void setGalleryButtonMaximumWidth(int w);
105 void setSingleRowMode(bool on);
107 bool isSingleRowMode() const;
108Q_SIGNALS:
122 void triggered(QAction* action);
136 void hovered(QAction* action);
137
138public Q_SLOTS:
140 virtual void pageUp();
142 virtual void pageDown();
144 virtual void showMoreDetail();
145protected Q_SLOTS:
147 void onItemClicked(const QModelIndex& index);
149 virtual void onTriggered(QAction* action);
150
151private:
152 SARibbonGalleryViewport* ensureGetPopupViewPort();
153
154protected:
156 void resizeEvent(QResizeEvent* event) override;
158 void changeEvent(QEvent* event) override;
159};
160
170class SARibbonGalleryViewport : public QScrollArea
171{
172 Q_OBJECT
173public:
174 explicit SARibbonGalleryViewport(QWidget* parent);
175 // 添加窗口不带标题
176 void addWidget(QWidget* w);
177 // 添加窗口,带标题
178 void addWidget(QWidget* w, const QString& title);
179 // 通过SARibbonGalleryGroup获取对应的标题,用户可以通过此函数设置QLabel的属性
180 QLabel* titleLabel(QWidget* w);
181 // 移除窗口
182 void removeWidget(QWidget* w);
183 // 获取此窗口下所有的SARibbonGalleryGroup
184 QList< SARibbonGalleryGroup* > galleryGroupList() const;
185 // 获取gallery的高度
186 int galleryHeight() const;
187 // 根据宽度计算高度推荐值
188 int heightHintForWidth(int w) const;
189public Q_SLOTS:
190 void onTitleChanged(QWidget* w, const QString& title);
191
192protected: // 新增
193 bool eventFilter(QObject* o, QEvent* e) override;
194 void showEvent(QShowEvent* e) override;
195 void hideEvent(QHideEvent* e) override;
196 void resizeEvent(QResizeEvent* e) override;
197
198private:
199 QWidget* m_contentWidget { nullptr };
200 QVBoxLayout* m_layout;
201 QMap< QWidget*, QLabel* > m_widgetToTitleLabel;
202 QSizeGrip* m_sizeGrip;
203};
204
205#endif // SARIBBONGALLERY_H
Definition SARibbonGallery.h:25
Definition SARibbonGalleryGroup.h:100
Definition SARibbonGallery.h:171
void addWidget(QWidget *w)
添加窗口不带标题
Definition SARibbonGallery.cpp:182
QLabel * titleLabel(QWidget *w)
通过SARibbonGalleryGroup获取对应的标题,用户可以通过此函数设置QLabel的属性
Definition SARibbonGallery.cpp:231
int heightHintForWidth(int w) const
根据宽度计算高度推荐值
Definition SARibbonGallery.cpp:280
void resizeEvent(QResizeEvent *e) override
Definition SARibbonGallery.cpp:351
void removeWidget(QWidget *w)
移除窗口
Definition SARibbonGallery.cpp:240
void onTitleChanged(QWidget *w, const QString &title)
widget的标题改变
Definition SARibbonGallery.cpp:305
Definition SARibbonGallery.h:80
void hovered(QAction *action)
void triggered(QAction *action)