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/// nameFilters - Name filters for file browsing (simple wildcards only).
18/// defaultText - Placeholder shown when the Fact value is empty.
19RowLayout {
20 id: root
21
22 property string label: fact.shortDescription
23 property Fact fact
24 property string dialogTitle: label
25 property bool selectFolder: true
26 property var nameFilters: []
27 property string defaultText: qsTr("<not set>")
28
29 spacing: ScreenTools.defaultFontPixelWidth * 2
30
31 ColumnLayout {
32 Layout.fillWidth: true
33 Layout.minimumWidth: implicitWidth
34 spacing: 0
35
36 QGCLabel {
37 Layout.fillWidth: true
38 text: root.label
39 }
40
41 QGCLabel {
42 Layout.fillWidth: true
43 font.pointSize: ScreenTools.smallFontPointSize
44 text: root.fact.rawValue === "" ? root.defaultText : root.fact.value
45 elide: Text.ElideMiddle
46 }
47 }
48
49 QGCButton {
50 text: qsTr("Browse")
51 onClicked: _browseDialog.openForLoad()
52
53 QGCFileDialog {
54 id: _browseDialog
55 title: root.dialogTitle
56 folder: root.fact.rawValue
57 selectFolder: root.selectFolder
58 nameFilters: root.nameFilters
59 onAcceptedForLoad: (file) => root.fact.rawValue = file
60 }
61 }
62}