-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implememnt exclusive button lists as RadioButtons in settings
- Loading branch information
1 parent
50e5f9f
commit af2b8dd
Showing
7 changed files
with
155 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import QtQuick | ||
import QtQuick.Templates as T | ||
|
||
import Lith.Core | ||
|
||
T.RadioButton { | ||
id: control | ||
checked: true | ||
implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, | ||
Math.max(implicitContentWidth, indicator.width) + leftPadding + rightPadding) | ||
implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, | ||
implicitContentHeight + topPadding + bottomPadding, | ||
implicitIndicatorHeight + topPadding + bottomPadding) | ||
|
||
spacing: 0 | ||
padding: 6 | ||
|
||
background: Item {} | ||
|
||
indicator: Rectangle { | ||
id: backgroundRect | ||
implicitWidth: 26 * Math.max(1.0, Lith.settings.baseFontSize / 20) | ||
implicitHeight: implicitWidth | ||
anchors.verticalCenter: parent.verticalCenter | ||
|
||
radius: width / 2 | ||
border.color: ColorUtils.mixColors(LithPalette.regular.button, LithPalette.regular.text, 0.9) | ||
border.width: control.flat ? 0 : 0.5 | ||
readonly property real themeQuotient: WindowHelper.lightTheme ? 0.0 : WindowHelper.useBlack ? 0.5 : 0.5 | ||
color: { | ||
if (control.flat) | ||
return LithPalette.regular.window | ||
if (!control.enabled) { | ||
if (control.down) { | ||
return ColorUtils.darken(LithPalette.disabled.button, 1.1 + backgroundRect.themeQuotient) | ||
} | ||
else { | ||
return LithPalette.disabled.button | ||
} | ||
} | ||
return LithPalette.regular.button | ||
} | ||
property color startColor: { | ||
if (!control.enabled) | ||
return backgroundRect.color | ||
if (control.pressed) | ||
return ColorUtils.darken(LithPalette.regular.button, 1.4 + backgroundRect.themeQuotient) | ||
if (control.hovered || !control.flat) | ||
return ColorUtils.lighten(LithPalette.regular.button, 1.15 + 0.2 * backgroundRect.themeQuotient) | ||
return backgroundRect.color | ||
} | ||
property color endColor: { | ||
if (!control.enabled) | ||
return backgroundRect.color | ||
if (control.pressed) | ||
return ColorUtils.darken(LithPalette.regular.button, 1.2 + backgroundRect.themeQuotient) | ||
if (control.hovered) | ||
return ColorUtils.lighten(LithPalette.regular.button, 1.2 + 0.2 * backgroundRect.themeQuotient) | ||
return backgroundRect.color | ||
} | ||
Behavior on startColor { ColorAnimation { duration: 100 } } | ||
Behavior on endColor { ColorAnimation { duration: 100 } } | ||
gradient: Gradient { | ||
GradientStop { position: 0.0; color: backgroundRect.startColor } | ||
GradientStop { position: 0.6; color: backgroundRect.endColor } | ||
} | ||
|
||
Rectangle { | ||
anchors.centerIn: parent | ||
width: parent.width / 3 | ||
height: width | ||
radius: width / 2 | ||
color: ColorUtils.mixColors(LithPalette.regular.windowText, LithPalette.regular.button, control.enabled ? 1.0 : 0.4) | ||
visible: control.checked | ||
} | ||
} | ||
|
||
contentItem: Label { | ||
leftPadding: visible && control.indicator && !control.mirrored ? control.indicator.width + control.spacing : 0 | ||
rightPadding: visible && control.indicator && control.mirrored ? control.indicator.width + control.spacing : 0 | ||
visible: text.length > 0 | ||
text: control.text | ||
font: control.font | ||
color: ColorUtils.mixColors(LithPalette.regular.windowText, LithPalette.regular.window, enabled ? 1.0 : 0.3) | ||
verticalAlignment: Text.AlignVCenter | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import QtQuick | ||
import QtQuick.Controls | ||
import QtQuick.Layouts | ||
|
||
Base { | ||
id: root | ||
property alias model: repeater.model | ||
property int currentIndex: -1 | ||
onCurrentIndexChanged: { | ||
if (currentIndex < 0) { | ||
for (const button in buttonGroup.buttons) { | ||
button.checked = false | ||
} | ||
} | ||
else if (currentIndex < buttonGroup.buttons.length) { | ||
buttonGroup.buttons[currentIndex].checked = true | ||
} | ||
} | ||
Component.onCompleted: { | ||
if (currentIndex >= 0 && currentIndex < buttonGroup.buttons.length) { | ||
buttonGroup.buttons[currentIndex].checked = true | ||
} | ||
} | ||
|
||
ButtonGroup { | ||
id: buttonGroup | ||
onCheckedButtonChanged: root.currentIndex = checkedButton.index | ||
} | ||
|
||
rowComponent: ColumnLayout { | ||
Layout.topMargin: 6 | ||
Layout.bottomMargin: 6 | ||
spacing: 6 | ||
Repeater { | ||
id: repeater | ||
RowLayout { | ||
id: radioDelegateLayout | ||
required property var modelData | ||
required property int index | ||
|
||
Layout.alignment: Qt.AlignRight | ||
|
||
Label { | ||
text: modelData | ||
} | ||
|
||
RadioButton { | ||
ButtonGroup.group: buttonGroup | ||
checked: false | ||
readonly property int index: radioDelegateLayout.index | ||
padding: 0 | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters