mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 06:57: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
|
||||
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"]
|
||||
|
|
|
@ -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,34 +56,40 @@ UM.TooltipArea
|
|||
elide: Text.ElideRight
|
||||
//width: Math.max(0, settingsTabs.labelColumnWidth)
|
||||
}
|
||||
ComboBox
|
||||
|
||||
ListModel
|
||||
{
|
||||
id: comboBox
|
||||
model: ListModel
|
||||
id: optionsModel
|
||||
Component.onCompleted:
|
||||
{
|
||||
id: optionsModel
|
||||
Component.onCompleted:
|
||||
// Options come in as a string-representation of an OrderedDict
|
||||
var options = propertyProvider.properties.options.match(/^OrderedDict\(\[\((.*)\)\]\)$/)
|
||||
if (options)
|
||||
{
|
||||
// Options come in as a string-representation of an OrderedDict
|
||||
var options = propertyProvider.properties.options.match(/^OrderedDict\(\[\((.*)\)\]\)$/)
|
||||
if (options)
|
||||
options = options[1].split("), (")
|
||||
for (var i = 0; i < options.length; i++)
|
||||
{
|
||||
options = options[1].split("), (")
|
||||
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]});
|
||||
}
|
||||
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:
|
||||
{
|
||||
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()
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
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