mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 15:07:28 -06:00
WIP: Create new machine settings page
This commit is contained in:
parent
6c2e80d2a1
commit
3e4624774a
4 changed files with 166 additions and 24 deletions
|
@ -3,7 +3,7 @@
|
||||||
import os
|
import os
|
||||||
from typing import TYPE_CHECKING, Optional
|
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.Qt.ListModel import ListModel
|
||||||
from UM.Resources import Resources
|
from UM.Resources import Resources
|
||||||
|
@ -29,6 +29,14 @@ class WelcomePagesModel(ListModel):
|
||||||
|
|
||||||
def initialize(self) -> None:
|
def initialize(self) -> None:
|
||||||
from cura.CuraApplication import CuraApplication
|
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
|
# Add default welcome pages
|
||||||
self._pages.append({"id": "welcome",
|
self._pages.append({"id": "welcome",
|
||||||
"page_url": QUrl.fromLocalFile(Resources.getPath(CuraApplication.ResourceTypes.QmlFiles,
|
"page_url": QUrl.fromLocalFile(Resources.getPath(CuraApplication.ResourceTypes.QmlFiles,
|
||||||
|
@ -68,8 +76,8 @@ class WelcomePagesModel(ListModel):
|
||||||
|
|
||||||
self.setItems(self._pages)
|
self.setItems(self._pages)
|
||||||
|
|
||||||
|
|
||||||
def addPage(self):
|
def addPage(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
__all__ = ["WelcomePagesModel"]
|
__all__ = ["WelcomePagesModel"]
|
||||||
|
|
|
@ -20,7 +20,7 @@ UM.TooltipArea
|
||||||
|
|
||||||
height: childrenRect.height
|
height: childrenRect.height
|
||||||
width: childrenRect.width
|
width: childrenRect.width
|
||||||
text: tooltip
|
text: tooltipText
|
||||||
|
|
||||||
property alias containerStackId: propertyProvider.containerStackId
|
property alias containerStackId: propertyProvider.containerStackId
|
||||||
property alias settingKey: propertyProvider.key
|
property alias settingKey: propertyProvider.key
|
||||||
|
@ -29,7 +29,7 @@ UM.TooltipArea
|
||||||
property alias labelText: fieldLabel.text
|
property alias labelText: fieldLabel.text
|
||||||
property alias labelWidth: fieldLabel.width
|
property alias labelWidth: fieldLabel.width
|
||||||
|
|
||||||
property string tooltip: propertyProvider.properties.description
|
property string tooltipText: propertyProvider.properties.description
|
||||||
|
|
||||||
// callback functions
|
// callback functions
|
||||||
property var afterOnActivateFunction: dummy_func
|
property var afterOnActivateFunction: dummy_func
|
||||||
|
@ -56,34 +56,40 @@ UM.TooltipArea
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
//width: Math.max(0, settingsTabs.labelColumnWidth)
|
//width: Math.max(0, settingsTabs.labelColumnWidth)
|
||||||
}
|
}
|
||||||
ComboBox
|
|
||||||
|
ListModel
|
||||||
{
|
{
|
||||||
id: comboBox
|
id: optionsModel
|
||||||
model: ListModel
|
Component.onCompleted:
|
||||||
{
|
{
|
||||||
id: optionsModel
|
// Options come in as a string-representation of an OrderedDict
|
||||||
Component.onCompleted:
|
var options = propertyProvider.properties.options.match(/^OrderedDict\(\[\((.*)\)\]\)$/)
|
||||||
|
if (options)
|
||||||
{
|
{
|
||||||
// Options come in as a string-representation of an OrderedDict
|
options = options[1].split("), (")
|
||||||
var options = propertyProvider.properties.options.match(/^OrderedDict\(\[\((.*)\)\]\)$/)
|
for (var i = 0; i < options.length; i++)
|
||||||
if (options)
|
|
||||||
{
|
{
|
||||||
options = options[1].split("), (")
|
var option = options[i].substring(1, options[i].length - 1).split("', '")
|
||||||
for (var i = 0; i < options.length; i++)
|
optionsModel.append({text: option[1], value: option[0]})
|
||||||
{
|
|
||||||
var option = options[i].substring(1, options[i].length - 1).split("', '")
|
|
||||||
optionsModel.append({text: option[1], value: option[0]});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ComboBox
|
||||||
|
{
|
||||||
|
id: comboBox
|
||||||
|
model: optionsModel
|
||||||
|
|
||||||
|
textRole: "text"
|
||||||
|
|
||||||
currentIndex:
|
currentIndex:
|
||||||
{
|
{
|
||||||
var currentValue = propertyProvider.properties.value
|
var currentValue = propertyProvider.properties.value
|
||||||
var index = 0
|
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
|
index = i
|
||||||
break
|
break
|
||||||
|
@ -93,9 +99,9 @@ UM.TooltipArea
|
||||||
}
|
}
|
||||||
onActivated:
|
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()
|
forceUpdateOnChangeFunction()
|
||||||
afterOnActivateFunction()
|
afterOnActivateFunction()
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,8 @@ UM.TooltipArea
|
||||||
|
|
||||||
height: childrenRect.height
|
height: childrenRect.height
|
||||||
width: childrenRect.width
|
width: childrenRect.width
|
||||||
text: tooltip
|
|
||||||
|
text: tooltipText
|
||||||
|
|
||||||
property alias containerStackId: propertyProvider.containerStackId
|
property alias containerStackId: propertyProvider.containerStackId
|
||||||
property alias settingKey: propertyProvider.key
|
property alias settingKey: propertyProvider.key
|
||||||
|
@ -30,7 +31,7 @@ UM.TooltipArea
|
||||||
property alias labelWidth: fieldLabel.width
|
property alias labelWidth: fieldLabel.width
|
||||||
property alias unitText: unitLabel.text
|
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.
|
// whether negative value is allowed. This affects the validation of the input field.
|
||||||
property bool allowNegativeValue: false
|
property bool allowNegativeValue: false
|
||||||
|
@ -43,6 +44,7 @@ UM.TooltipArea
|
||||||
// a dummy function for default property values
|
// a dummy function for default property values
|
||||||
function dummy_func() {}
|
function dummy_func() {}
|
||||||
|
|
||||||
|
|
||||||
UM.SettingPropertyProvider
|
UM.SettingPropertyProvider
|
||||||
{
|
{
|
||||||
id: propertyProvider
|
id: propertyProvider
|
||||||
|
|
126
resources/qml/WelcomePages/TestContent.qml
Normal file
126
resources/qml/WelcomePages/TestContent.qml
Normal 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")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue