Added enum for the roundedCorner property

This makes it a whole lot easier to read what is being set.

CURA-5785
This commit is contained in:
Jaime van Kessel 2018-11-21 11:50:39 +01:00
parent b826a42026
commit eef6ad662d
4 changed files with 20 additions and 10 deletions

View file

@ -42,7 +42,7 @@ Item
{
id: machineSelection
z: openFileButtonBackground.z - 1 //Ensure that the tooltip of the open file button stays above the item row.
headerCornerSide: 2 // Show corners on the left.
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

View file

@ -34,7 +34,7 @@ Item
id: viewSelector
iconSource: expanded ? UM.Theme.getIcon("arrow_bottom") : UM.Theme.getIcon("arrow_left")
height: parent.height
headerCornerSide: 2 // Show corners on the left side
headerCornerSide: Cura.RoundedRectangle.Direction.Left
property var viewModel: UM.ViewModel { }

View file

@ -259,7 +259,7 @@ UM.MainWindow
onHideTooltip: base.hideTooltip()
width: UM.Theme.getSize("print_setup_widget").width
height: UM.Theme.getSize("stage_menu").height
headerCornerSide: 4 // Show corners on the right side
headerCornerSide: RoundedRectangle.Direction.Right
}
}

View file

@ -1,4 +1,4 @@
import QtQuick 2.0
import QtQuick 2.7
import UM 1.2 as UM
@ -11,29 +11,39 @@ Item
// As per regular rectangle
property int radius: UM.Theme.getSize("default_radius").width
// On what side should the corners be shown 0 can be used if no radius is needed.
// 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: 0
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 != 0 ? parent.radius : 0
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 != 0
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 == 2 ? parent.right: undefined
bottom: cornerSide == 3 ? parent.bottom: undefined
right: cornerSide == RoundedRectangle.Direction.Left ? parent.right: undefined
bottom: cornerSide == RoundedRectangle.Direction.Up ? parent.bottom: undefined
}
}
}