mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-08-08 06:23:59 -06:00
Move TopBar to the Skeleton folder.
Clean up the Cura.qml even more by moving some components to the ApplicationMenu, where they are called. Contributes to CURA-5784.
This commit is contained in:
parent
193f113851
commit
8bdd27183f
4 changed files with 229 additions and 222 deletions
|
@ -11,224 +11,267 @@ import UM 1.3 as UM
|
|||
import Cura 1.1 as Cura
|
||||
|
||||
import "../Menus"
|
||||
import "../Dialogs"
|
||||
|
||||
UM.ApplicationMenu
|
||||
Item
|
||||
{
|
||||
id: menu
|
||||
width: applicationMenu.width
|
||||
height: applicationMenu.height
|
||||
property alias window: applicationMenu.window
|
||||
|
||||
Menu
|
||||
UM.ApplicationMenu
|
||||
{
|
||||
id: fileMenu
|
||||
title: catalog.i18nc("@title:menu menubar:toplevel","&File")
|
||||
id: applicationMenu
|
||||
|
||||
MenuItem
|
||||
Menu
|
||||
{
|
||||
id: newProjectMenu
|
||||
action: Cura.Actions.newProject
|
||||
}
|
||||
id: fileMenu
|
||||
title: catalog.i18nc("@title:menu menubar:toplevel","&File")
|
||||
|
||||
MenuItem
|
||||
{
|
||||
id: openMenu
|
||||
action: Cura.Actions.open
|
||||
}
|
||||
|
||||
RecentFilesMenu { }
|
||||
|
||||
MenuItem
|
||||
{
|
||||
id: saveWorkspaceMenu
|
||||
text: catalog.i18nc("@title:menu menubar:file","&Save...")
|
||||
onTriggered:
|
||||
MenuItem
|
||||
{
|
||||
var args = { "filter_by_machine": false, "file_type": "workspace", "preferred_mimetypes": "application/vnd.ms-package.3dmanufacturing-3dmodel+xml" };
|
||||
if(UM.Preferences.getValue("cura/dialog_on_project_save"))
|
||||
id: newProjectMenu
|
||||
action: Cura.Actions.newProject
|
||||
}
|
||||
|
||||
MenuItem
|
||||
{
|
||||
id: openMenu
|
||||
action: Cura.Actions.open
|
||||
}
|
||||
|
||||
RecentFilesMenu { }
|
||||
|
||||
MenuItem
|
||||
{
|
||||
id: saveWorkspaceMenu
|
||||
text: catalog.i18nc("@title:menu menubar:file","&Save...")
|
||||
onTriggered:
|
||||
{
|
||||
saveWorkspaceDialog.args = args
|
||||
saveWorkspaceDialog.open()
|
||||
}
|
||||
else
|
||||
{
|
||||
UM.OutputDeviceManager.requestWriteToDevice("local_file", PrintInformation.jobName, args)
|
||||
var args = { "filter_by_machine": false, "file_type": "workspace", "preferred_mimetypes": "application/vnd.ms-package.3dmanufacturing-3dmodel+xml" };
|
||||
if(UM.Preferences.getValue("cura/dialog_on_project_save"))
|
||||
{
|
||||
saveWorkspaceDialog.args = args
|
||||
saveWorkspaceDialog.open()
|
||||
}
|
||||
else
|
||||
{
|
||||
UM.OutputDeviceManager.requestWriteToDevice("local_file", PrintInformation.jobName, args)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MenuSeparator { }
|
||||
MenuSeparator { }
|
||||
|
||||
MenuItem
|
||||
{
|
||||
id: saveAsMenu
|
||||
text: catalog.i18nc("@title:menu menubar:file", "&Export...")
|
||||
onTriggered:
|
||||
MenuItem
|
||||
{
|
||||
var localDeviceId = "local_file"
|
||||
UM.OutputDeviceManager.requestWriteToDevice(localDeviceId, PrintInformation.jobName, { "filter_by_machine": false, "preferred_mimetypes": "application/vnd.ms-package.3dmanufacturing-3dmodel+xml"})
|
||||
id: saveAsMenu
|
||||
text: catalog.i18nc("@title:menu menubar:file", "&Export...")
|
||||
onTriggered:
|
||||
{
|
||||
var localDeviceId = "local_file"
|
||||
UM.OutputDeviceManager.requestWriteToDevice(localDeviceId, PrintInformation.jobName, { "filter_by_machine": false, "preferred_mimetypes": "application/vnd.ms-package.3dmanufacturing-3dmodel+xml"})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MenuItem
|
||||
{
|
||||
id: exportSelectionMenu
|
||||
text: catalog.i18nc("@action:inmenu menubar:file", "Export Selection...")
|
||||
enabled: UM.Selection.hasSelection
|
||||
iconName: "document-save-as"
|
||||
onTriggered: UM.OutputDeviceManager.requestWriteSelectionToDevice("local_file", PrintInformation.jobName, { "filter_by_machine": false, "preferred_mimetypes": "application/vnd.ms-package.3dmanufacturing-3dmodel+xml"})
|
||||
}
|
||||
|
||||
MenuSeparator { }
|
||||
|
||||
MenuItem
|
||||
{
|
||||
id: reloadAllMenu
|
||||
action: Cura.Actions.reloadAll
|
||||
}
|
||||
|
||||
MenuSeparator { }
|
||||
|
||||
MenuItem { action: Cura.Actions.quit }
|
||||
}
|
||||
|
||||
Menu
|
||||
{
|
||||
title: catalog.i18nc("@title:menu menubar:toplevel","&Edit")
|
||||
|
||||
MenuItem { action: Cura.Actions.undo }
|
||||
MenuItem { action: Cura.Actions.redo }
|
||||
MenuSeparator { }
|
||||
MenuItem { action: Cura.Actions.selectAll }
|
||||
MenuItem { action: Cura.Actions.arrangeAll }
|
||||
MenuItem { action: Cura.Actions.deleteSelection }
|
||||
MenuItem { action: Cura.Actions.deleteAll }
|
||||
MenuItem { action: Cura.Actions.resetAllTranslation }
|
||||
MenuItem { action: Cura.Actions.resetAll }
|
||||
MenuSeparator { }
|
||||
MenuItem { action: Cura.Actions.groupObjects }
|
||||
MenuItem { action: Cura.Actions.mergeObjects }
|
||||
MenuItem { action: Cura.Actions.unGroupObjects }
|
||||
}
|
||||
|
||||
ViewMenu { title: catalog.i18nc("@title:menu", "&View") }
|
||||
|
||||
Menu
|
||||
{
|
||||
id: settingsMenu
|
||||
title: catalog.i18nc("@title:menu", "&Settings")
|
||||
|
||||
PrinterMenu { title: catalog.i18nc("@title:menu menubar:settings", "&Printer") }
|
||||
|
||||
Instantiator
|
||||
{
|
||||
model: Cura.ExtrudersModel { simpleNames: true }
|
||||
Menu {
|
||||
title: model.name
|
||||
|
||||
NozzleMenu { title: Cura.MachineManager.activeDefinitionVariantsName; visible: Cura.MachineManager.hasVariants; extruderIndex: index }
|
||||
MaterialMenu { title: catalog.i18nc("@title:menu", "&Material"); visible: Cura.MachineManager.hasMaterials; extruderIndex: index }
|
||||
|
||||
MenuSeparator
|
||||
{
|
||||
visible: Cura.MachineManager.hasVariants || Cura.MachineManager.hasMaterials
|
||||
}
|
||||
|
||||
MenuItem
|
||||
{
|
||||
text: catalog.i18nc("@action:inmenu", "Set as Active Extruder")
|
||||
onTriggered: Cura.MachineManager.setExtruderIndex(model.index)
|
||||
}
|
||||
|
||||
MenuItem
|
||||
{
|
||||
text: catalog.i18nc("@action:inmenu", "Enable Extruder")
|
||||
onTriggered: Cura.MachineManager.setExtruderEnabled(model.index, true)
|
||||
visible: !Cura.MachineManager.getExtruder(model.index).isEnabled
|
||||
}
|
||||
|
||||
MenuItem
|
||||
{
|
||||
text: catalog.i18nc("@action:inmenu", "Disable Extruder")
|
||||
onTriggered: Cura.MachineManager.setExtruderEnabled(model.index, false)
|
||||
visible: Cura.MachineManager.getExtruder(model.index).isEnabled
|
||||
enabled: Cura.MachineManager.numberExtrudersEnabled > 1
|
||||
}
|
||||
|
||||
}
|
||||
onObjectAdded: settingsMenu.insertItem(index, object)
|
||||
onObjectRemoved: settingsMenu.removeItem(object)
|
||||
}
|
||||
|
||||
// TODO Only show in dev mode. Remove check when feature ready
|
||||
BuildplateMenu
|
||||
{
|
||||
title: catalog.i18nc("@title:menu", "&Build plate")
|
||||
visible: CuraSDKVersion == "dev" && Cura.MachineManager.hasVariantBuildplates
|
||||
}
|
||||
ProfileMenu { title: catalog.i18nc("@title:settings", "&Profile") }
|
||||
|
||||
MenuSeparator { }
|
||||
|
||||
MenuItem { action: Cura.Actions.configureSettingVisibility }
|
||||
}
|
||||
|
||||
Menu
|
||||
{
|
||||
id: extension_menu
|
||||
title: catalog.i18nc("@title:menu menubar:toplevel","E&xtensions")
|
||||
|
||||
Instantiator
|
||||
{
|
||||
id: extensions
|
||||
model: UM.ExtensionModel { }
|
||||
|
||||
Menu
|
||||
MenuItem
|
||||
{
|
||||
id: sub_menu
|
||||
title: model.name;
|
||||
visible: actions != null
|
||||
enabled: actions != null
|
||||
Instantiator
|
||||
{
|
||||
model: actions
|
||||
id: exportSelectionMenu
|
||||
text: catalog.i18nc("@action:inmenu menubar:file", "Export Selection...")
|
||||
enabled: UM.Selection.hasSelection
|
||||
iconName: "document-save-as"
|
||||
onTriggered: UM.OutputDeviceManager.requestWriteSelectionToDevice("local_file", PrintInformation.jobName, { "filter_by_machine": false, "preferred_mimetypes": "application/vnd.ms-package.3dmanufacturing-3dmodel+xml"})
|
||||
}
|
||||
|
||||
MenuSeparator { }
|
||||
|
||||
MenuItem
|
||||
{
|
||||
id: reloadAllMenu
|
||||
action: Cura.Actions.reloadAll
|
||||
}
|
||||
|
||||
MenuSeparator { }
|
||||
|
||||
MenuItem { action: Cura.Actions.quit }
|
||||
}
|
||||
|
||||
Menu
|
||||
{
|
||||
title: catalog.i18nc("@title:menu menubar:toplevel","&Edit")
|
||||
|
||||
MenuItem { action: Cura.Actions.undo }
|
||||
MenuItem { action: Cura.Actions.redo }
|
||||
MenuSeparator { }
|
||||
MenuItem { action: Cura.Actions.selectAll }
|
||||
MenuItem { action: Cura.Actions.arrangeAll }
|
||||
MenuItem { action: Cura.Actions.deleteSelection }
|
||||
MenuItem { action: Cura.Actions.deleteAll }
|
||||
MenuItem { action: Cura.Actions.resetAllTranslation }
|
||||
MenuItem { action: Cura.Actions.resetAll }
|
||||
MenuSeparator { }
|
||||
MenuItem { action: Cura.Actions.groupObjects }
|
||||
MenuItem { action: Cura.Actions.mergeObjects }
|
||||
MenuItem { action: Cura.Actions.unGroupObjects }
|
||||
}
|
||||
|
||||
ViewMenu { title: catalog.i18nc("@title:menu", "&View") }
|
||||
|
||||
Menu
|
||||
{
|
||||
id: settingsMenu
|
||||
title: catalog.i18nc("@title:menu", "&Settings")
|
||||
|
||||
PrinterMenu { title: catalog.i18nc("@title:menu menubar:settings", "&Printer") }
|
||||
|
||||
Instantiator
|
||||
{
|
||||
model: Cura.ExtrudersModel { simpleNames: true }
|
||||
Menu {
|
||||
title: model.name
|
||||
|
||||
NozzleMenu { title: Cura.MachineManager.activeDefinitionVariantsName; visible: Cura.MachineManager.hasVariants; extruderIndex: index }
|
||||
MaterialMenu { title: catalog.i18nc("@title:menu", "&Material"); visible: Cura.MachineManager.hasMaterials; extruderIndex: index }
|
||||
|
||||
MenuSeparator
|
||||
{
|
||||
visible: Cura.MachineManager.hasVariants || Cura.MachineManager.hasMaterials
|
||||
}
|
||||
|
||||
MenuItem
|
||||
{
|
||||
text: model.text
|
||||
onTriggered: extensions.model.subMenuTriggered(name, model.text)
|
||||
text: catalog.i18nc("@action:inmenu", "Set as Active Extruder")
|
||||
onTriggered: Cura.MachineManager.setExtruderIndex(model.index)
|
||||
}
|
||||
onObjectAdded: sub_menu.insertItem(index, object)
|
||||
onObjectRemoved: sub_menu.removeItem(object)
|
||||
|
||||
MenuItem
|
||||
{
|
||||
text: catalog.i18nc("@action:inmenu", "Enable Extruder")
|
||||
onTriggered: Cura.MachineManager.setExtruderEnabled(model.index, true)
|
||||
visible: !Cura.MachineManager.getExtruder(model.index).isEnabled
|
||||
}
|
||||
|
||||
MenuItem
|
||||
{
|
||||
text: catalog.i18nc("@action:inmenu", "Disable Extruder")
|
||||
onTriggered: Cura.MachineManager.setExtruderEnabled(model.index, false)
|
||||
visible: Cura.MachineManager.getExtruder(model.index).isEnabled
|
||||
enabled: Cura.MachineManager.numberExtrudersEnabled > 1
|
||||
}
|
||||
|
||||
}
|
||||
onObjectAdded: settingsMenu.insertItem(index, object)
|
||||
onObjectRemoved: settingsMenu.removeItem(object)
|
||||
}
|
||||
|
||||
onObjectAdded: extension_menu.insertItem(index, object)
|
||||
onObjectRemoved: extension_menu.removeItem(object)
|
||||
// TODO Only show in dev mode. Remove check when feature ready
|
||||
BuildplateMenu
|
||||
{
|
||||
title: catalog.i18nc("@title:menu", "&Build plate")
|
||||
visible: CuraSDKVersion == "dev" && Cura.MachineManager.hasVariantBuildplates
|
||||
}
|
||||
ProfileMenu { title: catalog.i18nc("@title:settings", "&Profile") }
|
||||
|
||||
MenuSeparator { }
|
||||
|
||||
MenuItem { action: Cura.Actions.configureSettingVisibility }
|
||||
}
|
||||
|
||||
Menu
|
||||
{
|
||||
id: extension_menu
|
||||
title: catalog.i18nc("@title:menu menubar:toplevel","E&xtensions")
|
||||
|
||||
Instantiator
|
||||
{
|
||||
id: extensions
|
||||
model: UM.ExtensionModel { }
|
||||
|
||||
Menu
|
||||
{
|
||||
id: sub_menu
|
||||
title: model.name;
|
||||
visible: actions != null
|
||||
enabled: actions != null
|
||||
Instantiator
|
||||
{
|
||||
model: actions
|
||||
MenuItem
|
||||
{
|
||||
text: model.text
|
||||
onTriggered: extensions.model.subMenuTriggered(name, model.text)
|
||||
}
|
||||
onObjectAdded: sub_menu.insertItem(index, object)
|
||||
onObjectRemoved: sub_menu.removeItem(object)
|
||||
}
|
||||
}
|
||||
|
||||
onObjectAdded: extension_menu.insertItem(index, object)
|
||||
onObjectRemoved: extension_menu.removeItem(object)
|
||||
}
|
||||
}
|
||||
|
||||
Menu
|
||||
{
|
||||
id: plugin_menu
|
||||
title: catalog.i18nc("@title:menu menubar:toplevel", "&Toolbox")
|
||||
|
||||
MenuItem { action: Cura.Actions.browsePackages }
|
||||
}
|
||||
|
||||
Menu
|
||||
{
|
||||
id: preferencesMenu
|
||||
title: catalog.i18nc("@title:menu menubar:toplevel","P&references")
|
||||
|
||||
MenuItem { action: Cura.Actions.preferences }
|
||||
}
|
||||
|
||||
Menu
|
||||
{
|
||||
id: helpMenu
|
||||
title: catalog.i18nc("@title:menu menubar:toplevel","&Help")
|
||||
|
||||
MenuItem { action: Cura.Actions.showProfileFolder }
|
||||
MenuItem { action: Cura.Actions.documentation }
|
||||
MenuItem { action: Cura.Actions.reportBug }
|
||||
MenuSeparator { }
|
||||
MenuItem { action: Cura.Actions.about }
|
||||
}
|
||||
}
|
||||
|
||||
Menu
|
||||
WorkspaceSummaryDialog
|
||||
{
|
||||
id: plugin_menu
|
||||
title: catalog.i18nc("@title:menu menubar:toplevel", "&Toolbox")
|
||||
|
||||
MenuItem { action: Cura.Actions.browsePackages }
|
||||
id: saveWorkspaceDialog
|
||||
property var args
|
||||
onYes: UM.OutputDeviceManager.requestWriteToDevice("local_file", PrintInformation.jobName, args)
|
||||
}
|
||||
|
||||
Menu
|
||||
MessageDialog
|
||||
{
|
||||
id: preferencesMenu
|
||||
title: catalog.i18nc("@title:menu menubar:toplevel","P&references")
|
||||
|
||||
MenuItem { action: Cura.Actions.preferences }
|
||||
id: newProjectDialog
|
||||
modality: Qt.ApplicationModal
|
||||
title: catalog.i18nc("@title:window", "New project")
|
||||
text: catalog.i18nc("@info:question", "Are you sure you want to start a new project? This will clear the build plate and any unsaved settings.")
|
||||
standardButtons: StandardButton.Yes | StandardButton.No
|
||||
icon: StandardIcon.Question
|
||||
onYes:
|
||||
{
|
||||
CuraApplication.deleteAll();
|
||||
Cura.Actions.resetProfile.trigger();
|
||||
}
|
||||
}
|
||||
|
||||
Menu
|
||||
Connections
|
||||
{
|
||||
id: helpMenu
|
||||
title: catalog.i18nc("@title:menu menubar:toplevel","&Help")
|
||||
|
||||
MenuItem { action: Cura.Actions.showProfileFolder }
|
||||
MenuItem { action: Cura.Actions.documentation }
|
||||
MenuItem { action: Cura.Actions.reportBug }
|
||||
MenuSeparator { }
|
||||
MenuItem { action: Cura.Actions.about }
|
||||
target: Cura.Actions.newProject
|
||||
onTriggered:
|
||||
{
|
||||
if(Printer.platformActivity || Cura.MachineManager.hasUserSettings)
|
||||
{
|
||||
newProjectDialog.visible = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
246
resources/qml/Skeleton/Topbar.qml
Normal file
246
resources/qml/Skeleton/Topbar.qml
Normal file
|
@ -0,0 +1,246 @@
|
|||
// Copyright (c) 2018 Ultimaker B.V.
|
||||
// Cura is released under the terms of the LGPLv3 or higher.
|
||||
|
||||
import QtQuick 2.2
|
||||
import QtQuick.Controls 1.1
|
||||
import QtQuick.Controls.Styles 1.1
|
||||
import QtQuick.Layouts 1.1
|
||||
|
||||
import UM 1.4 as UM
|
||||
import Cura 1.0 as Cura
|
||||
|
||||
Rectangle
|
||||
{
|
||||
id: base
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
height: UM.Theme.getSize("sidebar_header").height
|
||||
color: UM.Controller.activeStage.stageId == "MonitorStage" ? UM.Theme.getColor("topbar_background_color_monitoring") : UM.Theme.getColor("topbar_background_color")
|
||||
|
||||
property bool printerConnected: Cura.MachineManager.printerConnected
|
||||
property bool printerAcceptsCommands: printerConnected && Cura.MachineManager.printerOutputDevices[0].acceptsCommands
|
||||
|
||||
property int rightMargin: UM.Theme.getSize("sidebar").width + UM.Theme.getSize("default_margin").width;
|
||||
property int allItemsWidth: 0;
|
||||
|
||||
function updateMarginsAndSizes() {
|
||||
if (UM.Preferences.getValue("cura/sidebar_collapsed"))
|
||||
{
|
||||
rightMargin = UM.Theme.getSize("default_margin").width;
|
||||
}
|
||||
else
|
||||
{
|
||||
rightMargin = UM.Theme.getSize("sidebar").width + UM.Theme.getSize("default_margin").width;
|
||||
}
|
||||
allItemsWidth = (
|
||||
logo.width + UM.Theme.getSize("topbar_logo_right_margin").width +
|
||||
UM.Theme.getSize("topbar_logo_right_margin").width + stagesMenuContainer.width +
|
||||
UM.Theme.getSize("default_margin").width + viewModeButton.width +
|
||||
rightMargin);
|
||||
}
|
||||
|
||||
UM.I18nCatalog
|
||||
{
|
||||
id: catalog
|
||||
name:"cura"
|
||||
}
|
||||
|
||||
Image
|
||||
{
|
||||
id: logo
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: UM.Theme.getSize("default_margin").width
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
||||
source: UM.Theme.getImage("logo");
|
||||
width: UM.Theme.getSize("logo").width;
|
||||
height: UM.Theme.getSize("logo").height;
|
||||
|
||||
sourceSize.width: width;
|
||||
sourceSize.height: height;
|
||||
}
|
||||
|
||||
Row
|
||||
{
|
||||
id: stagesMenuContainer
|
||||
anchors.left: logo.right
|
||||
anchors.leftMargin: UM.Theme.getSize("topbar_logo_right_margin").width
|
||||
spacing: UM.Theme.getSize("default_margin").width
|
||||
|
||||
// The topbar is dynamically filled with all available stages
|
||||
Repeater
|
||||
{
|
||||
id: stagesMenu
|
||||
|
||||
model: UM.StageModel{}
|
||||
|
||||
delegate: Button
|
||||
{
|
||||
text: model.name
|
||||
checkable: true
|
||||
checked: model.active
|
||||
exclusiveGroup: topbarMenuGroup
|
||||
style: (model.stage.iconSource != "") ? UM.Theme.styles.topbar_header_tab_no_overlay : UM.Theme.styles.topbar_header_tab
|
||||
height: UM.Theme.getSize("sidebar_header").height
|
||||
onClicked: UM.Controller.setActiveStage(model.id)
|
||||
iconSource: model.stage.iconSource
|
||||
|
||||
property color overlayColor: "transparent"
|
||||
property string overlayIconSource: ""
|
||||
}
|
||||
}
|
||||
|
||||
ExclusiveGroup { id: topbarMenuGroup }
|
||||
}
|
||||
|
||||
// View orientation Item
|
||||
Row
|
||||
{
|
||||
id: viewOrientationControl
|
||||
height: 30
|
||||
|
||||
spacing: 2
|
||||
visible: UM.Controller.activeStage.stageId != "MonitorStage"
|
||||
|
||||
anchors
|
||||
{
|
||||
verticalCenter: base.verticalCenter
|
||||
right: viewModeButton.left
|
||||
rightMargin: UM.Theme.getSize("default_margin").width
|
||||
}
|
||||
|
||||
// #1 3d view
|
||||
Button
|
||||
{
|
||||
iconSource: UM.Theme.getIcon("view_3d")
|
||||
style: UM.Theme.styles.small_tool_button
|
||||
anchors.verticalCenter: viewOrientationControl.verticalCenter
|
||||
onClicked:UM.Controller.rotateView("3d", 0)
|
||||
visible: base.width - allItemsWidth - 4 * this.width > 0
|
||||
}
|
||||
|
||||
// #2 Front view
|
||||
Button
|
||||
{
|
||||
iconSource: UM.Theme.getIcon("view_front")
|
||||
style: UM.Theme.styles.small_tool_button
|
||||
anchors.verticalCenter: viewOrientationControl.verticalCenter
|
||||
onClicked: UM.Controller.rotateView("home", 0);
|
||||
visible: base.width - allItemsWidth - 3 * this.width > 0
|
||||
}
|
||||
|
||||
// #3 Top view
|
||||
Button
|
||||
{
|
||||
iconSource: UM.Theme.getIcon("view_top")
|
||||
style: UM.Theme.styles.small_tool_button
|
||||
anchors.verticalCenter: viewOrientationControl.verticalCenter
|
||||
onClicked: UM.Controller.rotateView("y", 90)
|
||||
visible: base.width - allItemsWidth - 2 * this.width > 0
|
||||
}
|
||||
|
||||
// #4 Left view
|
||||
Button
|
||||
{
|
||||
iconSource: UM.Theme.getIcon("view_left")
|
||||
style: UM.Theme.styles.small_tool_button
|
||||
anchors.verticalCenter: viewOrientationControl.verticalCenter
|
||||
onClicked: UM.Controller.rotateView("x", 90)
|
||||
visible: base.width - allItemsWidth - 1 * this.width > 0
|
||||
}
|
||||
|
||||
// #5 Right view
|
||||
Button
|
||||
{
|
||||
iconSource: UM.Theme.getIcon("view_right")
|
||||
style: UM.Theme.styles.small_tool_button
|
||||
anchors.verticalCenter: viewOrientationControl.verticalCenter
|
||||
onClicked: UM.Controller.rotateView("x", -90)
|
||||
visible: base.width - allItemsWidth > 0
|
||||
}
|
||||
}
|
||||
|
||||
ComboBox
|
||||
{
|
||||
id: viewModeButton
|
||||
|
||||
anchors {
|
||||
verticalCenter: parent.verticalCenter
|
||||
right: parent.right
|
||||
rightMargin: rightMargin
|
||||
}
|
||||
|
||||
style: UM.Theme.styles.combobox
|
||||
visible: UM.Controller.activeStage.stageId != "MonitorStage"
|
||||
|
||||
model: UM.ViewModel { }
|
||||
textRole: "name"
|
||||
|
||||
// update the model's active index
|
||||
function updateItemActiveFlags () {
|
||||
currentIndex = getActiveIndex()
|
||||
for (var i = 0; i < model.rowCount(); i++) {
|
||||
model.getItem(i).active = (i == currentIndex)
|
||||
}
|
||||
}
|
||||
|
||||
// get the index of the active model item on start
|
||||
function getActiveIndex () {
|
||||
for (var i = 0; i < model.rowCount(); i++) {
|
||||
if (model.getItem(i).active) {
|
||||
return i
|
||||
}
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// set the active index
|
||||
function setActiveIndex (index) {
|
||||
UM.Controller.setActiveView(index)
|
||||
// the connection to UM.ActiveView will trigger update so there is no reason to call it manually here
|
||||
}
|
||||
|
||||
onCurrentIndexChanged:
|
||||
{
|
||||
if (model.getItem(currentIndex).id != undefined)
|
||||
viewModeButton.setActiveIndex(model.getItem(currentIndex).id)
|
||||
}
|
||||
currentIndex: getActiveIndex()
|
||||
|
||||
// watch the active view proxy for changes made from the menu item
|
||||
Connections
|
||||
{
|
||||
target: UM.ActiveView
|
||||
onActiveViewChanged: viewModeButton.updateItemActiveFlags()
|
||||
}
|
||||
}
|
||||
|
||||
Loader
|
||||
{
|
||||
id: view_panel
|
||||
|
||||
anchors.top: viewModeButton.bottom
|
||||
anchors.topMargin: UM.Theme.getSize("default_margin").height
|
||||
anchors.right: viewModeButton.right
|
||||
|
||||
property var buttonTarget: Qt.point(viewModeButton.x + Math.round(viewModeButton.width / 2), viewModeButton.y + Math.round(viewModeButton.height / 2))
|
||||
|
||||
height: childrenRect.height
|
||||
width: childrenRect.width
|
||||
|
||||
source: UM.ActiveView.valid ? UM.ActiveView.activeViewPanel : "";
|
||||
}
|
||||
|
||||
// Expand or collapse sidebar
|
||||
Connections
|
||||
{
|
||||
target: Cura.Actions.expandSidebar
|
||||
onTriggered: updateMarginsAndSizes()
|
||||
}
|
||||
|
||||
Component.onCompleted:
|
||||
{
|
||||
updateMarginsAndSizes();
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue