SARibbon 2.5.2
SARibbon wiki
载入中...
搜索中...
未找到
SARibbonPanel类 参考

panel页窗口,panel是ribbon的面板用于承放控件 / Ribbon panel container, used to hold controls 更多...

#include <SARibbonPanel.h>

类 SARibbonPanel 继承关系图:

class  PrivateData
 

Public 类型

enum  PanelLayoutMode { ThreeRowMode , TwoRowMode }
 Layout mode for the panel / 面板的布局模式 更多...
 
using FpRibbonToolButtonIterate = std::function< bool(SARibbonToolButton *) >
 

信号

void actionTriggered (QAction *action)
 
void panelNameChanged (const QString &n)
 

Public 成员函数

 SARibbonPanel (QWidget *parent=nullptr)
 Constructor for SARibbonPanel
 
 SARibbonPanel (const QString &name, QWidget *parent=nullptr)
 Constructor for SARibbonPanel with name
 
 ~SARibbonPanel () Q_DECL_OVERRIDE
 Destructor for SARibbonPanel
 
void addAction (QAction *action, SARibbonPanelItem::RowProportion rowProportion)
 Add action to panel with specified row proportion
 
void addAction (QAction *act, QToolButton::ToolButtonPopupMode popMode, SARibbonPanelItem::RowProportion rowProportion=SARibbonPanelItem::Large)
 Generate and add an action with specified popup mode and row proportion
 
void addLargeAction (QAction *action)
 Add action to panel with large icon display
 
void addMediumAction (QAction *action)
 Add action to panel with medium icon display in three-row mode
 
void addSmallAction (QAction *action)
 Add action to panel with small icon display
 
void addSmallAction (QAction *action, QToolButton::ToolButtonPopupMode popMode)
 Add action to panel with small icon display and specified popup mode
 
void addLargeAction (QAction *action, QToolButton::ToolButtonPopupMode popMode)
 Add action to panel with large icon display and specified popup mode
 
void addMediumAction (QAction *action, QToolButton::ToolButtonPopupMode popMode)
 Add action to panel with medium icon display in three-row mode and specified popup mode
 
QAction * addAction (const QString &text, const QIcon &icon, QToolButton::ToolButtonPopupMode popMode, SARibbonPanelItem::RowProportion rowProportion=SARibbonPanelItem::Large)
 Generate and add an action with text, icon, popup mode, and row proportion
 
void addMenu (QMenu *menu, SARibbonPanelItem::RowProportion rowProportion, QToolButton::ToolButtonPopupMode popMode=QToolButton::InstantPopup)
 Add menu with specified row proportion and popup mode
 
void addLargeMenu (QMenu *menu, QToolButton::ToolButtonPopupMode popMode=QToolButton::InstantPopup)
 Add large menu with specified popup mode
 
void addMediumMenu (QMenu *menu, QToolButton::ToolButtonPopupMode popMode=QToolButton::InstantPopup)
 Add medium menu with specified popup mode
 
void addSmallMenu (QMenu *menu, QToolButton::ToolButtonPopupMode popMode=QToolButton::InstantPopup)
 Add small menu with specified popup mode
 
QAction * addWidget (QWidget *w, SARibbonPanelItem::RowProportion rowProportion)
 Add widget with specified row proportion
 
QAction * addSmallWidget (QWidget *w)
 Add small widget (occupies one row of ribbon)
 
QAction * addMediumWidget (QWidget *w)
 Add medium widget (occupies one row of ribbon)
 
QAction * addLargeWidget (QWidget *w)
 Add large widget (occupies all rows)
 
SARibbonGalleryaddGallery (bool expanding=true)
 Add a gallery
 
QAction * addSeparator ()
 Add separator
 
SARibbonToolButtonactionToRibbonToolButton (QAction *action)
 Extract the button corresponding to the action from the panel, returns nullptr if no corresponding button
 
void setOptionAction (QAction *action)
 
bool isHaveOptionAction () const
 Check if option action exists
 
QList< SARibbonToolButton * > ribbonToolButtons () const
 Get all buttons
 
PanelLayoutMode panelLayoutMode () const
 Get PanelLayoutMode
 
void setPanelLayoutMode (PanelLayoutMode mode)
 Set PanelLayoutMode
 
