![]() |
SARibbon 2.5.1
SARibbon wiki
|
Layout manager for SARibbonPanel / SARibbonPanel的布局管理器 更多...
#include <SARibbonPanelLayout.h>
Public 成员函数 | |
SARibbonPanelLayout (QWidget *p=nullptr) | |
SARibbonPanel * | ribbonPanel () const |
Gets the SARibbonPanel that owns this layout / 获取拥有此布局的SARibbonPanel | |
void | insertAction (int index, QAction *act, SARibbonPanelItem::RowProportion rp=SARibbonPanelItem::None) |
Inserts an action at a specific index / 在指定索引处插入一个action | |
void | setOptionAction (QAction *action) |
Sets the option action for the panel / 为面板设置选项action | |
bool | isHaveOptionAction () const |
Checks if an option action is set / 检查是否设置了选项action | |
SARibbonPanelItem * | panelItem (QAction *action) const |
Retrieves the SARibbonPanelItem associated with an action / 获取与action关联的SARibbonPanelItem | |
SARibbonPanelItem * | lastItem () const |
Gets the last item added to the layout / 获取最后添加到布局的项目 | |
QWidget * | lastWidget () const |
Gets the widget associated with the last item / 获取与最后一个项目关联的窗口部件 | |
void | move (int from, int to) |
Moves an item from one index to another / 将一个项目从一个索引移动到另一个索引 | |
bool | isDirty () const |
判断是否需要重新布局 | |
void | updateGeomArray () |
int | indexByAction (QAction *action) const |
Finds the index of an action in the layout / 在布局中查找一个action的索引 | |
int | panelTitleHeight () const |
Gets the height of the panel's title / 获取面板标题的高度 | |
void | setPanelTitleHeight (int newTitleHeight) |
Sets the height of the panel's title / 设置面板标题的高度 | |
bool | isEnableShowPanelTitle () const |
Checks if the panel's title is enabled for display / 检查面板标题是否启用显示 | |
void | setEnableShowPanelTitle (bool on) |
Sets whether the panel's title is enabled for display / 设置面板标题是否启用显示 | |
int | largeButtonHeight () const |
Gets the height of large buttons / 获取大按钮的高度 | |
int | panelTitleSpace () const |
Gets the spacing between the title and the buttons / 获取标题与按钮之间的间距 | |
void | setPanelTitleSpace (int newTitleSpace) |
Sets the spacing between the title and the buttons / 设置标题与按钮之间的间距 | |
SARibbonPanelLabel * | panelTitleLabel () const |
Gets the panel's title label / 获取面板的标题标签 | |
void | setToolButtonIconSize (const QSize &s) |
Sets the default icon size for tool buttons / 设置工具按钮的默认图标尺寸 | |
QSize | toolButtonIconSize () const |
Gets the default icon size for tool buttons / 获取工具按钮的默认图标尺寸 | |
bool | isEnableWordWrap () const |
是否允许文字换行 | |
qreal | buttonMaximumAspectRatio () const |
按钮最大宽高比,这个系数决定按钮的最大宽度 | |
void | addItem (QLayoutItem *item) Q_DECL_OVERRIDE |
Adds an item to the layout (not supported) / 向布局添加一个项目(不支持) | |
QLayoutItem * | itemAt (int index) const Q_DECL_OVERRIDE |
Retrieves the item at the specified index / 获取指定索引处的项目 | |
QLayoutItem * | takeAt (int index) Q_DECL_OVERRIDE |
Removes and returns the item at the specified index / 移除并返回指定索引处的项目 | |
int | count () const Q_DECL_OVERRIDE |
Gets the number of items in the layout / 获取布局中项目的数量 | |
bool | isEmpty () const Q_DECL_OVERRIDE |
Checks if the layout is empty / 检查布局是否为空 | |
void | invalidate () Q_DECL_OVERRIDE |
Invalidates the layout, marking it as dirty / 使布局失效,将其标记为“脏” | |
Qt::Orientations | expandingDirections () const Q_DECL_OVERRIDE |
Returns the directions in which the layout can expand / 返回布局可以扩展的方向 | |
void | setGeometry (const QRect &rect) Q_DECL_OVERRIDE |
QSize | minimumSize () const Q_DECL_OVERRIDE |
QSize | sizeHint () const Q_DECL_OVERRIDE |
Protected 成员函数 | |
QSize | optionActionButtonSize () const |
Gets the size of the option action button / 获取选项action按钮的尺寸 | |
void | doLayout () |
布局所有action | |
SARibbonPanelItem * | createItem (QAction *action, SARibbonPanelItem::RowProportion rp=SARibbonPanelItem::None) |
把action转换为item | |
void | updateGeomArray (const QRect &setrect) |
更新尺寸 | |
void | recalcExpandGeomArray (const QRect &setrect) |
void | setEnableWordWrap (bool on) |
设置文字允许换行 | |
void | setButtonMaximumAspectRatio (qreal fac=1.4) |
设置按钮最大宽高比,这个系数决定按钮的最大宽度 | |
友元 | |
class | SARibbonPanel |
Layout manager for SARibbonPanel / SARibbonPanel的布局管理器
SARibbonPanelLayout
is a custom QLayout
subclass responsible for arranging SARibbonToolButton
and other widgets within a SARibbonPanel
. It handles the complex Ribbon-specific layout logic, including Large, Medium, and Small button proportions, and the optional title and option button.
SARibbonPanelLayout
是一个自定义的 QLayout
子类,负责在 SARibbonPanel
内排列 SARibbonToolButton
和其他窗口部件。它处理复杂的Ribbon特定布局逻辑,包括大、中、小按钮比例,以及可选的标题和选项按钮。
void SARibbonPanelLayout::addItem | ( | QLayoutItem * | item | ) |
Adds an item to the layout (not supported) / 向布局添加一个项目(不支持)
This layout only accepts items created from QAction
via insertAction
. Calling this function directly will result in a warning.
此布局仅接受通过 insertAction
从 QAction
创建的项目。直接调用此函数将导致警告。
item | The layout item to add / 要添加的布局项目 |
qreal SARibbonPanelLayout::buttonMaximumAspectRatio | ( | ) | const |
int SARibbonPanelLayout::count | ( | ) | const |
Gets the number of items in the layout / 获取布局中项目的数量
|
protected |
把action转换为item
此函数参考QToolBarItem *QToolBarLayout::createItem(QAction *action)
对于普通QAction,此函数会创建SARibbonToolButton,SARibbonToolButton的类型参考SARibbonPanelItem::RowProportion,
action | |
rp | 行高占比情况 |
Qt::Orientations SARibbonPanelLayout::expandingDirections | ( | ) | const |
Returns the directions in which the layout can expand / 返回布局可以扩展的方向
int SARibbonPanelLayout::indexByAction | ( | QAction * | action | ) | const |
Finds the index of an action in the layout / 在布局中查找一个action的索引
action | The action to find / 要查找的action |
void SARibbonPanelLayout::insertAction | ( | int | index, |
QAction * | act, | ||
SARibbonPanelItem::RowProportion | rp = SARibbonPanelItem::None |
||
) |
Inserts an action at a specific index / 在指定索引处插入一个action
This is the primary method for adding content to the layout. It creates a SARibbonPanelItem
from the QAction
and inserts it at the specified position.
这是向布局添加内容的主要方法。它从 QAction
创建一个 SARibbonPanelItem
并将其插入到指定位置。
index | The index at which to insert the action / 插入action的索引 |
act | The action to insert / 要插入的action |
rp | The row proportion for the action / action的行占比 |
void SARibbonPanelLayout::invalidate | ( | ) |
Invalidates the layout, marking it as dirty / 使布局失效,将其标记为“脏”
This forces a recalculation of the layout geometry on the next update.
这会强制在下次更新时重新计算布局几何形状。
bool SARibbonPanelLayout::isDirty | ( | ) | const |
判断是否需要重新布局
bool SARibbonPanelLayout::isEmpty | ( | ) | const |
Checks if the layout is empty / 检查布局是否为空
bool SARibbonPanelLayout::isEnableShowPanelTitle | ( | ) | const |
Checks if the panel's title is enabled for display / 检查面板标题是否启用显示
bool SARibbonPanelLayout::isEnableWordWrap | ( | ) | const |
是否允许文字换行
bool SARibbonPanelLayout::isHaveOptionAction | ( | ) | const |
Checks if an option action is set / 检查是否设置了选项action
QLayoutItem * SARibbonPanelLayout::itemAt | ( | int | index | ) | const |
Retrieves the item at the specified index / 获取指定索引处的项目
index | The index of the item / 项目的索引 |
int SARibbonPanelLayout::largeButtonHeight | ( | ) | const |
Gets the height of large buttons / 获取大按钮的高度
SARibbonPanelItem * SARibbonPanelLayout::lastItem | ( | ) | const |
Gets the last item added to the layout / 获取最后添加到布局的项目
QWidget * SARibbonPanelLayout::lastWidget | ( | ) | const |
Gets the widget associated with the last item / 获取与最后一个项目关联的窗口部件
void SARibbonPanelLayout::move | ( | int | from, |
int | to | ||
) |
Moves an item from one index to another / 将一个项目从一个索引移动到另一个索引
from | The current index of the item / 项目的当前索引 |
to | The new index for the item / 项目的新索引 |
|
protected |
Gets the size of the option action button / 获取选项action按钮的尺寸
SARibbonPanelItem * SARibbonPanelLayout::panelItem | ( | QAction * | action | ) | const |
Retrieves the SARibbonPanelItem associated with an action / 获取与action关联的SARibbonPanelItem
action | The action to query / 要查询的action |
int SARibbonPanelLayout::panelTitleHeight | ( | ) | const |
Gets the height of the panel's title / 获取面板标题的高度
SARibbonPanelLabel * SARibbonPanelLayout::panelTitleLabel | ( | ) | const |
Gets the panel's title label / 获取面板的标题标签
int SARibbonPanelLayout::panelTitleSpace | ( | ) | const |
Gets the spacing between the title and the buttons / 获取标题与按钮之间的间距
|
protected |
< 原来的列宽
< 列的最大宽度
< 扩展后列的宽度
SARibbonPanel * SARibbonPanelLayout::ribbonPanel | ( | ) | const |
Gets the SARibbonPanel that owns this layout / 获取拥有此布局的SARibbonPanel
|
protected |
设置按钮最大宽高比,这个系数决定按钮的最大宽度
按钮的最大宽度为按钮高度*此系数,例如按钮高度为h,那么按钮最大宽度maxw=h*buttonMaximumAspectRatio 如果在此宽度下文字还无法完全显示,那么按钮将不会继续横向扩展,将使用...替代未完全显示的文字
void SARibbonPanelLayout::setEnableShowPanelTitle | ( | bool | on | ) |
Sets whether the panel's title is enabled for display / 设置面板标题是否启用显示
on | If true, the title is enabled / 如果为true,则启用标题 |
|
protected |
设置文字允许换行
enableWordWrap |
void SARibbonPanelLayout::setOptionAction | ( | QAction * | action | ) |
Sets the option action for the panel / 为面板设置选项action
The option action is displayed as a button in the panel's title area. Pass nullptr
to remove the current option action.
选项action显示在面板标题区域的一个按钮中。 传入 nullptr
以移除当前的选项action。
action | The option action, or nullptr to remove / 选项action,或传入nullptr以移除 |
void SARibbonPanelLayout::setPanelTitleHeight | ( | int | newTitleHeight | ) |
Sets the height of the panel's title / 设置面板标题的高度
newTitleHeight | The new title height / 新的标题高度 |
void SARibbonPanelLayout::setPanelTitleSpace | ( | int | newTitleSpace | ) |
Sets the spacing between the title and the buttons / 设置标题与按钮之间的间距
newTitleSpace | The new spacing value / 新的间距值 |
void SARibbonPanelLayout::setToolButtonIconSize | ( | const QSize & | s | ) |
Sets the default icon size for tool buttons / 设置工具按钮的默认图标尺寸
s | The new icon size / 新的图标尺寸 |
QLayoutItem * SARibbonPanelLayout::takeAt | ( | int | index | ) |
Removes and returns the item at the specified index / 移除并返回指定索引处的项目
index | The index of the item to remove / 要移除的项目的索引 |
QSize SARibbonPanelLayout::toolButtonIconSize | ( | ) | const |
Gets the default icon size for tool buttons / 获取工具按钮的默认图标尺寸