Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Ultimaker/Cura.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjoeydelarago <joeydelarago@gmail.com>2022-08-23 15:29:05 +0300
committerjoeydelarago <joeydelarago@gmail.com>2022-08-23 15:29:05 +0300
commitb18080c332ed945a55d301da6354a9f6820b5ad2 (patch)
treeb8e3ea71049ce5e8fc2285be4d3321c29530d450
parentbedb76d516e4a58058010f7d9a9612d6eee75227 (diff)
Rename AbstractStacksModel.py -> MachineListModel.py since this model includes both abstract machine stacks and regular machines
Add machineCount for displaying the number of machines of a type. MachineSelectorButton is in use in other places, swapped it out for a new Component MachineListButton. CURA-9514
-rwxr-xr-xcura/CuraApplication.py4
-rw-r--r--cura/Machines/Models/MachineListModel.py (renamed from cura/Machines/Models/AbstractStacksModel.py)10
-rw-r--r--resources/qml/PrinterSelector/MachineListButton.qml88
-rw-r--r--resources/qml/PrinterSelector/MachineSelectorList.qml9
-rw-r--r--resources/qml/qmldir1
-rw-r--r--resources/themes/cura-light/theme.json3
6 files changed, 104 insertions, 11 deletions
diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py
index 2afbfbd3e8..3cd0ecbf97 100755
--- a/cura/CuraApplication.py
+++ b/cura/CuraApplication.py
@@ -115,7 +115,7 @@ from . import CuraActions
from . import PlatformPhysics
from . import PrintJobPreviewImageProvider
from .AutoSave import AutoSave
-from .Machines.Models.AbstractStacksModel import AbstractStacksModel
+from .Machines.Models.MachineListModel import MachineListModel
from .Machines.Models.ActiveIntentQualitiesModel import ActiveIntentQualitiesModel
from .Machines.Models.IntentSelectionModel import IntentSelectionModel
from .SingleInstance import SingleInstance
@@ -1195,7 +1195,7 @@ class CuraApplication(QtApplication):
qmlRegisterType(InstanceContainer, "Cura", 1, 0, "InstanceContainer")
qmlRegisterType(ExtrudersModel, "Cura", 1, 0, "ExtrudersModel")
qmlRegisterType(GlobalStacksModel, "Cura", 1, 0, "GlobalStacksModel")
- qmlRegisterType(AbstractStacksModel, "Cura", 1, 0, "AbstractStacksModel")
+ qmlRegisterType(MachineListModel, "Cura", 1, 0, "MachineListModel")
self.processEvents()
qmlRegisterType(FavoriteMaterialsModel, "Cura", 1, 0, "FavoriteMaterialsModel")
diff --git a/cura/Machines/Models/AbstractStacksModel.py b/cura/Machines/Models/MachineListModel.py
index e9b991962b..1f9b3d9eba 100644
--- a/cura/Machines/Models/AbstractStacksModel.py
+++ b/cura/Machines/Models/MachineListModel.py
@@ -14,7 +14,8 @@ from cura.Settings.AbstractMachine import AbstractMachine
from cura.Settings.CuraContainerRegistry import CuraContainerRegistry
from cura.Settings.GlobalStack import GlobalStack
-class AbstractStacksModel(ListModel):
+
+class MachineListModel(ListModel):
NameRole = Qt.ItemDataRole.UserRole + 1
IdRole = Qt.ItemDataRole.UserRole + 2
HasRemoteConnectionRole = Qt.ItemDataRole.UserRole + 3
@@ -24,6 +25,7 @@ class AbstractStacksModel(ListModel):
RemovalWarningRole = Qt.ItemDataRole.UserRole + 7
IsOnlineRole = Qt.ItemDataRole.UserRole + 8
MachineTypeRole = Qt.ItemDataRole.UserRole + 9
+ MachineCountRole = Qt.ItemDataRole.UserRole + 10
def __init__(self, parent=None) -> None:
super().__init__(parent)
@@ -37,6 +39,7 @@ class AbstractStacksModel(ListModel):
self.addRoleName(self.DiscoverySourceRole, "discoverySource")
self.addRoleName(self.IsOnlineRole, "isOnline")
self.addRoleName(self.MachineTypeRole, "machineType")
+ self.addRoleName(self.MachineCountRole, "machineCount")
self._change_timer = QTimer()
self._change_timer.setInterval(200)
@@ -71,7 +74,7 @@ class AbstractStacksModel(ListModel):
# Create item for abstract printer
- items.append(self.createItem(abstract_machine))
+ items.append(self.createItem(abstract_machine, len(machine_stacks)))
# Create list of printers that are children of the abstract printer
for stack in machine_stacks:
@@ -81,7 +84,7 @@ class AbstractStacksModel(ListModel):
self.setItems(items)
- def createItem(self, container_stack: ContainerStack) -> Optional[Dict]:
+ def createItem(self, container_stack: ContainerStack, machine_count: int = 0) -> Optional[Dict]:
if parseBool(container_stack.getMetaDataEntry("hidden", False)):
return
@@ -105,4 +108,5 @@ class AbstractStacksModel(ListModel):
"removalWarning": container_stack.getMetaDataEntry("removal_warning", default_removal_warning),
"isOnline": container_stack.getMetaDataEntry("is_online", False),
"machineType": container_stack.getMetaDataEntry("type"),
+ "machineCount": machine_count,
}
diff --git a/resources/qml/PrinterSelector/MachineListButton.qml b/resources/qml/PrinterSelector/MachineListButton.qml
new file mode 100644
index 0000000000..b6b7f4c1dd
--- /dev/null
+++ b/resources/qml/PrinterSelector/MachineListButton.qml
@@ -0,0 +1,88 @@
+// Copyright (c) 2018 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.5 as UM
+import Cura 1.0 as Cura
+
+
+Button
+{
+ id: machineListButton
+
+ width: parent.width
+ height: UM.Theme.getSize("large_button").height
+ leftPadding: UM.Theme.getSize("default_margin").width
+ rightPadding: UM.Theme.getSize("default_margin").width
+ checkable: true
+ hoverEnabled: true
+
+ contentItem: Item
+ {
+ width: machineListButton.width - machineListButton.leftPadding - machineListButton.rightPadding
+ height: UM.Theme.getSize("action_button").height
+
+ UM.ColorImage
+ {
+ id: printerIcon
+ height: UM.Theme.getSize("medium_button").height
+ width: UM.Theme.getSize("medium_button").width
+ color: UM.Theme.getColor("machine_selector_printer_icon")
+ visible: model.machineType == "abstract_machine"
+ source: model.machineType == "abstract_machine" ? UM.Theme.getIcon("PrinterTriple", "medium") : UM.Theme.getIcon("Printer", "medium")
+
+ anchors
+ {
+ left: parent.left
+ verticalCenter: parent.verticalCenter
+ }
+ }
+
+ UM.Label
+ {
+ id: buttonText
+ anchors
+ {
+ left: printerIcon.right
+ right: printerCount.left
+ verticalCenter: parent.verticalCenter
+ leftMargin: UM.Theme.getSize("default_margin").width
+ }
+ text: machineListButton.text
+ font: model.machineType == "abstract_machine" ? UM.Theme.getFont("medium_bold") : UM.Theme.getFont("medium")
+ visible: text != ""
+ elide: Text.ElideRight
+ }
+
+ Rectangle
+ {
+ id: printerCount
+ color: UM.Theme.getColor("background_2")
+ radius: height
+ width: height
+ anchors
+ {
+ right: parent.right
+ top: buttonText.top
+ bottom: buttonText.bottom
+ verticalCenter: parent.verticalCenter
+ }
+ visible: model.machineType == "abstract_machine"
+
+ UM.Label
+ {
+ text: model.machineCount
+ anchors.centerIn: parent
+ font: UM.Theme.getFont("default_bold")
+ }
+ }
+ }
+
+ background: Rectangle
+ {
+ id: backgroundRect
+ color: machineListButton.hovered ? UM.Theme.getColor("action_button_hovered") : "transparent"
+ }
+}
diff --git a/resources/qml/PrinterSelector/MachineSelectorList.qml b/resources/qml/PrinterSelector/MachineSelectorList.qml
index 822bdad3c5..de14846fb7 100644
--- a/resources/qml/PrinterSelector/MachineSelectorList.qml
+++ b/resources/qml/PrinterSelector/MachineSelectorList.qml
@@ -10,8 +10,8 @@ import Cura 1.0 as Cura
ListView
{
id: listView
- model: Cura.AbstractStacksModel {}
- section.property: "hasRemoteConnection"
+ model: Cura.MachineListModel {}
+ section.property: "section"
property real contentHeight: childrenRect.height
ScrollBar.vertical: UM.ScrollBar
@@ -29,13 +29,10 @@ ListView
color: UM.Theme.getColor("text_medium")
}
- delegate: MachineSelectorButton
+ delegate: MachineListButton
{
text: model.name ? model.name : ""
width: listView.width - scrollBar.width
- outputDevice: Cura.MachineManager.printerOutputDevices.length >= 1 ? Cura.MachineManager.printerOutputDevices[0] : null
-
- checked: Cura.MachineManager.activeMachine ? Cura.MachineManager.activeMachine.id == model.id : false
onClicked:
{
diff --git a/resources/qml/qmldir b/resources/qml/qmldir
index a47d85545b..6ec3ca91c8 100644
--- a/resources/qml/qmldir
+++ b/resources/qml/qmldir
@@ -2,6 +2,7 @@ module Cura
MachineSelector 1.0 MachineSelector.qml
MachineSelectorButton 1.0 MachineSelectorButton.qml
+MachineListButton 1.0 MachineListButton.qml
CustomConfigurationSelector 1.0 CustomConfigurationSelector.qml
PrintSetupSelector 1.0 PrintSetupSelector.qml
ProfileOverview 1.6 ProfileOverview.qml
diff --git a/resources/themes/cura-light/theme.json b/resources/themes/cura-light/theme.json
index e7622bc685..84dfdd5fc2 100644
--- a/resources/themes/cura-light/theme.json
+++ b/resources/themes/cura-light/theme.json
@@ -564,6 +564,9 @@
"medium_button": [2.5, 2.5],
"medium_button_icon": [2, 2],
+ "large_button": [3.5, 3.5],
+ "large_button_icon": [2.8, 2.8],
+
"context_menu": [20, 2],
"icon_indicator": [1, 1],