void resetToolButtonSize ()
 Update button sizes, this function needs to be called after panel layout state changes
 
bool isTwoRow () const
 Check if it is two-row mode
 
void setExpanding (bool isExpanding=true)
 Set panel to expanding mode, which will expand the horizontal area
 
bool isExpanding () const
 Check if it is expanding mode
 
int titleHeight () const
 Title bar height
 
bool isEnableShowTitle () const
 Check if title is enabled, after enabling title, the title height needs to be set, default height is 15
 
int actionIndex (QAction *act) const
 Layout index corresponding to action, this operation is generally used for moveAction, other meanings are not significant
 
void moveAction (int from, int to)
 Move action
 
bool isCanCustomize () const
 Check if customization is allowed
 
void setCanCustomize (bool b)
 Set customization allowed
 
QString panelName () const
 Panel name
 
void setPanelName (const QString &title)
 Set panel name
 
int largeButtonHeight () const
 Large button height
 
const QList< SARibbonPanelItem * > & ribbonPanelItem () const
 Get layout corresponding items, this function is currently only used in the customization process
 
SARibbonPanelLayoutpanelLayout () const
 Get panel layout
 
void updateItemGeometry ()
 Update layout
 
SARibbonCategorycategory () const
 Get category pointer, returns nullptr if no parent or not managed by category
 
SARibbonBarribbonBar () const
 Get ribbonBar pointer, returns nullptr if none
 
int spacing () const
 Spacing between buttons
 
void setToolButtonIconSize (const QSize &smallSize, const QSize &largeSize)
 Set button icon sizes
 
QPair< QSize, QSize > toolButtonIconSize () const
 Get button icon sizes
 
void setLargeIconSize (const QSize &largeSize)
 Large button icon size
 
QSize largeIconSize () const
 Get large icon size
 
void setSmallIconSize (const QSize &smallSize)
 Small button icon size
 
QSize smallIconSize () const
 Get small icon size
 
SARibbonToolButtonlastAddActionButton ()
 Get last added button
 
SARibbonPanelLabeltitleLabel () const
 Get panel title label widget
 
bool isEnableWordWrap () const
 Check if word wrap is enabled
 
qreal buttonMaximumAspectRatio () const
 Maximum aspect ratio of buttons, this coefficient determines the maximum width of buttons
 
bool iterateButton (FpRibbonToolButtonIterate fp) const
 
virtual QSize sizeHint () const Q_DECL_OVERRIDE
 Get size hint
 
virtual QSize minimumSizeHint () const Q_DECL_OVERRIDE
 Get minimum size hint
 

静态 Public 成员函数

static int panelHeightHint (const QFontMetrics &fm, PanelLayoutMode layMode, int panelTitleHeight)
 Recommended panel height
 
static void setActionRowProportionProperty (QAction *action, SARibbonPanelItem::RowProportion rp)
 Set action row proportion property into action, action itself carries row property
 
static SARibbonPanelItem::RowProportion getActionRowProportionProperty (QAction *action)
 Get action row proportion property
 
static void setActionToolButtonPopupModeProperty (QAction *action, QToolButton::ToolButtonPopupMode popMode)
 Set action PopupMode property into action, action itself carries PopupMode property
 
static QToolButton::ToolButtonPopupMode getActionToolButtonPopupModeProperty (QAction *action)
 Get action PopupMode property
 
static void setActionToolButtonStyleProperty (QAction *action, Qt::ToolButtonStyle buttonStyle)
 Set action ToolButtonStyle property into action, action itself carries ToolButtonStyle property
 
static Qt::ToolButtonStyle getActionToolButtonStyleProperty (QAction *action)
 Get action ToolButtonStyle property
 

Protected 成员函数

virtual void actionEvent (QActionEvent *e) Q_DECL_OVERRIDE
 Handle action events
 
virtual void changeEvent (QEvent *e) Q_DECL_OVERRIDE
 Handle change events
 
void setTitleHeight (int h)
 Set title bar height
 
void setSpacing (int n)
 Set spacing between buttons
 
void setEnableShowTitle (bool on)
 Set whether to show title, after showing title, the title height needs to be set, default height is 15
 
