summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@digia.com>2014-07-07 14:23:31 +0200
committerAlex Blasche <alexander.blasche@digia.com>2014-07-15 20:39:46 +0200
commit74a4d1b1ab44274d208d4a52d666d39010f2227a (patch)
treeb404e803933b12fe2464cb8b9523ebaf577b72e1
parentc39189a922ce7057b410eba12e80abac589712cf (diff)
Improve qlowenergyscanner example UI
This patch improves the UI. The changes will be validated against a high DPI device at a later stage. Change-Id: Iac15941dd983fb65cc5f3ccf6803c2e95d43c3b4 Reviewed-by: Fabian Bumberger <fbumberger@rim.com>
-rw-r--r--examples/bluetooth/lowenergyscanner/assets/Characteristics.qml39
-rw-r--r--examples/bluetooth/lowenergyscanner/assets/Dialog.qml1
-rw-r--r--examples/bluetooth/lowenergyscanner/assets/Label.qml3
-rw-r--r--examples/bluetooth/lowenergyscanner/assets/Menu.qml2
-rw-r--r--examples/bluetooth/lowenergyscanner/assets/Services.qml23
-rw-r--r--examples/bluetooth/lowenergyscanner/assets/main.qml26
-rw-r--r--examples/bluetooth/lowenergyscanner/characteristicinfo.cpp12
-rw-r--r--src/bluetooth/qlowenergyservice.cpp4
8 files changed, 63 insertions, 47 deletions
diff --git a/examples/bluetooth/lowenergyscanner/assets/Characteristics.qml b/examples/bluetooth/lowenergyscanner/assets/Characteristics.qml
index 37d6a999..ef1538ab 100644
--- a/examples/bluetooth/lowenergyscanner/assets/Characteristics.qml
+++ b/examples/bluetooth/lowenergyscanner/assets/Characteristics.qml
@@ -57,9 +57,15 @@ Rectangle {
visible: false
}
+ Component.onCompleted: {
+ info.visible = true;
+ info.dialogText = "Scanning for characteristics...";
+ }
+
ListView {
id: characteristicview
width: parent.width
+ clip: true
anchors.top: header.bottom
anchors.bottom: menu.top
@@ -67,26 +73,36 @@ Rectangle {
delegate: Rectangle {
id: characteristicbox
- height:350
+ height:300
width: parent.width
+ color: "lightsteelblue"
+ border.width: 2
+ border.color: "black"
+ radius: 5
- Component.onCompleted: menu.menuText = "Back"
+ Component.onCompleted: {
+ menu.menuText = "Back"
+ info.visible = false
+ }
Label {
- id: characteristicName1
+ id: characteristicName
textContent: modelData.characteristicName
anchors.top: parent.top
anchors.topMargin: 5
}
Label {
- id: characteristicUuid1
+ id: characteristicUuid
+ font.pointSize: characteristicName.font.pointSize*0.7
textContent: modelData.characteristicUuid
- anchors.verticalCenter: parent.verticalCenter
+ anchors.top: characteristicName.bottom
+ anchors.topMargin: 5
}
Label {
id: characteristicValue
+ font.pointSize: characteristicName.font.pointSize*0.7
textContent: ("Value: " + modelData.characteristicValue)
anchors.bottom: characteristicHandle.top
horizontalAlignment: Text.AlignHCenter
@@ -95,6 +111,7 @@ Rectangle {
Label {
id: characteristicHandle
+ font.pointSize: characteristicName.font.pointSize*0.7
textContent: ("Handlers: " + modelData.characteristicHandle)
anchors.bottom: characteristicPermission.top
anchors.topMargin: 5
@@ -102,17 +119,11 @@ Rectangle {
Label {
id: characteristicPermission
+ font.pointSize: characteristicName.font.pointSize*0.7
textContent: modelData.characteristicPermission
anchors.bottom: parent.bottom
- anchors.topMargin: 10
- }
-
- Rectangle {
- id: bottomarea
- anchors.bottom: characteristicbox.bottom
- width: parent.width
- height: 2
- color: "#363636"
+ anchors.topMargin: 5
+ anchors.bottomMargin: 5
}
}
}
diff --git a/examples/bluetooth/lowenergyscanner/assets/Dialog.qml b/examples/bluetooth/lowenergyscanner/assets/Dialog.qml
index f374d762..be5388b5 100644
--- a/examples/bluetooth/lowenergyscanner/assets/Dialog.qml
+++ b/examples/bluetooth/lowenergyscanner/assets/Dialog.qml
@@ -56,5 +56,6 @@ Rectangle {
elide: Text.ElideMiddle
text: dialogText
color: "#363636"
+ wrapMode: Text.Wrap
}
}
diff --git a/examples/bluetooth/lowenergyscanner/assets/Label.qml b/examples/bluetooth/lowenergyscanner/assets/Label.qml
index 7576ffb7..1dced831 100644
--- a/examples/bluetooth/lowenergyscanner/assets/Label.qml
+++ b/examples/bluetooth/lowenergyscanner/assets/Label.qml
@@ -45,6 +45,9 @@ Text {
font.pixelSize: 30
anchors.horizontalCenter: parent.horizontalCenter
color: "#363636"
+ horizontalAlignment: Text.AlignHCenter
elide: Text.ElideMiddle
+ width: parent.width
+ wrapMode: Text.Wrap
text: textContent
}
diff --git a/examples/bluetooth/lowenergyscanner/assets/Menu.qml b/examples/bluetooth/lowenergyscanner/assets/Menu.qml
index 7c043f30..1555db8a 100644
--- a/examples/bluetooth/lowenergyscanner/assets/Menu.qml
+++ b/examples/bluetooth/lowenergyscanner/assets/Menu.qml
@@ -60,7 +60,7 @@ Rectangle {
color: "#363636"
border.width: 1
border.color: "#E3E3E3"
- radius: 10
+ radius: 5
Text {
id: searchText
horizontalAlignment: Text.AlignHCenter
diff --git a/examples/bluetooth/lowenergyscanner/assets/Services.qml b/examples/bluetooth/lowenergyscanner/assets/Services.qml
index ba9f3831..de3eb187 100644
--- a/examples/bluetooth/lowenergyscanner/assets/Services.qml
+++ b/examples/bluetooth/lowenergyscanner/assets/Services.qml
@@ -68,17 +68,20 @@ Rectangle {
anchors.top: header.bottom
anchors.bottom: menu.top
model: device.servicesList
+ clip: true
delegate: Rectangle {
id: servicebox
- height:140
+ height:100
+ color: "lightsteelblue"
+ border.width: 2
+ border.color: "black"
+ radius: 5
width: parent.width
Component.onCompleted: info.visible = false
MouseArea {
anchors.fill: parent
- onPressed: { servicebox.height= 135; bottomarea.height = 7}
- onReleased: { servicebox.height= 140; bottomarea.height = 2}
onClicked: {
device.connectToService(modelData.serviceUuid);
pageLoader.source = "Characteristics.qml";
@@ -86,7 +89,7 @@ Rectangle {
}
Label {
- id: serviceName1
+ id: serviceName
textContent: modelData.serviceName
anchors.top: parent.top
anchors.topMargin: 5
@@ -94,18 +97,10 @@ Rectangle {
Label {
id: serviceUuid
- font.pointSize: serviceName1.font.pointSize * 0.5
+ font.pointSize: serviceName.font.pointSize * 0.5
textContent: modelData.serviceUuid
- anchors.bottom: bottomarea.top
- anchors.bottomMargin: 5
- }
-
- Rectangle {
- id: bottomarea
anchors.bottom: servicebox.bottom
- width: parent.width
- height: 2
- color: "#363636"
+ anchors.bottomMargin: 5
}
}
}
diff --git a/examples/bluetooth/lowenergyscanner/assets/main.qml b/examples/bluetooth/lowenergyscanner/assets/main.qml
index b5a1f14d..9f0395d5 100644
--- a/examples/bluetooth/lowenergyscanner/assets/main.qml
+++ b/examples/bluetooth/lowenergyscanner/assets/main.qml
@@ -66,6 +66,7 @@ Rectangle {
ListView {
id: theListView
width: parent.width
+ clip: true
anchors.top: header.bottom
anchors.bottom: menu.top
@@ -73,8 +74,13 @@ Rectangle {
delegate: Rectangle {
id: box
- height:140
+ height:100
width: parent.width
+ color: "lightsteelblue"
+ border.width: 2
+ border.color: "black"
+ radius: 5
+
Component.onCompleted: {
info.visible = false;
header.headerText = "Select a device";
@@ -82,35 +88,25 @@ Rectangle {
MouseArea {
anchors.fill: parent
- onPressed: { box.height = 135; downpart.height = 7}
- onReleased: { box.height = 140; downpart.height = 2}
onClicked: {
device.scanServices(modelData.deviceAddress);
pageLoader.source = "Services.qml"
}
-
}
Label {
- id: deviceName1
+ id: deviceName
textContent: modelData.deviceName
anchors.top: parent.top
anchors.topMargin: 5
}
Label {
- id: deviceAddress1
+ id: deviceAddress
textContent: modelData.deviceAddress
- anchors.bottom: downpart.top
- anchors.bottomMargin: 5
- }
-
- Rectangle {
- id: downpart
+ font.pointSize: deviceName.font.pointSize*0.7
anchors.bottom: box.bottom
- width: parent.width
- height: 2
- color: "#363636"
+ anchors.bottomMargin: 5
}
}
}
diff --git a/examples/bluetooth/lowenergyscanner/characteristicinfo.cpp b/examples/bluetooth/lowenergyscanner/characteristicinfo.cpp
index b0a60b34..29e97f56 100644
--- a/examples/bluetooth/lowenergyscanner/characteristicinfo.cpp
+++ b/examples/bluetooth/lowenergyscanner/characteristicinfo.cpp
@@ -99,8 +99,15 @@ QString CharacteristicInfo::getValue() const
// Show human string first and hex value below
QByteArray a = m_characteristic.value();
QString result;
- result += QByteArray::fromHex(a) + QLatin1Char('\n');
+ if (a.isEmpty()) {
+ result = QStringLiteral("<none>");
+ return result;
+ }
+
+ result = QByteArray::fromHex(a);
+ result += QLatin1Char('\n');
result += a;
+
return result;
}
@@ -111,7 +118,7 @@ QString CharacteristicInfo::getHandle() const
QString CharacteristicInfo::getPermission() const
{
- QString properties = "Properties:";
+ QString properties = "( ";
int permission = m_characteristic.properties();
if (permission & QLowEnergyCharacteristic::Read)
properties += QStringLiteral(" Read");
@@ -129,6 +136,7 @@ QString CharacteristicInfo::getPermission() const
properties += QStringLiteral(" WriteNoResp");
if (permission & QLowEnergyCharacteristic::WriteSigned)
properties += QStringLiteral(" WriteSigned");
+ properties += " )";
return properties;
}
diff --git a/src/bluetooth/qlowenergyservice.cpp b/src/bluetooth/qlowenergyservice.cpp
index 6469474f..564898ce 100644
--- a/src/bluetooth/qlowenergyservice.cpp
+++ b/src/bluetooth/qlowenergyservice.cpp
@@ -125,7 +125,9 @@ QString QLowEnergyService::serviceName() const
if (ok) {
QBluetoothUuid::ServiceClassUuid id
= static_cast<QBluetoothUuid::ServiceClassUuid>(clsId);
- return QBluetoothUuid::serviceClassToString(id);
+ const QString name = QBluetoothUuid::serviceClassToString(id);
+ if (!name.isEmpty())
+ return name;
}
return qApp ?
qApp->translate("QBluetoothServiceDiscoveryAgent", "Unknown Service") :