BluetoothSettings.qml 4.94 KB
Newer Older
1 2 3 4 5 6 7 8
/****************************************************************************
 *
 *   (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
 *
 * 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 30
    ExclusiveGroup { id: linkGroup }
    Row {
        spacing:    ScreenTools.defaultFontPixelWidth
dogmaphobic's avatar
dogmaphobic committed
31
        QGCLabel {
32 33
            text:   qsTr("Device:")
            width:  _firstColumn
dogmaphobic's avatar
dogmaphobic committed
34
        }
35 36 37
        QGCLabel {
            id:     deviceField
            text:   subEditConfig && subEditConfig.linkType === LinkConfiguration.TypeBluetooth ? subEditConfig.devName : ""
dogmaphobic's avatar
dogmaphobic committed
38
        }
39 40 41 42 43 44 45
    }
    Row {
        visible:    !ScreenTools.isiOS
        spacing:    ScreenTools.defaultFontPixelWidth
        QGCLabel {
            text:   qsTr("Address:")
            width:  _firstColumn
dogmaphobic's avatar
dogmaphobic committed
46
        }
47 48 49
        QGCLabel {
            id:     addressField
            text:   subEditConfig && subEditConfig.linkType === LinkConfiguration.TypeBluetooth ? subEditConfig.address : ""
dogmaphobic's avatar
dogmaphobic committed
50
        }
51 52 53 54 55 56 57 58 59 60 61
    }
    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
62
        Row {
63 64 65 66
            id:      hostRow
            spacing: ScreenTools.defaultFontPixelWidth
            Item {
                height: 1
dogmaphobic's avatar
dogmaphobic committed
67 68
                width:  _firstColumn
            }
69 70 71 72 73 74 75 76
            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
77
                }
78 79 80 81 82 83 84 85 86 87 88 89 90
                Repeater {
                    model: subEditConfig && subEditConfig.linkType === LinkConfiguration.TypeBluetooth ? subEditConfig.nameList : ""
                    delegate:
                    QGCButton {
                        text:   modelData
                        width:  _secondColumn
                        anchors.leftMargin: ScreenTools.defaultFontPixelWidth * 2
                        exclusiveGroup: linkGroup
                        onClicked: {
                            checked = true
                            if(subEditConfig && modelData !== "")
                                subEditConfig.devName = modelData
                        }
dogmaphobic's avatar
dogmaphobic committed
91
                    }
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
                }
                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
109
                        QGCButton {
110 111 112
                            width:      ScreenTools.defaultFontPixelWidth * 10
                            text:       qsTr("Scan")
                            enabled:    subEditConfig && subEditConfig.linkType === LinkConfiguration.TypeBluetooth && !subEditConfig.scanning
dogmaphobic's avatar
dogmaphobic committed
113
                            onClicked: {
114 115
                                if(subEditConfig)
                                    subEditConfig.startScan()
dogmaphobic's avatar
dogmaphobic committed
116 117
                            }
                        }
118 119 120 121 122 123 124
                        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
125 126 127 128 129 130 131 132
                            }
                        }
                    }
                }
            }
        }
    }
}
133