void setEnableWordWrap (bool on)
 
void setButtonMaximumAspectRatio (qreal fac=1.4)
 Set the maximum aspect ratio of buttons, this coefficient determines the maximum width of buttons
 

属性

bool isCanCustomize
 
bool isExpanding
 
QString panelName
 

友元

class SARibbonBar
 
class SARibbonCategory
 
class SARibbonCategoryPrivate
 
class SARibbonCustomizeWidgetPrivate
 
class SARibbonPanelLayout
 

详细描述

panel页窗口,panel是ribbon的面板用于承放控件 / Ribbon panel container, used to hold controls

The SARibbonPanel is a core component of the Ribbon interface. It acts as a container for QAction objects, automatically creating and managing SARibbonToolButton instances based on the specified layout proportion (Large, Medium, Small). It supports dynamic layout modes (ThreeRowMode, TwoRowMode) and can display an optional title and an option button.

SARibbonPanel 是 Ribbon 界面的核心组件之一。它作为 QAction 对象的容器, 根据指定的布局比例(大、中、小)自动创建和管理 SARibbonToolButton 实例。 它支持动态布局模式(三行模式、两行模式),并可显示可选的标题和选项按钮。


布局模式 / Layout Modes

The panel has two layout modes: two-row and three-row.

  • ThreeRowMode: The Ribbon in Microsoft Office is a representative.
  • TwoRowMode: The "compact style" represented by WPS. You can specify the mode via SARibbonBar::RibbonStyle (using SARibbonBar::setRibbonStyle).

ribbon的panel分为两行模式和三行模式。

  • 三行模式: 以 Microsoft Office 为代表。
  • 两行模式: 以 WPS 为代表的“紧凑派”。 可通过 SARibbonBar::RibbonStyle (使用 SARibbonBar::setRibbonStyle 函数) 来指定模式。

扩展模式 / Expanding Mode

Within a panel, you can use setExpanding to specify horizontal expansion. Recommendation: Only use this if the panel contains expandable widgets (e.g., SARibbonGallery). Otherwise, blank space will be left.

在panel中,可以通过setExpanding 函数指定panel水平扩展。 建议: 仅在面板内包含可扩展控件(如 SARibbonGallery)时使用此函数。 否则,将会留白。


自定义布局 / Custom Layout

The panel's layout is implemented by SARibbonPanelLayout. To use a custom layout, inherit from SARibbonElementCreateDelegate::createRibbonPanel.

panel的布局通过SARibbonPanelLayout 来实现。 如需自定义布局,请继承 SARibbonElementCreateDelegate::createRibbonPanel 函数。


全局属性设置 / Global Property Settings

SARibbonPanel is a child of SARibbonCategory, which belongs to SARibbonBar. Important: Setting properties directly on a standalone SARibbonPanel is often meaningless. Global properties (like title height, spacing) are managed by SARibbonBar. Use these functions in SARibbonBar instead:

  • panelTitleHeight
  • isEnableShowPanelTitle
  • panelSpacing
  • panelToolButtonIconSize

SARibbonPanel属于SARibbonCategory的子对象,SARibbonCategory又属于SARibbonBar的对象。 重要: 单独设置一个SARibbonPanel的属性很多情况是没有意义的。 全局性属性(如标题高度、间距)由SARibbonBar统一管理。 请改用SARibbonBar中的以下函数:

  • panelTitleHeight
  • isEnableShowPanelTitle
  • panelSpacing
  • panelToolButtonIconSize

成员枚举类型说明

◆ PanelLayoutMode

Layout mode for the panel / 面板的布局模式

枚举值
ThreeRowMode 

Three-row layout mode / 三行布局模式

In this mode, small buttons are arranged in three rows, while medium buttons occupy two rows. Large buttons always occupy the full height.

在此模式下,小按钮排列成三行,中等按钮占据两行。 大按钮始终占据整个高度。

TwoRowMode 

Two-row layout mode / 两行布局模式

In this mode, both small and medium buttons are arranged in two rows. Large buttons always occupy the full height.

在此模式下,小按钮和中等按钮都排列成两行。 大按钮始终占据整个高度。

构造及析构函数说明

◆ SARibbonPanel() [1/2]

