diff options
Diffstat (limited to '')
| -rw-r--r-- | components/controls/SplitButtonRow.qml | 62 | ||||
| -rw-r--r-- | components/controls/ToggleButton.qml | 2 |
2 files changed, 62 insertions, 2 deletions
diff --git a/components/controls/SplitButtonRow.qml b/components/controls/SplitButtonRow.qml new file mode 100644 index 0000000..4ecc8bf --- /dev/null +++ b/components/controls/SplitButtonRow.qml @@ -0,0 +1,62 @@ +pragma ComponentBehavior: Bound + +import ".." +import qs.components +import qs.components.effects +import qs.services +import qs.config +import QtQuick +import QtQuick.Layouts + +StyledRect { + id: root + + required property string label + property int expandedZ: 100 + property bool enabled: true + + property alias menuItems: splitButton.menuItems + property alias active: splitButton.active + property alias expanded: splitButton.expanded + property alias type: splitButton.type + + signal selected(item: MenuItem) + + Layout.fillWidth: true + implicitHeight: row.implicitHeight + Appearance.padding.large * 2 + radius: Appearance.rounding.normal + color: Colours.layer(Colours.palette.m3surfaceContainer, 2) + + clip: false + z: splitButton.menu.implicitHeight > 0 ? expandedZ : 1 + opacity: enabled ? 1.0 : 0.5 + + RowLayout { + id: row + anchors.fill: parent + anchors.margins: Appearance.padding.large + spacing: Appearance.spacing.normal + + StyledText { + Layout.fillWidth: true + text: root.label + color: root.enabled ? Colours.palette.m3onSurface : Colours.palette.m3onSurfaceVariant + } + + SplitButton { + id: splitButton + enabled: root.enabled + type: SplitButton.Filled + + menu.z: 1 + + stateLayer.onClicked: { + splitButton.expanded = !splitButton.expanded + } + + menu.onItemSelected: (item) => { + root.selected(item); + } + } + } +} diff --git a/components/controls/ToggleButton.qml b/components/controls/ToggleButton.qml index b2c2afe..8bdcb04 100644 --- a/components/controls/ToggleButton.qml +++ b/components/controls/ToggleButton.qml @@ -74,7 +74,6 @@ StyledRect { } Loader { - asynchronous: true active: !!root.label visible: active @@ -103,7 +102,6 @@ StyledRect { Loader { id: tooltipLoader active: root.tooltip !== "" - asynchronous: true z: 10000 width: 0 height: 0 |