Skip to content

Commit 0a13a29

Browse files
committed
New NColorCHoice widget + reset sliders
1 parent 89a9fa4 commit 0a13a29

1 file changed

Lines changed: 10 additions & 103 deletions

File tree

slowbongo/Settings.qml

Lines changed: 10 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ ColumnLayout {
1919
property string editCatColor: {
2020
let saved = pluginApi?.pluginSettings?.catColor
2121
if (saved && saved.length > 0) return saved
22-
return pluginApi?.manifest?.metadata?.defaultSettings?.catColor ?? "default"
22+
return pluginApi?.manifest?.metadata?.defaultSettings?.catColor ?? "none"
2323
}
2424

2525
property real editCatSize: {
@@ -64,14 +64,6 @@ ColumnLayout {
6464
readonly property color statusSuccessColor: Color.mPrimary
6565
readonly property color statusErrorColor: Color.mError ?? "#c00202"
6666

67-
// Configuration data
68-
readonly property var colorOptions: [
69-
{ key: "default", labelKey: "colors.default", color: Color.mOnSurface },
70-
{ key: "primary", labelKey: "colors.primary", color: Color.mPrimary },
71-
{ key: "secondary", labelKey: "colors.secondary", color: Color.mSecondary },
72-
{ key: "tertiary", labelKey: "colors.tertiary", color: Color.mTertiary },
73-
]
74-
7567
property var inputDevices: []
7668

7769
function isSelected(key) {
@@ -383,100 +375,11 @@ ColumnLayout {
383375
Layout.fillWidth: true
384376
}
385377

386-
// Colours Section
387-
Text {
388-
text: pluginApi?.tr("settings.colours") || "Colours"
389-
color: Color.mOnSurface
390-
font.pointSize: Style.fontSizeM
391-
font.weight: Font.DemiBold
392-
}
393-
394-
NBox {
395-
id: colourBox
396-
Layout.fillWidth: true
397-
implicitHeight: colourContent.implicitHeight + Style.marginM * 2
398-
399-
property int circleSize: Math.round(Style.baseWidgetSize * 0.9)
400-
property int columnCount: root.colorOptions.length
401-
property real availableInner: colourBox.width - Style.marginM * 2
402-
property real columnWidth: columnCount > 0 ? availableInner / columnCount : 0
403-
404-
ColumnLayout {
405-
id: colourContent
406-
anchors.left: parent.left
407-
anchors.right: parent.right
408-
anchors.top: parent.top
409-
anchors.margins: Style.marginM
410-
spacing: 0
411-
412-
Row {
413-
id: colourRow
414-
Layout.fillWidth: true
415-
416-
Repeater {
417-
model: root.colorOptions
418-
419-
Item {
420-
required property var modelData
421-
required property int index
422-
423-
width: colourBox.columnWidth
424-
height: colorCol.implicitHeight
425-
426-
ColumnLayout {
427-
id: colorCol
428-
anchors.horizontalCenter: parent.horizontalCenter
429-
spacing: Style.marginXS
430-
431-
Rectangle {
432-
id: colorCircle
433-
property bool isSelected: root.editCatColor === modelData.key
434-
property bool isHovered: circleMouseArea.containsMouse
435-
436-
Layout.alignment: Qt.AlignHCenter
437-
implicitWidth: colourBox.circleSize
438-
implicitHeight: implicitWidth
439-
radius: width / 2
440-
color: modelData.color
441-
border.color: isSelected ? Color.mOnSurface : "transparent"
442-
border.width: isSelected ? Style.borderS + 1 : 0
443-
scale: isHovered ? 1.15 : 1.0
444-
445-
Behavior on scale {
446-
NumberAnimation { duration: Style.animationFast; easing.type: Easing.OutCubic }
447-
}
448-
Behavior on border.color {
449-
ColorAnimation { duration: Style.animationFast }
450-
}
451-
452-
MouseArea {
453-
id: circleMouseArea
454-
anchors.fill: parent
455-
hoverEnabled: true
456-
cursorShape: Qt.PointingHandCursor
457-
onClicked: root.editCatColor = modelData.key
458-
}
459-
460-
NIcon {
461-
anchors.centerIn: parent
462-
icon: "check"
463-
pointSize: Math.max(Style.fontSizeXS, colorCircle.implicitWidth * 0.4)
464-
color: Color.mOnPrimary
465-
visible: colorCircle.isSelected
466-
}
467-
}
468-
469-
Text {
470-
Layout.alignment: Qt.AlignHCenter
471-
text: pluginApi?.tr(modelData.labelKey) || modelData.key.charAt(0).toUpperCase() + modelData.key.slice(1)
472-
color: Color.mOnSurfaceVariant
473-
font.pointSize: Style.fontSizeS
474-
}
475-
}
476-
}
477-
}
478-
}
479-
}
378+
// Widget Color
379+
NColorChoice {
380+
label: pluginApi?.tr("settings.colours") || "Colours"
381+
currentKey: root.editCatColor
382+
onSelected: key => { root.editCatColor = key; }
480383
}
481384

482385
// Rave Mode
@@ -518,6 +421,8 @@ ColumnLayout {
518421
from: 0.5
519422
to: 1.5
520423
stepSize: 0.01
424+
defaultValue: 1.0
425+
showReset: true
521426
text: Math.round(root.editCatSize * 100) + "%"
522427
onMoved: value => root.editCatSize = value
523428
}
@@ -530,6 +435,8 @@ ColumnLayout {
530435
from: -0.39
531436
to: 0.61
532437
stepSize: 0.01
438+
defaultValue: 0.11
439+
showReset: true
533440
text: { let v = Math.round(-(root.editCatOffsetY - 0.11) * 100) / 100; return (v > 0 ? "+" : "") + v.toFixed(2) }
534441
onMoved: value => root.editCatOffsetY = value
535442
}

0 commit comments

Comments
 (0)