More fixes for the Firmware update window

Now it works on MacOSX

Contributes to Ultimaker/Uranium#8
This commit is contained in:
Arjen Hiemstra 2015-07-01 02:49:44 +02:00
parent 9aa386c2b0
commit cc58f4d159
3 changed files with 85 additions and 71 deletions

View file

@ -5,9 +5,14 @@ import QtQuick 2.1
import QtQuick.Controls 1.1 import QtQuick.Controls 1.1
import QtQuick.Layouts 1.1 import QtQuick.Layouts 1.1
Rectangle import UM 1.0 as UM
{
UM.Dialog {
width: 300; height: 100 width: 300; height: 100
Rectangle
{
anchors.fill: parent;
ColumnLayout ColumnLayout
{ {
RowLayout RowLayout
@ -60,4 +65,5 @@ Rectangle
height: 25 height: 25
} }
} }
}
} }

View file

@ -1,26 +1,27 @@
// Copyright (c) 2015 Ultimaker B.V. // Copyright (c) 2015 Ultimaker B.V.
// Cura is released under the terms of the AGPLv3 or higher. // Cura is released under the terms of the AGPLv3 or higher.
import QtQuick 2.1 import QtQuick 2.2
import QtQuick.Controls 1.1 import QtQuick.Window 2.2
import QtQuick.Window 2.1 import QtQuick.Controls 1.2
Rectangle import UM 1.0 as UM
UM.Dialog
{ {
id: base; id: base;
width: 500 * Screen.devicePixelRatio; width: 500 * Screen.devicePixelRatio;
height: 100 * Screen.devicePixelRatio; height: 100 * Screen.devicePixelRatio;
color: palette.window; visible: true;
modality: Qt.ApplicationModal;
signal close();
Column Column
{ {
anchors.fill: parent; anchors.fill: parent;
anchors.margins: 8 * Screen.devicePixelRatio;
Label Text
{ {
anchors { anchors {
left: parent.left; left: parent.left;
@ -47,6 +48,7 @@ Rectangle
wrapMode: Text.Wrap; wrapMode: Text.Wrap;
} }
ProgressBar ProgressBar
{ {
id: prog; id: prog;
@ -59,14 +61,15 @@ Rectangle
} }
} }
Button {
anchors.right: parent.right;
text: qsTr("Close");
onClicked: base.close();
}
}
SystemPalette { SystemPalette {
id: palette; id: palette;
} }
}
rightButtons: Button {
text: qsTr("Close");
enabled: true;
}
} }

View file

@ -20,6 +20,7 @@ import sys
from UM.Extension import Extension from UM.Extension import Extension
from PyQt5.QtQuick import QQuickView from PyQt5.QtQuick import QQuickView
from PyQt5.QtQml import QQmlComponent, QQmlContext
from PyQt5.QtCore import QUrl, QObject, pyqtSlot, pyqtProperty, pyqtSignal, Qt from PyQt5.QtCore import QUrl, QObject, pyqtSlot, pyqtProperty, pyqtSignal, Qt
from UM.i18n import i18nCatalog from UM.i18n import i18nCatalog
@ -55,23 +56,27 @@ class USBPrinterManager(QObject, SignalEmitter, Extension):
# This will create the view if its not already created. # This will create the view if its not already created.
def spawnFirmwareInterface(self, serial_port): def spawnFirmwareInterface(self, serial_port):
if self._firmware_view is None: if self._firmware_view is None:
self._firmware_view = QQuickView() path = QUrl.fromLocalFile(os.path.join(PluginRegistry.getInstance().getPluginPath("USBPrinting"), "FirmwareUpdateWindow.qml"))
self._firmware_view.setFlags(Qt.Dialog) component = QQmlComponent(Application.getInstance()._engine, path)
self._firmware_view.setResizeMode(QQuickView.SizeRootObjectToView);
self._firmware_view.engine().rootContext().setContextProperty("manager",self) context = QQmlContext(Application.getInstance()._engine.rootContext())
self._firmware_view.setSource(QUrl.fromLocalFile(os.path.join(PluginRegistry.getInstance().getPluginPath("USBPrinting"), "FirmwareUpdateWindow.qml"))) context.setContextProperty("manager", self)
self._firmware_view.rootObject().close.connect(self._firmware_view.close) self._firmware_view = component.create(context)
self._firmware_view.show() self._firmware_view.show()
## Show control interface. ## Show control interface.
# This will create the view if its not already created. # This will create the view if its not already created.
def spawnControlInterface(self,serial_port): def spawnControlInterface(self,serial_port):
if self._control_view is None: if self._control_view is None:
self._control_view = QQuickView() path = QUrl.fromLocalFile(os.path.join(PluginRegistry.getInstance().getPluginPath("USBPrinting"), "ControlWindow.qml"))
self._control_view.setFlags(Qt.Dialog)
self._control_view.setResizeMode(QQuickView.SizeRootObjectToView); component = QQmlComponent(Application.getInstance()._engine, path)
self._control_view.engine().rootContext().setContextProperty("manager",self) context = QQmlContext(Application.getInstance()._engine.rootContext())
self._control_view.setSource(QUrl.fromLocalFile(os.path.join(PluginRegistry.getInstance().getPluginPath("USBPrinting"), "ControlWindow.qml"))) context.setContextProperty("manager", self)
self._control_view = component.create(context)
self._control_view.show() self._control_view.show()
@pyqtProperty(float,notify = processingProgress) @pyqtProperty(float,notify = processingProgress)