import QtQuick import Weave.Controls import Weave.Templates as T import "internal" T.Switch { id: root implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, implicitContentWidth + leftPadding + rightPadding, implicitIndicatorWidth + leftPadding + rightPadding) implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, implicitContentHeight + topPadding + bottomPadding, implicitIndicatorHeight + topPadding + bottomPadding) spacing: root.text.length > 0 ? Theme.component.label.positionSide.paddingLeft : 0 font.family: Theme.component.label.fontFamily font.pixelSize: Theme.component.label.positionSide.fontSize font.weight: Theme.component.label.fontWeight hoverEnabled: root.enabled switchAlignment: mirrored ? Switch.AlignRight : Switch.AlignLeft opacity: enabled ? 1.0 : Theme.component.toggle.opacity.disabled indicator: SwitchIndicator { checked: root.checked pressed: root.pressed hovered: root.hovered visualFocus: root.visualFocus visualPosition: root.visualPosition } background: Item { implicitHeight: Theme.component.toggle.container.height implicitWidth: Theme.component.toggle.container.width } contentItem: TableLayoutRow { horizontalSpacing: root.spacing verticalItemAlignment: TableLayout.AlignVCenter layoutDirection: root.switchAlignment === Switch.AlignLeft ? Qt.LeftToRight : Qt.RightToLeft TableLayoutProxyItem { target: root.indicator } Text { TableLayout.horizontalFillMode: TableLayout.Preferred text: root.text color: Theme.component.label.textColor font: root.font } } }