![]() |
SARibbon 2.5.2
SARibbon wiki
|
SARibbonBar继承于QMenuBar,在SARibbonMainWindow中直接替换了原来的QMenuBar 更多...
#include <SARibbonBar.h>
类 | |
| class | PrivateData |
Public 类型 | |
| enum | RibbonStyleFlag { RibbonStyleLoose = 0x0001 , RibbonStyleCompact = 0x0002 , RibbonStyleThreeRow = 0x0010 , RibbonStyleTwoRow = 0x0020 , RibbonStyleLooseThreeRow = RibbonStyleLoose | RibbonStyleThreeRow , RibbonStyleCompactThreeRow = RibbonStyleCompact | RibbonStyleThreeRow , RibbonStyleLooseTwoRow = RibbonStyleLoose | RibbonStyleTwoRow , RibbonStyleCompactTwoRow = RibbonStyleCompact | RibbonStyleTwoRow } |
| enum | RibbonMode { MinimumRibbonMode , NormalRibbonMode } |
| 定义当前ribbon 的状态 更多... | |
| using | FpCategoryIterate = std::function< bool(SARibbonCategory *) > |
| using | FpPanelIterate = SARibbonCategory::FpPanelIterate |
| using | FpContextCategoryHighlight = std::function< QColor(const QColor &) > |
| 这是针对上下文标签的高亮颜色绘制,用户可以设置一个函数指针,来针对上下文标签的高亮颜色进行调整 | |
信号 | |
| void | applicationButtonClicked () |
| 应用按钮点击响应 - 左上角的按钮,通过关联此信号触发应用按钮点击的效果 | |
| void | currentRibbonTabChanged (int index) |
| 标签页变化触发的信号 | |
| void | ribbonModeChanged (SARibbonBar::RibbonMode nowState) |
| ribbon的状态发生了变化后触发此信号 | |
| void | ribbonStyleChanged (SARibbonBar::RibbonStyles nowStyle) |
| ribbon的状态发生了变化后触发此信号 | |
| void | titleBarHeightChanged (int oldHeight, int newHeight) |
| 标题栏高度发生了变化的信号 | |
| void | actionTriggered (QAction *action) |
| 参考QToolBar::actionTriggered的信号 | |
Public 成员函数 | |
| SARibbonBar (QWidget *parent=nullptr) | |
| SARibbonBar构造函数 | |
| QAbstractButton * | applicationButton () |
| 返回applicationButton | |
| void | setApplicationButton (QAbstractButton *btn) |
| 设置applicationButton,如果想隐藏,可以传入nullptr | |
| SARibbonTabBar * | ribbonTabBar () |
| 返回tabbar | |
| SARibbonCategory * | addCategoryPage (const QString &title) |
| 添加一个标签 如果需要删除,直接delete即可,SARibbonBar会对其进行处理 | |
| void | addCategoryPage (SARibbonCategory *category) |
| 添加一个标签 | |
| Q_INVOKABLE void | addCategoryPage (QWidget *category) |
| qtdesigner专用 | |
| SARibbonCategory * | insertCategoryPage (const QString &title, int index) |
| 添加一个category,category的位置在index,如果当前category数量少于index,将插入到最后 | |
| void | insertCategoryPage (SARibbonCategory *category, int index) |
| 插入一个category | |
| SARibbonCategory * | categoryByName (const QString &title) const |
| 通过名字查找Category | |
| SARibbonCategory * | categoryByObjectName (const QString &objname) const |
| 通过ObjectName查找Category | |
| SARibbonCategory * | categoryByIndex (int index) const |
| 通过索引找到category,如果超过索引范围,会返回nullptr | |
| void | hideCategory (SARibbonCategory *category) |
| 隐藏category,并不会删除或者取走,只是隐藏 | |
| void | showCategory (SARibbonCategory *category) |
| 显示被隐藏的category | |
| bool | isCategoryVisible (const SARibbonCategory *c) const |
| 判断这个category是否在显示状态,也就是tabbar有这个category | |
| int | categoryIndex (const SARibbonCategory *c) const |
| 获取category的索引 | |
| void | moveCategory (int from, int to) |
| 移动一个Category从from index到to index | |
| QList< SARibbonCategory * > | categoryPages (bool getAll=true) const |
| 获取当前显示的所有的SARibbonCategory,包含未显示的SARibbonContextCategory的SARibbonCategory也一并返回 | |
| void | removeCategory (SARibbonCategory *category) |
| 移除SARibbonCategory | |
| SARibbonContextCategory * | addContextCategory (const QString &title, const QColor &color=QColor(), const QVariant &id=QVariant()) |
| 添加上下文标签 | |
| void | addContextCategory (SARibbonContextCategory *context) |
| 添加上下文标签 | |
| void | showContextCategory (SARibbonContextCategory *context) |
| 显示上下文标签 | |
| void | hideContextCategory (SARibbonContextCategory *context) |
| 隐藏上下文标签 | |
| bool | isContextCategoryVisible (SARibbonContextCategory *context) |
| 判断上下文是否在显示状态 | |
| void | setContextCategoryVisible (SARibbonContextCategory *context, bool visible) |
| 设置上下文标签的显示状态 | |
| QList< SARibbonContextCategory * > | contextCategoryList () const |
| 获取所有的上下文标签 | |
| void | destroyContextCategory (SARibbonContextCategory *context) |
| 销毁上下文标签,上下文标签的SARibbonCategory也会随之销毁 | |
| QList< int > | currentVisibleContextCategoryTabIndexs () const |
| 获取当前可见的上下文标签的tab索引 | |
| void | setMinimumMode (bool isHide) |
| 设置为最小/正常模式 | |
| bool | isMinimumMode () const |
| 当前ribbon是否是隐藏模式 | |
| void | showMinimumModeButton (bool isShow=true) |
| 显示隐藏ribbon的按钮 | |
| bool | haveShowMinimumModeButton () const |
| 是否显示隐藏ribbon按钮 | |
| QAction * | minimumModeAction () const |
| 隐藏ribbon对应的action | |
| bool | isEnableTabDoubleClickToMinimumMode () const |
| 是否允许tab双击后进入ribbon的最小模式 | |
| void | setTabDoubleClickToMinimumMode (bool on=true) const |
| 设置是否允许tab双击后,ribbon进入最小化模式,此属性默认开启 | |
| RibbonMode | currentRibbonState () const |
| 当前ribbon的状态(正常|最小化) | |
| int | tabBarHeight () const |
| tabBar的高度 | |
| void | setTabBarHeight (int h, bool resizeByNow=true) |
| 设置tabbar的高度 | |
| int | titleBarHeight () const |
| 返回标题栏高度 | |
| void | setTitleBarHeight (int h, bool resizeByNow=true) |
| 设置标题栏的高度 | |
| int | categoryHeight () const |
| category的高度 | |
| void | setCategoryHeight (int h, bool resizeByNow=true) |
| 设置category的高度 | |
| int | normalModeMainBarHeight () const |
| 正常模式下的高度 | |
| int | minimumModeMainBarHeight () const |
| 最小模式下的高度 | |
| SARibbonButtonGroupWidget * | activeRightButtonGroup () |
| 激活tabbar右边的按钮群 | |
| SARibbonButtonGroupWidget * | rightButtonGroup () |
| 返回右边的按钮群指针 | |
| SARibbonQuickAccessBar * | activeQuickAccessBar () |
| 激活QuickAccessBar | |
| SARibbonQuickAccessBar * | quickAccessBar () |
| SARibbonTitleIconWidget * | titleIconWidget () const |
| 获取标题栏窗口 | |
| void | setTitleIconVisible (bool on=true) |
| 设置标题图标可见性 | |
| bool | isTitleIconVisible () const |
| 标题图标是否可见 | |
| void | setRibbonStyle (RibbonStyles v) |
| 设置ribbonbar的风格,此函数会重新设置所有元素,包括button的布局方式, 尤其是从三行变到两行的过程,重设的内容较多 | |
| RibbonStyles | currentRibbonStyle () const |
| 返回当前ribbon的风格 | |
| void | setCurrentIndex (int index) |
| 切换到对应标签 | |
| int | currentIndex () |
| 返回当前的tab索引 | |
| void | raiseCategory (SARibbonCategory *category) |
| 确保标签显示出来,tab并切换到对应页 | |
| bool | isTwoRowStyle () const |
| 判断当前的样式是否为2行 | |
| bool | isThreeRowStyle () const |
| 判断当前的样式是否为3行 | |
| bool | isLooseStyle () const |
| 判断当前的样式是否为宽松样式 | |
| bool | isCompactStyle () const |
| 判断当前的样式是否为紧凑样式 | |
| void | updateRibbonGeometry () |
| 更新ribbon的布局数据,此函数适用于一些关键性尺寸变化,换起ribbon下面元素的布局 | |
| SARibbonPanel::PanelLayoutMode | panelLayoutMode () const |
| SARibbonPanel的布局模式 | |
| void | setPanelLayoutMode (SARibbonPanel::PanelLayoutMode m) |
| SARibbonPanel的布局模式设置 | |
| void | setTabOnTitle (bool on) |
| 设置tab在title上面,这样可以省略title区域 | |
| bool | isTabOnTitle () const |
| tab是否在title上面 | |
| void | setTabBarBaseLineColor (const QColor &clr) |
| tabbar 底部会绘制一条线条,此接口定义线条颜色 | |
| QColor | tabBarBaseLineColor () const |
| 获取tabbar底部基线颜色 | |
| void | setWindowTitleTextColor (const QColor &clr) |
| 设置标题的文字颜色 | |
| QColor | windowTitleTextColor () const |
| 获取标题的文字颜色 | |
| void | setTitleVisible (bool on=false) |
| 设置是否显示标题 | |
| bool | isTitleVisible () const |
| 判断标题是否显示 | |
| void | setWindowTitleBackgroundBrush (const QBrush &bk) |
| 设置标题栏的背景颜色 | |
| QBrush | windowTitleBackgroundBrush () const |
| 标题栏的背景颜色 | |
| void | setWindowTitleAligment (Qt::Alignment al) |
| 设置标题的对齐方式 | |
| Qt::Alignment | windowTitleAligment () const |
| 获取标题的对齐方式 | |
| void | setEnableWordWrap (bool on) |
| 设置ribbonbar的按钮文字允许换行 | |
| bool | isEnableWordWrap () const |
| 判断是否允许换行 | |
| void | setButtonMaximumAspectRatio (qreal fac=1.4) |
| 设置按钮最大宽高比,这个系数决定按钮的最大宽度 | |
| qreal | buttonMaximumAspectRatio () const |
| 按钮最大宽高比,这个系数决定按钮的最大宽度 | |
| int | panelTitleHeight () const |
| panel标题栏的高度 | |
| void | setPanelTitleHeight (int h) |
| 设置panel的高度 | |
| bool | isEnableShowPanelTitle () const |
| 是否panel显示标题栏 | |
| void | setEnableShowPanelTitle (bool on) |
| 设置显示panel标题 | |
| void | setPanelSpacing (int n) |
| 设置panel的spacing | |
| int | panelSpacing () const |
| panel的spacing | |
| void | setPanelToolButtonIconSize (const QSize &s) |
| 设置panel按钮的icon尺寸,large action不受此尺寸影响 | |
| QSize | panelToolButtonIconSize () const |
| panel按钮的icon尺寸,large action不受此尺寸影响 | |
| SARibbonStackedWidget * | ribbonStackedWidget () |
| ribbonbar内部的StackedWidget 所有的category都放置在StackedWidget中 | |
| void | setContextCategoryColorList (const QList< QColor > &cls) |
| 设置上下文标签的颜色列表 | |
| QList< QColor > | contextCategoryColorList () const |
| 获取上下文标签的颜色列表 | |
| void | setContextCategoryTitleTextColor (const QColor &clr) |
| 设置contextCategory 标题的颜色 | |
| QColor | contextCategoryTitleTextColor () const |
| contextCategory 标题的颜色 | |
| void | setContextCategoryColorHighLight (FpContextCategoryHighlight fp) |
| 设置一个函数指针,函数指针输入上下文标签设定的颜色,输出一个高亮颜色,高亮颜色用于绘制上下文标签的高亮部位,例如最顶部的横线 | |
| void | setRibbonAlignment (SARibbonAlignment al) |
| 设置ribbon的对齐方式 | |
| SARibbonAlignment | ribbonAlignment () const |
| ribbon的对齐方式 | |
| bool | iterateCategory (FpCategoryIterate fp) const |
| 此函数会遍历SARibbonBar下的所有Category,执行函数指针bool(SARibbonCategory*) | |
| bool | iteratePanel (FpPanelIterate fp) const |
| 此函数会遍历SARibbonBar下的所有Category,并迭代所有的panel,执行函数指针bool(SARibbonPanel*) | |
| void | setCornerWidgetVisible (bool on, Qt::Corner c=Qt::TopLeftCorner) |
| 设置边角widget可见性,对于mdi窗口,会出现TopLeftCorner和TopRightCorner两个corner widget | |
| void | setApplicationButtonVerticalExpansion (bool on=true) |
| 设置ApplicationButton垂直方向扩充,这样ApplicationButton能占用标题栏和tab栏两个栏的高度 | |
| bool | isApplicationButtonVerticalExpansion () const |
| applicationButton是否是在垂直方向扩充 | |
| QList< QAction * > | allActions () const |
| 此函数会遍历所有panel,并获取它下面的action | |
| bool | isUseRibbonFrame () const |
| 判断当前是否使用的是无边框,而不是native边框 | |
静态 Public 成员函数 | |
| static bool | isTwoRowStyle (RibbonStyles s) |
| static bool | isThreeRowStyle (RibbonStyles s) |
| 判断样式是否为3行 | |
| static bool | isLooseStyle (RibbonStyles s) |
| static bool | isCompactStyle (RibbonStyles s) |
| 判断是否是紧凑样式 | |
| static QString | versionString () |
| 获取版本信息 | |
| static QList< QColor > | defaultContextCategoryColorList () |
| 获取默认的上下文标签颜色列表 | |
| static void | initHighDpi () |
| 提供高分屏的支持静态函数 | |
Protected 槽 | |
| void | onWindowTitleChanged (const QString &title) |
| void | onWindowIconChanged (const QIcon &i) |
| void | onCategoryWindowTitleChanged (const QString &title) |
| category的名字发生改变触发 | |
| void | onStackWidgetHided () |
| ribbon的显示界面隐藏 | |
| virtual void | onCurrentRibbonTabChanged (int index) |
| 标签切换触发槽函数 | |
| virtual void | onCurrentRibbonTabClicked (int index) |
| ribbon tab bar单击 | |
| virtual void | onCurrentRibbonTabDoubleClicked (int index) |
| ribbon tab bar双击 | |
| void | onContextsCategoryPageAdded (SARibbonCategory *category) |
| void | onContextsCategoryCategoryNameChanged (SARibbonCategory *category, const QString &title) |
| 上下文标签管理的标签的名字发生变换 | |
| void | onTabMoved (int from, int to) |
| 标签移动的信号 | |
Protected 成员函数 | |
| bool | eventFilter (QObject *obj, QEvent *e) override |
| SARibbonBar::eventFilter | |
| int | calcMinTabBarWidth () const |
| 根据情况重置tabbar的宽度,主要针对wps模式 | |
| void | updateCategoryTitleToTabName () |
| 更新所有的category title对应的tab名 | |
| void | setSystemButtonGroupSize (const QSize &s) |
| 告知WindowButtonGroup的尺寸 | |
| void | setMainWindowStyles (SARibbonMainWindowStyles s) |
| 更新标题栏的区域位置 | |
| void | setRibbonMainwindowStyle () |
| virtual void | paintEvent (QPaintEvent *e) override |
| virtual void | moveEvent (QMoveEvent *e) override |
| 重写moveevent是为了在移动时调整isPopupMode状态下的stackedContainerWidget位置 | |
| virtual void | changeEvent (QEvent *e) override |
| 跟踪字体改变 | |
| virtual void | paintTabbarBaseLine (QPainter &painter) |
| 绘制tabbar下的基准线,这个方法仅仅在office2013模式下需要 | |
| virtual void | paintWindowTitle (QPainter &painter, const QString &title, const QRect &titleRegion) |
| 绘制标题栏 | |
| virtual void | paintContextCategoryTab (QPainter &painter, const QString &title, const QRect &contextRect, const QColor &color) |
| 绘制上下文标签的背景 | |
属性 | |
| RibbonStyles | ribbonStyle |
| bool | minimumMode |
| bool | minimumModeButton |
| QColor | windowTitleTextColor |
| QColor | tabBarBaseLineColor |
| Qt::Alignment | windowTitleAligment |
| bool | enableWordWrap |
| bool | enableShowPanelTitle |
| bool | tabOnTitle |
| SARibbonPanel::PanelLayoutMode | panelLayoutMode |
友元 | |
| class | SARibbonMainWindow |
| class | SARibbonSystemButtonBar |
SARibbonBar继承于QMenuBar,在SARibbonMainWindow中直接替换了原来的QMenuBar
通过setRibbonStyle函数设置ribbon的风格:
SARibbonBar参考office和wps,提供了四种风格的Ribbon模式,SARibbonBar::RibbonStyles
如果想ribbon占用的空间足够小,WpsLiteStyleTwoRow模式能比OfficeStyle节省35的高度空间
如何生成ribbon?先看看一个传统的Menu/ToolBar是如何生成的:
传统的Menu/ToolBar主要通过QMenu的addMenu添加菜单,通过QMainWindow::addToolBar生成QToolBar, 再把QAction设置进QMenu和QToolBar中
SARibbonBar和传统方法相似,不过相对于传统的Menu/ToolBar QMenu和QToolBar是平级的, Ribbon是有明显的层级关系,SARibbonBar下面是 SARibbonCategory, SARibbonCategory下面是SARibbonPanel ,SARibbonPanel下面是SARibbonToolButton , SARibbonToolButton管理着QAction
因此,生成一个ribbon只需以下几个函数:
因此生成步骤如下:
|
explicit |
SARibbonBar构造函数
| parent |
|
signal |
参考QToolBar::actionTriggered的信号
| action |
| SARibbonQuickAccessBar * SARibbonBar::activeQuickAccessBar | ( | ) |
激活QuickAccessBar
| SARibbonButtonGroupWidget * SARibbonBar::activeRightButtonGroup | ( | ) |
激活tabbar右边的按钮群
| SARibbonCategory * SARibbonBar::addCategoryPage | ( | const QString & | title | ) |
添加一个标签 如果需要删除,直接delete即可,SARibbonBar会对其进行处理
| title | 标签名字,默认情况下SARibbonCategory的object name也被设置为title |
| void SARibbonBar::addCategoryPage | ( | QWidget * | category | ) |
qtdesigner专用
| category |
| void SARibbonBar::addCategoryPage | ( | SARibbonCategory * | category | ) |
添加一个标签
| category |
| SARibbonContextCategory * SARibbonBar::addContextCategory | ( | const QString & | title, |
| const QColor & | color = QColor(), |
||
| const QVariant & | id = QVariant() |
||
| ) |
添加上下文标签
上下文标签是特殊时候触发的标签,需要用户手动触发
调用SARibbonContextCategory::addCategoryPage 可在上下文标签中添加SARibbonCategory, 在上下文标签添加的SARibbonCategory,只有在上下文标签显示的时候才会显示
| title | 上下文标签的标题,在Office模式下会显示,在wps模式下不显示。默认情况下SARibbonContextCategory的object name也被设置为title |
| color | 上下文标签的颜色,如果指定为空QColor(),将会使用SARibbonBar的默认色系 |
| id | 上下文标签的id,以便进行查找 |
| void SARibbonBar::addContextCategory | ( | SARibbonContextCategory * | context | ) |
添加上下文标签
| context |
| QList< QAction * > SARibbonBar::allActions | ( | ) | const |
此函数会遍历所有panel,并获取它下面的action
| QAbstractButton * SARibbonBar::applicationButton | ( | ) |
返回applicationButton
|
signal |
应用按钮点击响应 - 左上角的按钮,通过关联此信号触发应用按钮点击的效果
例如想点击按钮后弹出一个全屏的窗口(如office这些)
| qreal SARibbonBar::buttonMaximumAspectRatio | ( | ) | const |
| SARibbonCategory * SARibbonBar::categoryByIndex | ( | int | index | ) | const |
通过索引找到category,如果超过索引范围,会返回nullptr
| index | 索引 |
| SARibbonCategory * SARibbonBar::categoryByName | ( | const QString & | title | ) | const |
通过名字查找Category
| title | Category的名字,既标签的标题 |
| SARibbonCategory * SARibbonBar::categoryByObjectName | ( | const QString & | objname | ) | const |
通过ObjectName查找Category
| objname |
| int SARibbonBar::categoryHeight | ( | ) | const |
category的高度
| int SARibbonBar::categoryIndex | ( | const SARibbonCategory * | c | ) | const |
获取category的索引
| c |
| QList< SARibbonCategory * > SARibbonBar::categoryPages | ( | bool | getAll = true | ) | const |
获取当前显示的所有的SARibbonCategory,包含未显示的SARibbonContextCategory的SARibbonCategory也一并返回
|
overrideprotectedvirtual |
跟踪字体改变
| event |
这种是针对先new 一个对象,再设置到MainWindow的情况,例如 SARibbonBar* ribbon = new SARibbonBar(); mainwinodw->setRibbonBar(ribbon);
这种方式,构造的时候由于没有设置父窗口,因此,如果在构造函数绑定信号槽就有可能绑定不上(parent为空) 所以在事件里绑定
| QList< QColor > SARibbonBar::contextCategoryColorList | ( | ) | const |
获取上下文标签的颜色列表
| QList< SARibbonContextCategory * > SARibbonBar::contextCategoryList | ( | ) | const |
获取所有的上下文标签
| QColor SARibbonBar::contextCategoryTitleTextColor | ( | ) | const |
contextCategory 标题的颜色
| int SARibbonBar::currentIndex | ( | ) |
返回当前的tab索引
| SARibbonBar::RibbonMode SARibbonBar::currentRibbonState | ( | ) | const |
当前ribbon的状态(正常|最小化)
| SARibbonBar::RibbonStyles SARibbonBar::currentRibbonStyle | ( | ) | const |
返回当前ribbon的风格
|
signal |
标签页变化触发的信号
| index |
| QList< int > SARibbonBar::currentVisibleContextCategoryTabIndexs | ( | ) | const |
获取当前可见的上下文标签的tab索引
|
static |
获取默认的上下文标签颜色列表
| void SARibbonBar::destroyContextCategory | ( | SARibbonContextCategory * | context | ) |
销毁上下文标签,上下文标签的SARibbonCategory也会随之销毁
| context | 需要销毁的上下文标签指针 |
1、如果上下文标签显示中,先隐藏
2、删除上下文标签的相关内容
|
overrideprotected |
| bool SARibbonBar::haveShowMinimumModeButton | ( | ) | const |
是否显示隐藏ribbon按钮
| void SARibbonBar::hideCategory | ( | SARibbonCategory * | category | ) |
隐藏category,并不会删除或者取走,只是隐藏
| category |
| void SARibbonBar::hideContextCategory | ( | SARibbonContextCategory * | context | ) |
隐藏上下文标签
| context | 上下文标签指针 |
|
static |
提供高分屏的支持静态函数
| SARibbonCategory * SARibbonBar::insertCategoryPage | ( | const QString & | title, |
| int | index | ||
| ) |
添加一个category,category的位置在index,如果当前category数量少于index,将插入到最后
| title | category的标题 |
| index | category的位置 |
| void SARibbonBar::insertCategoryPage | ( | SARibbonCategory * | category, |
| int | index | ||
| ) |
插入一个category
| category | SARibbonCategory指针 |
| index | 插入的位置,如果超出范围,将默认插入到最后 |
| bool SARibbonBar::isApplicationButtonVerticalExpansion | ( | ) | const |
applicationButton是否是在垂直方向扩充
默认为false
| bool SARibbonBar::isCategoryVisible | ( | const SARibbonCategory * | c | ) | const |
判断这个category是否在显示状态,也就是tabbar有这个category
| category |
| bool SARibbonBar::isCompactStyle | ( | ) | const |
判断当前的样式是否为紧凑样式
|
static |
判断是否是紧凑样式
| s |
| bool SARibbonBar::isContextCategoryVisible | ( | SARibbonContextCategory * | context | ) |
| bool SARibbonBar::isEnableShowPanelTitle | ( | ) | const |
是否panel显示标题栏
| bool SARibbonBar::isEnableTabDoubleClickToMinimumMode | ( | ) | const |
是否允许tab双击后进入ribbon的最小模式
| bool SARibbonBar::isEnableWordWrap | ( | ) | const |
判断是否允许换行
| bool SARibbonBar::isLooseStyle | ( | ) | const |
判断当前的样式是否为宽松样式
| bool SARibbonBar::isMinimumMode | ( | ) | const |
当前ribbon是否是隐藏模式
| bool SARibbonBar::isTabOnTitle | ( | ) | const |
tab是否在title上面
| bool SARibbonBar::isThreeRowStyle | ( | ) | const |
判断当前的样式是否为3行
|
static |
判断样式是否为3行
| s |
| bool SARibbonBar::isTitleIconVisible | ( | ) | const |
标题图标是否可见
| bool SARibbonBar::isTitleVisible | ( | ) | const |
判断标题是否显示
| bool SARibbonBar::isTwoRowStyle | ( | ) | const |
判断当前的样式是否为2行
| bool SARibbonBar::isUseRibbonFrame | ( | ) | const |
判断当前是否使用的是无边框,而不是native边框
| bool SARibbonBar::iterateCategory | ( | FpCategoryIterate | fp | ) | const |
此函数会遍历SARibbonBar下的所有Category,执行函数指针bool(SARibbonCategory*)
| fp | 函数指针返回false则停止迭代 |
| bool SARibbonBar::iteratePanel | ( | FpPanelIterate | fp | ) | const |
此函数会遍历SARibbonBar下的所有Category,并迭代所有的panel,执行函数指针bool(SARibbonPanel*)
| fp | 函数指针返回false则停止迭代 |
| QAction * SARibbonBar::minimumModeAction | ( | ) | const |
隐藏ribbon对应的action
| int SARibbonBar::minimumModeMainBarHeight | ( | ) | const |
最小模式下的高度
| void SARibbonBar::moveCategory | ( | int | from, |
| int | to | ||
| ) |
移动一个Category从from index到to index
| from | |
| to |
|
overrideprotectedvirtual |
重写moveevent是为了在移动时调整isPopupMode状态下的stackedContainerWidget位置
| event |
| int SARibbonBar::normalModeMainBarHeight | ( | ) | const |
正常模式下的高度
有可能SARibbonBar::height和mainBarHeight不相等,这种情况发生在RibbonState::MinimumRibbonMode状态下
|
protectedslot |
category的名字发生改变触发
| title |
|
protectedslot |
上下文标签管理的标签的名字发生变换
| category | |
| title |
|
protectedvirtualslot |
标签切换触发槽函数
| index |
|
protectedvirtualslot |
ribbon tab bar单击
此实现必须在eventfilter中传递stackedwidget的QEvent::MouseButtonDblClick事件到tabbar中,否则会导致双击变两次单击
单击事件仅用于响应点击同一个tab时
| index |
|
protectedvirtualslot |
ribbon tab bar双击
默认情况下双击会切换最小和正常模式
| index |
|
protectedslot |
标签移动的信号
| from | |
| to |
|
protectedvirtual |
绘制上下文标签的背景
| painter | 绘图QPainter |
| title | 上下文标签的title |
| contextRect | 上下文标签的绘制区域 |
| color | 上下文标签赋予的颜色 |
|
protectedvirtual |
绘制tabbar下的基准线,这个方法仅仅在office2013模式下需要
| painter |
|
protectedvirtual |
绘制标题栏
| painter | |
| title | 标题 |
| contextCategoryRegion | 当前显示的上下文标签的范围,上下文标签是可以遮挡标题栏的,因此需要知道上下文标签的范围 x表示左边界,y表示右边界 |
| SARibbonPanel::PanelLayoutMode SARibbonBar::panelLayoutMode | ( | ) | const |
SARibbonPanel的布局模式
| int SARibbonBar::panelSpacing | ( | ) | const |
panel的spacing
| int SARibbonBar::panelTitleHeight | ( | ) | const |
panel标题栏的高度
| QSize SARibbonBar::panelToolButtonIconSize | ( | ) | const |
panel按钮的icon尺寸,large action不受此尺寸影响
| void SARibbonBar::raiseCategory | ( | SARibbonCategory * | category | ) |
确保标签显示出来,tab并切换到对应页
| category | 标签指针 |
| void SARibbonBar::removeCategory | ( | SARibbonCategory * | category | ) |
移除SARibbonCategory
SARibbonBar不会delete SARibbonCategory*,但这个SARibbonCategory会脱离SARibbonBar的管理 表现在tabbar会移除,面板会移除,使用此函数后可以对SARibbonCategory进行delete
| category |
| SARibbonAlignment SARibbonBar::ribbonAlignment | ( | ) | const |
ribbon的对齐方式
|
signal |
ribbon的状态发生了变化后触发此信号
| nowState | 变更之后的ribbon状态 |
| SARibbonStackedWidget * SARibbonBar::ribbonStackedWidget | ( | ) |
ribbonbar内部的StackedWidget 所有的category都放置在StackedWidget中
|
signal |
ribbon的状态发生了变化后触发此信号
| nowStyle | 变更之后的ribbon样式 |
| SARibbonTabBar * SARibbonBar::ribbonTabBar | ( | ) |
| SARibbonButtonGroupWidget * SARibbonBar::rightButtonGroup | ( | ) |
返回右边的按钮群指针
| void SARibbonBar::setApplicationButton | ( | QAbstractButton * | btn | ) |
设置applicationButton,如果想隐藏,可以传入nullptr
默认会有一个SARibbonApplicationButton,如果想取消,可传入nullptr,或者自定义的button也可以传入
| btn | applicationButton指针,可以传入SARibbonApplicationButton, SA已经对SARibbonApplicationButton进行了样式设置 |
| void SARibbonBar::setApplicationButtonVerticalExpansion | ( | bool | on = true | ) |
设置ApplicationButton垂直方向扩充,这样ApplicationButton能占用标题栏和tab栏两个栏的高度
| on |
| void SARibbonBar::setButtonMaximumAspectRatio | ( | qreal | fac = 1.4 | ) |
设置按钮最大宽高比,这个系数决定按钮的最大宽度
按钮的最大宽度为按钮高度*此系数,例如按钮高度为h,那么按钮最大宽度maxw=h*buttonMaximumAspectRatio 如果在此宽度下文字还无法完全显示,那么按钮将不会继续横向扩展,将使用...替代未完全显示的文字
| void SARibbonBar::setCategoryHeight | ( | int | h, |
| bool | resizeByNow = true |
||
| ) |
设置category的高度
| h | |
| resizeByNow |
| void SARibbonBar::setContextCategoryColorHighLight | ( | FpContextCategoryHighlight | fp | ) |
设置一个函数指针,函数指针输入上下文标签设定的颜色,输出一个高亮颜色,高亮颜色用于绘制上下文标签的高亮部位,例如最顶部的横线
| fp |
| void SARibbonBar::setContextCategoryColorList | ( | const QList< QColor > & | cls | ) |
设置上下文标签的颜色列表
上下文标签显示的时候,会从颜色列表中取颜色进行标签的渲染
| cls |
| void SARibbonBar::setContextCategoryTitleTextColor | ( | const QColor & | clr | ) |
设置contextCategory 标题的颜色
| clr |
| void SARibbonBar::setContextCategoryVisible | ( | SARibbonContextCategory * | context, |
| bool | visible | ||
| ) |
| void SARibbonBar::setCornerWidgetVisible | ( | bool | on, |
| Qt::Corner | c = Qt::TopLeftCorner |
||
| ) |
设置边角widget可见性,对于mdi窗口,会出现TopLeftCorner和TopRightCorner两个corner widget
| on | |
| c |
| void SARibbonBar::setCurrentIndex | ( | int | index | ) |
切换到对应标签
| index | 标签索引 |
| void SARibbonBar::setEnableShowPanelTitle | ( | bool | on | ) |
设置显示panel标题
| on |
| void SARibbonBar::setEnableWordWrap | ( | bool | on | ) |
设置ribbonbar的按钮文字允许换行
| on |
|
protected |
| void SARibbonBar::setMinimumMode | ( | bool | isMinimum | ) |
设置为最小/正常模式
隐藏模式下,只会显示tabbar,不会显示内容,默认状态是显示模式
默认下双击tabbar会切换隐藏显示模式,如果想禁用此功能,可以重载 onCurrentRibbonTabDoubleClicked 函数,不对函数进行任何处理即可
| isMinimum | 参数为true时,切换为Minimum模式 |
| void SARibbonBar::setPanelLayoutMode | ( | SARibbonPanel::PanelLayoutMode | m | ) |
SARibbonPanel的布局模式设置
| m |
| void SARibbonBar::setPanelSpacing | ( | int | n | ) |
设置panel的spacing
| n |
| void SARibbonBar::setPanelTitleHeight | ( | int | h | ) |
设置panel的高度
| h |
| void SARibbonBar::setPanelToolButtonIconSize | ( | const QSize & | s | ) |
设置panel按钮的icon尺寸,large action不受此尺寸影响
| s |
| void SARibbonBar::setRibbonAlignment | ( | SARibbonAlignment | al | ) |
设置ribbon的对齐方式
| al |
| void SARibbonBar::setRibbonStyle | ( | RibbonStyles | v | ) |
设置ribbonbar的风格,此函数会重新设置所有元素,包括button的布局方式, 尤其是从三行变到两行的过程,重设的内容较多
| v | 样式,见SARibbonBar::RibbonStyle |
|
protected |
告知WindowButtonGroup的尺寸
| s |
| void SARibbonBar::setTabBarBaseLineColor | ( | const QColor & | clr | ) |
tabbar 底部会绘制一条线条,此接口定义线条颜色
| clr |
| void SARibbonBar::setTabBarHeight | ( | int | h, |
| bool | resizeByNow = true |
||
| ) |
设置tabbar的高度
用户调用setTabBarHeight后,将使用用户设定的高度,而不使用自动计算的高度,这时tabbar高度不会跟随字体等信息重新计算
| h |
| void SARibbonBar::setTabDoubleClickToMinimumMode | ( | bool | on = true | ) | const |
设置是否允许tab双击后,ribbon进入最小化模式,此属性默认开启
| on |
| void SARibbonBar::setTabOnTitle | ( | bool | on | ) |
设置tab在title上面,这样可以省略title区域
| on |
| void SARibbonBar::setTitleBarHeight | ( | int | h, |
| bool | resizeByNow = true |
||
| ) |
| void SARibbonBar::setTitleIconVisible | ( | bool | on = true | ) |
设置标题图标可见性
| on | 是否可见 |
| void SARibbonBar::setTitleVisible | ( | bool | on = false | ) |
设置是否显示标题
| on |
| void SARibbonBar::setWindowTitleAligment | ( | Qt::Alignment | al | ) |
设置标题的对齐方式
| al |
| void SARibbonBar::setWindowTitleBackgroundBrush | ( | const QBrush & | bk | ) |
设置标题栏的背景颜色
如果不需要颜色,设置Qt::NoBrush
| bk | 背景颜色 |
| void SARibbonBar::setWindowTitleTextColor | ( | const QColor & | clr | ) |
设置标题的文字颜色
标题是mainwindow的windowTitle,如果要设置标题,直接调用SARibbonMainWindow::setWindowTitle 进行设置
如果不设置标题颜色,默认是SARibbonBar的qss的color属性
| clr |
| void SARibbonBar::showCategory | ( | SARibbonCategory * | category | ) |
显示被隐藏的category
| category |
| void SARibbonBar::showContextCategory | ( | SARibbonContextCategory * | context | ) |
显示上下文标签
| context | 上下文标签指针 |
| void SARibbonBar::showMinimumModeButton | ( | bool | isShow = true | ) |
显示隐藏ribbon的按钮
| isShow |
| QColor SARibbonBar::tabBarBaseLineColor | ( | ) | const |
获取tabbar底部基线颜色
| int SARibbonBar::tabBarHeight | ( | ) | const |
tabBar的高度
| int SARibbonBar::titleBarHeight | ( | ) | const |
|
signal |
标题栏高度发生了变化的信号
| oldHeight | |
| newHeight |
| SARibbonTitleIconWidget * SARibbonBar::titleIconWidget | ( | ) | const |
获取标题栏窗口
|
protected |
更新所有的category title对应的tab名
此函数会对所有的category的名字和tab进行匹配,如果匹配不上会重新设置tab名
| void SARibbonBar::updateRibbonGeometry | ( | ) |
更新ribbon的布局数据,此函数适用于一些关键性尺寸变化,换起ribbon下面元素的布局
|
static |
获取版本信息
| Qt::Alignment SARibbonBar::windowTitleAligment | ( | ) | const |
获取标题的对齐方式
| QBrush SARibbonBar::windowTitleBackgroundBrush | ( | ) | const |
标题栏的背景颜色
颜色为Qt::NoBrush时,代表没有背景颜色 @default Qt::NoBrush
| QColor SARibbonBar::windowTitleTextColor | ( | ) | const |
获取标题的文字颜色