mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-04-29 07:14:24 +08:00
Connect the visibility of the components through their properties
As Ghostkeeper suspected correctly in the review comment https://github.com/Ultimaker/Cura/pull/9012#discussion_r549707433 the binding wasn't working because the model was being retrieved using a function (CuraApplication.getFileProviderModel()). Separating this model into a variable allows us to properly bind the "visible" properties of the menu items with the count property of the model without a problem. CURA-7868
This commit is contained in:
parent
71994eaaf9
commit
70550594cd
@ -11,6 +11,7 @@ Menu
|
|||||||
{
|
{
|
||||||
id: base
|
id: base
|
||||||
title: catalog.i18nc("@title:menu menubar:toplevel", "&File")
|
title: catalog.i18nc("@title:menu menubar:toplevel", "&File")
|
||||||
|
property var fileProviderModel: CuraApplication.getFileProviderModel()
|
||||||
|
|
||||||
MenuItem
|
MenuItem
|
||||||
{
|
{
|
||||||
@ -22,23 +23,13 @@ Menu
|
|||||||
{
|
{
|
||||||
id: openMenu
|
id: openMenu
|
||||||
action: Cura.Actions.open
|
action: Cura.Actions.open
|
||||||
visible: (CuraApplication.getFileProviderModel().count == 1)
|
visible: (base.fileProviderModel.count == 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
OpenFilesMenu
|
OpenFilesMenu
|
||||||
{
|
{
|
||||||
id: openFilesMenu
|
id: openFilesMenu
|
||||||
visible: (CuraApplication.getFileProviderModel().count > 1)
|
visible: (base.fileProviderModel.count > 1)
|
||||||
}
|
|
||||||
|
|
||||||
Connections
|
|
||||||
{
|
|
||||||
target: CuraApplication.getFileProviderModel()
|
|
||||||
onItemsChanged:
|
|
||||||
{
|
|
||||||
openMenu.visible = (CuraApplication.getFileProviderModel().count == 1) // 1 because the open local files menu should always exist in the model
|
|
||||||
openFilesMenu.visible = (CuraApplication.getFileProviderModel().count > 1)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RecentFilesMenu { }
|
RecentFilesMenu { }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user