mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-15 18:25:54 +08:00
Use a StackView and non-dynamic instantation for the sidebar modes
Improves performance at the cost of flexibility. But we did not use that flexibility anyway.
This commit is contained in:
parent
8dc6353738
commit
edf2802099
@ -82,6 +82,10 @@ Rectangle
|
|||||||
onCurrentModeIndexChanged:
|
onCurrentModeIndexChanged:
|
||||||
{
|
{
|
||||||
UM.Preferences.setValue("cura/active_mode", currentModeIndex);
|
UM.Preferences.setValue("cura/active_mode", currentModeIndex);
|
||||||
|
if(modesListModel.count > base.currentModeIndex)
|
||||||
|
{
|
||||||
|
sidebarContents.push({ "item": modesListModel.get(base.currentModeIndex).item, "replace": true });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
@ -153,31 +157,40 @@ Rectangle
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Loader
|
StackView
|
||||||
{
|
{
|
||||||
id: sidebarContents;
|
id: sidebarContents
|
||||||
|
|
||||||
anchors.bottom: footerSeparator.top
|
anchors.bottom: footerSeparator.top
|
||||||
anchors.top: profileItem.bottom
|
anchors.top: profileItem.bottom
|
||||||
anchors.topMargin: UM.Theme.sizes.default_margin.height
|
anchors.topMargin: UM.Theme.sizes.default_margin.height
|
||||||
anchors.left: base.left
|
anchors.left: base.left
|
||||||
anchors.right: base.right
|
anchors.right: base.right
|
||||||
|
|
||||||
source: modesListModel.count > base.currentModeIndex ? modesListModel.get(base.currentModeIndex).file : "";
|
delegate: StackViewDelegate
|
||||||
|
|
||||||
property Item sidebar: base;
|
|
||||||
|
|
||||||
onLoaded:
|
|
||||||
{
|
{
|
||||||
if(item)
|
function transitionFinished(properties)
|
||||||
{
|
{
|
||||||
item.configureSettings = base.configureMachinesAction;
|
properties.exitItem.opacity = 1
|
||||||
if(item.onShowTooltip != undefined)
|
}
|
||||||
|
|
||||||
|
pushTransition: StackViewTransition
|
||||||
|
{
|
||||||
|
PropertyAnimation
|
||||||
{
|
{
|
||||||
item.showTooltip.connect(base.showTooltip)
|
target: enterItem
|
||||||
|
property: "opacity"
|
||||||
|
from: 0
|
||||||
|
to: 1
|
||||||
|
duration: 100
|
||||||
}
|
}
|
||||||
if(item.onHideTooltip != undefined)
|
PropertyAnimation
|
||||||
{
|
{
|
||||||
item.hideTooltip.connect(base.hideTooltip)
|
target: exitItem
|
||||||
|
property: "opacity"
|
||||||
|
from: 1
|
||||||
|
to: 0
|
||||||
|
duration: 100
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -210,10 +223,25 @@ Rectangle
|
|||||||
id: modesListModel;
|
id: modesListModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SidebarSimple
|
||||||
|
{
|
||||||
|
id: sidebarSimple;
|
||||||
|
visible: false;
|
||||||
|
}
|
||||||
|
SidebarAdvanced
|
||||||
|
{
|
||||||
|
id: sidebarAdvanced;
|
||||||
|
visible: false;
|
||||||
|
|
||||||
|
configureSettings: base.configureMachinesAction;
|
||||||
|
onShowTooltip: base.showTooltip(item, location, text)
|
||||||
|
onHideTooltip: base.hideTooltip()
|
||||||
|
}
|
||||||
|
|
||||||
Component.onCompleted:
|
Component.onCompleted:
|
||||||
{
|
{
|
||||||
modesListModel.append({ text: catalog.i18nc("@title:tab", "Simple"), file: "SidebarSimple.qml" })
|
modesListModel.append({ text: catalog.i18nc("@title:tab", "Simple"), item: sidebarSimple })
|
||||||
modesListModel.append({ text: catalog.i18nc("@title:tab", "Advanced"), file: "SidebarAdvanced.qml" })
|
modesListModel.append({ text: catalog.i18nc("@title:tab", "Advanced"), item: sidebarAdvanced })
|
||||||
sidebarContents.setSource(modesListModel.get(base.currentModeIndex).file)
|
sidebarContents.push({ "item": modesListModel.get(base.currentModeIndex).item, "immediate": true });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,6 @@ import UM 1.1 as UM
|
|||||||
Item
|
Item
|
||||||
{
|
{
|
||||||
id: base;
|
id: base;
|
||||||
anchors.fill: parent;
|
|
||||||
|
|
||||||
signal showTooltip(Item item, point location, string text);
|
signal showTooltip(Item item, point location, string text);
|
||||||
signal hideTooltip();
|
signal hideTooltip();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user