Fix merge conflicts

This commit is contained in:
Lipu Fei 2019-04-09 11:33:07 +02:00
commit f94344263b
14 changed files with 345 additions and 503 deletions

View file

@ -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
id: localPrinterSelectionItem
anchors.left: parent.left
anchors.right: parent.right
anchors.top: parent.top
height: childrenRect.height
model: UM.DefinitionContainersModel
// 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
Button
{
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.bold: true
renderType: Text.NativeRendering
}
}
onClicked:
{
base.currentSection = section
base.updateCurrentItemUponSectionChange()
}
}
}
Component
{
id: machineButton
Cura.RadioButton
{
id: radioButton
id: scrollView
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
anchors.top: parent.top
checked: ListView.view.currentIndex == index
onCheckedChanged:
height: maxItemCountAtOnce * UM.Theme.getSize("action_button").height
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
ScrollBar.vertical.policy: ScrollBar.AsNeeded
clip: true
ListView
{
if(checked)
id: machineList
model: UM.DefinitionContainersModel
{
machineList.currentIndex = index
id: machineDefinitionsModel
filter: { "visible": true }
sectionProperty: "category"
preferredSectionValue: preferredCategory
}
section.property: "section"
section.delegate: sectionHeader
delegate: machineButton
}
Component
{
id: sectionHeader
Button
{
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()
}
}
}
text: name
visible: base.currentSection == section
onClicked: ListView.view.currentIndex = index
Component
{
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
}
}
}
}
// Horizontal line
Rectangle
{
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
Label
{
text: catalog.i18nc("@label", "Printer Name")
anchors.verticalCenter: parent.verticalCenter
font: UM.Theme.getFont("medium")
verticalAlignment: Text.AlignVCenter
renderType: Text.NativeRendering
}
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: /.+/ }
}
}
}

View file

@ -118,11 +118,14 @@ Item
}
else
{
return addLocalPrinterDropDown.contentItem.currentItem != null
// Printer name cannot be empty
const localPrinterItem = addLocalPrinterDropDown.contentItem.currentItem
const isPrinterNameValid = addLocalPrinterDropDown.contentItem.isPrinterNameValid
return localPrinterItem != null && isPrinterNameValid
}
}
text: catalog.i18nc("@button", "Next")
text: base.currentItem.next_page_button_text
onClicked:
{
// Create a network printer or a local printer according to the selection
@ -139,7 +142,8 @@ Item
{
// Create a local printer
const localPrinterItem = addLocalPrinterDropDown.contentItem.currentItem
Cura.MachineManager.addMachine(localPrinterItem.id)
const printerName = addLocalPrinterDropDown.contentItem.printerName
Cura.MachineManager.addMachine(localPrinterItem.id, printerName)
base.showNextPage()
}

View file

@ -60,7 +60,7 @@ Item
anchors.left: header.left
anchors.right: header.right
// Add 2x lining, because it needs a bit of space on the top and the bottom.
height: contentLoader.height + 2 * UM.Theme.getSize("thick_lining").height
height: contentLoader.item.height + 2 * UM.Theme.getSize("thick_lining").height
border.width: UM.Theme.getSize("default_lining").width
border.color: UM.Theme.getColor("lining")

View file

@ -11,7 +11,7 @@ import Cura 1.1 as Cura
//
// This is a no-frame dialog that shows the welcome process.
// This is an Item that tries to mimic a dialog for showing the welcome process.
//
Item
{
@ -38,7 +38,7 @@ Item
WizardPanel
{
id: stepPanel
id: wizardPanel
anchors.fill: parent
model: dialog.model
}
@ -48,8 +48,8 @@ Item
{
id: shadow
radius: UM.Theme.getSize("first_run_shadow_radius").width
anchors.fill: stepPanel
source: stepPanel
anchors.fill: wizardPanel
source: wizardPanel
horizontalOffset: shadowOffset
verticalOffset: shadowOffset
color: UM.Theme.getColor("first_run_shadow")

View 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 QtQuick.Window 2.2
import UM 1.3 as UM
import Cura 1.1 as Cura
//
// This is a dialog for showing a set of processes that's defined in a WelcomePagesModel or some other Qt ListModel with
// a compatible interface.
//
Window
{
UM.I18nCatalog { id: catalog; name: "cura" }
id: dialog
flags: Qt.Dialog
minimumWidth: 580 * screenScaleFactor
minimumHeight: 600 * screenScaleFactor
color: UM.Theme.getColor("main_background")
property var model: null // Needs to be set by whoever is using this dialog.
property alias progressBarVisible: wizardPanel.progressBarVisible
onVisibilityChanged:
{
if (visible)
{
model.resetState()
}
}
WizardPanel
{
id: wizardPanel
anchors.fill: parent
model: dialog.model
}
// Close this dialog when there's no more page to show
Connections
{
target: model
onAllFinished: dialog.hide()
}
}

View file

@ -25,6 +25,7 @@ Item
property var progressValue: model == null ? 0 : model.currentProgress
property string pageUrl: currentItem == null ? "" : currentItem.page_url
property alias progressBarVisible: progressBar.visible
property alias backgroundColor: panelBackground.color
signal showNextPage()
@ -44,6 +45,7 @@ Item
anchors.fill: parent
radius: UM.Theme.getSize("default_radius").width
color: UM.Theme.getColor("main_background")
UM.ProgressBar
{
id: progressBar