Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cura 11561 mockup pap #18246

Merged
merged 21 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions plugins/3MFReader/SpecificSettingsModel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Copyright (c) 2024 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher.

from PyQt6.QtCore import Qt

from UM.Settings.SettingDefinition import SettingDefinition
from UM.Qt.ListModel import ListModel


class SpecificSettingsModel(ListModel):
CategoryRole = Qt.ItemDataRole.UserRole + 1
LabelRole = Qt.ItemDataRole.UserRole + 2
ValueRole = Qt.ItemDataRole.UserRole + 3

def __init__(self, parent = None):
super().__init__(parent = parent)
self.addRoleName(self.CategoryRole, "category")
self.addRoleName(self.LabelRole, "label")
self.addRoleName(self.ValueRole, "value")

self._i18n_catalog = None

def addSettingsFromStack(self, stack, category, settings):
for setting, value in settings.items():
unit = stack.getProperty(setting, "unit")

setting_type = stack.getProperty(setting, "type")
if setting_type is not None:
# This is not very good looking, but will do for now
value = SettingDefinition.settingValueToString(setting_type, value) + " " + unit
else:
value = str(value)

self.appendItem({
"category": category,
"label": stack.getProperty(setting, "label"),
"value": value
})
9 changes: 8 additions & 1 deletion plugins/3MFReader/ThreeMFReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,15 @@ def __init__(self) -> None:
suffixes=["3mf"]
)
)
MimeTypeDatabase.addMimeType(
MimeType(
name="application/x-ucp",
comment="UCP",
suffixes=["ucp"]
)
)

self._supported_extensions = [".3mf"]
self._supported_extensions = [".3mf", ".ucp"]
self._root = None
self._base_name = ""
self._unit = None
Expand Down
248 changes: 164 additions & 84 deletions plugins/3MFReader/ThreeMFWorkspaceReader.py

Large diffs are not rendered by default.

54 changes: 54 additions & 0 deletions plugins/3MFReader/WorkspaceDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

from cura.CuraApplication import CuraApplication

from .SpecificSettingsModel import SpecificSettingsModel

i18n_catalog = i18nCatalog("cura")


Expand Down Expand Up @@ -71,6 +73,11 @@ def __init__(self, parent = None) -> None:
self._install_missing_package_dialog: Optional[QObject] = None
self._is_abstract_machine = False
self._is_networked_machine = False
self._is_compatible_machine = False
self._has_visible_select_same_profile = False
self._select_same_profile_checked = True
self._allow_create_machine = True
self._exported_settings_model = SpecificSettingsModel()

machineConflictChanged = pyqtSignal()
qualityChangesConflictChanged = pyqtSignal()
Expand All @@ -94,6 +101,9 @@ def __init__(self, parent = None) -> None:
extrudersChanged = pyqtSignal()
isPrinterGroupChanged = pyqtSignal()
missingPackagesChanged = pyqtSignal()
isCompatibleMachineChanged = pyqtSignal()
hasVisibleSelectSameProfileChanged = pyqtSignal()
selectSameProfileCheckedChanged = pyqtSignal()

@pyqtProperty(bool, notify = isPrinterGroupChanged)
def isPrinterGroup(self) -> bool:
Expand Down Expand Up @@ -292,6 +302,50 @@ def getMachineToOverride(self) -> str:
@pyqtSlot(str)
def setMachineToOverride(self, machine_name: str) -> None:
self._override_machine = machine_name
self.updateCompatibleMachine()

def updateCompatibleMachine(self):
registry = ContainerRegistry.getInstance()
containers_expected = registry.findDefinitionContainers(name=self._machine_type)
containers_selected = registry.findContainerStacks(id=self._override_machine)
if len(containers_expected) == 1 and len(containers_selected) == 1:
new_compatible_machine = (containers_expected[0] == containers_selected[0].definition)
if new_compatible_machine != self._is_compatible_machine:
self._is_compatible_machine = new_compatible_machine
self.isCompatibleMachineChanged.emit()

@pyqtProperty(bool, notify = isCompatibleMachineChanged)
def isCompatibleMachine(self) -> bool:
return self._is_compatible_machine

def setHasVisibleSelectSameProfileChanged(self, has_visible_select_same_profile):
if has_visible_select_same_profile != self._has_visible_select_same_profile:
self._has_visible_select_same_profile = has_visible_select_same_profile
self.hasVisibleSelectSameProfileChanged.emit()

