Update the settings menu to controls 2

CURA-8683
This commit is contained in:
Jaime van Kessel 2022-01-11 10:31:39 +01:00
parent 770f6f94c9
commit 2bad5c5cd3
8 changed files with 121 additions and 140 deletions

View file

@ -1,60 +1,89 @@
// Copyright (c) 2018 Ultimaker B.V.
// Copyright (c) 2022 Ultimaker B.V.
// Cura is released under the terms of the LGPLv3 or higher.
import QtQuick 2.2
import QtQuick.Controls 1.4
import QtQuick.Controls 2.4
import UM 1.2 as UM
import UM 1.6 as UM
import Cura 1.0 as Cura
Menu
{
id: menu
// TODO Enable custom style to the menu
// style: MenuStyle
// {
// frame: Rectangle
// {
// color: "white"
// }
// }
MenuItem
UM.MenuItem
{
id: networkEnabledPrinterItem
text: catalog.i18nc("@label:category menu label", "Network enabled printers")
enabled: false
visible: networkPrinterMenu.count > 0
visible: networKPrinterInstantiator.count > 0
}
NetworkPrinterMenu
Instantiator
{
id: networkPrinterMenu
id: networKPrinterInstantiator
model: Cura.GlobalStacksModel {filterOnlineOnly: true}
UM.MenuItem
{
property string connectGroupName:
{
if("group_name" in model.metadata)
{
return model.metadata["group_name"]
}
return ""
}
text: connectGroupName
checkable: true
checked: Cura.MachineManager.activeMachineNetworkGroupName == connectGroupName
onTriggered:
{
print(typeof(model.id))
Cura.MachineManager.someFunction("YAY")
Cura.MachineManager.setActiveMachine(model.id)
}
}
onObjectAdded: menu.insertItem(2, object)
onObjectRemoved: menu.removeItem(object)
}
MenuSeparator
{
visible: networkPrinterMenu.count > 0
visible: networKPrinterInstantiator.count > 0
}
MenuItem
{
text: catalog.i18nc("@label:category menu label", "Local printers")
enabled: false
visible: localPrinterMenu.count > 0
}
LocalPrinterMenu
UM.MenuItem
{
id: localPrinterMenu
text: catalog.i18nc("@label:category menu label", "Local printers")
enabled: false
visible: localPrinterInstantiator.count > 0
}
ExclusiveGroup { id: group; }
Instantiator
{
id: localPrinterInstantiator
model: Cura.GlobalStacksModel {}
UM.MenuItem
{
text: model.name
checkable: true
checked: Cura.MachineManager.activeMachine !== null ? Cura.MachineManager.activeMachine.id == model.id: false
visible: !model.hasRemoteConnection
height: visible ? implicitHeight: 0
onTriggered: Cura.MachineManager.setActiveMachine(model.id)
}
// A bit hackish, but we have 2 items at the end, put them before that
onObjectAdded: menu.insertItem(menu.count - 2, object)
onObjectRemoved: menu.removeItem(object)
}
MenuSeparator
{
visible: localPrinterMenu.count > 0
visible: localPrinterInstantiator.count > 0
}
MenuItem { action: Cura.Actions.addMachine; }
MenuItem { action: Cura.Actions.configureMachines; }
UM.MenuItem { action: Cura.Actions.addMachine }
UM.MenuItem { action: Cura.Actions.configureMachines }
}