BluetoothSettings.qml 4.92 KB
Newer Older
1 2
/****************************************************************************
 *
Gus Grubba's avatar
Gus Grubba committed
3
 * (c) 2009-2020 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
4 5 6 7 8
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/
dogmaphobic's avatar
dogmaphobic committed
9 10


11 12
import QtQuick          2.3
import QtQuick.Controls 1.2
13
import QtQuick.Dialogs  1.2
dogmaphobic's avatar
dogmaphobic committed
14 15 16 17 18 19

import QGroundControl                       1.0
import QGroundControl.Controls              1.0
import QGroundControl.ScreenTools           1.0
import QGroundControl.Palette               1.0

20 21 22 23 24
Column {
    id:                 _btSettings
    spacing:            ScreenTools.defaultFontPixelHeight * 0.5
    anchors.margins:    ScreenTools.defaultFontPixelWidth
    visible:            QGroundControl.linkManager.isBluetoothAvailable
dogmaphobic's avatar
dogmaphobic committed
25 26 27
    function saveSettings() {
        // No need
    }
28 29
    Row {
        spacing:    ScreenTools.defaultFontPixelWidth
dogmaphobic's avatar
dogmaphobic committed
30
        QGCLabel {
31 32
            text:   qsTr("Device:")
            width:  _firstColumn
dogmaphobic's avatar
dogmaphobic committed
33
        }
34 35 36
        QGCLabel {
            id:     deviceField
            text:   subEditConfig && subEditConfig.linkType === LinkConfiguration.TypeBluetooth ? subEditConfig.devName : ""
dogmaphobic's avatar
dogmaphobic committed
37
        }
38 39 40 41 42 43 44
    }
    Row {
        visible:    !ScreenTools.isiOS
        spacing:    ScreenTools.defaultFontPixelWidth
        QGCLabel {
            text:   qsTr("Address:")
            width:  _firstColumn
dogmaphobic's avatar
dogmaphobic committed
45
        }
46 47 48
        QGCLabel {
            id:     addressField
            text:   subEditConfig && subEditConfig.linkType === LinkConfiguration.TypeBluetooth ? subEditConfig.address : ""
dogmaphobic's avatar
dogmaphobic committed
49
        }
50 51 52 53 54 55 56 57 58 59 60
    }
    Item {
        height: ScreenTools.defaultFontPixelHeight / 2
        width:  parent.width
    }
    QGCLabel {
        text:   qsTr("Bluetooth Devices:")
    }
    Item {
        width:  hostRow.width
        height: hostRow.height
dogmaphobic's avatar
dogmaphobic committed
61
        Row {
62 63 64 65
            id:      hostRow
            spacing: ScreenTools.defaultFontPixelWidth
            Item {
                height: 1
dogmaphobic's avatar
dogmaphobic committed
66 67
                width:  _firstColumn
            }
68 69 70 71 72 73 74 75
            Column {
                id:         hostColumn
                spacing:    ScreenTools.defaultFontPixelHeight / 2
                Rectangle {
                    height:  1
                    width:   _secondColumn
                    color:   qgcPal.button
                    visible: subEditConfig && subEditConfig.linkType === LinkConfiguration.TypeBluetooth && subEditConfig.nameList.length > 0
dogmaphobic's avatar
dogmaphobic committed
76
                }
77 78 79 80
                Repeater {
                    model: subEditConfig && subEditConfig.linkType === LinkConfiguration.TypeBluetooth ? subEditConfig.nameList : ""
                    delegate:
                    QGCButton {
81 82
                        text:               modelData
                        width:              _secondColumn
83
                        anchors.leftMargin: ScreenTools.defaultFontPixelWidth * 2
84
                        autoExclusive:      true
85 86 87 88 89
                        onClicked: {
                            checked = true
                            if(subEditConfig && modelData !== "")
                                subEditConfig.devName = modelData
                        }
dogmaphobic's avatar
dogmaphobic committed
90
                    }
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
                }
                Rectangle {
                    height: 1
                    width:  _secondColumn
                    color:  qgcPal.button
                }
                Item {
                    height: ScreenTools.defaultFontPixelHeight / 2
                    width:  parent.width
                }
                Item {
                    width:  _secondColumn
                    height: udpButtonRow.height
                    Row {
                        id:         udpButtonRow
                        spacing:    ScreenTools.defaultFontPixelWidth
                        anchors.horizontalCenter: parent.horizontalCenter
dogmaphobic's avatar
dogmaphobic committed
108
                        QGCButton {
109 110 111
                            width:      ScreenTools.defaultFontPixelWidth * 10
                            text:       qsTr("Scan")
                            enabled:    subEditConfig && subEditConfig.linkType === LinkConfiguration.TypeBluetooth && !subEditConfig.scanning
dogmaphobic's avatar
dogmaphobic committed
112
                            onClicked: {
113 114
                                if(subEditConfig)
                                    subEditConfig.startScan()
dogmaphobic's avatar
dogmaphobic committed
115 116
                            }
                        }
117 118 119 120 121 122 123
                        QGCButton {
                            width:      ScreenTools.defaultFontPixelWidth * 10
                            text:       qsTr("Stop")
                            enabled:    subEditConfig && subEditConfig.linkType === LinkConfiguration.TypeBluetooth && subEditConfig.scanning
                            onClicked: {
                                if(subEditConfig)
                                    subEditConfig.stopScan()
dogmaphobic's avatar
dogmaphobic committed
124 125 126 127 128 129 130 131
                            }
                        }
                    }
                }
            }
        }
    }
}
132