WIP: Create new machine settings page

This commit is contained in:
Lipu Fei 2019-03-12 13:07:21 +01:00
parent 6c2e80d2a1
commit 3e4624774a
4 changed files with 166 additions and 24 deletions

View file

@ -3,7 +3,7 @@
import os
from typing import TYPE_CHECKING, Optional
from PyQt5.QtCore import QUrl, Qt, pyqtSlot
from PyQt5.QtCore import QUrl, Qt
from UM.Qt.ListModel import ListModel
from UM.Resources import Resources
@ -29,6 +29,14 @@ class WelcomePagesModel(ListModel):
def initialize(self) -> None:
from cura.CuraApplication import CuraApplication
self._pages.append({"id": "test",
"page_url": QUrl.fromLocalFile(Resources.getPath(CuraApplication.ResourceTypes.QmlFiles,
os.path.join("WelcomePages",
"TestContent.qml"))),
})
# Add default welcome pages
self._pages.append({"id": "welcome",
"page_url": QUrl.fromLocalFile(Resources.getPath(CuraApplication.ResourceTypes.QmlFiles,
@ -68,8 +76,8 @@ class WelcomePagesModel(ListModel):
self.setItems(self._pages)
def addPage(self):
pass
__all__ = ["WelcomePagesModel"]

View file

@ -20,7 +20,7 @@ UM.TooltipArea
height: childrenRect.height
width: childrenRect.width
text: tooltip
text: tooltipText
property alias containerStackId: propertyProvider.containerStackId
property alias settingKey: propertyProvider.key
@ -29,7 +29,7 @@ UM.TooltipArea
property alias labelText: fieldLabel.text
property alias labelWidth: fieldLabel.width
property string tooltip: propertyProvider.properties.description
property string tooltipText: propertyProvider.properties.description
// callback functions
property var afterOnActivateFunction: dummy_func
@ -56,10 +56,8 @@ UM.TooltipArea
elide: Text.ElideRight
//width: Math.max(0, settingsTabs.labelColumnWidth)
}
ComboBox
{
id: comboBox
model: ListModel
ListModel
{
id: optionsModel
Component.onCompleted:
@ -72,18 +70,26 @@ UM.TooltipArea
for (var i = 0; i < options.length; i++)
{
var option = options[i].substring(1, options[i].length - 1).split("', '")
optionsModel.append({text: option[1], value: option[0]});
optionsModel.append({text: option[1], value: option[0]})
}
}
}
}
ComboBox
{
id: comboBox
model: optionsModel
textRole: "text"
currentIndex:
{
var currentValue = propertyProvider.properties.value
var index = 0
for (var i = 0; i < optionsModel.count; i++)
for (var i = 0; i < model.count; i++)
{
if (optionsModel.get(i).value == currentValue)
if (model.get(i).value == currentValue)
{
index = i
break
@ -93,9 +99,9 @@ UM.TooltipArea
}
onActivated:
{
if(propertyProvider.properties.value != optionsModel.get(index).value)
if(propertyProvider.properties.value != model.get(index).value)
{
propertyProvider.setPropertyValue("value", optionsModel.get(index).value);
propertyProvider.setPropertyValue("value", model.get(index).value)
forceUpdateOnChangeFunction()
afterOnActivateFunction()
}

View file

@ -20,7 +20,8 @@ UM.TooltipArea
height: childrenRect.height
width: childrenRect.width
text: tooltip
text: tooltipText
property alias containerStackId: propertyProvider.containerStackId
property alias settingKey: propertyProvider.key
@ -30,7 +31,7 @@ UM.TooltipArea
property alias labelWidth: fieldLabel.width
property alias unitText: unitLabel.text
property string tooltip: propertyProvider.properties.description
property string tooltipText: propertyProvider.properties.description
// whether negative value is allowed. This affects the validation of the input field.
property bool allowNegativeValue: false
@ -43,6 +44,7 @@ UM.TooltipArea
// a dummy function for default property values
function dummy_func() {}
UM.SettingPropertyProvider
{
id: propertyProvider

View file

@ -0,0 +1,126 @@
// 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.1 as Cura
import "../MachineSettings"
//
// This component contains the content for the "Welcome" page of the welcome on-boarding process.
//
Row
{
id: base
UM.I18nCatalog { id: catalog; name: "cura" }
property int labelWidth: 100
// Left-side column for "Printer Settings"
Column
{
spacing: 10
Label
{
text: catalog.i18nc("@title:label", "Printer Settings")
font: UM.Theme.getFont("medium_bold")
}
NumericTextFieldWithUnit // "X (Width)"
{
id: machineXWidthField
containerStackId: Cura.MachineManager.activeMachineId
settingKey: "machine_width"
settingStoreIndex: 1 // TODO
labelText: catalog.i18nc("@label", "X (Width)")
labelWidth: base.labelWidth
unitText: catalog.i18nc("@label", "mm")
// TODO: add forceUpdateOnChangeFunction:
}
NumericTextFieldWithUnit // "Y (Depth)"
{
id: machineYDepthField
containerStackId: Cura.MachineManager.activeMachineId
settingKey: "machine_depth"
settingStoreIndex: 1 // TODO
labelText: catalog.i18nc("@label", "Y (Depth)")
labelWidth: base.labelWidth
unitText: catalog.i18nc("@label", "mm")
// TODO: add forceUpdateOnChangeFunction:
}
NumericTextFieldWithUnit // "Z (Height)"
{
id: machineZHeightField
containerStackId: Cura.MachineManager.activeMachineId
settingKey: "machine_height"
settingStoreIndex: 1 // TODO
labelText: catalog.i18nc("@label", "Z (Height)")
labelWidth: base.labelWidth
unitText: catalog.i18nc("@label", "mm")
// TODO: add forceUpdateOnChangeFunction:
}
ComboBoxWithOptions // "Build plate shape"
{
id: buildPlateShapeComboBox
containerStackId: Cura.MachineManager.activeMachineId
settingKey: "machine_shape"
settingStoreIndex: 1 // TODO
labelText: catalog.i18nc("@label", "Build plate shape")
labelWidth: base.labelWidth
// TODO: add forceUpdateOnChangeFunction:
}
SimpleCheckBox // "Origin at center"
{
id: originAtCenterCheckBox
containerStackId: Cura.MachineManager.activeMachineId
settingKey: "machine_center_is_zero"
settingStoreIndex: 1 // TODO
labelText: catalog.i18nc("@label", "Origin at center")
// TODO: add forceUpdateOnChangeFunction:
}
SimpleCheckBox // "Heated bed"
{
id: heatedBedCheckBox
containerStackId: Cura.MachineManager.activeMachineId
settingKey: "machine_heated_bed"
settingStoreIndex: 1 // TODO
labelText: catalog.i18nc("@label", "Heated bed")
// TODO: add forceUpdateOnChangeFunction:
}
ComboBoxWithOptions // "G-code flavor"
{
id: gcodeFlavorComboBox
containerStackId: Cura.MachineManager.activeMachineId
settingKey: "machine_gcode_flavor"
settingStoreIndex: 1 // TODO
labelText: catalog.i18nc("@label", "G-code flavor")
labelWidth: base.labelWidth
// TODO: add forceUpdateOnChangeFunction:
// TODO: add afterOnActivate: manager.updateHasMaterialsMetadata
}
}
// Right-side column for "Printhead Settings"
Column
{
spacing: 10
Label
{
text: catalog.i18nc("@title:label", "Printhead Settings")
font: UM.Theme.getFont("medium_bold")
}
}
}