QmlMaterial 0.1.0
Loading...
Searching...
No Matches
ToolBarLayout Class Reference

#include <qml_material/kirigami/toolbarlayout.h>

Public Types

enum  HeightMode { AlwaysCenter , AlwaysFill , ConstrainIfLarger }
 

Public Member Functions

void addAction (QObject *action)
 
void removeAction (QObject *action)
 
void clearActions ()
 
Q_SLOT void relayout ()
 

Properties

QQmlListProperty< QObject > actions
 
QList< QObject * > hiddenActions
 
QQmlComponent * fullDelegate
 
QQmlComponent * iconDelegate
 
QQmlComponent * separatorDelegate
 
QQmlComponent * moreButton
 
qreal spacing
 
Qt::Alignment alignment
 
qreal visibleWidth
 
qreal minimumWidth
 
Qt::LayoutDirection layoutDirection
 
HeightMode heightMode
 

Detailed Description

An item that creates delegates for actions and lays them out in a row.

This effectively combines RowLayout and Repeater in a single item, with the addition of some extra performance enhancing tweaks. It will create instances of fullDelegate and ::itemDelegate for each action in actions . These are then positioned horizontally. Any action that ends up being placed outside the width of the item is hidden and will be part of hiddenActions.

The items created as delegates are always created asynchronously, to avoid creation lag spikes. Each delegate has access to the action it was created for through the ToolBarLayoutAttached attached property.

Member Enumeration Documentation

◆ HeightMode

An enum describing several modes that can be used to deal with items with a height that does not match the toolbar's height.

Enumerator
AlwaysCenter 

Always center items, allowing them to go outside the bounds of the layout if they are larger.

AlwaysFill 

Always match the height of the layout. Larger items will be reduced in height, smaller items will be increased.

ConstrainIfLarger 

If the item is larger than the toolbar, reduce its height. Otherwise center it in the toolbar.

Member Function Documentation

◆ addAction()

void ToolBarLayout::addAction ( QObject * action)

Add an action to the list of actions.

Parameters
actionThe action to add.

◆ clearActions()

void ToolBarLayout::clearActions ( )

Clear the list of actions.

◆ relayout()

void ToolBarLayout::relayout ( )

Queue a relayout of this layout.

Note
The layouting happens during the next scene graph polishing phase.

◆ removeAction()

void ToolBarLayout::removeAction ( QObject * action)

Remove an action from the list of actions.

Parameters
actionThe action to remove.

Property Documentation

◆ actions

QQmlListProperty<QObject> ToolBarLayout::actions
read

The actions this layout should create delegates for.

◆ alignment

Qt::Alignment ToolBarLayout::alignment
readwrite

How to align the delegates within this layout.

When there is more space available than required by the visible delegates, we need to determine how to place the delegates. This property determines how to do that. Note that the moreButton, if visible, will always be placed at the end of the layout.

◆ fullDelegate

QQmlComponent * ToolBarLayout::fullDelegate
readwrite

A component that is used to create full-size delegates from.

Each delegate has three states, it can be full-size, icon-only or hidden. By default, the full-size delegate is used. When the action has the DisplayHint::IconOnly hint set, it will always use the iconDelegate. When it has the DisplayHint::KeepVisible hint set, it will use the full-size delegate when it fits. If not, it will use the iconDelegate, unless even that does not fit, in which case it will still be hidden.

◆ heightMode

HeightMode ToolBarLayout::heightMode
readwrite

How to handle items that do not match the toolbar's height.

When toolbar items do not match the height of the toolbar, there are several ways we can deal with this. This property sets the preferred way.

The default is HeightMode::ConstrainIfLarger .

See also
HeightMode

◆ hiddenActions

QList<QObject *> ToolBarLayout::hiddenActions
read

A list of actions that do not fit in the current view and are thus hidden.

◆ iconDelegate

QQmlComponent * ToolBarLayout::iconDelegate
readwrite

A component that is used to create icon-only delegates from.

See also
fullDelegate

◆ layoutDirection

Qt::LayoutDirection ToolBarLayout::layoutDirection
readwrite

Which direction to layout in.

This is primarily intended to support right-to-left layouts. When set to LeftToRight, delegates will be layout with the first item on the left and following items to the right of that. The more button will be placed at the rightmost position. Alignment flags work normally.

When set to RightToLeft, delegates will be layout with the first item on the right and following items to the left of that. The more button will be placed at the leftmost position. Alignment flags are inverted, so AlignLeft will align items to the right, and vice-versa.

◆ minimumWidth

qreal ToolBarLayout::minimumWidth
read

The minimum width this layout can have.

This is equal to the width of the moreButton.

◆ moreButton

QQmlComponent * ToolBarLayout::moreButton
readwrite

A component that is used to create the "more button" item from.

The more button is shown when there are actions that do not fit the current view. It is intended to have functionality to show these hidden actions, like popup a menu with them showing.

◆ separatorDelegate

QQmlComponent * ToolBarLayout::separatorDelegate
readwrite

A component that is used to create separator delegates from.

See also
fullDelegate

◆ spacing

qreal ToolBarLayout::spacing
readwrite

The amount of spacing between individual delegates.

◆ visibleWidth

qreal ToolBarLayout::visibleWidth
read

The combined width of visible delegates in this layout.


The documentation for this class was generated from the following files: