From 53d595f698a95aeff9859c523b246af0f518a5da Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Mon, 6 May 2019 13:05:28 +0200 Subject: [PATCH 1/3] Use loader for machine actions in dialog CURA-6495 --- cura/MachineAction.py | 27 ++++++++++++------- .../Models/FirstStartMachineActionsModel.py | 2 +- .../MachineSettingsExtruderTab.qml | 2 +- .../MachineSettingsPrinterTab.qml | 2 +- resources/qml/Preferences/MachinesPage.qml | 17 +++++------- 5 files changed, 27 insertions(+), 23 deletions(-) diff --git a/cura/MachineAction.py b/cura/MachineAction.py index 773a1cad1a..0f05401c89 100644 --- a/cura/MachineAction.py +++ b/cura/MachineAction.py @@ -2,8 +2,9 @@ # Cura is released under the terms of the LGPLv3 or higher. import os +from typing import Optional -from PyQt5.QtCore import QObject, pyqtSlot, pyqtProperty, pyqtSignal +from PyQt5.QtCore import QObject, QUrl, pyqtSlot, pyqtProperty, pyqtSignal from UM.Logger import Logger from UM.PluginObject import PluginObject @@ -72,18 +73,26 @@ class MachineAction(QObject, PluginObject): return self._finished ## Protected helper to create a view object based on provided QML. - def _createViewFromQML(self) -> None: + def _createViewFromQML(self) -> Optional["QObject"]: plugin_path = PluginRegistry.getInstance().getPluginPath(self.getPluginId()) if plugin_path is None: Logger.log("e", "Cannot create QML view: cannot find plugin path for plugin [%s]", self.getPluginId()) - return + return None path = os.path.join(plugin_path, self._qml_url) from cura.CuraApplication import CuraApplication - self._view = CuraApplication.getInstance().createQmlComponent(path, {"manager": self}) + view = CuraApplication.getInstance().createQmlComponent(path, {"manager": self}) + return view - @pyqtProperty(QObject, constant = True) - def displayItem(self): - if not self._view: - self._createViewFromQML() - return self._view + @pyqtProperty(QUrl, constant = True) + def qmlPath(self) -> "QUrl": + plugin_path = PluginRegistry.getInstance().getPluginPath(self.getPluginId()) + if plugin_path is None: + Logger.log("e", "Cannot create QML view: cannot find plugin path for plugin [%s]", self.getPluginId()) + return QUrl("") + path = os.path.join(plugin_path, self._qml_url) + return QUrl.fromLocalFile(path) + + @pyqtSlot(result = QObject) + def getDisplayItem(self) -> Optional["QObject"]: + return self._createViewFromQML() diff --git a/cura/Machines/Models/FirstStartMachineActionsModel.py b/cura/Machines/Models/FirstStartMachineActionsModel.py index 240571e6dc..ce0e9bf856 100644 --- a/cura/Machines/Models/FirstStartMachineActionsModel.py +++ b/cura/Machines/Models/FirstStartMachineActionsModel.py @@ -100,7 +100,7 @@ class FirstStartMachineActionsModel(ListModel): item_list = [] for item in first_start_actions: item_list.append({"title": item.label, - "content": item.displayItem, + "content": item.getDisplayItem(), "action": item, }) item.reset() diff --git a/plugins/MachineSettingsAction/MachineSettingsExtruderTab.qml b/plugins/MachineSettingsAction/MachineSettingsExtruderTab.qml index e05d8e75fc..65f1e8a57a 100644 --- a/plugins/MachineSettingsAction/MachineSettingsExtruderTab.qml +++ b/plugins/MachineSettingsAction/MachineSettingsExtruderTab.qml @@ -26,7 +26,7 @@ Item property int columnWidth: ((parent.width - 2 * UM.Theme.getSize("default_margin").width) / 2) | 0 property int columnSpacing: 3 * screenScaleFactor - property int propertyStoreIndex: manager.storeContainerIndex // definition_changes + property int propertyStoreIndex: manager ? manager.storeContainerIndex : 1 // definition_changes property string extruderStackId: "" property int extruderPosition: 0 diff --git a/plugins/MachineSettingsAction/MachineSettingsPrinterTab.qml b/plugins/MachineSettingsAction/MachineSettingsPrinterTab.qml index 3b31a5de36..4ba0d19390 100644 --- a/plugins/MachineSettingsAction/MachineSettingsPrinterTab.qml +++ b/plugins/MachineSettingsAction/MachineSettingsPrinterTab.qml @@ -26,7 +26,7 @@ Item property int columnWidth: ((parent.width - 2 * UM.Theme.getSize("default_margin").width) / 2) | 0 property int columnSpacing: 3 * screenScaleFactor - property int propertyStoreIndex: manager.storeContainerIndex // definition_changes + property int propertyStoreIndex: manager ? manager.storeContainerIndex : 1 // definition_changes property string machineStackId: Cura.MachineManager.activeMachineId diff --git a/resources/qml/Preferences/MachinesPage.qml b/resources/qml/Preferences/MachinesPage.qml index cbbb0b80bf..932529de99 100644 --- a/resources/qml/Preferences/MachinesPage.qml +++ b/resources/qml/Preferences/MachinesPage.qml @@ -100,10 +100,11 @@ UM.ManagementPage text: machineActionRepeater.model[index].label onClicked: { - actionDialog.content = machineActionRepeater.model[index].displayItem; - machineActionRepeater.model[index].displayItem.reset(); - actionDialog.title = machineActionRepeater.model[index].label; - actionDialog.show(); + var currentItem = machineActionRepeater.model[index] + actionDialog.loader.manager = currentItem + actionDialog.loader.source = currentItem.qmlPath + actionDialog.title = currentItem.label + actionDialog.show() } } } @@ -113,13 +114,7 @@ UM.ManagementPage UM.Dialog { id: actionDialog - property var content - onContentChanged: - { - contents = content; - content.onCompleted.connect(hide) - content.dialog = actionDialog - } + rightButtons: Button { text: catalog.i18nc("@action:button", "Close") From afeb9b90ecf2100a1beb51b61defb2f0471422cb Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Mon, 6 May 2019 13:42:39 +0200 Subject: [PATCH 2/3] Increase width of toolbox header tab CURA-6503 --- resources/themes/cura-light/theme.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/themes/cura-light/theme.json b/resources/themes/cura-light/theme.json index f1e35f189f..d1c4600f27 100644 --- a/resources/themes/cura-light/theme.json +++ b/resources/themes/cura-light/theme.json @@ -591,7 +591,7 @@ "toolbox_thumbnail_large": [12.0, 10.0], "toolbox_footer": [1.0, 4.5], "toolbox_footer_button": [8.0, 2.5], - "toolbox_header_tab": [8.0, 4.0], + "toolbox_header_tab": [12.0, 4.0], "toolbox_detail_header": [1.0, 14.0], "toolbox_back_column": [6.0, 1.0], "toolbox_back_button": [6.0, 2.0], From b09c6a4f12bb4d0e4ae935bcd8d8c7c9fa5341c2 Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Mon, 6 May 2019 13:56:18 +0200 Subject: [PATCH 3/3] Elide long website URLs CURA-6504 --- plugins/Toolbox/resources/qml/ToolboxAuthorPage.qml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/Toolbox/resources/qml/ToolboxAuthorPage.qml b/plugins/Toolbox/resources/qml/ToolboxAuthorPage.qml index 42ece4043d..08ac1f83a5 100644 --- a/plugins/Toolbox/resources/qml/ToolboxAuthorPage.qml +++ b/plugins/Toolbox/resources/qml/ToolboxAuthorPage.qml @@ -109,6 +109,8 @@ Item top: description.bottom left: properties.right leftMargin: UM.Theme.getSize("default_margin").width + right: parent.right + rightMargin: UM.Theme.getSize("default_margin").width topMargin: UM.Theme.getSize("default_margin").height } spacing: Math.floor(UM.Theme.getSize("narrow_margin").height) @@ -123,6 +125,8 @@ Item } return "" } + width: parent.width + elide: Text.ElideRight font: UM.Theme.getFont("default") color: UM.Theme.getColor("text") linkColor: UM.Theme.getColor("text_link")