@pyqtProperty(bool, notify = hasVisibleSelectSameProfileChanged)
def hasVisibleSelectSameProfile(self):
return self._has_visible_select_same_profile

def setSelectSameProfileChecked(self, select_same_profile_checked):
if select_same_profile_checked != self._select_same_profile_checked:
self._select_same_profile_checked = select_same_profile_checked
self.selectSameProfileCheckedChanged.emit()

@pyqtProperty(bool, notify = selectSameProfileCheckedChanged, fset = setSelectSameProfileChecked)
def selectSameProfileChecked(self):
return self._select_same_profile_checked

def setAllowCreatemachine(self, allow_create_machine):
self._allow_create_machine = allow_create_machine

@pyqtProperty(bool, constant = True)
def allowCreateMachine(self):
return self._allow_create_machine

@pyqtProperty(QObject, constant = True)
def exportedSettingModel(self):
return self._exported_settings_model

@pyqtSlot()
def closeBackend(self) -> None:
Expand Down
61 changes: 56 additions & 5 deletions plugins/3MFReader/WorkspaceDialog.qml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import QtQuick.Controls 2.3
import QtQuick.Layouts 1.3
import QtQuick.Window 2.2

import UM 1.5 as UM
import UM 1.6 as UM
import Cura 1.1 as Cura

UM.Dialog
Expand Down Expand Up @@ -120,13 +120,17 @@ UM.Dialog

minDropDownWidth: machineSelector.width

buttons: [
Component
{
id: componentNewPrinter

Cura.SecondaryButton
{
id: createNewPrinter
text: catalog.i18nc("@button", "Create new")
fixedWidthMode: true
width: parent.width - leftPadding * 1.5
visible: manager.allowCreateMachine
onClicked:
{
toggleContent()
Expand All @@ -136,7 +140,9 @@ UM.Dialog
manager.setIsNetworkedMachine(false)
}
}
]
}

buttons: manager.allowCreateMachine ? [componentNewPrinter.createObject()] : []

onSelectPrinter: function(machine)
{
Expand Down Expand Up @@ -165,26 +171,71 @@ UM.Dialog
{
leftLabelText: catalog.i18nc("@action:label", "Name")
rightLabelText: manager.qualityName
visible: manager.isCompatibleMachine
}

WorkspaceRow
{
leftLabelText: catalog.i18nc("@action:label", "Intent")
rightLabelText: manager.intentName
visible: manager.isCompatibleMachine
}

WorkspaceRow
{
leftLabelText: catalog.i18nc("@action:label", "Not in profile")
rightLabelText: catalog.i18ncp("@action:label", "%1 override", "%1 overrides", manager.numUserSettings).arg(manager.numUserSettings)
visible: manager.numUserSettings != 0
visible: manager.numUserSettings != 0 && manager.selectSameProfileChecked && manager.isCompatibleMachine
}

WorkspaceRow
{
leftLabelText: catalog.i18nc("@action:label", "Derivative from")
rightLabelText: catalog.i18ncp("@action:label", "%1, %2 override", "%1, %2 overrides", manager.numSettingsOverridenByQualityChanges).arg(manager.qualityType).arg(manager.numSettingsOverridenByQualityChanges)
visible: manager.numSettingsOverridenByQualityChanges != 0
visible: manager.numSettingsOverridenByQualityChanges != 0 && manager.selectSameProfileChecked && manager.isCompatibleMachine
}

WorkspaceRow
{
leftLabelText: catalog.i18nc("@action:label", "Specific settings")
rightLabelText: catalog.i18ncp("@action:label", "%1 override", "%1 overrides", manager.exportedSettingModel.rowCount()).arg(manager.exportedSettingModel.rowCount())
buttonText: tableViewSpecificSettings.shouldBeVisible ? catalog.i18nc("@action:button", "Hide settings") : catalog.i18nc("@action:button", "Show settings")
visible: !manager.selectSameProfileChecked || !manager.isCompatibleMachine
onButtonClicked: tableViewSpecificSettings.shouldBeVisible = !tableViewSpecificSettings.shouldBeVisible
}

Cura.TableView
{
id: tableViewSpecificSettings
width: parent.width - parent.leftPadding - UM.Theme.getSize("default_margin").width
height: UM.Theme.getSize("card").height
visible: shouldBeVisible && (!manager.selectSameProfileChecked || !manager.isCompatibleMachine)
property bool shouldBeVisible: false

columnHeaders:
[
catalog.i18nc("@title:column", "Applies on"),
catalog.i18nc("@title:column", "Setting"),
catalog.i18nc("@title:column", "Value")
]

model: UM.TableModel
{
id: tableModel
headers: ["category", "label", "value"]
rows: manager.exportedSettingModel.items
}
}

UM.CheckBox
{
text: catalog.i18nc("@action:checkbox", "Select the same profile")
onEnabledChanged: manager.selectSameProfileChecked = enabled
tooltip: enabled ? "" : catalog.i18nc("@tooltip", "You can use the same profile only if you have the same printer as the project was published with")
visible: manager.hasVisibleSelectSameProfile && manager.isCompatibleMachine

checked: manager.selectSameProfileChecked
onCheckedChanged: manager.selectSameProfileChecked = checked
}
}

