mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-21 21:58:01 -06:00
Add extension menu to application menu
CURA-8683
This commit is contained in:
parent
2bad5c5cd3
commit
d1461c5d7f
3 changed files with 69 additions and 3 deletions
|
@ -64,6 +64,8 @@ Item
|
|||
title: (Qt.platform.os == "osx") ? "&Settings" : catalog.i18nc("@title:menu menubar:toplevel", "&Settings")
|
||||
}
|
||||
|
||||
ExtensionMenu {}
|
||||
|
||||
}
|
||||
|
||||
/*UM.ApplicationMenu
|
||||
|
|
64
resources/qml/Menus/ExtensionMenu.qml
Normal file
64
resources/qml/Menus/ExtensionMenu.qml
Normal file
|
@ -0,0 +1,64 @@
|
|||
// Copyright (c) 2022 Ultimaker B.V.
|
||||
// Cura is released under the terms of the LGPLv3 or higher.
|
||||
|
||||
import QtQuick 2.7
|
||||
import QtQuick.Controls 2.4
|
||||
|
||||
import UM 1.5 as UM
|
||||
import Cura 1.0 as Cura
|
||||
|
||||
UM.Menu
|
||||
{
|
||||
id: extensionMenu
|
||||
title: catalog.i18nc("@title:menu menubar:toplevel", "E&xtensions")
|
||||
|
||||
Component
|
||||
{
|
||||
id: extensionsMenuItem
|
||||
|
||||
UM.MenuItem
|
||||
{
|
||||
text: modelText
|
||||
onTriggered: extensionsModel.subMenuTriggered(extensionName, modelText)
|
||||
}
|
||||
}
|
||||
|
||||
Component
|
||||
{
|
||||
id: extensionsMenuSeparator
|
||||
|
||||
MenuSeparator {}
|
||||
}
|
||||
|
||||
Instantiator
|
||||
{
|
||||
id: extensions
|
||||
model: UM.ExtensionModel { }
|
||||
|
||||
UM.Menu
|
||||
{
|
||||
id: sub_menu
|
||||
title: model.name
|
||||
shouldBeVisible: actions !== undefined
|
||||
enabled: actions != null
|
||||
Instantiator
|
||||
{
|
||||
model: actions
|
||||
Loader
|
||||
{
|
||||
property var extensionsModel: extensions.model
|
||||
property var modelText: model.text
|
||||
property var extensionName: name
|
||||
|
||||
sourceComponent: modelText.trim() == "" ? extensionsMenuSeparator : extensionsMenuItem
|
||||
}
|
||||
|
||||
onObjectAdded: sub_menu.insertItem(index, object.item)
|
||||
onObjectRemoved: sub_menu.removeItem(object.item)
|
||||
}
|
||||
}
|
||||
|
||||
onObjectAdded: extensionMenu.insertMenu(index, object)
|
||||
onObjectRemoved: extensionMenu.removeMenu(object)
|
||||
}
|
||||
}
|
|
@ -1,10 +1,10 @@
|
|||
//Copyright (c) 2022 Ultimaker B.V.
|
||||
//Cura is released under the terms of the LGPLv3 or higher.
|
||||
// Copyright (c) 2022 Ultimaker B.V.
|
||||
// Cura is released under the terms of the LGPLv3 or higher.
|
||||
|
||||
import QtQuick 2.7
|
||||
import QtQuick.Controls 2.4
|
||||
|
||||
import UM 1.6 as UM
|
||||
import UM 1.5 as UM
|
||||
import Cura 1.0 as Cura
|
||||
|
||||
UM.Menu
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue