From b358f7d991e58f32cf0ebae7f7d3151bbb3bea63 Mon Sep 17 00:00:00 2001 From: Fabian Bumberger Date: Fri, 13 Sep 2013 16:12:30 +0200 Subject: Remove qdeclarativebluetoothimageprovider This class in unfinished and does not work properly plus it introduces a dependency to the svg module. I also refactored the example where the icon was used. Change-Id: If3bd5e2eb6b05e090255f1bae0015d69c2a83065 Reviewed-by: Alex Blasche --- examples/bluetooth/scanner/default.png | Bin 0 -> 4738 bytes examples/bluetooth/scanner/scanner.qml | 170 +++++++-------------- examples/bluetooth/scanner/scanner.qrc | 1 + src/imports/bluetooth/bluetooth.pro | 5 +- src/imports/bluetooth/bluetooth.qrc | 5 - src/imports/bluetooth/default.svg | 24 --- src/imports/bluetooth/plugin.cpp | 6 - .../qdeclarativebluetoothdiscoverymodel.cpp | 2 - .../qdeclarativebluetoothimageprovider.cpp | 97 ------------ .../qdeclarativebluetoothimageprovider_p.h | 61 -------- 10 files changed, 60 insertions(+), 311 deletions(-) create mode 100644 examples/bluetooth/scanner/default.png delete mode 100644 src/imports/bluetooth/bluetooth.qrc delete mode 100644 src/imports/bluetooth/default.svg delete mode 100644 src/imports/bluetooth/qdeclarativebluetoothimageprovider.cpp delete mode 100644 src/imports/bluetooth/qdeclarativebluetoothimageprovider_p.h diff --git a/examples/bluetooth/scanner/default.png b/examples/bluetooth/scanner/default.png new file mode 100644 index 00000000..a1a74af5 Binary files /dev/null and b/examples/bluetooth/scanner/default.png 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: "Scanning" + 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 += "
Service: " + s.serviceName; } if (s.serviceDescription) { str += "
Description: " + s.serviceDescription; } - if (s.serviceProtocol) { str += "
Port: " + s.serviceProtocol; } + if (s.serviceProtocol) { str += "
Protocol: " + s.serviceProtocol; } if (s.servicePort) { str += "
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 @@ scanner.qml + default.png 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 @@ - - - default.svg - - 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 @@ - - - - -]> - - - - - - - - - - - - - - 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 #include "qdeclarativebluetoothdiscoverymodel_p.h" -#include "qdeclarativebluetoothimageprovider_p.h" #include "qdeclarativebluetoothservice_p.h" #include "qdeclarativebluetoothsocket_p.h" @@ -65,11 +64,6 @@ public: qmlRegisterType(uri, major, minor, "BluetoothService"); qmlRegisterType(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 -#include - -#include -#include -#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 -#include - -#include - -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 m_thumbnails; -}; - -- cgit v1.2.3