mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-12 12:39:04 +08:00
Make PrintSetupSelector use layout instead of fixed width
This makes the components autoscale a bit when needed. CURA-5785
This commit is contained in:
parent
ca63733827
commit
54685c983a
@ -8,18 +8,29 @@ import QtQuick.Layouts 1.3
|
|||||||
import UM 1.2 as UM
|
import UM 1.2 as UM
|
||||||
import Cura 1.0 as Cura
|
import Cura 1.0 as Cura
|
||||||
|
|
||||||
// Reusable component that holds an (re-colorable) icon on the left with some text on the right
|
// Reusable component that holds an (re-colorable) icon on the left with some text on the right.
|
||||||
|
// This component is also designed to be used with layouts. It will use the width of the text + icon as preferred width
|
||||||
|
// It sets the icon size + half of the content as it's minium width (in which case it will elide the text)
|
||||||
Item
|
Item
|
||||||
{
|
{
|
||||||
property alias iconColor: icon.color
|
property alias iconColor: icon.color
|
||||||
property alias source: icon.source
|
property alias source: icon.source
|
||||||
property alias text: label.text
|
property alias text: label.text
|
||||||
|
|
||||||
|
property real margin: UM.Theme.getSize("narrow_margin").width
|
||||||
|
|
||||||
|
// These properties can be used in combination with layouts.
|
||||||
|
readonly property real contentWidth: icon.width + margin + label.contentWidth
|
||||||
|
readonly property real minContentWidth: icon.width + margin + 0.5 * label.contentWidth
|
||||||
|
|
||||||
|
Layout.minimumWidth: minContentWidth
|
||||||
|
Layout.preferredWidth: contentWidth
|
||||||
|
Layout.fillHeight: true
|
||||||
|
Layout.fillWidth: true
|
||||||
|
|
||||||
implicitWidth: icon.width + 100
|
implicitWidth: icon.width + 100
|
||||||
implicitHeight: icon.height
|
implicitHeight: icon.height
|
||||||
|
|
||||||
Component.onCompleted: print(label.contentWidth)
|
|
||||||
|
|
||||||
UM.RecolorImage
|
UM.RecolorImage
|
||||||
{
|
{
|
||||||
id: icon
|
id: icon
|
||||||
@ -35,18 +46,17 @@ Item
|
|||||||
left: parent.left
|
left: parent.left
|
||||||
verticalCenter: parent.verticalCenter
|
verticalCenter: parent.verticalCenter
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Label
|
Label
|
||||||
{
|
{
|
||||||
id: label
|
id: label
|
||||||
height: contentHeight
|
|
||||||
font: UM.Theme.getFont("default")
|
font: UM.Theme.getFont("default")
|
||||||
color: UM.Theme.getColor("text")
|
color: UM.Theme.getColor("text")
|
||||||
renderType: Text.NativeRendering
|
renderType: Text.NativeRendering
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
|
||||||
anchors
|
anchors
|
||||||
{
|
{
|
||||||
left: icon.right
|
left: icon.right
|
||||||
@ -54,7 +64,7 @@ Item
|
|||||||
top: parent.top
|
top: parent.top
|
||||||
bottom: parent.bottom
|
bottom: parent.bottom
|
||||||
rightMargin: 0
|
rightMargin: 0
|
||||||
margins: UM.Theme.getSize("narrow_margin").width
|
margins: margin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -18,8 +18,8 @@ Cura.ExpandableComponent
|
|||||||
property int currentModeIndex: -1
|
property int currentModeIndex: -1
|
||||||
property bool hideSettings: PrintInformation.preSliced
|
property bool hideSettings: PrintInformation.preSliced
|
||||||
|
|
||||||
property string enabledText: catalog.i18nc("@label", "On")
|
property string enabledText: catalog.i18nc("@label:Should be short", "On")
|
||||||
property string disabledText: catalog.i18nc("@label", "Off")
|
property string disabledText: catalog.i18nc("@label:Should be short", "Off")
|
||||||
|
|
||||||
// This widget doesn't show tooltips by itself. Instead it emits signals so others can do something with it.
|
// This widget doesn't show tooltips by itself. Instead it emits signals so others can do something with it.
|
||||||
signal showTooltip(Item item, point location, string text)
|
signal showTooltip(Item item, point location, string text)
|
||||||
@ -44,7 +44,7 @@ Cura.ExpandableComponent
|
|||||||
|
|
||||||
onCurrentModeIndexChanged: UM.Preferences.setValue("cura/active_mode", currentModeIndex)
|
onCurrentModeIndexChanged: UM.Preferences.setValue("cura/active_mode", currentModeIndex)
|
||||||
|
|
||||||
headerItem: Row
|
headerItem: RowLayout
|
||||||
{
|
{
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
@ -52,8 +52,6 @@ Cura.ExpandableComponent
|
|||||||
{
|
{
|
||||||
source: UM.Theme.getIcon("category_layer_height")
|
source: UM.Theme.getIcon("category_layer_height")
|
||||||
text: Cura.MachineManager.activeQualityOrQualityChangesName + " " + layerHeight.properties.value + "mm"
|
text: Cura.MachineManager.activeQualityOrQualityChangesName + " " + layerHeight.properties.value + "mm"
|
||||||
width: parent.width / 4
|
|
||||||
height: parent.height
|
|
||||||
|
|
||||||
UM.SettingPropertyProvider
|
UM.SettingPropertyProvider
|
||||||
{
|
{
|
||||||
@ -68,8 +66,6 @@ Cura.ExpandableComponent
|
|||||||
{
|
{
|
||||||
source: UM.Theme.getIcon("category_infill")
|
source: UM.Theme.getIcon("category_infill")
|
||||||
text: parseInt(infillDensity.properties.value) + "%"
|
text: parseInt(infillDensity.properties.value) + "%"
|
||||||
width: parent.width / 4
|
|
||||||
height: parent.height
|
|
||||||
|
|
||||||
UM.SettingPropertyProvider
|
UM.SettingPropertyProvider
|
||||||
{
|
{
|
||||||
@ -84,8 +80,7 @@ Cura.ExpandableComponent
|
|||||||
{
|
{
|
||||||
source: UM.Theme.getIcon("category_support")
|
source: UM.Theme.getIcon("category_support")
|
||||||
text: supportEnabled.properties.value == "True" ? enabledText : disabledText
|
text: supportEnabled.properties.value == "True" ? enabledText : disabledText
|
||||||
width: parent.width / 4
|
|
||||||
height: parent.height
|
|
||||||
|
|
||||||
UM.SettingPropertyProvider
|
UM.SettingPropertyProvider
|
||||||
{
|
{
|
||||||
@ -100,8 +95,6 @@ Cura.ExpandableComponent
|
|||||||
{
|
{
|
||||||
source: UM.Theme.getIcon("category_adhesion")
|
source: UM.Theme.getIcon("category_adhesion")
|
||||||
text: platformAdhesionType.properties.value != "skirt" && platformAdhesionType.properties.value != "none" ? enabledText : disabledText
|
text: platformAdhesionType.properties.value != "skirt" && platformAdhesionType.properties.value != "none" ? enabledText : disabledText
|
||||||
width: parent.width / 4
|
|
||||||
height: parent.height
|
|
||||||
|
|
||||||
UM.SettingPropertyProvider
|
UM.SettingPropertyProvider
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user