mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 23:17:32 -06:00
Create Cura.RadioButton
This commit is contained in:
parent
839d8c2227
commit
f99affd4f5
3 changed files with 55 additions and 41 deletions
|
@ -129,7 +129,7 @@ ScrollView
|
|||
{
|
||||
id: machineButton
|
||||
|
||||
RadioButton
|
||||
Cura.RadioButton
|
||||
{
|
||||
id: radioButton
|
||||
anchors.left: parent.left
|
||||
|
@ -140,47 +140,7 @@ ScrollView
|
|||
|
||||
checked: ListView.view.currentIndex == index
|
||||
text: name
|
||||
font: UM.Theme.getFont("default")
|
||||
visible: base.currentSection == section
|
||||
|
||||
background: Item
|
||||
{
|
||||
anchors.fill: parent
|
||||
}
|
||||
|
||||
indicator: Rectangle
|
||||
{
|
||||
implicitWidth: UM.Theme.getSize("radio_button").width
|
||||
implicitHeight: UM.Theme.getSize("radio_button").height
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
radius: (width / 2) | 0
|
||||
border.width: UM.Theme.getSize("default_lining").width
|
||||
border.color: radioButton.hovered ? UM.Theme.getColor("small_button_text") : UM.Theme.getColor("small_button_text_hover")
|
||||
|
||||
Rectangle
|
||||
{
|
||||
width: (parent.width / 2) | 0
|
||||
height: width
|
||||
anchors.centerIn: parent
|
||||
radius: (width / 2) | 0
|
||||
color: radioButton.hovered ? UM.Theme.getColor("primary_button_hover") : UM.Theme.getColor("primary_button")
|
||||
visible: radioButton.checked
|
||||
}
|
||||
}
|
||||
|
||||
contentItem: Label
|
||||
{
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
leftPadding: radioButton.indicator.width + radioButton.spacing
|
||||
text: radioButton.text
|
||||
font: radioButton.font
|
||||
renderType: Text.NativeRendering
|
||||
}
|
||||
|
||||
onClicked:
|
||||
{
|
||||
ListView.view.currentIndex = index
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
53
resources/qml/Widgets/RadioButton.qml
Normal file
53
resources/qml/Widgets/RadioButton.qml
Normal file
|
@ -0,0 +1,53 @@
|
|||
// Copyright (c) 2019 Ultimaker B.V.
|
||||
// Cura is released under the terms of the LGPLv3 or higher.
|
||||
|
||||
import QtQuick 2.10
|
||||
import QtQuick.Controls 2.3
|
||||
|
||||
import UM 1.3 as UM
|
||||
import Cura 1.0 as Cura
|
||||
|
||||
|
||||
//
|
||||
// Cura-style RadioButton.
|
||||
//
|
||||
RadioButton
|
||||
{
|
||||
id: radioButton
|
||||
|
||||
font: UM.Theme.getFont("default")
|
||||
|
||||
background: Item
|
||||
{
|
||||
anchors.fill: parent
|
||||
}
|
||||
|
||||
indicator: Rectangle
|
||||
{
|
||||
implicitWidth: UM.Theme.getSize("radio_button").width
|
||||
implicitHeight: UM.Theme.getSize("radio_button").height
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
radius: (width / 2) | 0
|
||||
border.width: UM.Theme.getSize("default_lining").width
|
||||
border.color: radioButton.hovered ? UM.Theme.getColor("small_button_text") : UM.Theme.getColor("small_button_text_hover")
|
||||
|
||||
Rectangle
|
||||
{
|
||||
width: (parent.width / 2) | 0
|
||||
height: width
|
||||
anchors.centerIn: parent
|
||||
radius: (width / 2) | 0
|
||||
color: radioButton.hovered ? UM.Theme.getColor("primary_button_hover") : UM.Theme.getColor("primary_button")
|
||||
visible: radioButton.checked
|
||||
}
|
||||
}
|
||||
|
||||
contentItem: Label
|
||||
{
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
leftPadding: radioButton.indicator.width + radioButton.spacing
|
||||
text: radioButton.text
|
||||
font: radioButton.font
|
||||
renderType: Text.NativeRendering
|
||||
}
|
||||
}
|
|
@ -24,6 +24,7 @@ ToolTip 1.0 ToolTip.qml
|
|||
CheckBox 1.0 CheckBox.qml
|
||||
ComboBox 1.0 ComboBox.qml
|
||||
ProgressBar 1.0 ProgressBar.qml
|
||||
RadioButton 1.0 RadioButton.qml
|
||||
TabButton 1.0 TabButton.qml
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue