QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
PlanPanelTabBar.qml
Go to the documentation of this file.
1import QtQuick
2import QtQuick.Controls
3
4import QGroundControl
5import QGroundControl.Controls
6
7/// Column of tab pills, styled like QGCGroupBox header buttons. Pills show vertical text when there is room and icons
8/// otherwise. The right side of each pill is padding meant to sit under the panel it is attached to.
9Column {
10 id: root
11
12 property var model: [] ///< Entries from PlanPanelLogic.tabModel()
13 property string currentTab
14 property string style: "icon" ///< "text" or "icon"
15
16 signal tabClicked(string tab)
17
18 readonly property bool _textStyle: style === "text"
19 readonly property var _icons: ({
20 "plan": "/qmlimages/Plan.svg",
21 "mission": "/res/waypoint.svg",
22 "fence": "/res/GeoFence.svg",
23 "rally": "/res/RallyPoint.svg"
24 })
25 readonly property var _labels: ({
26 "plan": qsTr("Plan"),
27 "mission": qsTr("Mission"),
28 "fence": qsTr("Fence"),
29 "rally": qsTr("Rally")
30 })
31
32 spacing: ScreenTools.defaultFontPixelWidth / 2
33
34 Repeater {
35 model: root.model
36
37 AbstractButton {
38 id: pill
39
40 required property var modelData
41
42 readonly property bool current: modelData.id === root.currentTab
43
44 objectName: "planPanel_tab_" + modelData.id
45 text: root._labels[modelData.id]
46 enabled: modelData.enabled
47 implicitWidth: ScreenTools.defaultFontPixelHeight * 2.2
48 implicitHeight: root._textStyle ? ScreenTools.defaultFontPixelHeight * 1.5 + tabText.implicitWidth : ScreenTools.defaultFontPixelHeight * 2.6
49 rightPadding: ScreenTools.defaultBorderRadius * 2
50 hoverEnabled: !ScreenTools.isMobile
51 focusPolicy: Qt.ClickFocus
52
53 Accessible.name: text
54
55 onClicked: root.tabClicked(modelData.id)
56
57 QGCPalette { id: pillPal; colorGroupEnabled: pill.enabled }
58
59 background: Rectangle {
60 radius: ScreenTools.defaultBorderRadius
61 color: pill.current ? pillPal.accentSubtle : pillPal.windowPanel
62 border.width: 1
63 border.color: pill.current || pill.hovered || pill.pressed ? pillPal.accent : pillPal.borderSubtle
64 }
65
66 contentItem: Item {
67 QGCColoredImage {
68 anchors.centerIn: parent
69 width: ScreenTools.defaultFontPixelHeight
70 height: width
71 visible: !root._textStyle
72 source: root._icons[pill.modelData.id]
73 color: pillPal.textPrimary
74 fillMode: Image.PreserveAspectFit
75 sourceSize.height: height
76 }
77
78 QGCLabel {
79 id: tabText
80 anchors.centerIn: parent
81 rotation: -90
82 visible: root._textStyle
83 text: pill.text
84 color: pillPal.textPrimary
85 }
86 }
87
88 // Warning dot at the top-left corner of the pill, overlapping the icon or the end of the text a little
89 Rectangle {
90 id: badge
91
92 readonly property real margin: ScreenTools.defaultFontPixelHeight * 0.25
93
94 objectName: "planPanel_tabBadge_" + pill.modelData.id
95 x: margin
96 y: margin
97 z: 1
98 width: ScreenTools.defaultFontPixelHeight * 0.6
99 height: width
100 radius: width / 2
101 visible: pill.modelData.warn
102 color: pillPal.colorOrange
103 }
104 }
105 }
106}