mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-13 01:37:51 -06:00
Moved machinePage to Cura
CURA-1278
This commit is contained in:
parent
133229d086
commit
d8e4aa9078
3 changed files with 75 additions and 0 deletions
|
@ -27,6 +27,11 @@ class MachineManagerModel(QObject):
|
|||
def activeMachineId(self):
|
||||
return Application.getInstance().getGlobalContainerStack().getId()
|
||||
|
||||
@pyqtSlot(str, str)
|
||||
def renameMachine(self, machine_id, new_name):
|
||||
containers = ContainerRegistry.getInstance().findContainerStacks(id = machine_id)
|
||||
if containers:
|
||||
containers[0].setName(new_name)
|
||||
|
||||
|
||||
def createMachineManagerModel(engine, script_engine):
|
||||
|
|
|
@ -542,6 +542,8 @@ UM.MainWindow
|
|||
//: View preferences page title
|
||||
insertPage(1, catalog.i18nc("@title:tab","View"), Qt.resolvedUrl("ViewPage.qml"));
|
||||
|
||||
insertPage(2, catalog.i18nc("@title:tab", "Printers"), Qt.resolvedUrl("MachinesPage.qml"));
|
||||
|
||||
//Force refresh
|
||||
setPage(0);
|
||||
}
|
||||
|
|
68
resources/qml/MachinesPage.qml
Normal file
68
resources/qml/MachinesPage.qml
Normal file
|
@ -0,0 +1,68 @@
|
|||
// Copyright (c) 2016 Ultimaker B.V.
|
||||
// Uranium is released under the terms of the AGPLv3 or higher.
|
||||
|
||||
import QtQuick 2.1
|
||||
import QtQuick.Controls 1.1
|
||||
|
||||
import UM 1.2 as UM
|
||||
import Cura 1.0 as Cura
|
||||
|
||||
UM.ManagementPage
|
||||
{
|
||||
id: base;
|
||||
|
||||
title: catalog.i18nc("@title:tab", "Printers");
|
||||
property int numInstances: model.rowCount();
|
||||
model: UM.ContainerStacksModel
|
||||
{
|
||||
filter: {"type": "machine"}
|
||||
onDataChanged: numInstances = model.rowCount()
|
||||
}
|
||||
|
||||
onAddObject: model.requestAddMachine();
|
||||
onRemoveObject: confirmDialog.open();
|
||||
onRenameObject: renameDialog.open();
|
||||
|
||||
removeEnabled: numInstances > 1
|
||||
renameEnabled: numInstances > 0
|
||||
|
||||
Flow
|
||||
{
|
||||
anchors.fill: parent;
|
||||
spacing: UM.Theme.getSize("default_margin").height;
|
||||
|
||||
Label
|
||||
{
|
||||
text: base.currentItem && base.currentItem.name ? base.currentItem.name : ""
|
||||
font: UM.Theme.getFont("large")
|
||||
width: parent.width
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
|
||||
Label { text: catalog.i18nc("@label", "Type"); width: parent.width * 0.2; }
|
||||
Label { text: base.currentItem && base.currentItem.typeName ? base.currentItem.typeName : ""; width: parent.width * 0.7; }
|
||||
|
||||
UM.I18nCatalog { id: catalog; name: "uranium"; }
|
||||
|
||||
UM.ConfirmRemoveDialog
|
||||
{
|
||||
id: confirmDialog;
|
||||
object: base.currentItem && base.currentItem.name ? base.currentItem.name : "";
|
||||
onYes: base.model.removeMachineInstance(base.currentItem.name);
|
||||
}
|
||||
|
||||
UM.RenameDialog
|
||||
{
|
||||
id: renameDialog;
|
||||
object: base.currentItem && base.currentItem.name ? base.currentItem.name : "";
|
||||
onAccepted:
|
||||
{
|
||||
Cura.MachineManager.renameMachine(base.currentItem.id, newName.trim());
|
||||
//Reselect current item to update details panel
|
||||
var index = objectList.currentIndex
|
||||
objectList.currentIndex = -1
|
||||
objectList.currentIndex = index
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue