QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
LabelledFactBrowse.qml
Go to the documentation of this file.
1import QtQuick
2import QtQuick.Layouts
3
4import QGroundControl
5import QGroundControl.Controls
6import QGroundControl.FactControls
7
8/// File or folder browser control for a string-valued Fact.
9/// Shows a label, the current path (or a default placeholder), and a
10/// "Browse" button that opens a native file dialog.
11///
12/// Properties:
13/// fact - The string Fact whose rawValue stores the path (required).
14/// label - Display label (defaults to fact.shortDescription).
15/// dialogTitle - Title for the file dialog (defaults to label).
16/// selectFolder - true to browse folders, false for files (default true).
17/// defaultText - Placeholder shown when the Fact value is empty.
18RowLayout {
19 id: root
20
21 property string label: fact.shortDescription
22 property Fact fact
23 property string dialogTitle: label
24 property bool selectFolder: true
25 property string defaultText: qsTr("<not set>")
26
27 spacing: ScreenTools.defaultFontPixelWidth * 2
28
29 ColumnLayout {
30 Layout.fillWidth: true
31 Layout.minimumWidth: implicitWidth
32 spacing: 0
33
34 QGCLabel {
35 Layout.fillWidth: true
36 text: root.label
37 }
38
39 QGCLabel {
40 Layout.fillWidth: true
41 font.pointSize: ScreenTools.smallFontPointSize
42 text: root.fact.rawValue === "" ? root.defaultText : root.fact.value
43 elide: Text.ElideMiddle
44 }
45 }
46
47 QGCButton {
48 text: qsTr("Browse")
49 onClicked: _browseDialog.openForLoad()
50
51 QGCFileDialog {
52 id: _browseDialog
53 title: root.dialogTitle
54 folder: root.fact.rawValue
55 selectFolder: root.selectFolder
56 onAcceptedForLoad: (file) => root.fact.rawValue = file
57 }
58 }
59}