mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-25 15:44:04 -06:00
Merge branch 'CURA-5785-Restyle_stage_menu' into CURA-5942_printer_selector
This commit is contained in:
commit
4772972145
6 changed files with 199 additions and 161 deletions
|
@ -24,74 +24,62 @@ Item
|
||||||
Item
|
Item
|
||||||
{
|
{
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
width: openFileButtonBackground.width + itemRowBackground.width
|
width: openFileButtonBackground.width + itemRow.width + UM.Theme.getSize("default_margin").width
|
||||||
height: parent.height
|
height: parent.height
|
||||||
|
|
||||||
Rectangle
|
RowLayout
|
||||||
{
|
{
|
||||||
id: itemRowBackground
|
id: itemRow
|
||||||
radius: UM.Theme.getSize("default_radius").width
|
|
||||||
|
|
||||||
color: UM.Theme.getColor("toolbar_background")
|
|
||||||
|
|
||||||
width: itemRow.width + UM.Theme.getSize("default_margin").width
|
|
||||||
height: parent.height
|
|
||||||
|
|
||||||
anchors.left: openFileButtonBackground.right
|
anchors.left: openFileButtonBackground.right
|
||||||
anchors.leftMargin: UM.Theme.getSize("default_margin").width
|
anchors.leftMargin: UM.Theme.getSize("default_margin").width
|
||||||
|
|
||||||
RowLayout
|
width: Math.round(0.9 * prepareMenu.width)
|
||||||
|
height: parent.height
|
||||||
|
spacing: 0
|
||||||
|
|
||||||
|
Cura.MachineSelector
|
||||||
{
|
{
|
||||||
id: itemRow
|
id: machineSelection
|
||||||
|
z: openFileButtonBackground.z - 1 //Ensure that the tooltip of the open file button stays above the item row.
|
||||||
|
headerCornerSide: Cura.RoundedRectangle.Direction.Left
|
||||||
|
Layout.minimumWidth: UM.Theme.getSize("machine_selector_widget").width
|
||||||
|
Layout.maximumWidth: UM.Theme.getSize("machine_selector_widget").width
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.fillHeight: true
|
||||||
|
}
|
||||||
|
|
||||||
anchors.centerIn: parent
|
// Separator line
|
||||||
|
Rectangle
|
||||||
width: Math.round(0.9 * prepareMenu.width)
|
{
|
||||||
height: parent.height
|
height: parent.height
|
||||||
spacing: 0
|
width: UM.Theme.getSize("default_lining").width
|
||||||
|
color: UM.Theme.getColor("lining")
|
||||||
|
}
|
||||||
|
|
||||||
Cura.MachineSelector
|
Cura.QuickConfigurationSelector
|
||||||
{
|
{
|
||||||
id: machineSelection
|
Layout.fillHeight: true
|
||||||
z: openFileButtonBackground.z - 1 //Ensure that the tooltip of the open file button stays above the item row.
|
Layout.fillWidth: true
|
||||||
Layout.minimumWidth: UM.Theme.getSize("machine_selector_widget").width
|
Layout.preferredWidth: itemRow.width - machineSelection.width - printSetupSelectorItem.width - 2 * UM.Theme.getSize("default_lining").width
|
||||||
Layout.maximumWidth: UM.Theme.getSize("machine_selector_widget").width
|
}
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.fillHeight: true
|
|
||||||
}
|
|
||||||
|
|
||||||
// Separator line
|
// Separator line
|
||||||
Rectangle
|
Rectangle
|
||||||
{
|
{
|
||||||
height: parent.height
|
height: parent.height
|
||||||
width: UM.Theme.getSize("default_lining").width
|
width: UM.Theme.getSize("default_lining").width
|
||||||
color: UM.Theme.getColor("lining")
|
color: UM.Theme.getColor("lining")
|
||||||
}
|
}
|
||||||
|
|
||||||
Cura.QuickConfigurationSelector
|
Item
|
||||||
{
|
{
|
||||||
Layout.fillHeight: true
|
id: printSetupSelectorItem
|
||||||
Layout.fillWidth: true
|
// This is a work around to prevent the printSetupSelector from having to be re-loaded every time
|
||||||
Layout.preferredWidth: itemRow.width - machineSelection.width - printSetupSelectorItem.width - 2 * UM.Theme.getSize("default_lining").width
|
// a stage switch is done.
|
||||||
}
|
children: [printSetupSelector]
|
||||||
|
height: childrenRect.height
|
||||||
// Separator line
|
width: childrenRect.width
|
||||||
Rectangle
|
|
||||||
{
|
|
||||||
height: parent.height
|
|
||||||
width: UM.Theme.getSize("default_lining").width
|
|
||||||
color: UM.Theme.getColor("lining")
|
|
||||||
}
|
|
||||||
|
|
||||||
Item
|
|
||||||
{
|
|
||||||
id: printSetupSelectorItem
|
|
||||||
// This is a work around to prevent the printSetupSelector from having to be re-loaded every time
|
|
||||||
// a stage switch is done.
|
|
||||||
children: [printSetupSelector]
|
|
||||||
height: childrenRect.height
|
|
||||||
width: childrenRect.width
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,6 +91,7 @@ Item
|
||||||
|
|
||||||
radius: UM.Theme.getSize("default_radius").width
|
radius: UM.Theme.getSize("default_radius").width
|
||||||
color: UM.Theme.getColor("toolbar_background")
|
color: UM.Theme.getColor("toolbar_background")
|
||||||
|
|
||||||
Button
|
Button
|
||||||
{
|
{
|
||||||
id: openFileButton
|
id: openFileButton
|
||||||
|
|
|
@ -22,130 +22,122 @@ Item
|
||||||
name: "cura"
|
name: "cura"
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle
|
|
||||||
{
|
|
||||||
anchors.fill: stageMenu
|
|
||||||
anchors.leftMargin: -radius
|
|
||||||
radius: UM.Theme.getSize("default_radius").width
|
|
||||||
color: UM.Theme.getColor("toolbar_background")
|
|
||||||
}
|
|
||||||
|
|
||||||
Item
|
Row
|
||||||
{
|
{
|
||||||
id: stageMenu
|
id: stageMenuRow
|
||||||
|
anchors.centerIn: parent
|
||||||
height: parent.height
|
height: parent.height
|
||||||
width: stageMenuRow.width + UM.Theme.getSize("default_margin").width
|
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
Cura.ExpandableComponent
|
||||||
Row
|
|
||||||
{
|
{
|
||||||
id: stageMenuRow
|
id: viewSelector
|
||||||
anchors.centerIn: parent
|
iconSource: expanded ? UM.Theme.getIcon("arrow_bottom") : UM.Theme.getIcon("arrow_left")
|
||||||
height: parent.height
|
height: parent.height
|
||||||
|
headerCornerSide: Cura.RoundedRectangle.Direction.Left
|
||||||
|
|
||||||
Cura.ExpandableComponent
|
property var viewModel: UM.ViewModel { }
|
||||||
|
|
||||||
|
property var activeView:
|
||||||
{
|
{
|
||||||
id: viewSelector
|
for (var i = 0; i < viewModel.rowCount(); i++)
|
||||||
iconSource: expanded ? UM.Theme.getIcon("arrow_bottom") : UM.Theme.getIcon("arrow_left")
|
|
||||||
height: parent.height
|
|
||||||
|
|
||||||
property var viewModel: UM.ViewModel { }
|
|
||||||
|
|
||||||
property var activeView:
|
|
||||||
{
|
{
|
||||||
for (var i = 0; i < viewModel.rowCount(); i++)
|
if (viewModel.items[i].active)
|
||||||
{
|
{
|
||||||
if (viewModel.getItem(i).active)
|
return viewModel.items[i]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
Component.onCompleted:
|
||||||
|
{
|
||||||
|
// Nothing was active, so just return the first one (the list is sorted by priority, so the most
|
||||||
|
// important one should be returned)
|
||||||
|
if(activeView == null)
|
||||||
|
{
|
||||||
|
UM.Controller.setActiveView(viewModel.getItem(0).id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
headerItem: Label
|
||||||
|
{
|
||||||
|
text: viewSelector.activeView ? viewSelector.activeView.name : ""
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
height: parent.height
|
||||||
|
elide: Text.ElideRight
|
||||||
|
font: UM.Theme.getFont("default")
|
||||||
|
color: UM.Theme.getColor("text")
|
||||||
|
}
|
||||||
|
|
||||||
|
popupItem: Column
|
||||||
|
{
|
||||||
|
id: viewSelectorPopup
|
||||||
|
width: viewSelector.width - 2 * UM.Theme.getSize("default_margin").width
|
||||||
|
|
||||||
|
// For some reason the height/width of the column gets set to 0 if this is not set...
|
||||||
|
Component.onCompleted:
|
||||||
|
{
|
||||||
|
height = implicitHeight
|
||||||
|
width = viewSelector.width - 2 * UM.Theme.getSize("default_margin").width
|
||||||
|
}
|
||||||
|
|
||||||
|
Repeater
|
||||||
|
{
|
||||||
|
id: viewsList
|
||||||
|
model: viewSelector.viewModel
|
||||||
|
RoundButton
|
||||||
|
{
|
||||||
|
text: name
|
||||||
|
radius: UM.Theme.getSize("default_radius").width
|
||||||
|
checkable: true
|
||||||
|
checked: viewSelector.activeView != null ? viewSelector.activeView.id == id : false
|
||||||
|
onClicked:
|
||||||
{
|
{
|
||||||
return viewModel.getItem(i)
|
viewSelector.togglePopup()
|
||||||
|
UM.Controller.setActiveView(id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Nothing was active, so just return the first one (the list is sorted by priority, so the most
|
|
||||||
// important one should be returned)
|
|
||||||
return viewModel.getItem(0)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure that the controller is synced with whatever happend here.
|
|
||||||
onActiveViewChanged: UM.Controller.setActiveView(activeView.id)
|
|
||||||
|
|
||||||
headerItem: Label
|
|
||||||
{
|
|
||||||
text: viewSelector.activeView.name
|
|
||||||
verticalAlignment: Text.AlignVCenter
|
|
||||||
height: parent.height
|
|
||||||
elide: Text.ElideRight
|
|
||||||
font: UM.Theme.getFont("default")
|
|
||||||
color: UM.Theme.getColor("text")
|
|
||||||
}
|
|
||||||
|
|
||||||
popupItem: Column
|
|
||||||
{
|
|
||||||
id: viewSelectorPopup
|
|
||||||
width: viewSelector.width - 2 * UM.Theme.getSize("default_margin").width
|
|
||||||
|
|
||||||
// For some reason the height/width of the column gets set to 0 if this is not set...
|
|
||||||
Component.onCompleted:
|
|
||||||
{
|
|
||||||
height = implicitHeight
|
|
||||||
width = viewSelector.width - 2 * UM.Theme.getSize("default_margin").width
|
|
||||||
}
|
|
||||||
|
|
||||||
Repeater
|
|
||||||
{
|
|
||||||
id: viewsList
|
|
||||||
model: viewSelector.viewModel
|
|
||||||
RoundButton
|
|
||||||
{
|
|
||||||
text: name
|
|
||||||
radius: UM.Theme.getSize("default_radius").width
|
|
||||||
checkable: true
|
|
||||||
checked: active
|
|
||||||
onClicked:
|
|
||||||
{
|
|
||||||
viewSelector.togglePopup()
|
|
||||||
UM.Controller.setActiveView(id)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Separator line
|
// Separator line
|
||||||
Rectangle
|
Rectangle
|
||||||
{
|
{
|
||||||
height: parent.height
|
height: parent.height
|
||||||
// If there is no viewPanel, we only need a single spacer, so hide this one.
|
// If there is no viewPanel, we only need a single spacer, so hide this one.
|
||||||
visible: viewPanel.source != ""
|
visible: viewPanel.source != ""
|
||||||
width: visible ? UM.Theme.getSize("default_lining").width : 0
|
width: visible ? UM.Theme.getSize("default_lining").width : 0
|
||||||
|
|
||||||
color: UM.Theme.getColor("lining")
|
color: UM.Theme.getColor("lining")
|
||||||
}
|
}
|
||||||
|
|
||||||
Loader
|
Loader
|
||||||
{
|
{
|
||||||
id: viewPanel
|
id: viewPanel
|
||||||
height: parent.height
|
height: parent.height
|
||||||
width: childrenRect.width
|
width: childrenRect.width
|
||||||
source: UM.Controller.activeView != null && UM.Controller.activeView.stageMenuComponent != null ? UM.Controller.activeView.stageMenuComponent : ""
|
source: UM.Controller.activeView != null && UM.Controller.activeView.stageMenuComponent != null ? UM.Controller.activeView.stageMenuComponent : ""
|
||||||
}
|
}
|
||||||
|
|
||||||
// Separator line
|
// Separator line
|
||||||
Rectangle
|
Rectangle
|
||||||
{
|
{
|
||||||
height: parent.height
|
height: parent.height
|
||||||
width: UM.Theme.getSize("default_lining").width
|
width: UM.Theme.getSize("default_lining").width
|
||||||
color: UM.Theme.getColor("lining")
|
color: UM.Theme.getColor("lining")
|
||||||
}
|
}
|
||||||
|
|
||||||
Item
|
Item
|
||||||
{
|
{
|
||||||
id: printSetupSelectorItem
|
id: printSetupSelectorItem
|
||||||
// This is a work around to prevent the printSetupSelector from having to be re-loaded every time
|
// This is a work around to prevent the printSetupSelector from having to be re-loaded every time
|
||||||
// a stage switch is done.
|
// a stage switch is done.
|
||||||
children: [printSetupSelector]
|
children: [printSetupSelector]
|
||||||
height: childrenRect.height
|
height: childrenRect.height
|
||||||
width: childrenRect.width
|
width: childrenRect.width
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -259,6 +259,7 @@ UM.MainWindow
|
||||||
onHideTooltip: base.hideTooltip()
|
onHideTooltip: base.hideTooltip()
|
||||||
width: UM.Theme.getSize("print_setup_widget").width
|
width: UM.Theme.getSize("print_setup_widget").width
|
||||||
height: UM.Theme.getSize("stage_menu").height
|
height: UM.Theme.getSize("stage_menu").height
|
||||||
|
headerCornerSide: RoundedRectangle.Direction.Right
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,7 @@ UM.Dialog
|
||||||
{
|
{
|
||||||
top: parent.top
|
top: parent.top
|
||||||
left: parent.left
|
left: parent.left
|
||||||
topMargin: UM.Theme.getSize("default_margin")
|
topMargin: UM.Theme.getSize("default_margin").height
|
||||||
}
|
}
|
||||||
text: catalog.i18nc("@title:tab", "Add a printer to Cura")
|
text: catalog.i18nc("@title:tab", "Add a printer to Cura")
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,12 @@ Item
|
||||||
|
|
||||||
property alias expandedHighlightColor: expandedHighlight.color
|
property alias expandedHighlightColor: expandedHighlight.color
|
||||||
|
|
||||||
|
// What should the radius of the header be. This is also influenced by the headerCornerSide
|
||||||
|
property alias headerRadius: background.radius
|
||||||
|
|
||||||
|
// On what side should the header corners be shown? 1 is down, 2 is left, 3 is up and 4 is right.
|
||||||
|
property alias headerCornerSide: background.cornerSide
|
||||||
|
|
||||||
function togglePopup()
|
function togglePopup()
|
||||||
{
|
{
|
||||||
if(popup.visible)
|
if(popup.visible)
|
||||||
|
@ -81,7 +87,8 @@ Item
|
||||||
|
|
||||||
implicitHeight: 100 * screenScaleFactor
|
implicitHeight: 100 * screenScaleFactor
|
||||||
implicitWidth: 400 * screenScaleFactor
|
implicitWidth: 400 * screenScaleFactor
|
||||||
Rectangle
|
|
||||||
|
RoundedRectangle
|
||||||
{
|
{
|
||||||
id: background
|
id: background
|
||||||
property real padding: UM.Theme.getSize("default_margin").width
|
property real padding: UM.Theme.getSize("default_margin").width
|
||||||
|
|
49
resources/qml/RoundedRectangle.qml
Normal file
49
resources/qml/RoundedRectangle.qml
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
import QtQuick 2.7
|
||||||
|
|
||||||
|
import UM 1.2 as UM
|
||||||
|
|
||||||
|
// The rounded rectangle works mostly like a regular rectangle, but provides the option to have rounded corners on only one side of the rectangle.
|
||||||
|
Item
|
||||||
|
{
|
||||||
|
// As per the regular rectangle
|
||||||
|
property color color: "transparent"
|
||||||
|
|
||||||
|
// As per regular rectangle
|
||||||
|
property int radius: UM.Theme.getSize("default_radius").width
|
||||||
|
|
||||||
|
// On what side should the corners be shown 5 can be used if no radius is needed.
|
||||||
|
// 1 is down, 2 is left, 3 is up and 4 is right.
|
||||||
|
property int cornerSide: RoundedRectangle.Direction.None
|
||||||
|
|
||||||
|
enum Direction
|
||||||
|
{
|
||||||
|
None = 0,
|
||||||
|
Down = 1,
|
||||||
|
Left = 2,
|
||||||
|
Up = 3,
|
||||||
|
Right = 4,
|
||||||
|
All = 5
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle
|
||||||
|
{
|
||||||
|
id: background
|
||||||
|
anchors.fill: parent
|
||||||
|
radius: cornerSide != RoundedRectangle.Direction.None ? parent.radius : 0
|
||||||
|
color: parent.color
|
||||||
|
}
|
||||||
|
|
||||||
|
// The item that covers 2 of the corners to make them not rounded.
|
||||||
|
Rectangle
|
||||||
|
{
|
||||||
|
visible: cornerSide != RoundedRectangle.Direction.None && cornerSide != RoundedRectangle.Direction.All
|
||||||
|
height: cornerSide % 2 ? parent.radius: parent.height
|
||||||
|
width: cornerSide % 2 ? parent.width : parent.radius
|
||||||
|
color: parent.color
|
||||||
|
anchors
|
||||||
|
{
|
||||||
|
right: cornerSide == RoundedRectangle.Direction.Left ? parent.right: undefined
|
||||||
|
bottom: cornerSide == RoundedRectangle.Direction.Up ? parent.bottom: undefined
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue