diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2020-03-02 09:56:44 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2020-03-02 09:56:44 +0100 |
commit | 4211887afdc52dd423482b277a2ad36c3b0ea76a (patch) | |
tree | 75c875864b6a01785f2be5c52f30b2ea841dd889 | |
parent | 0823c68b6e34076afad31a12d3fb438b123879cc (diff) | |
parent | ae1e354bec49fa7d57074ec1636b1f0c0f7c5019 (diff) | |
download | qtsvg-4211887afdc52dd423482b277a2ad36c3b0ea76a.tar.gz |
Merge remote-tracking branch 'origin/5.15' into dev
Conflicts:
examples/svg/svg.pro
Change-Id: I186ffe58bd314b505060b2ef5b090503d5a59618
20 files changed, 20 insertions, 1816 deletions
diff --git a/doc/src/examples/bearercloud.qdoc b/doc/src/examples/bearercloud.qdoc deleted file mode 100644 index e4a21f1..0000000 --- a/doc/src/examples/bearercloud.qdoc +++ /dev/null @@ -1,183 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: https://www.gnu.org/licenses/fdl-1.3.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example network/bearercloud - \title Bearer Cloud Example - - The Bearer Cloud example shows how to use the Bearer Management API to monitor the - connectivity state of the local device. - - \image bearercloud-example.png Screenshot of the Bearer Cloud example - - Bearer Management provides the QNetworkConfigurationManager class which can be used to monitor - changes in the available \l {QNetworkConfiguration}{network configurations} and the - QNetworkSession class which is used to \l {QNetworkSession::open()}{open} and - \l {QNetworkSession::close()}{close} a session bringing a network interface up or down if - necessary. - - This example displays all known \l {QNetworkConfiguration}{network configurations} in a cloud - orbiting the local device. There are four orbits representing the four possible - \l {QNetworkConfiguration::StateFlags}{states} that the network configuration can be in. - The closer the orbit the more useful the network configuration is in its current state. - The inner orbit is populated with network configurations that are in the - \l {QNetworkConfiguration::Active}{Active} state. The second orbit is populated with network - configurations that are in the \l {QNetworkConfiguration::Discovered}{Discovered} state. The - third orbit is populated with network configurations that are in the - \l {QNetworkConfiguration::Defined}{Defined} state. Finally the outer orbit is populated by - configurations that are in the \l {QNetworkConfiguration::Undefined}{Undefined} state. - - Hovering the mouse over a network configuration will display information about the network - configuration in a tool tip. - - Double clicking on an Active or Discovered network configuration will - \l {QNetworkSession::close()}{close} or \l {QNetworkSession::open()}{open} a network session, - respectively. - - Lastly you can reorganize the cloud without changing the state of the network configurations by - dragging them around. - - This example consists of two main classes, the BearerCloud and Cloud classes. The Cloud class - represents a single network session and associated network configuration. The BearerCloud - class implements a Graphics View scene and manages the life-cycle of Cloud - objects in response to notification signals from QNetworkConfigurationManager. - - \section1 Setting the Scene - - When constructing the scene we first calculate some random offsets using \l - QRandomGenerator. We will use these offsets to scatter the initial position - of new Cloud objects. - - Next we place a text item in the center of the scene to represent the local device and - surround it with four concentric circles to help visualize the orbits. - - Finally we connect up the network configuration notification signals and queue the initial - population of the scene during the next iteration of the event loop. - - \snippet examples/network/bearercloud/bearercloud.cpp 0 - - Populating the scene with the initial list of known network configuration is easy. Iterate - over the list returned by QNetworkConfigurationManager::allConfigurations(), calling our - configurationAdded() slot on each one. - - We finishing off by calling cloudMoved() to ensure that animations are started. - - \snippet examples/network/bearercloud/bearercloud.cpp 1 - - The configurationAdded() slot gets called when a new network configuration is added to the - system. - - It stores the \l {QNetworkConfiguration::identifier()}{identifier} of the network - configuration in the \e {configStates} map, which is used to keep a count of the number of - network configurations in each state. This in turn is used to calculate the initial position - of new Cloud objects. - - Next we create a new Cloud object for this network configuration. Set its initial position - and store it in the \e {configurations} hash. - - The last step is to add it to the scene by calling QGraphicsScene::addItem(). - - \snippet examples/network/bearercloud/bearercloud.cpp 2 - - The configurationRemoved() slot gets called when a network configuration is removed from the - system. - - First we remove all references to the network configuration from the \e {configStates} and - \e {configurations} member variables. - - Next we initiate animation by setting a final scale value on the Cloud object associated with - the removed network configuration. - - Finally we flag the Cloud object to delete itself after it has finished animating. - - \snippet examples/network/bearercloud/bearercloud.cpp 3 - - The Cloud object will take care of most of the work required when a network configuration - changes. All we do in the configurationChanged() slot is update the \e {configStates} member - variable. - - \snippet examples/network/bearercloud/bearercloud.cpp 4 - - - \section1 Responding to Changes - - Each network session and associated network configuration known to the system is represented in - the scene as a Cloud object. - - In the Cloud constructor we first initialize member variables. Then we create a new - QNetworkSession object bound to the network configuration. Next we connect the QNetworkSession - signals which we use to monitor it for state changes. - - Next we set some QGraphicsItem properties. The QGraphicsItem::ItemIsMovable flag enables mouse - interaction with the Cloud object. - - The Cloud object consists of an icon and a text caption, these are constructed here. We will - assign values to them later, as these will change as the sessions state changes. - - Next we set the initial animation state and call our newConfigurationActivated() slot to finish - setting up the Cloud object based on the state of network session. - - \snippet examples/network/bearercloud/cloud.cpp 0 - - The newConfigurationActivated() slot is called when a session has successfully roamed from one - access point to another. - - The first thing we do is set the icon, inserting it into a shared SVG renderer cache if it is - not already available. Next we set the text caption to the name of the network configuration. - - We then set the position of the icon and text caption so that they are centered horizontally. - - Finally we call our stateChanged() slot. - - \snippet examples/network/bearercloud/cloud.cpp 1 - - The stateChanged() slot is called when the session state changes. - - In this slot we set lower the opacity of Cloud objects with network sessions that cannot be - \l {QNetworkSession::open()}{opened}, and set a detailed tool tip describing the sessions - state. - - \snippet examples/network/bearercloud/cloud.cpp 2 - - In our reimplementation of the QGraphicsItem::mouseDoubleClickEvent() function we call - QNetworkSession::open() or QNetworkSession::close() to open or close the session in response - to a double left click. - - \snippet examples/network/bearercloud/cloud.cpp 3 - - As we support the user dragging Cloud objects around we need to restart animations when the - position of the Cloud object changes. This is accomplished by reimplementing the - QGraphicsItem::itemChanged() function and calling the cloudMoved() function of the BearerCloud - object. - - \snippet examples/network/bearercloud/cloud.cpp 4 - - The remainder of the code for the Cloud object implements the animations. The - calculateForces() function calculates the new position of the Cloud object based on the - position of all the other Cloud objects in the scene. The new position is set when the - advance() function is called to update the Cloud object for the current animation frame. -*/ diff --git a/examples/svg/embedded/weatherinfo/weatherinfo.cpp b/examples/svg/embedded/weatherinfo/weatherinfo.cpp index 24a3bd7..21aa986 100644 --- a/examples/svg/embedded/weatherinfo/weatherinfo.cpp +++ b/examples/svg/embedded/weatherinfo/weatherinfo.cpp @@ -140,7 +140,7 @@ private slots: void handleNetworkData(QNetworkReply *networkReply) { QUrl url = networkReply->url(); - if (!networkReply->networkError()) + if (!networkReply->error()) digest(QString::fromUtf8(networkReply->readAll())); networkReply->deleteLater(); } diff --git a/examples/svg/network/bearercloud/bearercloud.cpp b/examples/svg/network/bearercloud/bearercloud.cpp deleted file mode 100644 index 0f08aec..0000000 --- a/examples/svg/network/bearercloud/bearercloud.cpp +++ /dev/null @@ -1,212 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "bearercloud.h" -#include "cloud.h" - -#include <QGraphicsTextItem> -#include <QTimer> -#include <QHostInfo> -#include <QRandomGenerator> - -#include <QDebug> - -#include <qmath.h> - -//! [0] -BearerCloud::BearerCloud(QObject *parent) -: QGraphicsScene(parent), timerId(0) -{ - setSceneRect(-300, -300, 600, 600); - - - offset[QNetworkConfiguration::Active] = QRandomGenerator::global()->bounded(2 * M_PI); - offset[QNetworkConfiguration::Discovered] = offset[QNetworkConfiguration::Active] + M_PI / 6; - offset[QNetworkConfiguration::Defined] = offset[QNetworkConfiguration::Discovered] - M_PI / 6; - offset[QNetworkConfiguration::Undefined] = offset[QNetworkConfiguration::Undefined] + M_PI / 6; - - thisDevice = new QGraphicsTextItem(QHostInfo::localHostName()); - thisDevice->setData(0, QLatin1String("This Device")); - thisDevice->setPos(thisDevice->boundingRect().width() / -2, - thisDevice->boundingRect().height() / -2); - addItem(thisDevice); - - qreal radius = Cloud::getRadiusForState(QNetworkConfiguration::Active); - QGraphicsEllipseItem *orbit = new QGraphicsEllipseItem(-radius, -radius, 2*radius, 2*radius); - orbit->setPen(QColor(Qt::green)); - addItem(orbit); - radius = Cloud::getRadiusForState(QNetworkConfiguration::Discovered); - orbit = new QGraphicsEllipseItem(-radius, -radius, 2*radius, 2*radius); - orbit->setPen(QColor(Qt::blue)); - addItem(orbit); - radius = Cloud::getRadiusForState(QNetworkConfiguration::Defined); - orbit = new QGraphicsEllipseItem(-radius, -radius, 2*radius, 2*radius); - orbit->setPen(QColor(Qt::darkGray)); - addItem(orbit); - radius = Cloud::getRadiusForState(QNetworkConfiguration::Undefined); - orbit = new QGraphicsEllipseItem(-radius, -radius, 2*radius, 2*radius); - orbit->setPen(QColor(Qt::lightGray)); - addItem(orbit); - - connect(&manager, SIGNAL(configurationAdded(QNetworkConfiguration)), - this, SLOT(configurationAdded(QNetworkConfiguration))); - connect(&manager, SIGNAL(configurationRemoved(QNetworkConfiguration)), - this, SLOT(configurationRemoved(QNetworkConfiguration))); - connect(&manager, SIGNAL(configurationChanged(QNetworkConfiguration)), - this, SLOT(configurationChanged(QNetworkConfiguration))); - - QTimer::singleShot(0, this, SLOT(updateConfigurations())); -} -//! [0] - -BearerCloud::~BearerCloud() -{ -} - -void BearerCloud::cloudMoved() -{ - if (!timerId) - timerId = startTimer(1000 / 25); -} - -void BearerCloud::timerEvent(QTimerEvent *) -{ - std::vector<Cloud *> clouds; - const auto graphicsItems = items(); - clouds.reserve(graphicsItems.size()); - for (QGraphicsItem *item : graphicsItems) { - if (Cloud *cloud = qgraphicsitem_cast<Cloud *>(item)) - clouds.push_back(cloud); - } - - for (Cloud *cloud : clouds) - cloud->calculateForces(); - - bool cloudsMoved = false; - for (Cloud *cloud : clouds) - cloudsMoved |= cloud->advanceAnimation(); - - if (!cloudsMoved) { - killTimer(timerId); - timerId = 0; - } -} - -//! [2] -void BearerCloud::configurationAdded(const QNetworkConfiguration &config) -{ - const QNetworkConfiguration::StateFlags state = config.state(); - - configStates.insert(state, config.identifier()); - - const qreal radius = Cloud::getRadiusForState(state); - const int count = configStates.count(state); - const qreal angle = 2 * M_PI / count; - - Cloud *item = new Cloud(config); - configurations.insert(config.identifier(), item); - - item->setPos(radius * cos((count-1) * angle + offset[state]), - radius * sin((count-1) * angle + offset[state])); - - addItem(item); - - cloudMoved(); -} -//! [2] - -//! [3] -void BearerCloud::configurationRemoved(const QNetworkConfiguration &config) -{ - const auto id = config.identifier(); - for (auto it = configStates.begin(), end = configStates.end(); it != end; /* erasing */) { - if (it.value() == id) - it = configStates.erase(it); - else - ++it; - } - - Cloud *item = configurations.take(config.identifier()); - - item->setFinalScale(0.0); - item->setDeleteAfterAnimation(true); - - cloudMoved(); -} -//! [3] - -//! [4] -void BearerCloud::configurationChanged(const QNetworkConfiguration &config) -{ - const auto id = config.identifier(); - for (auto it = configStates.begin(), end = configStates.end(); it != end; /* erasing */) { - if (it.value() == id) - it = configStates.erase(it); - else - ++it; - } - - configStates.insert(config.state(), id); - - cloudMoved(); -} -//! [4] - -//! [1] -void BearerCloud::updateConfigurations() -{ - const auto allConfigurations = manager.allConfigurations(); - for (const QNetworkConfiguration &config : allConfigurations) - configurationAdded(config); - - cloudMoved(); -} -//! [1] - diff --git a/examples/svg/network/bearercloud/bearercloud.h b/examples/svg/network/bearercloud/bearercloud.h deleted file mode 100644 index a9923ad..0000000 --- a/examples/svg/network/bearercloud/bearercloud.h +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QNetworkConfigurationManager> - -#include <QGraphicsScene> -#include <QMap> -#include <QHash> - -QT_USE_NAMESPACE - -class Cloud; - -class BearerCloud : public QGraphicsScene -{ - Q_OBJECT - -public: - BearerCloud(QObject *parent = 0); - ~BearerCloud(); - - void cloudMoved(); - - void timerEvent(QTimerEvent *event) override; - -private Q_SLOTS: - void configurationAdded(const QNetworkConfiguration &config); - void configurationRemoved(const QNetworkConfiguration &config); - void configurationChanged(const QNetworkConfiguration &config); - void updateConfigurations(); - -private: - QNetworkConfigurationManager manager; - - QGraphicsTextItem *thisDevice; - QHash<QString, Cloud *> configurations; - - QMap<QNetworkConfiguration::StateFlags, qreal> offset; - QMultiMap<QNetworkConfiguration::StateFlags, QString> configStates; - - int timerId; -}; - diff --git a/examples/svg/network/bearercloud/bearercloud.pro b/examples/svg/network/bearercloud/bearercloud.pro deleted file mode 100644 index f69780b..0000000 --- a/examples/svg/network/bearercloud/bearercloud.pro +++ /dev/null @@ -1,19 +0,0 @@ -HEADERS = bearercloud.h \ - cloud.h - -SOURCES = main.cpp \ - bearercloud.cpp \ - cloud.cpp - -RESOURCES = icons.qrc - -TARGET = bearercloud - -QT = core gui widgets network svg -requires(qtConfig(bearermanagement)) - -CONFIG += console - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/svg/network/bearercloud -INSTALLS += target diff --git a/examples/svg/network/bearercloud/bluetooth.svg b/examples/svg/network/bearercloud/bluetooth.svg deleted file mode 100644 index 32e2fa3..0000000 --- a/examples/svg/network/bearercloud/bluetooth.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="图层_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/examples/svg/network/bearercloud/cell.svg b/examples/svg/network/bearercloud/cell.svg deleted file mode 100644 index 7519868..0000000 --- a/examples/svg/network/bearercloud/cell.svg +++ /dev/null @@ -1,25 +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="图层_1" xmlns="&ns_svg;" xmlns:xlink="&ns_xlink;" width="15.667" height="15.794" - viewBox="0 0 15.667 15.794" style="overflow:visible;enable-background:new 0 0 15.667 15.794;" xml:space="preserve"> -<rect style="fill:none;" width="15.667" height="15.666"/> -<g> - <rect x="3.791" y="0.583" style="fill:#996633;" width="1" height="7.963"/> - <rect x="10.917" y="0.583" style="fill:#996633;" width="1" height="7.963"/> - <linearGradient id="XMLID_2_" gradientUnits="userSpaceOnUse" x1="7.8936" y1="1.6753" x2="7.8936" y2="15.1908"> - <stop offset="0" style="stop-color:#D9C7A8"/> - <stop offset="0.1575" style="stop-color:#CEB28C"/> - <stop offset="0.395" style="stop-color:#C09869"/> - <stop offset="0.6188" style="stop-color:#B58550"/> - <stop offset="0.8212" style="stop-color:#AF7940"/> - <stop offset="0.9831" style="stop-color:#AD753B"/> - </linearGradient> - <rect x="6.728" y="0.583" style="fill:url(#XMLID_2_);stroke:#000000;stroke-width:0.75;" width="2.333" height="14.836"/> - <rect x="3.433" y="2.541" style="fill:#C4AB96;stroke:#000000;stroke-width:0.75;" width="8.92" height="2.413"/> - <rect x="3.433" y="6.635" style="fill:#C4AB96;stroke:#000000;stroke-width:0.75;" width="8.92" height="2.412"/> -</g> -</svg> diff --git a/examples/svg/network/bearercloud/cloud.cpp b/examples/svg/network/bearercloud/cloud.cpp deleted file mode 100644 index 1117c94..0000000 --- a/examples/svg/network/bearercloud/cloud.cpp +++ /dev/null @@ -1,390 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "cloud.h" -#include "bearercloud.h" - -#include <qnetworksession.h> - -#include <QGraphicsTextItem> -#include <QGraphicsSvgItem> -#include <QGraphicsSceneMouseEvent> -#include <QSvgRenderer> -#include <QPainter> - -#include <QDebug> - -#include <math.h> - -static QMap<QNetworkConfiguration::BearerType, QSvgRenderer *> svgCache; - -//! [0] -Cloud::Cloud(const QNetworkConfiguration &config, QGraphicsItem *parent) -: QGraphicsItem(parent), configuration(config), deleteAfterAnimation(false) -{ - session = new QNetworkSession(configuration, this); - connect(session, SIGNAL(newConfigurationActivated()), - this, SLOT(newConfigurationActivated())); - connect(session, SIGNAL(stateChanged(QNetworkSession::State)), - this, SLOT(stateChanged(QNetworkSession::State))); - - setFlag(ItemIsMovable); - setFlag(ItemSendsGeometryChanges); - setZValue(1); - - icon = new QGraphicsSvgItem(this); - text = new QGraphicsTextItem(this); - - currentScale = 0; - finalScale = 1; - setTransform(QTransform::fromScale(currentScale, currentScale), false); - setOpacity(0); - - newConfigurationActivated(); -} -//! [0] - -Cloud::~Cloud() -{ -} - -void Cloud::setFinalScale(qreal factor) -{ - finalScale = factor; -} - -void Cloud::setDeleteAfterAnimation(bool deleteAfter) -{ - deleteAfterAnimation = deleteAfter; -} - -void Cloud::calculateForces() -{ - if (!scene() || scene()->mouseGrabberItem() == this) { - newPos = pos(); - return; - } - - // sum up all the forces push this item away - qreal xvel = 0; - qreal yvel = 0; - QLineF orbitForce; - const auto graphicsItems = scene()->items(); - for (QGraphicsItem *item : graphicsItems) { - // other clouds - Cloud *cloud = qgraphicsitem_cast<Cloud *>(item); - if (!cloud && item->data(0) != QLatin1String("This Device")) - continue; - - qreal factor = 1.0; - - QLineF line(cloud ? item->mapToScene(0, 0) : QPointF(0, 0), mapToScene(0, 0)); - if (item->data(0) == QLatin1String("This Device")) - orbitForce = line; - - if (cloud) - factor = cloud->currentScale; - - qreal dx = line.dx(); - qreal dy = line.dy(); - double l = 2.0 * (dx * dx + dy * dy); - if (l > 0) { - xvel += factor * dx * 200.0 / l; - yvel += factor * dy * 200.0 / l; - } - } - - // tendency to stay at a fixed orbit - qreal orbit = getRadiusForState(configuration.state()); - qreal distance = orbitForce.length(); - - QLineF unit = orbitForce.unitVector(); - - orbitForce.setLength(xvel * unit.dx() + yvel * unit.dy()); - - qreal w = 2 - exp(-pow(distance-orbit, 2)/(2 * 50)); - - if (distance < orbit) { - xvel += orbitForce.dx() * w; - yvel += orbitForce.dy() * w; - } else { - xvel -= orbitForce.dx() * w; - yvel -= orbitForce.dy() * w; - } - - if (qAbs(xvel) < 0.1 && qAbs(yvel) < 0.1) - xvel = yvel = 0; - - QRectF sceneRect = scene()->sceneRect(); - newPos = pos() + QPointF(xvel, yvel); - newPos.setX(qMin(qMax(newPos.x(), sceneRect.left() + 10), sceneRect.right() - 10)); - newPos.setY(qMin(qMax(newPos.y(), sceneRect.top() + 10), sceneRect.bottom() - 10)); -} - -bool Cloud::advanceAnimation() -{ - static const qreal scaleDelta = 0.01; - - bool animated = false; - - if (currentScale < finalScale) { - animated = true; - currentScale = qMin<qreal>(currentScale + scaleDelta, finalScale); - setTransform(QTransform::fromScale(currentScale, currentScale), false); - } else if (currentScale > finalScale) { - animated = true; - currentScale = qMax<qreal>(currentScale - scaleDelta, finalScale); - setTransform(QTransform::fromScale(currentScale, currentScale), false); - } - - if (newPos != pos()) { - setPos(newPos); - animated = true; - } - - if (opacity() != finalOpacity) { - animated = true; - if (qAbs(finalScale - currentScale) > 0.0) { - // use scale as reference - setOpacity(opacity() + scaleDelta * (finalOpacity - opacity()) / - qAbs(finalScale - currentScale)); - } else { - setOpacity(finalOpacity); - } - } - - if (!animated && deleteAfterAnimation) - deleteLater(); - - return animated; -} - -QRectF Cloud::boundingRect() const -{ - return childrenBoundingRect(); -} - -void Cloud::paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *) -{ -} - -//! [4] -QVariant Cloud::itemChange(GraphicsItemChange change, const QVariant &value) -{ - switch (change) { - case ItemPositionHasChanged: - if (BearerCloud *bearercloud = qobject_cast<BearerCloud *>(scene())) - bearercloud->cloudMoved(); - default: - ; - }; - - return QGraphicsItem::itemChange(change, value); -} -//! [4] - -//! [3] -void Cloud::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) -{ - if (event->button() == Qt::LeftButton) { - if (session->isOpen()) - session->close(); - else - session->open(); - - event->accept(); - } -} -//! [3] - -//! [2] -void Cloud::stateChanged(QNetworkSession::State state) -{ - if (configuration.name().isEmpty()) - finalOpacity = qreal(0.1); - else if (session->state() == QNetworkSession::NotAvailable) - finalOpacity = 0.5; - else - finalOpacity = 1.0; - - QString tooltip; - - if (configuration.name().isEmpty()) - tooltip += tr("<b>HIDDEN NETWORK</b><br>"); - else - tooltip += tr("<b>%1</b><br>").arg(configuration.name()); - -#ifndef QT_NO_NETWORKINTERFACE - const QNetworkInterface interface = session->interface(); - if (interface.isValid()) - tooltip += tr("<br>Interface: %1").arg(interface.humanReadableName()); - tooltip += tr("<br>Id: %1").arg(configuration.identifier()); -#endif - - const QString bearerTypeName = configuration.bearerTypeName(); - if (!bearerTypeName.isEmpty()) - tooltip += tr("<br>Bearer: %1").arg(bearerTypeName); - - QString s = tr("<br>State: %1 (%2)"); - switch (state) { - case QNetworkSession::Invalid: - s = s.arg(tr("Invalid")); - break; - case QNetworkSession::NotAvailable: - s = s.arg(tr("Not Available")); - break; - case QNetworkSession::Connecting: - s = s.arg(tr("Connecting")); - break; - case QNetworkSession::Connected: - s = s.arg(tr("Connected")); - break; - case QNetworkSession::Closing: - s = s.arg(tr("Closing")); - break; - case QNetworkSession::Disconnected: - s = s.arg(tr("Disconnected")); - break; - case QNetworkSession::Roaming: - s = s.arg(tr("Roaming")); - break; - default: - s = s.arg(tr("Unknown")); - } - - if (session->isOpen()) - s = s.arg(tr("Open")); - else - s = s.arg(tr("Closed")); - - tooltip += s; - - tooltip += tr("<br><br>Active time: %1 seconds").arg(session->activeTime()); - tooltip += tr("<br>Received data: %1 bytes").arg(session->bytesReceived()); - tooltip += tr("<br>Sent data: %1 bytes").arg(session->bytesWritten()); - - setToolTip(tooltip); -} -//! [2] - -//! [1] -void Cloud::newConfigurationActivated() -{ - QNetworkConfiguration::BearerType bearerType = configuration.bearerType(); - if (!svgCache.contains(bearerType)) { - QSvgRenderer *renderer = 0; - switch (bearerType) { - case QNetworkConfiguration::BearerWLAN: - renderer = new QSvgRenderer(QLatin1String(":wlan.svg")); - break; - case QNetworkConfiguration::BearerEthernet: - renderer = new QSvgRenderer(QLatin1String(":lan.svg")); - break; - case QNetworkConfiguration::Bearer2G: - renderer = new QSvgRenderer(QLatin1String(":cell.svg")); - break; - case QNetworkConfiguration::BearerBluetooth: - renderer = new QSvgRenderer(QLatin1String(":bluetooth.svg")); - break; - case QNetworkConfiguration::BearerCDMA2000: - case QNetworkConfiguration::BearerWCDMA: - case QNetworkConfiguration::BearerHSPA: - renderer = new QSvgRenderer(QLatin1String(":umts.svg")); - break; - default: - renderer = new QSvgRenderer(QLatin1String(":unknown.svg")); - } - - if (renderer) - svgCache.insert(bearerType, renderer); - } - - icon->setSharedRenderer(svgCache[bearerType]); - - if (configuration.name().isEmpty()) { - text->setPlainText(tr("HIDDEN NETWORK")); - } else { - if (configuration.type() == QNetworkConfiguration::ServiceNetwork) - text->setHtml("<b>" + configuration.name() + "</b>"); - else - text->setPlainText(configuration.name()); - } - - const qreal height = icon->boundingRect().height() + text->boundingRect().height(); - - icon->setPos(icon->boundingRect().width() / -2, height / -2); - - text->setPos(text->boundingRect().width() / -2, - height / 2 - text->boundingRect().height()); - - stateChanged(session->state()); -} -//! [1] - -qreal Cloud::getRadiusForState(QNetworkConfiguration::StateFlags state) -{ - switch (state) { - case QNetworkConfiguration::Active: - return 100; - break; - case QNetworkConfiguration::Discovered: - return 150; - break; - case QNetworkConfiguration::Defined: - return 200; - break; - case QNetworkConfiguration::Undefined: - return 250; - break; - default: - return 300; - } -} - diff --git a/examples/svg/network/bearercloud/cloud.h b/examples/svg/network/bearercloud/cloud.h deleted file mode 100644 index a91b994..0000000 --- a/examples/svg/network/bearercloud/cloud.h +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QNetworkConfiguration> -#include <QNetworkSession> - -#include <QGraphicsItem> -QT_USE_NAMESPACE - -QT_BEGIN_NAMESPACE -class QGraphicsTextItem; -class QGraphicsSvgItem; -QT_END_NAMESPACE - -class Cloud : public QObject, public QGraphicsItem -{ - Q_OBJECT - Q_INTERFACES(QGraphicsItem) - -public: - explicit Cloud(const QNetworkConfiguration &config, QGraphicsItem *parent = 0); - ~Cloud(); - - enum { Type = UserType + 1 }; - int type() const override { return Type; } - - void setFinalScale(qreal factor); - void setDeleteAfterAnimation(bool deleteAfter); - - void calculateForces(); - - bool advanceAnimation(); - QRectF boundingRect() const override; - void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *) override; - - static qreal getRadiusForState(QNetworkConfiguration::StateFlags state); - -protected: - QVariant itemChange(GraphicsItemChange change, const QVariant &value) override; - void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override; - -private Q_SLOTS: - void stateChanged(QNetworkSession::State state); - void newConfigurationActivated(); - -private: - QNetworkConfiguration configuration; - QNetworkSession *session; - - QGraphicsTextItem *text; - QGraphicsSvgItem *icon; - - qreal finalOpacity; - qreal finalScale; - qreal currentScale; - - QPointF newPos; - - bool deleteAfterAnimation; -}; - diff --git a/examples/svg/network/bearercloud/gprs.svg b/examples/svg/network/bearercloud/gprs.svg deleted file mode 100644 index 4a992c1..0000000 --- a/examples/svg/network/bearercloud/gprs.svg +++ /dev/null @@ -1,199 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<!-- Generator: Adobe Illustrator 12.0.1, SVG Export Plug-In . SVG Version: 6.00 Build 51448) --> -<svg - xmlns:dc="http://purl.org/dc/elements/1.1/" - xmlns:cc="http://web.resource.org/cc/" - xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" - xmlns:svg="http://www.w3.org/2000/svg" - xmlns="http://www.w3.org/2000/svg" - xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" - xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - version="1.0" - id="图层_1" - width="13" - height="14" - viewBox="0 0 21.228 20.825" - style="overflow:visible;enable-background:new 0 0 21.228 20.825;" - xml:space="preserve" - sodipodi:version="0.32" - inkscape:version="0.44.1" - sodipodi:docname="GPRS-online.svg" - sodipodi:docbase="/home/user"><metadata - id="metadata76"><rdf:RDF><cc:Work - rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type - rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs - id="defs74"> - <linearGradient - y2="18.770201" - x2="19.1735" - y1="2.1933999" - x1="2.5967" - gradientUnits="userSpaceOnUse" - id="XMLID_5_" - gradientTransform="matrix(1.749056,0,0,1.749987,1.149567,1.483541)"> - <stop - id="stop6" - style="stop-color:#F8DB41" - offset="0" /> - <stop - id="stop8" - style="stop-color:#F8D73F" - offset="0.1193" /> - <stop - id="stop10" - style="stop-color:#F9CB3A" - offset="0.2384" /> - <stop - id="stop12" - style="stop-color:#FAB731" - offset="0.3576" /> - <stop - id="stop14" - style="stop-color:#FC9B24" - offset="0.4768" /> - <stop - id="stop16" - style="stop-color:#FE7714" - offset="0.595" /> - <stop - id="stop18" - style="stop-color:#FE7513" - offset="0.6011" /> - </linearGradient> - - <linearGradient - y2="13.7331" - x2="24.2068" - y1="-2.8408" - x1="7.6328001" - gradientUnits="userSpaceOnUse" - id="XMLID_6_"> - <stop - id="stop23" - style="stop-color:#F8DB41" - offset="0" /> - <stop - id="stop25" - style="stop-color:#F8D73F" - offset="0.1193" /> - <stop - id="stop27" - style="stop-color:#F9CB3A" - offset="0.2384" /> - <stop - id="stop29" - style="stop-color:#FAB731" - offset="0.3576" /> - <stop - id="stop31" - style="stop-color:#FC9B24" - offset="0.4768" /> - <stop - id="stop33" - style="stop-color:#FE7714" - offset="0.595" /> - <stop - id="stop35" - style="stop-color:#FE7513" - offset="0.6011" /> - </linearGradient> - - <linearGradient - y2="23.8965" - x2="14.043" - y1="7.3242002" - x1="-2.5293" - gradientUnits="userSpaceOnUse" - id="XMLID_7_"> - <stop - id="stop40" - style="stop-color:#F8DB41" - offset="0" /> - <stop - id="stop42" - style="stop-color:#F8D73F" - offset="0.1193" /> - <stop - id="stop44" - style="stop-color:#F9CB3A" - offset="0.2384" /> - <stop - id="stop46" - style="stop-color:#FAB731" - offset="0.3576" /> - <stop - id="stop48" - style="stop-color:#FC9B24" - offset="0.4768" /> - <stop - id="stop50" - style="stop-color:#FE7714" - offset="0.595" /> - <stop - id="stop52" - style="stop-color:#FE7513" - offset="0.6011" /> - </linearGradient> - - <linearGradient - y2="18.5788" - x2="19.364" - y1="2.0039001" - x1="2.7890999" - gradientUnits="userSpaceOnUse" - id="XMLID_8_"> - <stop - id="stop57" - style="stop-color:#F8DB41" - offset="0" /> - <stop - id="stop59" - style="stop-color:#F8D73F" - offset="0.1193" /> - <stop - id="stop61" - style="stop-color:#F9CB3A" - offset="0.2384" /> - <stop - id="stop63" - style="stop-color:#FAB731" - offset="0.3576" /> - <stop - id="stop65" - style="stop-color:#FC9B24" - offset="0.4768" /> - <stop - id="stop67" - style="stop-color:#FE7714" - offset="0.595" /> - <stop - id="stop69" - style="stop-color:#FE7513" - offset="0.6011" /> - </linearGradient> - -</defs><sodipodi:namedview - inkscape:window-height="960" - inkscape:window-width="1183" - inkscape:pageshadow="2" - inkscape:pageopacity="0.0" - guidetolerance="10.0" - gridtolerance="10.0" - objecttolerance="10.0" - borderopacity="1.0" - bordercolor="#666666" - pagecolor="#ffffff" - id="base" - width="13px" - height="14px" - inkscape:zoom="19.543817" - inkscape:cx="10.614" - inkscape:cy="10.386917" - inkscape:window-x="186" - inkscape:window-y="93" - inkscape:current-layer="图层_1" /> -<path - id="path20" - d="M 11.043976,12.916206 L 11.043976,9.4232323 L 19.388723,9.4232323 L 19.388723,16.573679 C 17.790085,17.616671 16.380346,18.330666 15.15076,18.708663 C 13.922922,19.084911 12.465959,19.272159 10.779869,19.272159 C 8.7054879,19.272159 7.0141507,18.934412 5.7076059,18.253667 C 4.399312,17.574672 3.3866086,16.564929 2.6677466,15.222689 C 1.9488846,13.880449 1.58683,12.336961 1.58683,10.599223 C 1.58683,8.7652372 1.9803676,7.172749 2.7674428,5.820009 C 3.5527689,4.4655191 4.7053968,3.4365268 6.2288246,2.7312819 C 7.4111865,2.190536 9.0045765,1.921038 11.008995,1.921038 C 12.939953,1.921038 14.386422,2.0890367 15.343156,2.4232842 C 16.301639,2.7610318 17.093961,3.2825279 17.728868,3.9860227 C 18.360278,4.6930174 18.834272,5.5890108 19.150851,6.6722527 L 13.938664,7.5629961 C 13.72353,6.9330008 13.361475,6.4465044 12.849002,6.1157569 C 12.33478,5.7815093 11.68588,5.6117606 10.890059,5.6117606 C 9.7111951,5.6117606 8.7632067,6.0072577 8.0653334,6.7965018 C 7.3622129,7.5839959 7.0071545,8.8352366 7.0071545,10.541474 C 7.0071545,12.35621 7.365711,13.654701 8.0740787,14.433445 C 8.7824464,15.212189 9.7776592,15.600686 11.043976,15.600686 C 11.647401,15.600686 12.224589,15.514937 12.770295,15.346938 C 13.321247,15.18069 13.943911,14.897192 14.652279,14.492945 L 14.652279,12.917956 L 11.043976,12.917956 L 11.043976,12.916206 z " - style="fill:black;stroke:white;stroke-width:1.30633846;stroke-miterlimit:4;stroke-dasharray:none;stroke-linejoin:round;stroke-linecap:butt;stroke-opacity:1;fill-opacity:1" /> -</svg> diff --git a/examples/svg/network/bearercloud/icons.qrc b/examples/svg/network/bearercloud/icons.qrc deleted file mode 100644 index 7dea1f2..0000000 --- a/examples/svg/network/bearercloud/icons.qrc +++ /dev/null @@ -1,11 +0,0 @@ -<!DOCTYPE RCC><RCC version="1.0"> -<qresource> - <file>wlan.svg</file> - <file>lan.svg</file> - <file>unknown.svg</file> - <file>bluetooth.svg</file> - <file>cell.svg</file> - <file>gprs.svg</file> - <file>umts.svg</file> -</qresource> -</RCC> diff --git a/examples/svg/network/bearercloud/lan.svg b/examples/svg/network/bearercloud/lan.svg deleted file mode 100644 index 4f7f63d..0000000 --- a/examples/svg/network/bearercloud/lan.svg +++ /dev/null @@ -1,33 +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="图层_1" xmlns="&ns_svg;" xmlns:xlink="&ns_xlink;" width="21.929" height="20.665" - viewBox="0 0 21.929 20.665" style="overflow:visible;enable-background:new 0 0 21.929 20.665;" xml:space="preserve"> -<g> - <linearGradient id="XMLID_3_" gradientUnits="userSpaceOnUse" x1="1.7178" y1="5.3706" x2="20.9333" y2="5.3706"> - <stop offset="0.0393" style="stop-color:#C2DC1A"/> - <stop offset="0.2192" style="stop-color:#BEDA1A"/> - <stop offset="0.3978" style="stop-color:#B2D61B"/> - <stop offset="0.5758" style="stop-color:#9ECE1D"/> - <stop offset="0.7536" style="stop-color:#82C320"/> - <stop offset="0.9298" style="stop-color:#5FB423"/> - <stop offset="0.9326" style="stop-color:#5EB423"/> - </linearGradient> - <polygon style="fill:url(#XMLID_3_);stroke:#000000;stroke-linejoin:round;" points="21.429,7.716 10.965,7.716 10.965,0.5 - 0.5,10.241 21.429,10.241 "/> - <linearGradient id="XMLID_4_" gradientUnits="userSpaceOnUse" x1="1.7178" y1="15.2944" x2="20.9333" y2="15.2944"> - <stop offset="0.0393" style="stop-color:#C2DC1A"/> - <stop offset="0.2192" style="stop-color:#BEDA1A"/> - <stop offset="0.3978" style="stop-color:#B2D61B"/> - <stop offset="0.5758" style="stop-color:#9ECE1D"/> - <stop offset="0.7536" style="stop-color:#82C320"/> - <stop offset="0.9298" style="stop-color:#5FB423"/> - <stop offset="0.9326" style="stop-color:#5EB423"/> - </linearGradient> - <polygon style="fill:url(#XMLID_4_);stroke:#000000;stroke-linejoin:round;" points="0.5,12.949 10.965,12.949 10.965,20.165 - 21.429,10.424 0.5,10.424 "/> -</g> -</svg> diff --git a/examples/svg/network/bearercloud/main.cpp b/examples/svg/network/bearercloud/main.cpp deleted file mode 100644 index 33371ce..0000000 --- a/examples/svg/network/bearercloud/main.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "bearercloud.h" - -#include <QApplication> -#include <QGraphicsView> - -class CloudView : public QGraphicsView -{ - Q_OBJECT - -public: - CloudView(QGraphicsScene *scene); - ~CloudView() { } - -protected: - void resizeEvent(QResizeEvent *) override { - fitInView(sceneRect(), Qt::KeepAspectRatio); - } -}; - -CloudView::CloudView(QGraphicsScene *scene) -: QGraphicsView(scene) -{ - setRenderHints(QPainter::TextAntialiasing | QPainter::Antialiasing | - QPainter::SmoothPixmapTransform); -} - -#include "main.moc" - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - - BearerCloud bearerCloud; - - CloudView view(&bearerCloud); - view.show(); - - return app.exec(); -} - diff --git a/examples/svg/network/bearercloud/umts.svg b/examples/svg/network/bearercloud/umts.svg deleted file mode 100644 index c1b372e..0000000 --- a/examples/svg/network/bearercloud/umts.svg +++ /dev/null @@ -1,200 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<!-- Generator: Adobe Illustrator 12.0.1, SVG Export Plug-In . SVG Version: 6.00 Build 51448) --> -<svg - xmlns:dc="http://purl.org/dc/elements/1.1/" - xmlns:cc="http://web.resource.org/cc/" - xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" - xmlns:svg="http://www.w3.org/2000/svg" - xmlns="http://www.w3.org/2000/svg" - xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" - xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - version="1.0" - id="图层_1" - width="13" - height="14" - viewBox="0 0 21.228 20.825" - style="overflow:visible;enable-background:new 0 0 21.228 20.825;" - xml:space="preserve" - sodipodi:version="0.32" - inkscape:version="0.44.1" - sodipodi:docname="umts-enabled.svg" - sodipodi:docbase="/home/user"><metadata - id="metadata76"><rdf:RDF><cc:Work - rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type - rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs - id="defs74"> - <linearGradient - y2="18.770201" - x2="19.1735" - y1="2.1933999" - x1="2.5967" - gradientUnits="userSpaceOnUse" - id="XMLID_5_" - gradientTransform="matrix(1.749056,0,0,1.749987,1.149567,1.483541)"> - <stop - id="stop6" - style="stop-color:#F8DB41" - offset="0" /> - <stop - id="stop8" - style="stop-color:#F8D73F" - offset="0.1193" /> - <stop - id="stop10" - style="stop-color:#F9CB3A" - offset="0.2384" /> - <stop - id="stop12" - style="stop-color:#FAB731" - offset="0.3576" /> - <stop - id="stop14" - style="stop-color:#FC9B24" - offset="0.4768" /> - <stop - id="stop16" - style="stop-color:#FE7714" - offset="0.595" /> - <stop - id="stop18" - style="stop-color:#FE7513" - offset="0.6011" /> - </linearGradient> - - <linearGradient - y2="13.7331" - x2="24.2068" - y1="-2.8408" - x1="7.6328001" - gradientUnits="userSpaceOnUse" - id="XMLID_6_"> - <stop - id="stop23" - style="stop-color:#F8DB41" - offset="0" /> - <stop - id="stop25" - style="stop-color:#F8D73F" - offset="0.1193" /> - <stop - id="stop27" - style="stop-color:#F9CB3A" - offset="0.2384" /> - <stop - id="stop29" - style="stop-color:#FAB731" - offset="0.3576" /> - <stop - id="stop31" - style="stop-color:#FC9B24" - offset="0.4768" /> - <stop - id="stop33" - style="stop-color:#FE7714" - offset="0.595" /> - <stop - id="stop35" - style="stop-color:#FE7513" - offset="0.6011" /> - </linearGradient> - - <linearGradient - y2="23.8965" - x2="14.043" - y1="7.3242002" - x1="-2.5293" - gradientUnits="userSpaceOnUse" - id="XMLID_7_"> - <stop - id="stop40" - style="stop-color:#F8DB41" - offset="0" /> - <stop - id="stop42" - style="stop-color:#F8D73F" - offset="0.1193" /> - <stop - id="stop44" - style="stop-color:#F9CB3A" - offset="0.2384" /> - <stop - id="stop46" - style="stop-color:#FAB731" - offset="0.3576" /> - <stop - id="stop48" - style="stop-color:#FC9B24" - offset="0.4768" /> - <stop - id="stop50" - style="stop-color:#FE7714" - offset="0.595" /> - <stop - id="stop52" - style="stop-color:#FE7513" - offset="0.6011" /> - </linearGradient> - - <linearGradient - y2="18.5788" - x2="19.364" - y1="2.0039001" - x1="2.7890999" - gradientUnits="userSpaceOnUse" - id="XMLID_8_"> - <stop - id="stop57" - style="stop-color:#F8DB41" - offset="0" /> - <stop - id="stop59" - style="stop-color:#F8D73F" - offset="0.1193" /> - <stop - id="stop61" - style="stop-color:#F9CB3A" - offset="0.2384" /> - <stop - id="stop63" - style="stop-color:#FAB731" - offset="0.3576" /> - <stop - id="stop65" - style="stop-color:#FC9B24" - offset="0.4768" /> - <stop - id="stop67" - style="stop-color:#FE7714" - offset="0.595" /> - <stop - id="stop69" - style="stop-color:#FE7513" - offset="0.6011" /> - </linearGradient> - -</defs><sodipodi:namedview - inkscape:window-height="960" - inkscape:window-width="1183" - inkscape:pageshadow="2" - inkscape:pageopacity="0.0" - guidetolerance="10.0" - gridtolerance="10.0" - objecttolerance="10.0" - borderopacity="1.0" - bordercolor="#666666" - pagecolor="#ffffff" - id="base" - width="13px" - height="14px" - inkscape:zoom="53.714286" - inkscape:cx="6.5" - inkscape:cy="7" - inkscape:window-x="252" - inkscape:window-y="164" - inkscape:current-layer="图层_1" /> - -<path - style="font-size:26.12677002px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:black;fill-opacity:1;stroke:white;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - d="M 10.438113,0.60410378 C 9.5195858,0.60412318 8.5840584,0.67216158 7.6315264,0.80821918 C 6.6789835,0.94431518 5.6924268,1.1484304 4.7228823,1.4205653 L 4.7228823,5.0436132 C 5.5223309,4.6949314 6.3643059,4.4057684 7.1722669,4.2271517 C 7.9802179,4.0485668 8.7796689,3.9720237 9.5706225,3.9720075 C 10.64222,3.9720235 11.433166,4.1846436 12.020007,4.5843536 C 12.606829,4.9840947 12.938516,5.5369062 12.938526,6.2683055 C 12.938515,7.0592656 12.623838,7.663106 12.020007,8.054315 C 11.416156,8.4370429 10.497638,8.615644 9.2644494,8.615632 L 7.1722669,8.615632 L 7.1722669,11.779421 L 9.1623917,11.779421 C 10.548667,11.779429 11.569243,11.992048 12.275151,12.442796 C 12.989544,12.885053 13.346746,13.565437 13.346757,14.43292 C 13.346746,15.2749 13.023563,15.921266 12.32618,16.372017 C 11.637281,16.822775 10.616705,17.035395 9.3154783,17.035392 C 8.4394768,17.035395 7.5719873,16.907823 6.6619784,16.67819 C 5.7604653,16.440059 4.8249372,16.116877 3.9064208,15.657613 L 3.9064208,19.433747 C 4.8674613,19.748424 5.8370084,19.995064 6.815065,20.148151 C 7.8016169,20.309742 8.7966784,20.403295 9.7747379,20.403295 C 12.547295,20.403294 14.656485,19.901511 16.102315,18.923459 C 17.548116,17.936904 18.296539,16.474077 18.296555,14.586007 C 18.296539,13.318797 17.947843,12.289717 17.275978,11.473248 C 16.612589,10.648291 15.286744,9.8267627 14.975337,9.738267 C 15.211467,9.5707147 16.382959,8.96434 16.969805,8.2584304 C 17.556621,7.544039 17.837281,6.617016 17.837296,5.5028728 C 17.837281,3.8699658 17.233439,2.6367701 16.000257,1.8287961 C 14.775552,1.0123535 12.913001,0.60412318 10.438113,0.60410378 z M 10.570571,1.2772502 C 13.045459,1.2772695 14.306521,1.5736708 15.531226,2.3901134 C 16.764408,3.1980876 17.174992,3.8601944 17.175007,5.4931014 C 17.174992,6.6072444 16.924732,7.1976942 16.337916,7.9120856 C 15.75107,8.617996 15.186496,9.1223119 15.071966,9.2290638 L 14.321733,9.8826672 C 15.605945,10.214364 16.173958,10.84372 16.837348,11.668677 C 17.509211,12.485146 17.613621,13.298168 17.613637,14.565378 C 17.613621,16.453449 16.977028,17.365815 15.531226,18.35237 C 14.085396,19.330422 12.587467,19.720376 9.8149096,19.720377 C 8.8368504,19.720377 7.7809882,19.596424 6.7944362,19.434833 C 5.8163797,19.281747 5.4689503,19.167564 4.5079098,18.852887 L 4.4775095,16.626075 C 5.3960259,17.085338 5.6790363,17.174005 6.5805495,17.412136 C 7.4905585,17.641769 8.5827919,17.809513 9.4587934,17.80951 C 10.76002,17.809513 12.167112,17.341749 12.856012,16.89099 C 13.553395,16.440238 14.111093,15.203243 14.111104,14.361263 C 14.111093,13.493779 13.591033,12.385621 12.87664,11.943364 C 12.170732,11.492617 10.853754,11.107368 9.4674791,11.10736 L 7.8041559,11.117131 L 7.8041559,9.277922 L 9.3871358,9.257293 C 10.620324,9.257304 12.006788,8.936474 12.610639,8.553746 C 13.21447,8.1625376 13.682233,7.0288655 13.682244,6.2379054 C 13.682234,5.5065062 13.268032,4.4542632 12.681211,4.0545222 C 12.09437,3.6548121 10.824621,3.2391624 9.7530236,3.2391464 C 8.9620698,3.2391624 7.9791321,3.3048486 7.1711811,3.4834335 C 6.3632201,3.66205 6.1954773,3.6645831 5.3960287,4.0132649 L 5.3862573,1.9308538 C 6.3558019,1.6587188 6.8320701,1.5566613 7.784613,1.4205653 C 8.7371446,1.2845077 9.6520438,1.2772696 10.570571,1.2772502 z " - id="text1901" - sodipodi:nodetypes="csccsssssccccsssssccssssscsssccsssccsssssccsssssccccsssssccsc" /></svg>
\ No newline at end of file diff --git a/examples/svg/network/bearercloud/unknown.svg b/examples/svg/network/bearercloud/unknown.svg deleted file mode 100644 index fd10298..0000000 --- a/examples/svg/network/bearercloud/unknown.svg +++ /dev/null @@ -1,76 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<!-- Created with Inkscape (http://www.inkscape.org/) --> -<svg - xmlns:dc="http://purl.org/dc/elements/1.1/" - xmlns:cc="http://creativecommons.org/ns#" - xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" - xmlns:svg="http://www.w3.org/2000/svg" - xmlns="http://www.w3.org/2000/svg" - xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" - xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - width="25" - height="9.0681238" - id="svg2" - sodipodi:version="0.32" - inkscape:version="0.46" - version="1.0" - sodipodi:docname="unknown.svg" - inkscape:output_extension="org.inkscape.output.svg.inkscape"> - <defs - id="defs4"> - <inkscape:perspective - sodipodi:type="inkscape:persp3d" - inkscape:vp_x="0 : 526.18109 : 1" - inkscape:vp_y="0 : 1000 : 0" - inkscape:vp_z="744.09448 : 526.18109 : 1" - inkscape:persp3d-origin="372.04724 : 350.78739 : 1" - id="perspective10" /> - </defs> - <sodipodi:namedview - id="base" - pagecolor="#ffffff" - bordercolor="#666666" - borderopacity="1.0" - gridtolerance="10000" - guidetolerance="10" - objecttolerance="10" - inkscape:pageopacity="0.0" - inkscape:pageshadow="2" - inkscape:zoom="19.416667" - inkscape:cx="15.244635" - inkscape:cy="11.639485" - inkscape:document-units="px" - inkscape:current-layer="layer1" - showgrid="false" - inkscape:window-width="1459" - inkscape:window-height="964" - inkscape:window-x="453" - inkscape:window-y="166" /> - <metadata - id="metadata7"> - <rdf:RDF> - <cc:Work - rdf:about=""> - <dc:format>image/svg+xml</dc:format> - <dc:type - rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> - </cc:Work> - </rdf:RDF> - </metadata> - <g - inkscape:label="Layer 1" - inkscape:groupmode="layer" - id="layer1" - transform="translate(-6.891787e-8,-19.931876)"> - <text - xml:space="preserve" - style="font-size:13.16195393px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - x="-1.0539845" - y="29" - id="text3239"><tspan - sodipodi:role="line" - id="tspan3241" - x="-1.0539845" - y="29">NET</tspan></text> - </g> -</svg> diff --git a/examples/svg/network/bearercloud/wlan.svg b/examples/svg/network/bearercloud/wlan.svg deleted file mode 100644 index 8b86089..0000000 --- a/examples/svg/network/bearercloud/wlan.svg +++ /dev/null @@ -1,151 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<!-- Created with Inkscape (http://www.inkscape.org/) --> -<svg - xmlns:dc="http://purl.org/dc/elements/1.1/" - xmlns:cc="http://creativecommons.org/ns#" - xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" - xmlns:svg="http://www.w3.org/2000/svg" - xmlns="http://www.w3.org/2000/svg" - xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" - xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - width="27" - height="29" - id="svg2" - sodipodi:version="0.32" - inkscape:version="0.46" - version="1.0" - sodipodi:docname="wlan.svg" - inkscape:output_extension="org.inkscape.output.svg.inkscape"> - <defs - id="defs4"> - <inkscape:perspective - sodipodi:type="inkscape:persp3d" - inkscape:vp_x="0 : 526.18109 : 1" - inkscape:vp_y="0 : 1000 : 0" - inkscape:vp_z="744.09448 : 526.18109 : 1" - inkscape:persp3d-origin="372.04724 : 350.78739 : 1" - id="perspective10" /> - </defs> - <sodipodi:namedview - id="base" - pagecolor="#ffffff" - bordercolor="#666666" - borderopacity="1.0" - gridtolerance="10000" - guidetolerance="10" - objecttolerance="10" - inkscape:pageopacity="0.0" - inkscape:pageshadow="2" - inkscape:zoom="19.416667" - inkscape:cx="23.665236" - inkscape:cy="11.639485" - inkscape:document-units="px" - inkscape:current-layer="layer1" - showgrid="false" - inkscape:window-width="1912" - inkscape:window-height="1130" - inkscape:window-x="0" - inkscape:window-y="0" /> - <metadata - id="metadata7"> - <rdf:RDF> - <cc:Work - rdf:about=""> - <dc:format>image/svg+xml</dc:format> - <dc:type - rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> - </cc:Work> - </rdf:RDF> - </metadata> - <g - inkscape:label="Layer 1" - inkscape:groupmode="layer" - id="layer1"> - <g - id="g6334" - transform="translate(1.0000001,0)"> - <path - id="path2393" - d="M 12.500248,9.499893 L 12.500248,28.500095" - style="fill:none;fill-rule:evenodd;stroke:#3bb3ff;stroke-width:0.99981093;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> - <path - sodipodi:open="true" - sodipodi:end="4.1887902" - sodipodi:start="2.0943951" - transform="matrix(1.0216765,0,0,1.0324764,0.4493163,-22.692096)" - d="M 8.8583691,34.085043 A 3.9141631,3.9141631 0 0 1 8.8583691,27.305513" - sodipodi:ry="3.9141631" - sodipodi:rx="3.9141631" - sodipodi:cy="30.695278" - sodipodi:cx="10.815451" - id="path3171" - style="fill:none;fill-opacity:0;stroke:#3bb3ff;stroke-width:0.97365081;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" - sodipodi:type="arc" /> - <path - sodipodi:open="true" - sodipodi:end="4.1887902" - sodipodi:start="2.0943951" - transform="matrix(1.6055152,0,0,1.6224868,-7.5798083,-40.80263)" - d="M 8.8583691,34.085043 A 3.9141631,3.9141631 0 0 1 8.8583691,27.305513" - sodipodi:ry="3.9141631" - sodipodi:rx="3.9141631" - sodipodi:cy="30.695278" - sodipodi:cx="10.815451" - id="path3175" - style="fill:none;fill-opacity:0;stroke:#3bb3ff;stroke-width:0.61958688;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" - sodipodi:type="arc" /> - <path - sodipodi:open="true" - sodipodi:end="4.1887902" - sodipodi:start="2.0943951" - transform="matrix(2.4812855,0,0,2.5075146,-17.62358,-67.968804)" - d="M 8.8583691,34.085043 A 3.9141631,3.9141631 0 0 1 8.8583691,27.305513" - sodipodi:ry="3.9141631" - sodipodi:rx="3.9141631" - sodipodi:cy="30.695278" - sodipodi:cx="10.815451" - id="path3177" - style="fill:none;fill-opacity:0;stroke:#3bb3ff;stroke-width:0.40090355;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" - sodipodi:type="arc" /> - <path - sodipodi:open="true" - sodipodi:end="4.1887902" - sodipodi:start="2.0943951" - transform="matrix(-1.0216765,0,0,1.0324764,24.550388,-22.692096)" - d="M 8.8583691,34.085043 A 3.9141631,3.9141631 0 0 1 8.8583691,27.305513" - sodipodi:ry="3.9141631" - sodipodi:rx="3.9141631" - sodipodi:cy="30.695278" - sodipodi:cx="10.815451" - id="path3179" - style="fill:none;fill-opacity:0;stroke:#3bb3ff;stroke-width:0.97365081;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" - sodipodi:type="arc" /> - <path - sodipodi:open="true" - sodipodi:end="4.1887902" - sodipodi:start="2.0943951" - transform="matrix(-1.6055152,0,0,1.6224868,32.580246,-40.80263)" - d="M 8.8583691,34.085043 A 3.9141631,3.9141631 0 0 1 8.8583691,27.305513" - sodipodi:ry="3.9141631" - sodipodi:rx="3.9141631" - sodipodi:cy="30.695278" - sodipodi:cx="10.815451" - id="path3181" - style="fill:none;fill-opacity:0;stroke:#3bb3ff;stroke-width:0.61958688;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" - sodipodi:type="arc" /> - <path - sodipodi:open="true" - sodipodi:end="4.1887902" - sodipodi:start="2.0943951" - transform="matrix(-2.4812855,0,0,2.5075146,42.623143,-67.968804)" - d="M 8.8583691,34.085043 A 3.9141631,3.9141631 0 0 1 8.8583691,27.305513" - sodipodi:ry="3.9141631" - sodipodi:rx="3.9141631" - sodipodi:cy="30.695278" - sodipodi:cx="10.815451" - id="path3183" - style="fill:none;fill-opacity:0;stroke:#3bb3ff;stroke-width:0.40090355;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" - sodipodi:type="arc" /> - </g> - </g> -</svg> diff --git a/examples/svg/network/network.pro b/examples/svg/network/network.pro deleted file mode 100644 index 4f5c4cf..0000000 --- a/examples/svg/network/network.pro +++ /dev/null @@ -1,2 +0,0 @@ -TEMPLATE = subdirs -qtHaveModule(widgets):qtHaveModule(network): SUBDIRS += bearercloud diff --git a/examples/svg/svg.pro b/examples/svg/svg.pro index 4303b77..3f1f6b3 100644 --- a/examples/svg/svg.pro +++ b/examples/svg/svg.pro @@ -1,4 +1,4 @@ TEMPLATE = subdirs qtHaveModule(widgets): SUBDIRS += embeddedsvgviewer svggenerator svgviewer -SUBDIRS += embedded richtext draganddrop network +SUBDIRS += embedded richtext draganddrop diff --git a/src/svg/qsvggraphics.cpp b/src/svg/qsvggraphics.cpp index bcd2452..20a03ff 100644 --- a/src/svg/qsvggraphics.cpp +++ b/src/svg/qsvggraphics.cpp @@ -43,6 +43,7 @@ #include <qabstracttextdocumentlayout.h> #include <qdebug.h> +#include <qloggingcategory.h> #include <qpainter.h> #include <qscopedvaluerollback.h> #include <qtextcursor.h> @@ -53,6 +54,8 @@ QT_BEGIN_NAMESPACE +Q_LOGGING_CATEGORY(lcSvgDraw, "qt.svg.draw") + #define QT_SVG_DRAW_SHAPE(command) \ qreal oldOpacity = p->opacity(); \ QBrush oldBrush = p->brush(); \ @@ -469,15 +472,27 @@ void QSvgUse::draw(QPainter *p, QSvgExtraStates &states) if (Q_UNLIKELY(!m_link || isDescendantOf(m_link) || m_recursing)) return; + Q_ASSERT(states.nestedUseCount == 0 || states.nestedUseLevel > 0); + if (states.nestedUseLevel > 3 && states.nestedUseCount > (256 + states.nestedUseLevel * 2)) { + qCDebug(lcSvgDraw, "Too many nested use nodes at #%s!", qPrintable(m_linkId)); + return; + } + applyStyle(p, states); if (!m_start.isNull()) { p->translate(m_start); } + if (states.nestedUseLevel > 0) + ++states.nestedUseCount; { - QScopedValueRollback<bool> guard(m_recursing, true); + QScopedValueRollback<int> useLevelGuard(states.nestedUseLevel, states.nestedUseLevel + 1); + QScopedValueRollback<bool> recursingGuard(m_recursing, true); m_link->draw(p, states); } + if (states.nestedUseLevel == 0) + states.nestedUseCount = 0; + if (!m_start.isNull()) { p->translate(-m_start); } diff --git a/src/svg/qsvgstyle_p.h b/src/svg/qsvgstyle_p.h index 9dd4f53..5e0b7cc 100644 --- a/src/svg/qsvgstyle_p.h +++ b/src/svg/qsvgstyle_p.h @@ -145,6 +145,8 @@ struct Q_SVG_PRIVATE_EXPORT QSvgExtraStates int fontWeight; Qt::FillRule fillRule; qreal strokeDashOffset; + int nestedUseLevel = 0; + int nestedUseCount = 0; bool vectorEffect; // true if pen is cosmetic }; |