diff options
author | Kimmo Ollila <kimmo.ollila@theqtcompany.com> | 2016-02-23 09:13:21 +0200 |
---|---|---|
committer | Kimmo Ollila <kimmo.ollila@theqtcompany.com> | 2016-03-02 12:51:24 +0000 |
commit | c6b5855b446c73f8a60cc3d4427fc445e0ba400d (patch) | |
tree | b57f45df2a297335392f56953410a4c3ab599a8d /src/settingsui/bluetooth | |
parent | f1d884b6dad5a93d7a3077b6b05d3ec7fcd9a6ea (diff) |
Migrate settings UI to use Qt Quick Controls 2
Task-number: QTEE-1057
Change-Id: I389d784241d4b68384765dfde4b572e7652eb76c
Reviewed-by: Teemu Holappa <teemu.holappa@theqtcompany.com>
Diffstat (limited to 'src/settingsui/bluetooth')
-rw-r--r-- | src/settingsui/bluetooth/Bluetooth.qml | 55 | ||||
-rw-r--r-- | src/settingsui/bluetooth/Discovery.qml | 99 |
2 files changed, 68 insertions, 86 deletions
diff --git a/src/settingsui/bluetooth/Bluetooth.qml b/src/settingsui/bluetooth/Bluetooth.qml index d16bdb3..2bffe5b 100644 --- a/src/settingsui/bluetooth/Bluetooth.qml +++ b/src/settingsui/bluetooth/Bluetooth.qml @@ -33,57 +33,50 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -import QtQuick 2.5 -import QtQuick.Layouts 1.1 -import QtQuick.Controls 1.4 -import QtQuick.Controls.Styles.Flat 1.0 as Flat -import "../common" +import QtQuick 2.6 +import QtQuick.Layouts 1.3 +import Qt.labs.controls 1.0 +import Qt.labs.controls.material 1.0 +import Qt.labs.controls.universal 1.0 import com.theqtcompany.settings.bluetooth 1.0 Item { id: root property string title: qsTr("Bluetooth Settings") - Column { - id: content + ColumnLayout { + anchors.margins: 20 anchors.fill: parent - anchors.margins: Math.round(40 * Flat.FlatStyle.scaleFactor) + id: content + spacing: 20 GroupBox { id: groupBox width: parent.width title: qsTr("Bluetooth status") Layout.fillWidth: true + Layout.alignment: Qt.AlignTop - ColumnLayout { - spacing: Math.round(10 * Flat.FlatStyle.scaleFactor) - width: parent.width - Layout.fillWidth: true - - Row { - spacing: Math.round(10 * Flat.FlatStyle.scaleFactor) - TextLabel { - id: off - text: qsTr("Off") - } - - Switch { - checked: BtDevice.powered - onCheckedChanged: BtDevice.powered = checked - } - - TextLabel { - text: qsTr("On") - } + RowLayout { + spacing: 10 + Label { + id: off + text: qsTr("Off") + } + Switch { + checked: BtDevice.powered + onCheckedChanged: BtDevice.powered = checked + } + Label { + text: qsTr("On") } } } - Discovery { id: discovery visible: BtDevice.powered - width: parent.width - height: Math.round(content.height - 100 * Flat.FlatStyle.scaleFactor) + Layout.fillWidth: true + Layout.fillHeight: true } } } diff --git a/src/settingsui/bluetooth/Discovery.qml b/src/settingsui/bluetooth/Discovery.qml index a2dda84..9c1b674 100644 --- a/src/settingsui/bluetooth/Discovery.qml +++ b/src/settingsui/bluetooth/Discovery.qml @@ -33,27 +33,28 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -import QtQuick 2.5 -import QtQuick.Layouts 1.1 -import QtQuick.Controls 1.4 -import QtBluetooth 5.2 -import QtQuick.Controls.Styles.Flat 1.0 as Flat -import "../common" +import QtQuick 2.6 +import QtQuick.Layouts 1.3 +import Qt.labs.controls 1.0 +import Qt.labs.controls.material 1.0 +import Qt.labs.controls.universal 1.0 import com.theqtcompany.settings.bluetooth 1.0 Item { id: top - property BluetoothService currentService GroupBox { id: groupBox title: qsTr("Devices") - width: parent.width + anchors.fill: parent ListView { id: mainList - width: parent.width - height: top.height + anchors.fill: parent + opacity: BtDevice.scanning ? .5 : 1.0 + interactive: !BtDevice.scanning + clip: true + model: BtDevice.deviceModel function getIcon(deviceType) { switch (deviceType) { @@ -72,71 +73,59 @@ Item { } } - model: BtDevice.deviceModel - delegate: Rectangle { + delegate: Item { id: btDelegate width: parent.width - height: Math.round(column.height + 10 * Flat.FlatStyle.scaleFactor) - - property bool expended: false; - clip: true + height: expanded || connected ? column.height + 10 : bttext.height + 10 + property bool expanded: false; MouseArea { anchors.fill: parent - onClicked: btDelegate.expended = !btDelegate.expended + onClicked: { + if (!connected) + btDelegate.expanded = !btDelegate.expanded + } } - - RowLayout { - anchors.top: parent.top + Image { + id: bticon anchors.left: parent.left - spacing: Math.round(10 * Flat.FlatStyle.scaleFactor) - - Image { - id: bticon - source: mainList.getIcon(type) + anchors.top: parent.top + anchors.topMargin: 4 + source: mainList.getIcon(type) + } + Column { + id: column + anchors.left: bticon.right + anchors.leftMargin: 10 + anchors.right: connectButton.left + anchors.rightMargin: 10 + + Label { + id: bttext + text: name } - - Column { - id: column - TextLabel { - id: bttext - text: name - } - - TextLabel { - id: details - opacity: btDelegate.expended ? 1 : 0.0 - text: address - Behavior on opacity { - NumberAnimation { duration: 200} - } - } + Label { + id: details + opacity: btDelegate.expanded || connected ? 1 : 0.0 + text: address + Behavior on opacity { NumberAnimation { duration: 200} } } } - Button { + id: connectButton anchors.right: parent.right - anchors.rightMargin: Math.round(10 * Flat.FlatStyle.scaleFactor) - visible: !BtDevice.scanning + anchors.verticalCenter: parent.verticalCenter + visible: (expanded || connected) && !BtDevice.scanning text: connected ? qsTr("Disconnect") : qsTr("Connect") - onClicked : connected ? BtDevice.requestDisconnect(address) : BtDevice.requestPairing(address); } - Behavior on height { NumberAnimation { duration: 200} } - } focus: true } } - BusyIndicator { - anchors.right: groupBox.right - anchors.top: groupBox.top - anchors.topMargin: Math.round(40 * Flat.FlatStyle.scaleFactor) - anchors.rightMargin: Math.round(10 * Flat.FlatStyle.scaleFactor) - height: Math.round(20 * Flat.FlatStyle.scaleFactor) - width: Math.round(20 * Flat.FlatStyle.scaleFactor) + anchors.centerIn: parent running: BtDevice.scanning - } + } } |