2023-03-08 01:56:41 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Shapes 1.15
|
2023-10-25 10:38:56 +00:00
|
|
|
import QtQuick.Layouts 1.15
|
2023-03-08 01:56:41 +00:00
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
|
|
|
|
import utils 1.0
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\qmltype ShapeRectangle
|
|
|
|
\inherits Shape
|
|
|
|
\brief Rectangle-like component with the ability to further customize the outline/border style using a Shape/ShapePath;
|
|
|
|
with optional text in the middle
|
|
|
|
|
|
|
|
Example of how to use it:
|
|
|
|
|
|
|
|
\qml
|
|
|
|
ShapeRectangle {
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
Layout.preferredWidth: parent.width - 4 // the rectangular path is rendered outside
|
|
|
|
Layout.preferredHeight: 44
|
|
|
|
text: qsTr("Your links will appear here")
|
|
|
|
}
|
|
|
|
\endqml
|
|
|
|
|
|
|
|
\sa Shape
|
|
|
|
\sa ShapePath
|
|
|
|
*/
|
|
|
|
Shape {
|
|
|
|
id: root
|
|
|
|
|
2023-10-25 10:38:56 +00:00
|
|
|
property string icon
|
2023-03-08 01:56:41 +00:00
|
|
|
property string text
|
2023-05-02 08:01:04 +00:00
|
|
|
property color textColor: Theme.palette.baseColor1
|
|
|
|
property alias font: description.font
|
2023-03-08 01:56:41 +00:00
|
|
|
|
2023-03-20 12:29:05 +00:00
|
|
|
property int radius: Style.current.radius
|
2023-09-26 14:12:33 +00:00
|
|
|
property int leftTopRadius: radius
|
|
|
|
property int rightTopRadius: radius
|
|
|
|
property int leftBottomRadius: radius
|
|
|
|
property int rightBottomRadius: radius
|
2023-03-08 01:56:41 +00:00
|
|
|
readonly property alias path: path
|
|
|
|
|
|
|
|
asynchronous: true
|
|
|
|
|
|
|
|
// design values; Shape doesn't have an implicit size
|
|
|
|
implicitWidth: 448
|
|
|
|
implicitHeight: 44
|
|
|
|
|
2023-10-25 10:38:56 +00:00
|
|
|
RowLayout {
|
|
|
|
spacing: 4
|
2023-03-08 01:56:41 +00:00
|
|
|
anchors.centerIn: parent
|
2023-10-25 10:38:56 +00:00
|
|
|
|
|
|
|
StatusIcon {
|
|
|
|
id: icon
|
|
|
|
|
|
|
|
visible: root.icon
|
|
|
|
color: root.textColor
|
|
|
|
icon: root.icon
|
|
|
|
width: 16
|
|
|
|
height: width
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
id: description
|
|
|
|
color: root.textColor
|
|
|
|
text: root.text
|
|
|
|
font.pixelSize: 13
|
|
|
|
visible: !!text
|
|
|
|
}
|
2023-03-08 01:56:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ShapePath {
|
|
|
|
id: path
|
|
|
|
fillColor: "transparent"
|
|
|
|
strokeColor: Theme.palette.baseColor2
|
|
|
|
strokeWidth: 1
|
|
|
|
strokeStyle: ShapePath.DashLine
|
|
|
|
dashPattern: [4, 4]
|
|
|
|
|
2023-09-26 14:12:33 +00:00
|
|
|
startX: root.leftTopRadius
|
2023-03-08 01:56:41 +00:00
|
|
|
startY: 0
|
|
|
|
PathLine {
|
2023-09-26 14:12:33 +00:00
|
|
|
x: root.width - root.rightTopRadius
|
2023-03-08 01:56:41 +00:00
|
|
|
y: 0
|
|
|
|
}
|
2023-09-26 14:12:33 +00:00
|
|
|
PathArc {
|
2023-03-08 01:56:41 +00:00
|
|
|
x: root.width
|
2023-09-26 14:12:33 +00:00
|
|
|
y: root.rightTopRadius
|
|
|
|
radiusX: root.rightTopRadius
|
|
|
|
radiusY: root.rightTopRadius
|
2023-03-08 01:56:41 +00:00
|
|
|
}
|
|
|
|
PathLine {
|
|
|
|
x: root.width
|
2023-09-26 14:12:33 +00:00
|
|
|
y: root.height - root.rightBottomRadius
|
2023-03-08 01:56:41 +00:00
|
|
|
}
|
2023-09-26 14:12:33 +00:00
|
|
|
PathArc {
|
|
|
|
x:root.width - root.rightBottomRadius
|
2023-03-08 01:56:41 +00:00
|
|
|
y: root.height
|
2023-09-26 14:12:33 +00:00
|
|
|
radiusX: root.rightBottomRadius
|
|
|
|
radiusY: root.rightBottomRadius
|
2023-03-08 01:56:41 +00:00
|
|
|
}
|
|
|
|
PathLine {
|
2023-09-26 14:12:33 +00:00
|
|
|
x: root.leftBottomRadius
|
2023-03-08 01:56:41 +00:00
|
|
|
y: root.height
|
|
|
|
}
|
2023-09-26 14:12:33 +00:00
|
|
|
PathArc {
|
|
|
|
x:0
|
|
|
|
y: root.height - root.leftBottomRadius
|
|
|
|
radiusX: root.leftBottomRadius;
|
|
|
|
radiusY: root.leftBottomRadius
|
2023-03-08 01:56:41 +00:00
|
|
|
}
|
|
|
|
PathLine {
|
|
|
|
x: 0
|
2023-09-26 14:12:33 +00:00
|
|
|
y: root.leftTopRadius
|
2023-03-08 01:56:41 +00:00
|
|
|
}
|
2023-09-26 14:12:33 +00:00
|
|
|
PathArc {
|
|
|
|
x:root.leftTopRadius
|
2023-03-08 01:56:41 +00:00
|
|
|
y: 0
|
2023-09-26 14:12:33 +00:00
|
|
|
radiusX: root.leftTopRadius
|
|
|
|
radiusY: root.leftTopRadius
|
2023-03-08 01:56:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|