SARibbonPanel::SARibbonPanel ( QWidget *  parent = nullptr)
explicit

Constructor for SARibbonPanel

◆ SARibbonPanel() [2/2]

SARibbonPanel::SARibbonPanel ( const QString &  name,
QWidget *  parent = nullptr 
)
explicit

Constructor for SARibbonPanel with name

◆ ~SARibbonPanel()

SARibbonPanel::~SARibbonPanel ( )

Destructor for SARibbonPanel

成员函数说明

◆ actionEvent()

void SARibbonPanel::actionEvent ( QActionEvent *  e)
protectedvirtual

Handle action events

◆ actionIndex()

int SARibbonPanel::actionIndex ( QAction *  act) const

Layout index corresponding to action, this operation is generally used for moveAction, other meanings are not significant

◆ actionToRibbonToolButton()

SARibbonToolButton * SARibbonPanel::actionToRibbonToolButton ( QAction *  action)

Extract the button corresponding to the action from the panel, returns nullptr if no corresponding button

◆ actionTriggered

void SARibbonPanel::actionTriggered ( QAction *  action)
signal

◆ addAction() [1/3]

QAction * SARibbonPanel::addAction ( const QString &  text,
const QIcon &  icon,
QToolButton::ToolButtonPopupMode  popMode,
SARibbonPanelItem::RowProportion  rowProportion = SARibbonPanelItem::Large 
)

Generate and add an action with text, icon, popup mode, and row proportion

◆ addAction() [2/3]

void SARibbonPanel::addAction ( QAction *  act,
QToolButton::ToolButtonPopupMode  popMode,
SARibbonPanelItem::RowProportion  rowProportion = SARibbonPanelItem::Large 
)

Generate and add an action with specified popup mode and row proportion

◆ addAction() [3/3]

void SARibbonPanel::addAction ( QAction *  action,
SARibbonPanelItem::RowProportion  rowProportion 
)

Add action to panel with specified row proportion

◆ addGallery()

SARibbonGallery * SARibbonPanel::addGallery ( bool  expanding = true)

Add a gallery

◆ addLargeAction() [1/2]

void SARibbonPanel::addLargeAction ( QAction *  action)

Add action to panel with large icon display

◆ addLargeAction() [2/2]

void SARibbonPanel::addLargeAction ( QAction *  action,
QToolButton::ToolButtonPopupMode  popMode 
)

Add action to panel with large icon display and specified popup mode

◆ addLargeMenu()

void SARibbonPanel::addLargeMenu ( QMenu *  menu,
QToolButton::ToolButtonPopupMode  popMode = QToolButton::InstantPopup 
)

Add large menu with specified popup mode

◆ addLargeWidget()

QAction * SARibbonPanel::addLargeWidget ( QWidget *  w)

Add large widget (occupies all rows)

◆ addMediumAction() [1/2]

void SARibbonPanel::addMediumAction ( QAction *  action)

Add action to panel with medium icon display in three-row mode

◆ addMediumAction() [2/2]

void SARibbonPanel::addMediumAction ( QAction *  action,
QToolButton::ToolButtonPopupMode  popMode 
)

Add action to panel with medium icon display in three-row mode and specified popup mode

◆ addMediumMenu()

void SARibbonPanel::addMediumMenu ( QMenu *  menu,
QToolButton::ToolButtonPopupMode  popMode = QToolButton::InstantPopup 
)

Add medium menu with specified popup mode

◆ addMediumWidget()

QAction * SARibbonPanel::addMediumWidget ( QWidget *  w)

Add medium widget (occupies one row of ribbon)

◆ addMenu()

void SARibbonPanel::addMenu ( QMenu *  menu,
SARibbonPanelItem::RowProportion  rowProportion,
QToolButton::ToolButtonPopupMode  popMode = QToolButton::InstantPopup 
)

Add menu with specified row proportion and popup mode

◆ addSeparator()

QAction * SARibbonPanel::addSeparator ( )

Add separator

◆ addSmallAction() [1/2]

void SARibbonPanel::addSmallAction ( QAction *  action)

Add action to panel with small icon display

◆ addSmallAction() [2/2]

void SARibbonPanel::addSmallAction ( QAction *  action,
QToolButton::ToolButtonPopupMode  popMode 
)

