summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/bluetooth/scanner/default.pngbin0 -> 4738 bytes
-rw-r--r--examples/bluetooth/scanner/scanner.qml170
-rw-r--r--examples/bluetooth/scanner/scanner.qrc1
-rw-r--r--src/imports/bluetooth/bluetooth.pro5
-rw-r--r--src/imports/bluetooth/bluetooth.qrc5
-rw-r--r--src/imports/bluetooth/default.svg24
-rw-r--r--src/imports/bluetooth/plugin.cpp6
-rw-r--r--src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel.cpp2
-rw-r--r--src/imports/bluetooth/qdeclarativebluetoothimageprovider.cpp97
-rw-r--r--src/imports/bluetooth/qdeclarativebluetoothimageprovider_p.h61
10 files changed, 60 insertions, 311 deletions
diff --git a/examples/bluetooth/scanner/default.png b/examples/bluetooth/scanner/default.png
new file mode 100644
index 00000000..a1a74af5
--- /dev/null
+++ b/examples/bluetooth/scanner/default.png
Binary files differ
diff --git a/examples/bluetooth/scanner/scanner.qml b/examples/bluetooth/scanner/scanner.qml
index 130f0bb1..86d1477b 100644
--- a/examples/bluetooth/scanner/scanner.qml
+++ b/examples/bluetooth/scanner/scanner.qml
@@ -47,7 +47,7 @@ Item {
property BluetoothService currentService
BluetoothDiscoveryModel {
- id: myModel
+ id: btModel
minimalDiscovery: true
onDiscoveryChanged: console.log("Discovery mode: " + discovery)
onNewServiceDiscovered: console.log("Found new service " + service.deviceAddress + " " + service.deviceName + " " + service.serviceName);
@@ -56,16 +56,18 @@ Item {
Rectangle {
id: busy
- width: top.width/1.2;
- x: top.width/2-width/2
+ width: top.width * 0.8;
+ anchors.horizontalCenter: parent.horizontalCenter
anchors.top: top.top;
height: 20;
radius: 5
color: "#1c56f3"
+ visible: btModel.discovery
Text {
id: text
- text: "<b>Scanning</b>"
+ text: "Scanning"
+ font.bold: true
anchors.centerIn: parent
}
@@ -75,138 +77,95 @@ Item {
ColorAnimation { easing.type: Easing.InOutSine; to: "#1c56f3"; from: "white"; duration: 1000 }
loops: Animation.Infinite
}
- states: [
- State {
- name: "stopped"
- when: !myModel.discovery
- PropertyChanges { target: busy; height: 0; }
- PropertyChanges { target: busyThrobber; running: false }
- PropertyChanges { target: busy; visible: false }
- }
- ]
- transitions: [
- Transition {
- from: "*"
- to: "stopped"
- reversible: true
- NumberAnimation { property: "height"; to: 0; duration: 200 }
- }
- ]
}
- Component {
- id: del;
-
- Item {
- id: item
-
- property int text_height: 5+(bticon.height > bttext.height ? bticon.height : bttext.height)
+ ListView {
+ id: mainList
+ width: top.width
+ anchors.top: busy.bottom
+ anchors.bottom: fullDiscoveryButton.top
- height: text_height
+ model: btModel
+ delegate: Rectangle {
+ id: btDelegate
width: parent.width
+ height: column.height + 10
+
+ property bool expended: false;
+ clip: true
+ Image {
+ id: bticon
+ source: "qrc:/default.png";
+ width: bttext.height;
+ height: bttext.height;
+ anchors.top: parent.top
+ anchors.left: parent.left
+ anchors.margins: 5
+ }
Column {
- anchors.fill: item
- Row {
- width: parent.width
- Image {
- id: bticon
- source: icon;
- width: del.height;
- }
- Text {
- id: bttext
- text: name;
- font.family: "FreeSerif"
- font.pointSize: 12
- }
+ id: column
+ anchors.left: bticon.right
+ anchors.leftMargin: 5
+ Text {
+ id: bttext
+ text: name;
+ font.family: "FreeSerif"
+ font.pointSize: 12
}
+
Text {
+ id: details
function get_details(s) {
var str = "Address: " + s.deviceAddress;
if (s.serviceName) { str += "<br>Service: " + s.serviceName; }
if (s.serviceDescription) { str += "<br>Description: " + s.serviceDescription; }
- if (s.serviceProtocol) { str += "<br>Port: " + s.serviceProtocol; }
+ if (s.serviceProtocol) { str += "<br>Protocol: " + s.serviceProtocol; }
if (s.servicePort) { str += "<br>Port: " + s.servicePort; }
return str;
}
-
- id: details
- opacity: 0.0
+ visible: opacity !== 0
+ opacity: btDelegate.expended ? 1 : 0.0
text: get_details(service)
font: bttext.font
- x: bticon.width
+ Behavior on opacity {
+ NumberAnimation { duration: 200}
+ }
}
}
+ Behavior on height { NumberAnimation { duration: 200} }
MouseArea {
anchors.fill: parent
- onClicked: item.state = ((item.state == "details") ? "" : "details")
+ onClicked: btDelegate.expended = !btDelegate.expended
}
-
- states: [
- State {
- name: "details"
- PropertyChanges { target: item; height: item.text_height+details.height; }
- PropertyChanges { target: details; opacity: 1.0 }
- }
- ]
- transitions: [
- Transition {
- from: "*"
- to: "details"
- reversible: true
- NumberAnimation { target: item; property: "height"; duration: 200 }
- NumberAnimation { target: details; property: "lopacity"; duration: 200 }
- }
- ]
}
- }
-
- Component {
- id: highlightBox
-
- Rectangle {
- id: background
- border.color: "#34ca57"
- radius: 5
- border.width: 2
- }
- }
-
- ListView {
- id: mainList
- width: top.width
- anchors.top: busy.bottom
- anchors.bottom: fullbutton.top
-
- model: myModel
- highlight: highlightBox
- delegate: del
focus: true
}
Rectangle {
- id: fullbutton
+ id: fullDiscoveryButton
- function button_clicked() {
- myModel.minimalDiscovery = !myModel.minimalDiscovery;
- fullbutton.state = fullbutton.state == "clicked" ? "" : "clicked";
+ property bool fullDiscovery: false
+
+ onFullDiscoveryChanged: {
+ btModel.minimalDiscovery = !fullDiscovery;
//reset discovery since we changed the discovery mode
- myModel.discovery = false;
- myModel.discovery = true;
+ btModel.discovery = false;
+ btModel.discovery = true;
}
anchors.bottom: top.bottom
+ anchors.left: parent.left
+ anchors.right: parent.right
anchors.margins: 3
- width: top.width-6
- x: 3
height: 20
+ color: fullDiscovery ? "#1c56f3" : "white"
+
radius: 5
border.width: 1
- color: "white"
Text {
id: label
@@ -216,22 +175,9 @@ Item {
MouseArea {
anchors.fill: parent
- onClicked: fullbutton.button_clicked();
+ onClicked: parent.fullDiscovery = !parent.fullDiscovery
}
- states: [
- State {
- name: "clicked"
- PropertyChanges { target: fullbutton; color: "#1c56f3" }
- }
- ]
- transitions: [
- Transition {
- from: "*"
- to: "details"
- reversible: true
- ColorAnimation { duration: 200 }
- }
- ]
+ Behavior on color { ColorAnimation { duration: 200 } }
}
}
diff --git a/examples/bluetooth/scanner/scanner.qrc b/examples/bluetooth/scanner/scanner.qrc
index 93e9ce08..9543f065 100644
--- a/examples/bluetooth/scanner/scanner.qrc
+++ b/examples/bluetooth/scanner/scanner.qrc
@@ -1,5 +1,6 @@
<RCC>
<qresource prefix="/">
<file>scanner.qml</file>
+ <file>default.png</file>
</qresource>
</RCC>
diff --git a/src/imports/bluetooth/bluetooth.pro b/src/imports/bluetooth/bluetooth.pro
index 8d0d3308..5a554262 100644
--- a/src/imports/bluetooth/bluetooth.pro
+++ b/src/imports/bluetooth/bluetooth.pro
@@ -3,16 +3,13 @@ QT += quick bluetooth network
HEADERS += \
qdeclarativebluetoothservice_p.h \
qdeclarativebluetoothsocket_p.h \
- qdeclarativebluetoothimageprovider_p.h \
qdeclarativebluetoothdiscoverymodel_p.h
SOURCES += plugin.cpp \
qdeclarativebluetoothservice.cpp \
qdeclarativebluetoothsocket.cpp \
- qdeclarativebluetoothdiscoverymodel.cpp \
- qdeclarativebluetoothimageprovider.cpp
+ qdeclarativebluetoothdiscoverymodel.cpp
-RESOURCES += bluetooth.qrc
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
load(qml_plugin)
diff --git a/src/imports/bluetooth/bluetooth.qrc b/src/imports/bluetooth/bluetooth.qrc
deleted file mode 100644
index 1677bebb..00000000
--- a/src/imports/bluetooth/bluetooth.qrc
+++ /dev/null
@@ -1,5 +0,0 @@
-<RCC>
- <qresource prefix="/">
- <file>default.svg</file>
- </qresource>
-</RCC>
diff --git a/src/imports/bluetooth/default.svg b/src/imports/bluetooth/default.svg
deleted file mode 100644
index 0453ae53..00000000
--- a/src/imports/bluetooth/default.svg
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- Generator: Adobe Illustrator 12.0.1, SVG Export Plug-In . SVG Version: 6.00 Build 51448) -->
-<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [
- <!ENTITY ns_svg "http://www.w3.org/2000/svg">
- <!ENTITY ns_xlink "http://www.w3.org/1999/xlink">
-]>
-<svg version="1.1" id="&#x56FE;&#x5C42;_1" xmlns="&ns_svg;" xmlns:xlink="&ns_xlink;" width="21.792" height="21.819"
- viewBox="0 0 21.792 21.819" overflow="visible" enable-background="new 0 0 21.792 21.819" xml:space="preserve">
-<linearGradient id="XMLID_2_" gradientUnits="userSpaceOnUse" x1="11.0322" y1="2.8701" x2="11.0322" y2="21.2133">
- <stop offset="0" style="stop-color:#95D1DB"/>
- <stop offset="0.0684" style="stop-color:#7FBAE0"/>
- <stop offset="0.2073" style="stop-color:#5892EA"/>
- <stop offset="0.3506" style="stop-color:#3871F1"/>
- <stop offset="0.4971" style="stop-color:#2058F7"/>
- <stop offset="0.648" style="stop-color:#0E45FC"/>
- <stop offset="0.8061" style="stop-color:#033BFE"/>
- <stop offset="0.9831" style="stop-color:#0037FF"/>
-</linearGradient>
-<path fill="url(#XMLID_2_)" stroke="#4D4D4D" stroke-width="0.5" stroke-linejoin="round" d="M10.496,10.931l5.303-4.672
- L9.172,0.292l-0.05,9.427L9.109,9.708v0.029L7.304,8.168L6.266,9.364l1.802,1.567l-1.802,1.567l1.038,1.195l1.806-1.569v0.029
- l0.013-0.012l0.05,9.428l6.627-5.966L10.496,10.931z M10.672,3.993l2.502,2.252l-2.525,2.225L10.672,3.993z M13.174,15.617
- l-2.502,2.252l-0.023-4.477L13.174,15.617z"/>
-<rect opacity="0" fill="#FFFFFF" width="21.792" height="21.792"/>
-</svg>
diff --git a/src/imports/bluetooth/plugin.cpp b/src/imports/bluetooth/plugin.cpp
index de2e74f1..9d3b816f 100644
--- a/src/imports/bluetooth/plugin.cpp
+++ b/src/imports/bluetooth/plugin.cpp
@@ -44,7 +44,6 @@
#include <QtQml/QQmlExtensionPlugin>
#include "qdeclarativebluetoothdiscoverymodel_p.h"
-#include "qdeclarativebluetoothimageprovider_p.h"
#include "qdeclarativebluetoothservice_p.h"
#include "qdeclarativebluetoothsocket_p.h"
@@ -65,11 +64,6 @@ public:
qmlRegisterType<QDeclarativeBluetoothService>(uri, major, minor, "BluetoothService");
qmlRegisterType<QDeclarativeBluetoothSocket>(uri, major, minor, "BluetoothSocket");
}
-
- void initializeEngine(QQmlEngine *engine, const char *uri) {
- Q_UNUSED(uri);
- engine->addImageProvider("bluetoothicons", new BluetoothThumbnailImageProvider);
- }
};
#include "plugin.moc"
diff --git a/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel.cpp b/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel.cpp
index feaa5adc..0bcdd46c 100644
--- a/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel.cpp
+++ b/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel.cpp
@@ -224,8 +224,6 @@ QVariant QDeclarativeBluetoothDiscoveryModel::data(const QModelIndex &index, int
label += QStringLiteral(" ") + service->serviceName();
return label;
}
- case Qt::DecorationRole:
- return QLatin1String("image://bluetoothicons/default");
case ServiceRole:
return QVariant::fromValue(service);
}
diff --git a/src/imports/bluetooth/qdeclarativebluetoothimageprovider.cpp b/src/imports/bluetooth/qdeclarativebluetoothimageprovider.cpp
deleted file mode 100644
index 97f5f477..00000000
--- a/src/imports/bluetooth/qdeclarativebluetoothimageprovider.cpp
+++ /dev/null
@@ -1,97 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtBluetooth module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QDebug>
-#include <QQmlExtensionPlugin>
-
-#include <QQmlEngine>
-#include <qqml.h>
-#include "qdeclarativebluetoothimageprovider_p.h"
-
-
-QT_USE_NAMESPACE
-
-// This is run in a low priority thread.
-QImage BluetoothThumbnailImageProvider::requestImage(const QString &id, QSize *size, const QSize &req_size)
-{
- if (m_thumbnails.contains(id)) {
- if (size)
- *size = req_size;
- return m_thumbnails.value(id).scaled(req_size);
- }
-
- /* url format:
- image://bluetoothicons/{hosttype}
- */
-
-
- QImage image(
- req_size.width() > 0 ? req_size.width() : 100,
- req_size.height() > 0 ? req_size.height() : 50,
- QImage::Format_RGB32);
-
- QString imageUrl;
-
- if (id == "default")
- imageUrl = QLatin1String(":/default.svg");
-
- imageUrl = imageUrl.isEmpty() ? QLatin1String(":/default.svg") : imageUrl;
- image.load(imageUrl);
-
- if (size)
- *size = image.size();
-
- m_thumbnails.insert(id, image);
-
- return image;
-}
-
-BluetoothThumbnailImageProvider::BluetoothThumbnailImageProvider()
- :QQuickImageProvider(QQuickImageProvider::Image)
-{
-
-}
-
-BluetoothThumbnailImageProvider::~BluetoothThumbnailImageProvider()
-{
-}
-
-
diff --git a/src/imports/bluetooth/qdeclarativebluetoothimageprovider_p.h b/src/imports/bluetooth/qdeclarativebluetoothimageprovider_p.h
deleted file mode 100644
index 1d4a8cda..00000000
--- a/src/imports/bluetooth/qdeclarativebluetoothimageprovider_p.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtBluetooth module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtQuick/QQuickImageProvider>
-#include <QMap>
-
-#include <qbluetoothserviceinfo.h>
-
-QT_USE_NAMESPACE
-
-
-class BluetoothThumbnailImageProvider : public QQuickImageProvider
-{
-public:
- // This is run in a low priority thread.
- QImage requestImage(const QString &id, QSize *size, const QSize &req_size);
- BluetoothThumbnailImageProvider();
- ~BluetoothThumbnailImageProvider();
-
-private:
- QMap<QString, QImage> m_thumbnails;
-};
-