Replaced the old checkboxes in ArchUpdaterPanel with NCheckbox

ArchUpdater: use NCheckbox to make things more uniform
This commit is contained in:
Ly-sec 2025-08-28 17:03:28 +02:00
parent d0b7ccf302
commit 82d71d65fa
2 changed files with 15 additions and 10 deletions

View file

@ -106,14 +106,16 @@ NPanel {
anchors.margins: Style.marginS * scaling anchors.margins: Style.marginS * scaling
spacing: Style.marginS * scaling spacing: Style.marginS * scaling
// Checkbox for selection (pure bindings; no imperative state) // Checkbox for selection
NIconButton { NCheckbox {
id: checkbox id: checkbox
icon: ArchUpdaterService.isPackageSelected(modelData.name) ? "check_box" : "check_box_outline_blank" label: ""
onClicked: ArchUpdaterService.togglePackageSelection(modelData.name) description: ""
colorBg: Color.transparent checked: (ArchUpdaterService.selectedPackagesCount, ArchUpdaterService.isPackageSelected(modelData.name))
colorFg: ArchUpdaterService.isPackageSelected( onToggled: ArchUpdaterService.togglePackageSelection(modelData.name)
modelData.name) ? ((modelData.source === "aur") ? Color.mSecondary : Color.mPrimary) : Color.mOnSurfaceVariant activeColor: (modelData.source === "aur") ? Color.mSecondary : Color.mPrimary
activeOnColor: (modelData.source === "aur") ? Color.mOnSecondary : Color.mOnPrimary
Layout.fillWidth: false
Layout.preferredWidth: 30 * scaling Layout.preferredWidth: 30 * scaling
Layout.preferredHeight: 30 * scaling Layout.preferredHeight: 30 * scaling
} }

View file

@ -11,6 +11,9 @@ RowLayout {
property string description: "" property string description: ""
property bool checked: false property bool checked: false
property bool hovering: false property bool hovering: false
// Active state colors (allow override per-usage)
property color activeColor: Color.mPrimary
property color activeOnColor: Color.mOnPrimary
// Smaller default footprint than NToggle // Smaller default footprint than NToggle
property int baseSize: Math.max(Style.baseWidgetSize * 0.8, 14) property int baseSize: Math.max(Style.baseWidgetSize * 0.8, 14)
@ -31,15 +34,15 @@ RowLayout {
implicitWidth: root.baseSize * scaling implicitWidth: root.baseSize * scaling
implicitHeight: root.baseSize * scaling implicitHeight: root.baseSize * scaling
radius: Math.max(2 * scaling, Style.radiusXS * scaling) radius: Math.max(2 * scaling, Style.radiusXS * scaling)
color: root.checked ? Color.mPrimary : Color.mSurface color: root.checked ? root.activeColor : Color.mSurface
border.color: root.checked ? Color.mPrimary : Color.mOutline border.color: root.checked ? root.activeColor : Color.mOutline
border.width: Math.max(1, Style.borderM * scaling) border.width: Math.max(1, Style.borderM * scaling)
NIcon { NIcon {
visible: root.checked visible: root.checked
anchors.centerIn: parent anchors.centerIn: parent
text: "check" text: "check"
color: Color.mOnPrimary color: root.activeOnColor
font.pointSize: Math.max(Style.fontSizeS, root.baseSize * 0.7) * scaling font.pointSize: Math.max(Style.fontSizeS, root.baseSize * 0.7) * scaling
} }