Add action to panel with small icon display and specified popup mode

◆ addSmallMenu()

void SARibbonPanel::addSmallMenu ( QMenu *  menu,
QToolButton::ToolButtonPopupMode  popMode = QToolButton::InstantPopup 
)

Add small menu with specified popup mode

◆ addSmallWidget()

QAction * SARibbonPanel::addSmallWidget ( QWidget *  w)

Add small widget (occupies one row of ribbon)

◆ addWidget()

QAction * SARibbonPanel::addWidget ( QWidget *  w,
SARibbonPanelItem::RowProportion  rowProportion 
)

Add widget with specified row proportion

◆ buttonMaximumAspectRatio()

qreal SARibbonPanel::buttonMaximumAspectRatio ( ) const

Maximum aspect ratio of buttons, this coefficient determines the maximum width of buttons

◆ category()

SARibbonCategory * SARibbonPanel::category ( ) const

Get category pointer, returns nullptr if no parent or not managed by category

◆ changeEvent()

void SARibbonPanel::changeEvent ( QEvent *  e)
protectedvirtual

Handle change events

◆ getActionRowProportionProperty()

SARibbonPanelItem::RowProportion SARibbonPanel::getActionRowProportionProperty ( QAction *  action)
static

Get action row proportion property

◆ getActionToolButtonPopupModeProperty()

QToolButton::ToolButtonPopupMode SARibbonPanel::getActionToolButtonPopupModeProperty ( QAction *  action)
static

Get action PopupMode property

◆ getActionToolButtonStyleProperty()

Qt::ToolButtonStyle SARibbonPanel::getActionToolButtonStyleProperty ( QAction *  action)
static

Get action ToolButtonStyle property

◆ isCanCustomize()

bool SARibbonPanel::isCanCustomize ( ) const

Check if customization is allowed

◆ isEnableShowTitle()

bool SARibbonPanel::isEnableShowTitle ( ) const

Check if title is enabled, after enabling title, the title height needs to be set, default height is 15

◆ isEnableWordWrap()

bool SARibbonPanel::isEnableWordWrap ( ) const

Check if word wrap is enabled

◆ isExpanding()

bool SARibbonPanel::isExpanding ( ) const

Check if it is expanding mode

◆ isHaveOptionAction()

bool SARibbonPanel::isHaveOptionAction ( ) const

Check if option action exists

◆ isTwoRow()

bool SARibbonPanel::isTwoRow ( ) const

Check if it is two-row mode

◆ iterateButton()

bool SARibbonPanel::iterateButton ( SARibbonPanel::FpRibbonToolButtonIterate  fp) const

This function will iterate through all RibbonToolButton under SARibbonPanel, execute function pointer (bool(SARibbonRibbonToolButton*)), function pointer returns false to stop iteration

◆ largeButtonHeight()

int SARibbonPanel::largeButtonHeight ( ) const

Large button height

◆ largeIconSize()

QSize SARibbonPanel::largeIconSize ( ) const

Get large icon size

◆ lastAddActionButton()

SARibbonToolButton * SARibbonPanel::lastAddActionButton ( )

Get last added button

◆ minimumSizeHint()

QSize SARibbonPanel::minimumSizeHint ( ) const
virtual

Get minimum size hint

◆ moveAction()

void SARibbonPanel::moveAction ( int  from,
int  to 
)

Move action

◆ panelHeightHint()

int SARibbonPanel::panelHeightHint ( const QFontMetrics &  fm,
PanelLayoutMode  layMode,
int  panelTitleHeight 
)
static

Recommended panel height

◆ panelLayout()

SARibbonPanelLayout * SARibbonPanel::panelLayout ( ) const

Get panel layout

◆ panelLayoutMode()

SARibbonPanel::PanelLayoutMode SARibbonPanel::panelLayoutMode ( ) const

Get PanelLayoutMode

◆ panelName()

QString SARibbonPanel::panelName ( ) const

Panel name

◆ panelNameChanged

void SARibbonPanel::panelNameChanged ( const QString &  n)
signal

◆ resetToolButtonSize()

void SARibbonPanel::resetToolButtonSize ( )

Update button sizes, this function needs to be called after panel layout state changes

◆ ribbonBar()

