|
@@ -12,9 +12,12 @@ import Cura 1.0 as Cura
|
|
|
// This is the scroll view widget for adding a (local) printer. This scroll view shows a list view with printers
|
|
|
// categorized into 3 categories: "Ultimaker", "Custom", and "Other".
|
|
|
//
|
|
|
-ScrollView
|
|
|
+Item
|
|
|
{
|
|
|
+ UM.I18nCatalog { id: catalog; name: "cura" }
|
|
|
+
|
|
|
id: base
|
|
|
+ height: childrenRect.height
|
|
|
|
|
|
// The currently selected machine item in the local machine list.
|
|
|
property var currentItem: (machineList.currentIndex >= 0)
|
|
@@ -25,12 +28,16 @@ ScrollView
|
|
|
// By default (when this list shows up) we always expand the "Ultimaker" section.
|
|
|
property string preferredCategory: "Ultimaker"
|
|
|
|
|
|
- ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
|
|
|
- ScrollBar.vertical.policy: ScrollBar.AsNeeded
|
|
|
property int maxItemCountAtOnce: 10 // show at max 10 items at once, otherwise you need to scroll.
|
|
|
- height: maxItemCountAtOnce * UM.Theme.getSize("action_button").height
|
|
|
|
|
|
- clip: true
|
|
|
+ // User-editable printer name
|
|
|
+ property alias printerName: printerNameTextField.text
|
|
|
+ property alias isPrinterNameValid: printerNameTextField.acceptableInput
|
|
|
+
|
|
|
+ onCurrentItemChanged:
|
|
|
+ {
|
|
|
+ printerName = currentItem == null ? "" : currentItem.name
|
|
|
+ }
|
|
|
|
|
|
function updateCurrentItemUponSectionChange()
|
|
|
{
|
|
@@ -51,103 +58,164 @@ ScrollView
|
|
|
updateCurrentItemUponSectionChange()
|
|
|
}
|
|
|
|
|
|
- ListView
|
|
|
+ Item
|
|
|
{
|
|
|
- id: machineList
|
|
|
-
|
|
|
- model: UM.DefinitionContainersModel
|
|
|
+ id: localPrinterSelectionItem
|
|
|
+ anchors.left: parent.left
|
|
|
+ anchors.right: parent.right
|
|
|
+ anchors.top: parent.top
|
|
|
+ height: childrenRect.height
|
|
|
+
|
|
|
+ // ScrollView + ListView for selecting a local printer to add
|
|
|
+ ScrollView
|
|
|
{
|
|
|
- id: machineDefinitionsModel
|
|
|
- filter: { "visible": true }
|
|
|
- sectionProperty: "category"
|
|
|
- preferredSectionValue: preferredCategory
|
|
|
- }
|
|
|
-
|
|
|
- section.property: "section"
|
|
|
- section.delegate: sectionHeader
|
|
|
- delegate: machineButton
|
|
|
- }
|
|
|
-
|
|
|
- Component
|
|
|
- {
|
|
|
- id: sectionHeader
|
|
|
+ id: scrollView
|
|
|
+ anchors.left: parent.left
|
|
|
+ anchors.right: parent.right
|
|
|
+ anchors.top: parent.top
|
|
|
|
|
|
- Button
|
|
|
- {
|
|
|
- id: button
|
|
|
- width: ListView.view.width
|
|
|
- height: UM.Theme.getSize("action_button").height
|
|
|
- text: section
|
|
|
+ height: maxItemCountAtOnce * UM.Theme.getSize("action_button").height
|
|
|
|
|
|
- property bool isActive: base.currentSection == section
|
|
|
+ ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
|
|
|
+ ScrollBar.vertical.policy: ScrollBar.AsNeeded
|
|
|
|
|
|
- background: Rectangle
|
|
|
- {
|
|
|
- anchors.fill: parent
|
|
|
- color: isActive ? UM.Theme.getColor("setting_control_highlight") : "transparent"
|
|
|
- }
|
|
|
+ clip: true
|
|
|
|
|
|
- contentItem: Item
|
|
|
+ ListView
|
|
|
{
|
|
|
- width: childrenRect.width
|
|
|
- height: UM.Theme.getSize("action_button").height
|
|
|
+ id: machineList
|
|
|
|
|
|
- UM.RecolorImage
|
|
|
+ model: UM.DefinitionContainersModel
|
|
|
{
|
|
|
- id: arrow
|
|
|
- anchors.left: parent.left
|
|
|
- width: UM.Theme.getSize("standard_arrow").width
|
|
|
- height: UM.Theme.getSize("standard_arrow").height
|
|
|
- sourceSize.width: width
|
|
|
- sourceSize.height: height
|
|
|
- color: UM.Theme.getColor("text")
|
|
|
- source: base.currentSection == section ? UM.Theme.getIcon("arrow_bottom") : UM.Theme.getIcon("arrow_right")
|
|
|
+ id: machineDefinitionsModel
|
|
|
+ filter: { "visible": true }
|
|
|
+ sectionProperty: "category"
|
|
|
+ preferredSectionValue: preferredCategory
|
|
|
}
|
|
|
|
|
|
- Label
|
|
|
+ section.property: "section"
|
|
|
+ section.delegate: sectionHeader
|
|
|
+ delegate: machineButton
|
|
|
+ }
|
|
|
+
|
|
|
+ Component
|
|
|
+ {
|
|
|
+ id: sectionHeader
|
|
|
+
|
|
|
+ Button
|
|
|
{
|
|
|
- id: label
|
|
|
- anchors.left: arrow.right
|
|
|
- anchors.leftMargin: UM.Theme.getSize("default_margin").width
|
|
|
- verticalAlignment: Text.AlignVCenter
|
|
|
- text: button.text
|
|
|
- font.bold: true
|
|
|
- renderType: Text.NativeRendering
|
|
|
+ id: button
|
|
|
+ width: ListView.view.width
|
|
|
+ height: UM.Theme.getSize("action_button").height
|
|
|
+ text: section
|
|
|
+
|
|
|
+ property bool isActive: base.currentSection == section
|
|
|
+
|
|
|
+ background: Rectangle
|
|
|
+ {
|
|
|
+ anchors.fill: parent
|
|
|
+ color: isActive ? UM.Theme.getColor("setting_control_highlight") : "transparent"
|
|
|
+ }
|
|
|
+
|
|
|
+ contentItem: Item
|
|
|
+ {
|
|
|
+ width: childrenRect.width
|
|
|
+ height: UM.Theme.getSize("action_button").height
|
|
|
+
|
|
|
+ UM.RecolorImage
|
|
|
+ {
|
|
|
+ id: arrow
|
|
|
+ anchors.left: parent.left
|
|
|
+ width: UM.Theme.getSize("standard_arrow").width
|
|
|
+ height: UM.Theme.getSize("standard_arrow").height
|
|
|
+ sourceSize.width: width
|
|
|
+ sourceSize.height: height
|
|
|
+ color: UM.Theme.getColor("text")
|
|
|
+ source: base.currentSection == section ? UM.Theme.getIcon("arrow_bottom") : UM.Theme.getIcon("arrow_right")
|
|
|
+ }
|
|
|
+
|
|
|
+ Label
|
|
|
+ {
|
|
|
+ id: label
|
|
|
+ anchors.left: arrow.right
|
|
|
+ anchors.leftMargin: UM.Theme.getSize("default_margin").width
|
|
|
+ verticalAlignment: Text.AlignVCenter
|
|
|
+ text: button.text
|
|
|
+ font: UM.Theme.getFont("default_bold")
|
|
|
+ renderType: Text.NativeRendering
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ onClicked:
|
|
|
+ {
|
|
|
+ base.currentSection = section
|
|
|
+ base.updateCurrentItemUponSectionChange()
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- onClicked:
|
|
|
+ Component
|
|
|
{
|
|
|
- base.currentSection = section
|
|
|
- base.updateCurrentItemUponSectionChange()
|
|
|
+ id: machineButton
|
|
|
+
|
|
|
+ Cura.RadioButton
|
|
|
+ {
|
|
|
+ id: radioButton
|
|
|
+ anchors.left: parent.left
|
|
|
+ anchors.leftMargin: UM.Theme.getSize("standard_list_lineheight").width
|
|
|
+ anchors.right: parent.right
|
|
|
+ anchors.rightMargin: UM.Theme.getSize("default_margin").width
|
|
|
+ height: visible ? UM.Theme.getSize("standard_list_lineheight").height : 0
|
|
|
+
|
|
|
+ checked: ListView.view.currentIndex == index
|
|
|
+ text: name
|
|
|
+ visible: base.currentSection == section
|
|
|
+ onClicked: ListView.view.currentIndex = index
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- Component
|
|
|
+ // Horizontal line
|
|
|
+ Rectangle
|
|
|
{
|
|
|
- id: machineButton
|
|
|
+ id: horizontalLine
|
|
|
+ anchors.top: localPrinterSelectionItem.bottom
|
|
|
+ anchors.left: parent.left
|
|
|
+ anchors.right: parent.right
|
|
|
+ height: UM.Theme.getSize("default_lining").height
|
|
|
+ color: UM.Theme.getColor("lining")
|
|
|
+ }
|
|
|
+
|
|
|
+ // User-editable printer name row
|
|
|
+ Row
|
|
|
+ {
|
|
|
+ anchors.top: horizontalLine.bottom
|
|
|
+ anchors.left: parent.left
|
|
|
+ anchors.right: parent.right
|
|
|
+ anchors.topMargin: UM.Theme.getSize("default_lining").height
|
|
|
+ anchors.leftMargin: UM.Theme.getSize("default_margin").width
|
|
|
+
|
|
|
+ spacing: UM.Theme.getSize("default_margin").width
|
|
|
|
|
|
- Cura.RadioButton
|
|
|
+ Label
|
|
|
{
|
|
|
- id: radioButton
|
|
|
- anchors.left: parent.left
|
|
|
- anchors.leftMargin: UM.Theme.getSize("standard_list_lineheight").width
|
|
|
- anchors.right: parent.right
|
|
|
- anchors.rightMargin: UM.Theme.getSize("default_margin").width
|
|
|
- height: visible ? UM.Theme.getSize("standard_list_lineheight").height : 0
|
|
|
+ text: catalog.i18nc("@label", "Printer Name")
|
|
|
+ anchors.verticalCenter: parent.verticalCenter
|
|
|
+ font: UM.Theme.getFont("medium")
|
|
|
+ verticalAlignment: Text.AlignVCenter
|
|
|
+ renderType: Text.NativeRendering
|
|
|
+ }
|
|
|
|
|
|
- checked: ListView.view.currentIndex == index
|
|
|
- onCheckedChanged:
|
|
|
- {
|
|
|
- if(checked)
|
|
|
- {
|
|
|
- machineList.currentIndex = index
|
|
|
- }
|
|
|
- }
|
|
|
- text: name
|
|
|
- visible: base.currentSection == section
|
|
|
- onClicked: ListView.view.currentIndex = index
|
|
|
+ Cura.TextField
|
|
|
+ {
|
|
|
+ id: printerNameTextField
|
|
|
+ anchors.verticalCenter: parent.verticalCenter
|
|
|
+ width: (parent.width / 2) | 0
|
|
|
+ placeholderText: catalog.i18nc("@text", "Please give your printer a name")
|
|
|
+
|
|
|
+ // Make sure that the fill is not empty
|
|
|
+ validator: RegExpValidator { regExp: /.+/ }
|
|
|
}
|
|
|
}
|
|
|
}
|