QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
QGCTabButton.qml
Go to the documentation of this file.
1import QtQuick
2import QtQuick.Controls
3import QtQuick.Layouts
4
5import QGroundControl
6import QGroundControl.Controls
7
8// We implement our own TabButton to get around the fact that QtQuick.Controls TabBar does not
9// support hiding tabs. This version supports hiding tabs by setting the visible property
10// on the QGCTabButton instances.
11Button {
12 id: control
13 Layout.fillWidth: true
14 topPadding: _verticalPadding
15 bottomPadding: _verticalPadding
16 leftPadding: _horizontalPadding
17 rightPadding: _horizontalPadding
18 focusPolicy: Qt.ClickFocus
19 checkable: true
20
21 property bool primary: false ///< primary button for a group of buttons
22 property real pointSize: ScreenTools.defaultFontPointSize ///< Point size for button text
23 property bool showBorder: qgcPal.globalTheme === QGCPalette.Light
24 property real backRadius: ScreenTools.defaultBorderRadius
25 property real heightFactor: 0.5
26
27 property bool _showHighlight: enabled && (pressed | checked)
28 property int _horizontalPadding: ScreenTools.defaultFontPixelWidth
29 property int _verticalPadding: Math.round(ScreenTools.defaultFontPixelHeight * heightFactor)
30 property bool _showIcon: control.icon.source != ""
31
32 QGCPalette { id: qgcPal; colorGroupEnabled: enabled }
33
34 background: Rectangle {
35 id: backRect
36 implicitWidth: ScreenTools.implicitButtonWidth
37 implicitHeight: ScreenTools.implicitButtonHeight
38 //radius: backRadius
39 border.width: showBorder ? 1 : 0
40 border.color: qgcPal.buttonBorder
41 color: _showHighlight ? qgcPal.buttonHighlight : qgcPal.button
42 }
43
44 contentItem: Item {
45 implicitWidth: _showIcon ? icon.width : text.implicitWidth
46 implicitHeight: _showIcon ? icon.height : text.implicitHeight
47 baselineOffset: text.y + text.baselineOffset
48
49 QGCColoredImage {
50 id: icon
51 anchors.centerIn: parent
52 source: control.icon.source
53 height: source === "" ? 0 : ScreenTools.defaultFontPixelHeight
54 width: height
55 color: _showHighlight ? qgcPal.buttonHighlightText : qgcPal.buttonText
56 fillMode: Image.PreserveAspectFit
57 sourceSize.height: height
58 visible: _showIcon
59 }
60
61 Text {
62 id: text
63 anchors.centerIn: parent
64 antialiasing: true
65 text: control.text
66 font.pointSize: control.pointSize
67 font.family: ScreenTools.normalFontFamily
68 color: _showHighlight ? qgcPal.buttonHighlightText : qgcPal.buttonText
69 visible: !_showIcon
70 }
71 }
72}