Expand Down
20 changes: 16 additions & 4 deletions plugins/3MFReader/WorkspaceRow.qml
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,38 @@ import QtQuick.Window 2.2
import UM 1.5 as UM
import Cura 1.1 as Cura

Row
RowLayout
{
id: root

property alias leftLabelText: leftLabel.text
property alias rightLabelText: rightLabel.text
property alias buttonText: button.text
signal buttonClicked

width: parent.width
height: visible ? childrenRect.height : 0

UM.Label
{
id: leftLabel
text: catalog.i18nc("@action:label", "Type")
width: Math.round(parent.width / 4)
Layout.preferredWidth: Math.round(parent.width / 4)
wrapMode: Text.WordWrap
}

UM.Label
{
id: rightLabel
text: manager.machineType
width: Math.round(parent.width / 3)
wrapMode: Text.WordWrap
}

Cura.TertiaryButton
{
id: button
visible: !text.isEmpty
Layout.maximumHeight: leftLabel.implicitHeight
Layout.fillWidth: true
onClicked: root.buttonClicked()
}
}
31 changes: 5 additions & 26 deletions plugins/3MFReader/WorkspaceSection.qml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import QtQuick 2.10
import QtQuick.Controls 2.3


import UM 1.5 as UM
import UM 1.8 as UM


Item
Expand Down Expand Up @@ -80,34 +80,13 @@ Item
sourceComponent: combobox
}

MouseArea
UM.HelpIcon
{
id: helpIconMouseArea
anchors.right: parent.right
anchors.verticalCenter: comboboxLabel.verticalCenter
width: childrenRect.width
height: childrenRect.height
hoverEnabled: true

UM.ColorImage
{
width: UM.Theme.getSize("section_icon").width
height: width

visible: comboboxTooltipText != ""
source: UM.Theme.getIcon("Help")
color: UM.Theme.getColor("text")

UM.ToolTip
{
text: comboboxTooltipText
visible: helpIconMouseArea.containsMouse
targetPoint: Qt.point(parent.x + Math.round(parent.width / 2), parent.y)
x: 0
y: parent.y + parent.height + UM.Theme.getSize("default_margin").height
width: UM.Theme.getSize("tooltip").width
}
}

text: comboboxTooltipText
visible: comboboxTooltipText != ""
}
}

Expand Down
8 changes: 8 additions & 0 deletions plugins/3MFReader/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,20 @@ def getMetaData() -> Dict:
{
"extension": "3mf",
"description": catalog.i18nc("@item:inlistbox", "3MF File")
},
{
"extension": "ucp",
"description": catalog.i18nc("@item:inlistbox", "UCP File")
}
]
metaData["workspace_reader"] = [
{
"extension": workspace_extension,
"description": catalog.i18nc("@item:inlistbox", "3MF File")
},
{
"extension": "ucp",
"description": catalog.i18nc("@item:inlistbox", "UCP File")
}
]

Expand Down
2 changes: 1 addition & 1 deletion plugins/3MFReader/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "3MF Reader",
"author": "Ultimaker B.V.",
"version": "1.0.1",
"description": "Provides support for reading 3MF files.",
"description": "Provides support for reading 3MF and UCP files.",
"api": 8,
"i18n-catalog": "cura"
}
Loading
Loading