Create a reusable component for the printer type label. Other parts of

the UI can just reuse it.

Contributes to CURA-5942.
This commit is contained in:
Diego Prado Gesto 2018-11-22 15:00:35 +01:00
parent 0211122b12
commit 5c30df2a68
4 changed files with 39 additions and 23 deletions

View File

@ -3,7 +3,6 @@
import QtQuick 2.7 import QtQuick 2.7
import QtQuick.Controls 2.1 import QtQuick.Controls 2.1
import QtQuick.Layouts 1.3
import UM 1.1 as UM import UM 1.1 as UM

View File

@ -3,7 +3,6 @@
import QtQuick 2.7 import QtQuick 2.7
import QtQuick.Controls 2.1 import QtQuick.Controls 2.1
import QtQuick.Layouts 1.3
import UM 1.1 as UM import UM 1.1 as UM
import Cura 1.0 as Cura import Cura 1.0 as Cura
@ -15,6 +14,7 @@ Button
width: parent.width width: parent.width
height: UM.Theme.getSize("action_button").height height: UM.Theme.getSize("action_button").height
leftPadding: Math.round(1.5 * UM.Theme.getSize("default_margin").width) leftPadding: Math.round(1.5 * UM.Theme.getSize("default_margin").width)
rightPadding: Math.round(1.5 * UM.Theme.getSize("default_margin").width)
checkable: true checkable: true
property var outputDevice: null property var outputDevice: null
@ -63,27 +63,9 @@ Button
Repeater Repeater
{ {
model: printerTypesList model: printerTypesList
delegate: Item delegate: Cura.PrinterTypeLabel
{ {
width: UM.Theme.getSize("printer_type_label").width text: modelData
height: UM.Theme.getSize("printer_type_label").height
Rectangle
{
anchors.fill: parent
color: UM.Theme.getColor("printer_type_label_background")
}
Label
{
id: printerTypeLabel
text: modelData
anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter
renderType: Text.NativeRendering
font: UM.Theme.getFont("very_small")
color: UM.Theme.getColor("text")
}
} }
} }
} }

View File

@ -0,0 +1,34 @@
// Copyright (c) 2018 Ultimaker B.V.
// Cura is released under the terms of the LGPLv3 or higher.
import QtQuick 2.7
import QtQuick.Controls 2.1
import UM 1.1 as UM
// This component creates a label with the abbreviated name of a printer, with a rectangle surrounding the label.
// It is created in a separated place in order to be reused whenever needed.
Item
{
property alias text: printerTypeLabel.text
width: UM.Theme.getSize("printer_type_label").width
height: UM.Theme.getSize("printer_type_label").height
Rectangle
{
anchors.fill: parent
color: UM.Theme.getColor("printer_type_label_background")
}
Label
{
id: printerTypeLabel
text: "CFFFP" // As an abbreviated name of the Custom FFF Printer
anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter
renderType: Text.NativeRendering
font: UM.Theme.getFont("very_small")
color: UM.Theme.getColor("text")
}
}

View File

@ -10,4 +10,5 @@ NozzleMenu 1.0 NozzleMenu.qml
ActionPanelWidget 1.0 ActionPanelWidget.qml ActionPanelWidget 1.0 ActionPanelWidget.qml
IconLabel 1.0 IconLabel.qml IconLabel 1.0 IconLabel.qml
OutputDevicesActionButton 1.0 OutputDevicesActionButton.qml OutputDevicesActionButton 1.0 OutputDevicesActionButton.qml
ExpandableComponent 1.0 ExpandableComponent.qml ExpandableComponent 1.0 ExpandableComponent.qml
PrinterTypeLabel 1.0 PrinterTypeLabel.qml