summaryrefslogtreecommitdiffstats
path: root/examples/bluetooth/scanner
diff options
context:
space:
mode:
Diffstat (limited to 'examples/bluetooth/scanner')
-rw-r--r--examples/bluetooth/scanner/Button.qml8
-rw-r--r--examples/bluetooth/scanner/qmlscanner.cpp2
-rw-r--r--examples/bluetooth/scanner/scanner.pro8
-rw-r--r--examples/bluetooth/scanner/scanner.qml32
4 files changed, 38 insertions, 12 deletions
diff --git a/examples/bluetooth/scanner/Button.qml b/examples/bluetooth/scanner/Button.qml
index a3debfca..17fb38b5 100644
--- a/examples/bluetooth/scanner/Button.qml
+++ b/examples/bluetooth/scanner/Button.qml
@@ -48,9 +48,7 @@ Rectangle {
property alias text: label.text
signal clicked()
-
- height: 60
- width: 105
+ height: label.height*1.1
color: active ? "#1c56f3" : "white"
@@ -61,9 +59,11 @@ Rectangle {
id: label
text: "Full Discovery"
font.bold: true
- anchors.fill: parent
+ font.pointSize: 17
+ width: parent.width
wrapMode: Text.WordWrap
horizontalAlignment: Text.AlignHCenter
+ anchors.centerIn: parent
}
MouseArea {
diff --git a/examples/bluetooth/scanner/qmlscanner.cpp b/examples/bluetooth/scanner/qmlscanner.cpp
index 3602674b..47d0bb26 100644
--- a/examples/bluetooth/scanner/qmlscanner.cpp
+++ b/examples/bluetooth/scanner/qmlscanner.cpp
@@ -41,9 +41,11 @@
#include <QtGui/QGuiApplication>
#include <QtQuick/QQuickView>
#include <QtQml/QQmlEngine>
+#include <QtCore/QLoggingCategory>
int main(int argc, char *argv[])
{
+ //QLoggingCategory::setFilterRules(QStringLiteral("qt.bluetooth* = true"));
QGuiApplication application(argc, argv);
const QString mainQmlApp = QLatin1String("qrc:/scanner.qml");
QQuickView view;
diff --git a/examples/bluetooth/scanner/scanner.pro b/examples/bluetooth/scanner/scanner.pro
index 7e5c00f7..68572533 100644
--- a/examples/bluetooth/scanner/scanner.pro
+++ b/examples/bluetooth/scanner/scanner.pro
@@ -8,9 +8,11 @@ RESOURCES += \
scanner.qrc
OTHER_FILES += \
- scanner.qml
+ scanner.qml \
+ Button.qml \
+ default.png
#DEFINES += QMLJSDEBUGGER
-OTHER_FILES += \
- Button.qml
+target.path = $$[QT_INSTALL_EXAMPLES]/bluetooth/scanner
+INSTALLS += target
diff --git a/examples/bluetooth/scanner/scanner.qml b/examples/bluetooth/scanner/scanner.qml
index 48b2ee53..67aaecf0 100644
--- a/examples/bluetooth/scanner/scanner.qml
+++ b/examples/bluetooth/scanner/scanner.qml
@@ -54,6 +54,18 @@ Item {
onDiscoveryModeChanged: console.log("Discovery mode: " + discoveryMode)
onServiceDiscovered: console.log("Found new service " + service.deviceAddress + " " + service.deviceName + " " + service.serviceName);
onDeviceDiscovered: console.log("New device: " + device)
+ onErrorChanged: {
+ switch (btModel.error) {
+ case BluetoothDiscoveryModel.PoweredOffError:
+ console.log("Error: Bluetooth device not turned on"); break;
+ case BluetoothDiscoveryModel.InputOutputError:
+ console.log("Error: Bluetooth I/O Error"); break;
+ case BluetoothDiscoveryModel.NoError:
+ break;
+ default:
+ console.log("Error: Unknown Error"); break;
+ }
+ }
}
Rectangle {
@@ -62,7 +74,7 @@ Item {
width: top.width * 0.7;
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: top.top;
- height: 30;
+ height: text.height*1.2;
radius: 5
color: "#1c56f3"
visible: btModel.running
@@ -71,6 +83,7 @@ Item {
id: text
text: "Scanning"
font.bold: true
+ font.pointSize: 20
anchors.centerIn: parent
}
@@ -115,9 +128,9 @@ Item {
anchors.leftMargin: 5
Text {
id: bttext
- text: name;
+ text: deviceName ? deviceName : name
font.family: "FreeSerif"
- font.pointSize: 12
+ font.pointSize: 16
}
Text {
@@ -138,7 +151,8 @@ Item {
visible: opacity !== 0
opacity: btDelegate.expended ? 1 : 0.0
text: get_details(service)
- font: bttext.font
+ font.family: "FreeSerif"
+ font.pointSize: 14
Behavior on opacity {
NumberAnimation { duration: 200}
}
@@ -160,20 +174,28 @@ Item {
anchors.bottom: parent.bottom
anchors.horizontalCenter: parent.horizontalCenter
- spacing: 20
+ anchors.bottomMargin: 5
+ spacing: 10
Button {
id: fdButton
+ width: top.width/3*0.9
+ //mdButton has longest text
+ height: mdButton.height
text: "Full Discovery"
onClicked: btModel.discoveryMode = BluetoothDiscoveryModel.FullServiceDiscovery
}
Button {
id: mdButton
+ width: top.width/3*0.9
text: "Minimal Discovery"
onClicked: btModel.discoveryMode = BluetoothDiscoveryModel.MinimalServiceDiscovery
}
Button {
id: devButton
+ width: top.width/3*0.9
+ //mdButton has longest text
+ height: mdButton.height
text: "Device Discovery"
onClicked: btModel.discoveryMode = BluetoothDiscoveryModel.DeviceDiscovery
}