SARibbonBar * SARibbonPanel::ribbonBar ( ) const

Get ribbonBar pointer, returns nullptr if none

◆ ribbonPanelItem()

const QList< SARibbonPanelItem * > & SARibbonPanel::ribbonPanelItem ( ) const

Get layout corresponding items, this function is currently only used in the customization process

◆ ribbonToolButtons()

QList< SARibbonToolButton * > SARibbonPanel::ribbonToolButtons ( ) const

Get all buttons

◆ setActionRowProportionProperty()

void SARibbonPanel::setActionRowProportionProperty ( QAction *  action,
SARibbonPanelItem::RowProportion  rp 
)
static

Set action row proportion property into action, action itself carries row property

◆ setActionToolButtonPopupModeProperty()

void SARibbonPanel::setActionToolButtonPopupModeProperty ( QAction *  action,
QToolButton::ToolButtonPopupMode  popMode 
)
static

Set action PopupMode property into action, action itself carries PopupMode property

◆ setActionToolButtonStyleProperty()

void SARibbonPanel::setActionToolButtonStyleProperty ( QAction *  action,
Qt::ToolButtonStyle  buttonStyle 
)
static

Set action ToolButtonStyle property into action, action itself carries ToolButtonStyle property

◆ setButtonMaximumAspectRatio()

void SARibbonPanel::setButtonMaximumAspectRatio ( qreal  fac = 1.4)
protected

Set the maximum aspect ratio of buttons, this coefficient determines the maximum width of buttons

◆ setCanCustomize()

void SARibbonPanel::setCanCustomize ( bool  b)

Set customization allowed

◆ setEnableShowTitle()

void SARibbonPanel::setEnableShowTitle ( bool  on)
protected

Set whether to show title, after showing title, the title height needs to be set, default height is 15

◆ setEnableWordWrap()

void SARibbonPanel::setEnableWordWrap ( bool  on)
protected

Set whether buttons are allowed to wrap, note that the icon size is determined by the text, two lines of text will make the icon smaller, if you want the icon to be larger, it is best not to wrap the text

◆ setExpanding()

void SARibbonPanel::setExpanding ( bool  isExpanding = true)

Set panel to expanding mode, which will expand the horizontal area

◆ setLargeIconSize()

void SARibbonPanel::setLargeIconSize ( const QSize &  largeSize)

Large button icon size

◆ setOptionAction()

void SARibbonPanel::setOptionAction ( QAction *  action)

Set option action, pass nullptr to remove, SARibbonPanel does not manage QAction ownership OptionAction also triggers actionTriggered signal

◆ setPanelLayoutMode()

void SARibbonPanel::setPanelLayoutMode ( SARibbonPanel::PanelLayoutMode  mode)

Set PanelLayoutMode

◆ setPanelName()

void SARibbonPanel::setPanelName ( const QString &  title)

Set panel name

◆ setSmallIconSize()

void SARibbonPanel::setSmallIconSize ( const QSize &  smallSize)

Small button icon size

◆ setSpacing()

void SARibbonPanel::setSpacing ( int  n)
protected

Set spacing between buttons

◆ setTitleHeight()

void SARibbonPanel::setTitleHeight ( int  h)
protected

Set title bar height

◆ setToolButtonIconSize()

void SARibbonPanel::setToolButtonIconSize ( const QSize &  smallSize,
const QSize &  largeSize 
)

Set button icon sizes

◆ sizeHint()

QSize SARibbonPanel::sizeHint ( ) const
virtual

Get size hint

◆ smallIconSize()

QSize SARibbonPanel::smallIconSize ( ) const

Get small icon size

◆ spacing()

int SARibbonPanel::spacing ( ) const

Spacing between buttons

◆ titleHeight()

int SARibbonPanel::titleHeight ( ) const

Title bar height

◆ titleLabel()

SARibbonPanelLabel * SARibbonPanel::titleLabel ( ) const

Get panel title label widget

◆ toolButtonIconSize()

QPair< QSize, QSize > SARibbonPanel::toolButtonIconSize ( ) const

Get button icon sizes

◆ updateItemGeometry()

void SARibbonPanel::updateItemGeometry ( )

Update layout


该类的文档由以下文件生成: