Skip to content

Commit

Permalink
update CardType for using with focus navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
CyAn84 committed Oct 17, 2024
1 parent 49fa8c7 commit 8062aad
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion client/ui/qml/Controls2/CardType.qml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,40 @@ RadioButton {
property string pressedBorderColor: Qt.rgba(251/255, 178/255, 106/255, 0.3)
property string selectedBorderColor: AmneziaStyle.color.goldenApricot
property string defaultBodredColor: AmneziaStyle.color.transparent
property string focusBorderColor: AmneziaStyle.color.paleGray
property int borderWidth: 0

implicitWidth: content.implicitWidth
implicitHeight: content.implicitHeight

hoverEnabled: true

property bool isFocusable: true

Keys.onTabPressed: {
FocusController.nextKeyTabItem()
}

Keys.onBacktabPressed: {
FocusController.previousKeyTabItem()
}

Keys.onUpPressed: {
FocusController.nextKeyUpItem()
}

Keys.onDownPressed: {
FocusController.nextKeyDownItem()
}

Keys.onLeftPressed: {
FocusController.nextKeyLeftItem()
}

Keys.onRightPressed: {
FocusController.nextKeyRightItem()
}

indicator: Rectangle {
anchors.fill: parent
radius: 16
Expand All @@ -52,14 +79,16 @@ RadioButton {
return pressedBorderColor
} else if (root.checked) {
return selectedBorderColor
} else if (root.activeFocus) {
return focusBorderColor
}
}
return defaultBodredColor
}

border.width: {
if (root.enabled) {
if(root.checked) {
if(root.checked || root.activeFocus) {
return 1
}
return root.pressed ? 1 : 0
Expand Down

0 comments on commit 8062aad

Please sign in to comment.