mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-10-21 18:54:01 -04:00
deprecation notice to plugin compatibility shims - When qml-common became a thing, we left qs.Widgets shims in place for plugin compatibility - It's annoying to need to maintain them when qml-common has any change, add a warning so we can safely deprecate them in the future - One shot rename the common stuff to D to make it shorter and nicer to write
73 lines
2.5 KiB
QML
73 lines
2.5 KiB
QML
import QtQuick
|
|
import qs.Common
|
|
import qs.DCommon.Widgets
|
|
|
|
SettingsRow {
|
|
id: root
|
|
|
|
property string text: ""
|
|
property string description: ""
|
|
property alias model: buttonGroup.model
|
|
property alias currentIndex: buttonGroup.currentIndex
|
|
property alias initialSelection: buttonGroup.initialSelection
|
|
property alias currentSelection: buttonGroup.currentSelection
|
|
property alias selectionMode: buttonGroup.selectionMode
|
|
property alias buttonHeight: buttonGroup.buttonHeight
|
|
property alias minButtonWidth: buttonGroup.minButtonWidth
|
|
property alias buttonPadding: buttonGroup.buttonPadding
|
|
property alias checkIconSize: buttonGroup.checkIconSize
|
|
property alias textSize: buttonGroup.textSize
|
|
property alias checkEnabled: buttonGroup.checkEnabled
|
|
|
|
readonly property bool compact: width - buttonGroup.width - SettingsMetrics.rowPaddingH * 2 - SettingsMetrics.rowContentSpacing < SettingsMetrics.buttonGroupCompactThreshold
|
|
|
|
// `values` is index-aligned with `model`.
|
|
property var values: []
|
|
property var value: undefined
|
|
property var fallbackValue: undefined
|
|
|
|
signal selectionChanged(int index, bool selected)
|
|
signal valueSelected(var value)
|
|
|
|
function indexOfValue(value) {
|
|
const index = values.indexOf(value);
|
|
return index >= 0 ? index : Math.max(0, values.indexOf(fallbackValue));
|
|
}
|
|
|
|
title: text
|
|
subtitle: description
|
|
spacing: Theme.groupedListGap
|
|
|
|
Item {
|
|
id: trailingHost
|
|
width: root.compact ? 0 : buttonGroup.width
|
|
height: root.compact ? 0 : buttonGroup.height
|
|
visible: !root.compact
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
}
|
|
|
|
body: Item {
|
|
id: bodyHost
|
|
width: parent.width
|
|
height: buttonGroup.height
|
|
visible: root.compact
|
|
}
|
|
|
|
DButtonGroup {
|
|
id: buttonGroup
|
|
arrowKeysSelect: false
|
|
parent: root.compact ? bodyHost : trailingHost
|
|
x: root.compact ? (parent.width - width) / 2 : 0
|
|
selectionMode: "single"
|
|
currentIndex: root.values.length > 0 ? root.indexOfValue(root.value) : 0
|
|
spacing: root.spacing
|
|
enabled: root.enabled
|
|
maximumWidth: root.compact ? root.width - SettingsMetrics.rowPaddingH * 2 : -1
|
|
onSelectionChanged: (index, selected) => {
|
|
root.selectionChanged(index, selected);
|
|
if (selected && index < root.values.length)
|
|
root.valueSelected(root.values[index]);
|
|
}
|
|
}
|
|
}
|