From cc58f4d1594b61ca963aec833dcf5f4696efba43 Mon Sep 17 00:00:00 2001 From: Arjen Hiemstra Date: Wed, 1 Jul 2015 02:49:44 +0200 Subject: [PATCH] More fixes for the Firmware update window Now it works on MacOSX Contributes to Ultimaker/Uranium#8 --- plugins/USBPrinting/ControlWindow.qml | 94 +++++++++++--------- plugins/USBPrinting/FirmwareUpdateWindow.qml | 33 +++---- plugins/USBPrinting/USBPrinterManager.py | 29 +++--- 3 files changed, 85 insertions(+), 71 deletions(-) diff --git a/plugins/USBPrinting/ControlWindow.qml b/plugins/USBPrinting/ControlWindow.qml index e2ff1b5d23..91ef37c555 100644 --- a/plugins/USBPrinting/ControlWindow.qml +++ b/plugins/USBPrinting/ControlWindow.qml @@ -5,59 +5,65 @@ import QtQuick 2.1 import QtQuick.Controls 1.1 import QtQuick.Layouts 1.1 -Rectangle -{ +import UM 1.0 as UM + +UM.Dialog { width: 300; height: 100 - ColumnLayout + + Rectangle { - RowLayout + anchors.fill: parent; + ColumnLayout { - Text + RowLayout { - //: USB Printing dialog label, %1 is head temperature - text: qsTr("Extruder Temperature %1").arg(manager.extruderTemperature) + Text + { + //: USB Printing dialog label, %1 is head temperature + text: qsTr("Extruder Temperature %1").arg(manager.extruderTemperature) + } + Text + { + //: USB Printing dialog label, %1 is bed temperature + text: qsTr("Bed Temperature %1").arg(manager.bedTemperature) + } + Text + { + text: "" + manager.error + } + } - Text + RowLayout { - //: USB Printing dialog label, %1 is bed temperature - text: qsTr("Bed Temperature %1").arg(manager.bedTemperature) + Button + { + //: USB Printing dialog start print button + text: qsTr("Print"); + onClicked: { manager.startPrint() } + enabled: manager.progress == 0 ? true : false + } + Button + { + //: USB Printing dialog cancel print button + text: qsTr("Cancel"); + onClicked: { manager.cancelPrint() } + enabled: manager.progress == 0 ? false: true + } } - Text + ProgressBar { - text: "" + manager.error + id: prog; + value: manager.progress + minimumValue: 0; + maximumValue: 100; + Layout.maximumWidth:parent.width + Layout.preferredWidth:230 + Layout.preferredHeight:25 + Layout.minimumWidth:230 + Layout.minimumHeight:25 + width: 230 + height: 25 } - - } - RowLayout - { - Button - { - //: USB Printing dialog start print button - text: qsTr("Print"); - onClicked: { manager.startPrint() } - enabled: manager.progress == 0 ? true : false - } - Button - { - //: USB Printing dialog cancel print button - text: qsTr("Cancel"); - onClicked: { manager.cancelPrint() } - enabled: manager.progress == 0 ? false: true - } - } - ProgressBar - { - id: prog; - value: manager.progress - minimumValue: 0; - maximumValue: 100; - Layout.maximumWidth:parent.width - Layout.preferredWidth:230 - Layout.preferredHeight:25 - Layout.minimumWidth:230 - Layout.minimumHeight:25 - width: 230 - height: 25 } } } diff --git a/plugins/USBPrinting/FirmwareUpdateWindow.qml b/plugins/USBPrinting/FirmwareUpdateWindow.qml index d2754b1d56..a83e25c8b1 100644 --- a/plugins/USBPrinting/FirmwareUpdateWindow.qml +++ b/plugins/USBPrinting/FirmwareUpdateWindow.qml @@ -1,26 +1,27 @@ // Copyright (c) 2015 Ultimaker B.V. // Cura is released under the terms of the AGPLv3 or higher. -import QtQuick 2.1 -import QtQuick.Controls 1.1 -import QtQuick.Window 2.1 +import QtQuick 2.2 +import QtQuick.Window 2.2 +import QtQuick.Controls 1.2 -Rectangle +import UM 1.0 as UM + +UM.Dialog { id: base; width: 500 * Screen.devicePixelRatio; height: 100 * Screen.devicePixelRatio; - color: palette.window; - - signal close(); + visible: true; + modality: Qt.ApplicationModal; Column { anchors.fill: parent; - anchors.margins: 8 * Screen.devicePixelRatio; - Label + + Text { anchors { left: parent.left; @@ -47,6 +48,7 @@ Rectangle wrapMode: Text.Wrap; } + ProgressBar { id: prog; @@ -59,14 +61,15 @@ Rectangle } } - Button { - anchors.right: parent.right; - text: qsTr("Close"); - onClicked: base.close(); + + SystemPalette { + id: palette; } } - SystemPalette { - id: palette; + rightButtons: Button { + text: qsTr("Close"); + + enabled: true; } } diff --git a/plugins/USBPrinting/USBPrinterManager.py b/plugins/USBPrinting/USBPrinterManager.py index c22d3d5a10..f133ef8f40 100644 --- a/plugins/USBPrinting/USBPrinterManager.py +++ b/plugins/USBPrinting/USBPrinterManager.py @@ -20,6 +20,7 @@ import sys from UM.Extension import Extension from PyQt5.QtQuick import QQuickView +from PyQt5.QtQml import QQmlComponent, QQmlContext from PyQt5.QtCore import QUrl, QObject, pyqtSlot, pyqtProperty, pyqtSignal, Qt from UM.i18n import i18nCatalog @@ -55,23 +56,27 @@ class USBPrinterManager(QObject, SignalEmitter, Extension): # This will create the view if its not already created. def spawnFirmwareInterface(self, serial_port): if self._firmware_view is None: - self._firmware_view = QQuickView() - self._firmware_view.setFlags(Qt.Dialog) - self._firmware_view.setResizeMode(QQuickView.SizeRootObjectToView); - self._firmware_view.engine().rootContext().setContextProperty("manager",self) - self._firmware_view.setSource(QUrl.fromLocalFile(os.path.join(PluginRegistry.getInstance().getPluginPath("USBPrinting"), "FirmwareUpdateWindow.qml"))) - self._firmware_view.rootObject().close.connect(self._firmware_view.close) + path = QUrl.fromLocalFile(os.path.join(PluginRegistry.getInstance().getPluginPath("USBPrinting"), "FirmwareUpdateWindow.qml")) + component = QQmlComponent(Application.getInstance()._engine, path) + + context = QQmlContext(Application.getInstance()._engine.rootContext()) + context.setContextProperty("manager", self) + self._firmware_view = component.create(context) + self._firmware_view.show() - + ## Show control interface. # This will create the view if its not already created. def spawnControlInterface(self,serial_port): if self._control_view is None: - self._control_view = QQuickView() - self._control_view.setFlags(Qt.Dialog) - self._control_view.setResizeMode(QQuickView.SizeRootObjectToView); - self._control_view.engine().rootContext().setContextProperty("manager",self) - self._control_view.setSource(QUrl.fromLocalFile(os.path.join(PluginRegistry.getInstance().getPluginPath("USBPrinting"), "ControlWindow.qml"))) + path = QUrl.fromLocalFile(os.path.join(PluginRegistry.getInstance().getPluginPath("USBPrinting"), "ControlWindow.qml")) + + component = QQmlComponent(Application.getInstance()._engine, path) + context = QQmlContext(Application.getInstance()._engine.rootContext()) + context.setContextProperty("manager", self) + + self._control_view = component.create(context) + self._control_view.show() @pyqtProperty(float,notify = processingProgress)