mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-07-10 06:31:56 +08:00
Align radio buttons with new designs.
Fix radiobutton looking the same checked and unchecked when disabled CURA-8991
This commit is contained in:
parent
b86b1133df
commit
b3e8c7190e
@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2019 Ultimaker B.V.
|
// Copyright (c) 2022 Ultimaker B.V.
|
||||||
// Cura is released under the terms of the LGPLv3 or higher.
|
// Cura is released under the terms of the LGPLv3 or higher.
|
||||||
|
|
||||||
import QtQuick 2.10
|
import QtQuick 2.10
|
||||||
@ -13,32 +13,58 @@ import Cura 1.0 as Cura
|
|||||||
//
|
//
|
||||||
RadioButton
|
RadioButton
|
||||||
{
|
{
|
||||||
id: radioButton
|
id: control
|
||||||
|
|
||||||
font: UM.Theme.getFont("default")
|
font: UM.Theme.getFont("default")
|
||||||
|
|
||||||
states: [
|
states: [
|
||||||
State {
|
State {
|
||||||
name: "checked"
|
name: "selected-hover"
|
||||||
when: radioButton.checked
|
when: control.enabled && control.checked && control.hovered
|
||||||
PropertyChanges
|
PropertyChanges
|
||||||
{
|
{
|
||||||
target: indicator
|
target: indicator_background
|
||||||
color: UM.Theme.getColor("accent_1")
|
color: UM.Theme.getColor("radio_selected")
|
||||||
border.width: 0
|
border.color: UM.Theme.getColor("radio_border_hover")
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
State
|
State {
|
||||||
{
|
name: "selected"
|
||||||
name: "disabled"
|
when: control.enabled && control.checked
|
||||||
when: !radioButton.enabled
|
PropertyChanges
|
||||||
PropertyChanges { target: indicator; color: UM.Theme.getColor("background_1")}
|
{
|
||||||
|
target: indicator_background
|
||||||
|
color: UM.Theme.getColor("radio_selected")
|
||||||
|
}
|
||||||
},
|
},
|
||||||
State
|
State {
|
||||||
{
|
name: "hovered"
|
||||||
name: "highlighted"
|
when: control.enabled && control.hovered
|
||||||
when: radioButton.hovered || radioButton.activeFocus
|
PropertyChanges
|
||||||
PropertyChanges { target: indicator; border.color: UM.Theme.getColor("border_main_light")}
|
{
|
||||||
|
target: indicator_background
|
||||||
|
border.color: UM.Theme.getColor("radio_border_hover")
|
||||||
|
}
|
||||||
|
},
|
||||||
|
State {
|
||||||
|
name: "selected_disabled"
|
||||||
|
when: !control.enabled && control.checked
|
||||||
|
PropertyChanges
|
||||||
|
{
|
||||||
|
target: indicator_background
|
||||||
|
color: UM.Theme.getColor("radio_selected_disabled")
|
||||||
|
border.color: UM.Theme.getColor("radio_border_disabled")
|
||||||
|
}
|
||||||
|
},
|
||||||
|
State {
|
||||||
|
name: "disabled"
|
||||||
|
when: !control.enabled
|
||||||
|
PropertyChanges
|
||||||
|
{
|
||||||
|
target: indicator_background
|
||||||
|
color: UM.Theme.getColor("radio_disabled")
|
||||||
|
border.color: UM.Theme.getColor("radio_border_disabled")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -49,30 +75,35 @@ RadioButton
|
|||||||
|
|
||||||
indicator: Rectangle
|
indicator: Rectangle
|
||||||
{
|
{
|
||||||
|
id: indicator_background
|
||||||
implicitWidth: UM.Theme.getSize("radio_button").width
|
implicitWidth: UM.Theme.getSize("radio_button").width
|
||||||
implicitHeight: UM.Theme.getSize("radio_button").height
|
implicitHeight: UM.Theme.getSize("radio_button").height
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
anchors.alignWhenCentered: false
|
anchors.alignWhenCentered: false
|
||||||
radius: width / 2
|
radius: width / 2
|
||||||
color: UM.Theme.getColor("background_2")
|
color: UM.Theme.getColor("radio")
|
||||||
border.width: UM.Theme.getSize("default_lining").width
|
border.width: UM.Theme.getSize("default_lining").width
|
||||||
border.color: UM.Theme.getColor("text_disabled")
|
border.color: UM.Theme.getColor("radio_border")
|
||||||
|
|
||||||
Rectangle
|
Rectangle
|
||||||
{
|
{
|
||||||
|
id: indicator_dot
|
||||||
width: (parent.width / 2) | 0
|
width: (parent.width / 2) | 0
|
||||||
height: width
|
height: width
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
radius: width / 2
|
radius: width / 2
|
||||||
color: radioButton.enabled ? UM.Theme.getColor("background_2") : UM.Theme.getColor("background_1")
|
color: control.enabled ? UM.Theme.getColor("radio_dot") : UM.Theme.getColor("radio_dot_disabled")
|
||||||
visible: radioButton.checked
|
visible: control.checked
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
contentItem: UM.Label
|
contentItem: UM.Label
|
||||||
{
|
{
|
||||||
leftPadding: radioButton.indicator.width + radioButton.spacing
|
leftPadding: control.indicator.width + control.spacing
|
||||||
text: radioButton.text
|
text: control.text
|
||||||
font: radioButton.font
|
font: control.font
|
||||||
|
color: control.enabled ? UM.Theme.getColor("radio_text"): UM.Theme.getColor("radio_text_disabled")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -335,6 +335,19 @@
|
|||||||
"checkbox_text": "text_default",
|
"checkbox_text": "text_default",
|
||||||
"checkbox_text_disabled": "text_disabled",
|
"checkbox_text_disabled": "text_disabled",
|
||||||
|
|
||||||
|
"radio": "background_1",
|
||||||
|
"radio_disabled": "background_2",
|
||||||
|
"radio_selected": "accent_1",
|
||||||
|
"radio_selected_disabled": "text_disabled",
|
||||||
|
"radio_border": [180, 180, 180, 255],
|
||||||
|
"radio_border_hover": "border_main",
|
||||||
|
"radio_border_disabled": "text_disabled",
|
||||||
|
"radio_dot": "background_1",
|
||||||
|
"radio_dot_disabled": "background_2",
|
||||||
|
"radio_text": "text_default",
|
||||||
|
"radio_text_disabled": "text_disabled",
|
||||||
|
|
||||||
|
|
||||||
"category_background": "background_2",
|
"category_background": "background_2",
|
||||||
|
|
||||||
"tooltip": [25, 25, 25, 255],
|
"tooltip": [25, 25, 25, 255],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user