Add an Add Machine dialog

This commit is contained in:
Arjen Hiemstra 2015-02-26 14:36:04 +01:00
parent 1c329427ff
commit f1d6bb9472
3 changed files with 94 additions and 4 deletions

73
AddMachineWizard.qml Normal file
View File

@ -0,0 +1,73 @@
import QtQuick 2.2
import QtQuick.Controls 1.1
import QtQuick.Layouts 1.1
import QtQuick.Window 2.1
import UM 1.0 as UM
Window {
id: base
width: 640
height: 480
//: Add Printer dialog title
title: qsTr("Add Printer");
Rectangle {
anchors.fill: parent;
color: palette.window;
ColumnLayout {
anchors.fill: parent;
anchors.margins: UM.Theme.defaultMargin;
Label {
text: qsTr("Please select the type of printer:");
}
ScrollView {
Layout.fillWidth: true;
ListView {
id: machineList;
model: UM.Models.availableMachinesModel
delegate: RadioButton { exclusiveGroup: printerGroup; text: model.name; onClicked: ListView.view.currentIndex = index; }
}
}
Label {
text: qsTr("Printer Name:");
}
TextField { id: machineName; Layout.fillWidth: true; text: machineList.model.getItem(machineList.currentIndex).name }
Item { Layout.fillWidth: true; Layout.fillHeight: true; }
ExclusiveGroup { id: printerGroup; }
RowLayout {
Layout.fillWidth: true
Item { Layout.fillWidth: true; }
Button {
text: qsTr("Next");
onClicked: {
if(machineList.currentIndex != -1) {
UM.Models.availableMachinesModel.createMachine(machineList.currentIndex, machineName.text)
base.visible = false
}
}
}
Button {
text: qsTr("Cancel");
onClicked: base.visible = false;
}
}
}
}
SystemPalette { id: palette; colorGroup: SystemPalette.Active }
}

View File

@ -213,6 +213,8 @@ UM.MainWindow {
deleteSelection.onTriggered: UM.Controller.removeSelection(); deleteSelection.onTriggered: UM.Controller.removeSelection();
addMachine.onTriggered: addMachine.visible = true;
preferences.onTriggered: preferences.visible = true; preferences.onTriggered: preferences.visible = true;
settings.onTriggered: preferences.visible = true; settings.onTriggered: preferences.visible = true;
} }
@ -256,4 +258,13 @@ UM.MainWindow {
Printer.saveGCode(fileUrl); Printer.saveGCode(fileUrl);
} }
} }
AddMachineWizard {
id: addMachine;
}
Connections {
target: Printer
onRequestAddPrinter: addMachine.visible = true;
}
} }

View File

@ -12,7 +12,7 @@ from UM.Scene.Selection import Selection
from PlatformPhysics import PlatformPhysics from PlatformPhysics import PlatformPhysics
from BuildVolume import BuildVolume from BuildVolume import BuildVolume
from PyQt5.QtCore import pyqtSlot, QUrl, Qt from PyQt5.QtCore import pyqtSlot, QUrl, Qt, pyqtSignal
from PyQt5.QtGui import QColor from PyQt5.QtGui import QColor
import os.path import os.path
@ -66,13 +66,17 @@ class PrinterApplication(QtApplication):
controller.getScene().setActiveCamera('3d') controller.getScene().setActiveCamera('3d')
self.setActiveMachine(self.getMachines()[0])
self.showSplashMessage('Loading interface...') self.showSplashMessage('Loading interface...')
self.setMainQml(os.path.dirname(__file__) + "/Printer.qml") self.setMainQml(os.path.dirname(__file__) + "/Printer.qml")
self.initializeEngine() self.initializeEngine()
#TODO: Add support for active machine preference
if self.getMachines():
self.setActiveMachine(self.getMachines()[0])
else:
self.requestAddPrinter.emit()
if self._engine.rootObjects: if self._engine.rootObjects:
self.closeSplash() self.closeSplash()
self.exec_() self.exec_()
@ -102,6 +106,8 @@ class PrinterApplication(QtApplication):
with open(file.toLocalFile(), 'w') as f: with open(file.toLocalFile(), 'w') as f:
f.write(gcode) f.write(gcode)
requestAddPrinter = pyqtSignal()
def _onActiveMachineChanged(self): def _onActiveMachineChanged(self):
machine = self.getActiveMachine() machine = self.getActiveMachine()
if machine: if machine: