diff options
35 files changed, 164 insertions, 1900 deletions
diff --git a/.qmake.conf b/.qmake.conf index 5c26162..1121008 100644 --- a/.qmake.conf +++ b/.qmake.conf @@ -3,4 +3,4 @@ load(qt_build_config) CONFIG += warning_clean DEFINES += QT_NO_FOREACH -MODULE_VERSION = 5.14.2 +MODULE_VERSION = 5.15.0 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/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 410415b..8aa4c4e 100644 --- a/examples/svg/svg.pro +++ b/examples/svg/svg.pro @@ -1,6 +1,6 @@ TEMPLATE = subdirs qtHaveModule(widgets): SUBDIRS += embeddedsvgviewer svggenerator svgviewer -SUBDIRS += embedded richtext draganddrop network +SUBDIRS += embedded richtext draganddrop qtHaveModule(opengl):!qtConfig(opengles2): SUBDIRS += opengl diff --git a/examples/svg/svggenerator/displaywidget.h b/examples/svg/svggenerator/displaywidget.h index f999e2a..029872a 100644 --- a/examples/svg/svggenerator/displaywidget.h +++ b/examples/svg/svggenerator/displaywidget.h @@ -53,6 +53,7 @@ #include <QColor> #include <QHash> +#include <QPainterPath> #include <QWidget> //! [DisplayWidget class definition] diff --git a/examples/svg/svgviewer/exportdialog.cpp b/examples/svg/svgviewer/exportdialog.cpp index f6c7b90..f0d388d 100644 --- a/examples/svg/svgviewer/exportdialog.cpp +++ b/examples/svg/svgviewer/exportdialog.cpp @@ -51,7 +51,6 @@ #include "exportdialog.h" #include <QApplication> -#include <QDesktopWidget> #include <QDialogButtonBox> #include <QFileDialog> #include <QFormLayout> @@ -60,6 +59,7 @@ #include <QLabel> #include <QLineEdit> #include <QPushButton> +#include <QScreen> #include <QSpinBox> #include <QToolButton> #include <QVBoxLayout> @@ -89,7 +89,7 @@ ExportDialog::ExportDialog(QWidget *parent) QHBoxLayout *fileLayout = new QHBoxLayout; fileLayout->addWidget(m_fileNameLineEdit); - m_fileNameLineEdit->setMinimumWidth(QApplication::desktop()->availableGeometry(this).width() / 6); + m_fileNameLineEdit->setMinimumWidth(this->screen()->availableGeometry() .width() / 6); QPushButton *browseButton = new QPushButton(tr("Browse..."), this); fileLayout->addWidget(browseButton); connect(browseButton, &QAbstractButton::clicked, this, &ExportDialog::browse); diff --git a/examples/svg/svgviewer/mainwindow.cpp b/examples/svg/svgviewer/mainwindow.cpp index d095416..f67837e 100644 --- a/examples/svg/svgviewer/mainwindow.cpp +++ b/examples/svg/svgviewer/mainwindow.cpp @@ -179,7 +179,7 @@ bool MainWindow::loadFile(const QString &fileName) m_outlineAction->setEnabled(true); m_backgroundAction->setEnabled(true); - const QSize availableSize = QApplication::desktop()->availableGeometry(this).size(); + const QSize availableSize = this->screen()->availableGeometry().size(); resize(m_view->sizeHint().expandedTo(availableSize / 4) + QSize(80, 80 + menuBar()->height())); return true; diff --git a/src/plugins/imageformats/svg/main.cpp b/src/plugins/imageformats/svg/main.cpp index f9fcfc3..d3fe476 100644 --- a/src/plugins/imageformats/svg/main.cpp +++ b/src/plugins/imageformats/svg/main.cpp @@ -72,10 +72,9 @@ QImageIOPlugin::Capabilities QSvgPlugin::capabilities(QIODevice *device, const Q if (format == "svg") #endif return Capabilities(CanRead); - if (!format.isEmpty()) - return 0; - Capabilities cap; + if (!format.isEmpty()) + return cap; if (device->isReadable() && QSvgIOHandler::canRead(device)) cap |= CanRead; return cap; diff --git a/src/plugins/imageformats/svg/qsvgiohandler.cpp b/src/plugins/imageformats/svg/qsvgiohandler.cpp index 6999d51..334c24b 100644 --- a/src/plugins/imageformats/svg/qsvgiohandler.cpp +++ b/src/plugins/imageformats/svg/qsvgiohandler.cpp @@ -140,13 +140,6 @@ bool QSvgIOHandler::canRead() const return false; } -#if QT_DEPRECATED_SINCE(5, 13) -QByteArray QSvgIOHandler::name() const -{ - return "svg"; -} -#endif - bool QSvgIOHandler::read(QImage *image) { if (!d->readDone && d->load(device())) { diff --git a/src/plugins/imageformats/svg/qsvgiohandler.h b/src/plugins/imageformats/svg/qsvgiohandler.h index 5fdf6ee..5a952e1 100644 --- a/src/plugins/imageformats/svg/qsvgiohandler.h +++ b/src/plugins/imageformats/svg/qsvgiohandler.h @@ -58,9 +58,6 @@ public: QSvgIOHandler(); ~QSvgIOHandler(); bool canRead() const override; -#if QT_DEPRECATED_SINCE(5, 13) - QByteArray name() const override; -#endif bool read(QImage *image) override; static bool canRead(QIODevice *device); QVariant option(ImageOption option) const override; diff --git a/src/svg/qsvggenerator.cpp b/src/svg/qsvggenerator.cpp index b671c44..59dd7fc 100644 --- a/src/svg/qsvggenerator.cpp +++ b/src/svg/qsvggenerator.cpp @@ -53,6 +53,7 @@ #include "qbuffer.h" #include "qmath.h" #include "qbitmap.h" +#include "qtransform.h" #include "qdebug.h" @@ -117,7 +118,7 @@ public: QBrush brush; QPen pen; - QMatrix matrix; + QTransform matrix; QFont font; QString generateGradientName() { @@ -227,10 +228,10 @@ public: QString rct(QStringLiteral("<rect x=\"%1\" y=\"%2\" width=\"%3\" height=\"%4\" />")); QTextStream str(&d_func()->defs, QIODevice::Append); str << "<mask id=\"" << maskId << "\" x=\"0\" y=\"0\" width=\"8\" height=\"8\" " - << "stroke=\"none\" fill=\"#ffffff\" patternUnits=\"userSpaceOnUse\" >" << endl; + << "stroke=\"none\" fill=\"#ffffff\" patternUnits=\"userSpaceOnUse\" >" << Qt::endl; for (QRect r : reg) - str << rct.arg(r.x()).arg(r.y()).arg(r.width()).arg(r.height()) << endl; - str << QStringLiteral("</mask>") << endl << endl; + str << rct.arg(r.x()).arg(r.y()).arg(r.width()).arg(r.height()) << Qt::endl; + str << QStringLiteral("</mask>") << Qt::endl << Qt::endl; d_func()->savedPatternMasks.append(maskId); } return maskId; @@ -243,9 +244,9 @@ public: QString maskId = savePatternMask(brush.style()); QString geo(QStringLiteral("x=\"0\" y=\"0\" width=\"8\" height=\"8\"")); QTextStream str(&d_func()->defs, QIODevice::Append); - str << QString(QStringLiteral("<pattern id=\"%1\" %2 patternUnits=\"userSpaceOnUse\" >")).arg(patternId, geo) << endl; - str << QString(QStringLiteral("<rect %1 stroke=\"none\" fill=\"%2\" mask=\"url(#%3);\" />")).arg(geo, color, maskId) << endl; - str << QStringLiteral("</pattern>") << endl << endl; + str << QString(QStringLiteral("<pattern id=\"%1\" %2 patternUnits=\"userSpaceOnUse\" >")).arg(patternId, geo) << Qt::endl; + str << QString(QStringLiteral("<rect %1 stroke=\"none\" fill=\"%2\" mask=\"url(#%3);\" />")).arg(geo, color, maskId) << Qt::endl; + str << QStringLiteral("</pattern>") << Qt::endl << Qt::endl; d_func()->savedPatternBrushes.append(patternId); } return patternId; @@ -266,7 +267,7 @@ public: str << QLatin1String("id=\"") << d_func()->generateGradientName() << QLatin1String("\">\n"); saveGradientStops(str, g); - str << QLatin1String("</linearGradient>") <<endl; + str << QLatin1String("</linearGradient>") <<Qt::endl; } void saveRadialGradientBrush(const QGradient *g) { @@ -283,7 +284,7 @@ public: } str << QLatin1String("id=\"") <<d_func()->generateGradientName()<< QLatin1String("\">\n"); saveGradientStops(str, g); - str << QLatin1String("</radialGradient>") << endl; + str << QLatin1String("</radialGradient>") << Qt::endl; } void saveConicalGradientBrush(const QGradient *) { @@ -544,7 +545,7 @@ public: "font-size=\"" << d->attributes.font_size << "\" " "font-weight=\"" << d->attributes.font_weight << "\" " "font-style=\"" << d->attributes.font_style << "\" " - << endl; + << Qt::endl; } }; @@ -892,29 +893,29 @@ bool QSvgPaintEngine::begin(QPaintDevice *) d->stream = new QTextStream(&d->header); // stream out the header... - *d->stream << "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>" << endl << "<svg"; + *d->stream << "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>" << Qt::endl << "<svg"; if (d->size.isValid()) { qreal wmm = d->size.width() * 25.4 / d->resolution; qreal hmm = d->size.height() * 25.4 / d->resolution; - *d->stream << " width=\"" << wmm << "mm\" height=\"" << hmm << "mm\"" << endl; + *d->stream << " width=\"" << wmm << "mm\" height=\"" << hmm << "mm\"" << Qt::endl; } if (d->viewBox.isValid()) { *d->stream << " viewBox=\"" << d->viewBox.left() << ' ' << d->viewBox.top(); - *d->stream << ' ' << d->viewBox.width() << ' ' << d->viewBox.height() << '\"' << endl; + *d->stream << ' ' << d->viewBox.width() << ' ' << d->viewBox.height() << '\"' << Qt::endl; } *d->stream << " xmlns=\"http://www.w3.org/2000/svg\"" " xmlns:xlink=\"http://www.w3.org/1999/xlink\" " - " version=\"1.2\" baseProfile=\"tiny\">" << endl; + " version=\"1.2\" baseProfile=\"tiny\">" << Qt::endl; if (!d->attributes.document_title.isEmpty()) { - *d->stream << "<title>" << d->attributes.document_title << "</title>" << endl; + *d->stream << "<title>" << d->attributes.document_title << "</title>" << Qt::endl; } if (!d->attributes.document_description.isEmpty()) { - *d->stream << "<desc>" << d->attributes.document_description << "</desc>" << endl; + *d->stream << "<desc>" << d->attributes.document_description << "</desc>" << Qt::endl; } d->stream->setString(&d->defs); @@ -924,7 +925,7 @@ bool QSvgPaintEngine::begin(QPaintDevice *) // Start the initial graphics state... *d->stream << "<g "; generateQtDefaults(); - *d->stream << endl; + *d->stream << Qt::endl; return true; } @@ -945,10 +946,10 @@ bool QSvgPaintEngine::end() *d->stream << d->defs; *d->stream << d->body; if (d->afterFirstUpdate) - *d->stream << "</g>" << endl; // close the updateState + *d->stream << "</g>" << Qt::endl; // close the updateState - *d->stream << "</g>" << endl // close the Qt defaults - << "</svg>" << endl; + *d->stream << "</g>" << Qt::endl // close the Qt defaults + << "</svg>" << Qt::endl; delete d->stream; @@ -1009,13 +1010,13 @@ void QSvgPaintEngine::updateState(const QPaintEngineState &state) } if (flags & QPaintEngine::DirtyTransform) { - d->matrix = state.transform().toAffine(); + d->matrix = state.transform(); *d->stream << "transform=\"matrix(" << d->matrix.m11() << ',' << d->matrix.m12() << ',' << d->matrix.m21() << ',' << d->matrix.m22() << ',' << d->matrix.dx() << ',' << d->matrix.dy() << ")\"" - << endl; + << Qt::endl; } if (flags & QPaintEngine::DirtyFont) { @@ -1027,7 +1028,7 @@ void QSvgPaintEngine::updateState(const QPaintEngineState &state) stream() << "opacity=\""<<state.opacity()<<"\" "; } - *d->stream << '>' << endl; + *d->stream << '>' << Qt::endl; d->afterFirstUpdate = true; } @@ -1046,7 +1047,7 @@ void QSvgPaintEngine::drawEllipse(const QRectF &r) *d->stream << "\" r=\"" << r.width() / qreal(2.0); else *d->stream << "\" rx=\"" << r.width() / qreal(2.0) << "\" ry=\"" << r.height() / qreal(2.0); - *d->stream << "\"/>" << endl; + *d->stream << "\"/>" << Qt::endl; } void QSvgPaintEngine::drawPath(const QPainterPath &p) @@ -1090,7 +1091,7 @@ void QSvgPaintEngine::drawPath(const QPainterPath &p) } } - *d->stream << "\"/>" << endl; + *d->stream << "\"/>" << Qt::endl; } void QSvgPaintEngine::drawPolygon(const QPointF *points, int pointCount, @@ -1112,7 +1113,7 @@ void QSvgPaintEngine::drawPolygon(const QPointF *points, int pointCount, const QPointF &pt = points[i]; stream() << pt.x() << ',' << pt.y() << ' '; } - stream() << "\" />" <<endl; + stream() << "\" />" <<Qt::endl; } else { path.closeSubpath(); drawPath(path); @@ -1130,7 +1131,7 @@ void QSvgPaintEngine::drawRects(const QRectF *rects, int rectCount) *d->stream << " vector-effect=\"non-scaling-stroke\""; *d->stream << " x=\"" << rect.x() << "\" y=\"" << rect.y() << "\" width=\"" << rect.width() << "\" height=\"" << rect.height() - << "\"/>" << endl; + << "\"/>" << Qt::endl; } } @@ -1155,7 +1156,7 @@ void QSvgPaintEngine::drawTextItem(const QPointF &pt, const QTextItem &textItem) *d->stream << " >" << s.toHtmlEscaped() << "</text>" - << endl; + << Qt::endl; } QT_END_NAMESPACE diff --git a/src/svg/qsvghandler.cpp b/src/svg/qsvghandler.cpp index afdecdc..0d2e28e 100644 --- a/src/svg/qsvghandler.cpp +++ b/src/svg/qsvghandler.cpp @@ -60,6 +60,7 @@ #include "qmath.h" #include "qnumeric.h" #include <qregularexpression.h> +#include "qtransform.h" #include "qvarlengtharray.h" #include "private/qmath_p.h" @@ -1068,12 +1069,12 @@ static void parseBrush(QSvgNode *node, -static QMatrix parseTransformationMatrix(const QStringRef &value) +static QTransform parseTransformationMatrix(const QStringRef &value) { if (value.isEmpty()) - return QMatrix(); + return QTransform(); - QMatrix matrix; + QTransform matrix; const QChar *str = value.constData(); const QChar *end = str + value.length(); @@ -1156,9 +1157,9 @@ static QMatrix parseTransformationMatrix(const QStringRef &value) if(state == Matrix) { if(points.count() != 6) goto error; - matrix = QMatrix(points[0], points[1], - points[2], points[3], - points[4], points[5]) * matrix; + matrix = QTransform(points[0], points[1], + points[2], points[3], + points[4], points[5]) * matrix; } else if (state == Translate) { if (points.count() == 1) matrix.translate(points[0], 0); @@ -1438,7 +1439,7 @@ static void parseTransform(QSvgNode *node, { if (attributes.transform.isEmpty()) return; - QMatrix matrix = parseTransformationMatrix(trimRef(attributes.transform)); + QTransform matrix = parseTransformationMatrix(trimRef(attributes.transform)); if (!matrix.isIdentity()) { node->appendStyleProperty(new QSvgTransformStyle(QTransform(matrix)), attributes.id); @@ -2078,7 +2079,7 @@ static void cssStyleLookup(QSvgNode *node, static inline QStringList stringToList(const QString &str) { - QStringList lst = str.split(QLatin1Char(','), QString::SkipEmptyParts); + QStringList lst = str.split(QLatin1Char(','), Qt::SkipEmptyParts); return lst; } @@ -2849,7 +2850,7 @@ static void parseBaseGradient(QSvgNode *node, handler->pushColor(color); } - QMatrix matrix; + QTransform matrix; QGradient *grad = gradProp->qgradient(); if (!link.isEmpty()) { QSvgStyleProperty *prop = node->styleProperty(link); @@ -2864,7 +2865,7 @@ static void parseBaseGradient(QSvgNode *node, gradProp->setGradientStopsSet(inherited->gradientStopsSet()); } - matrix = inherited->qmatrix(); + matrix = inherited->qtransform(); } else { gradProp->setStopLink(link, handler->document()); } @@ -2872,9 +2873,9 @@ static void parseBaseGradient(QSvgNode *node, if (!trans.isEmpty()) { matrix = parseTransformationMatrix(trans); - gradProp->setMatrix(matrix); + gradProp->setTransform(matrix); } else if (!matrix.isIdentity()) { - gradProp->setMatrix(matrix); + gradProp->setTransform(matrix); } if (!spread.isEmpty()) { @@ -3267,7 +3268,7 @@ static QSvgNode *createSvgNode(QSvgNode *parent, viewBoxStr = viewBoxStr.replace(QLatin1Char('\r'), QLatin1Char(',')); viewBoxStr = viewBoxStr.replace(QLatin1Char('\n'), QLatin1Char(',')); viewBoxStr = viewBoxStr.replace(QLatin1Char('\t'), QLatin1Char(',')); - viewBoxValues = viewBoxStr.split(QLatin1Char(','), QString::SkipEmptyParts); + viewBoxValues = viewBoxStr.split(QLatin1Char(','), Qt::SkipEmptyParts); } if (viewBoxValues.count() == 4) { QString xStr = viewBoxValues.at(0).trimmed(); diff --git a/src/svg/qsvgrenderer.cpp b/src/svg/qsvgrenderer.cpp index da31a31..0097ec2 100644 --- a/src/svg/qsvgrenderer.cpp +++ b/src/svg/qsvgrenderer.cpp @@ -45,6 +45,7 @@ #include "qbytearray.h" #include "qtimer.h" +#include "qtransform.h" #include "qdebug.h" #include "private/qobject_p.h" @@ -256,6 +257,41 @@ void QSvgRenderer::setFramesPerSecond(int num) } /*! + \property QSvgRenderer::aspectRatioMode + + \brief how rendering adheres to the SVG view box aspect ratio + + The accepted modes are: + \list + \li Qt::IgnoreAspectRatio (the default): the aspect ratio is ignored and the + rendering is stretched to the target bounds. + \li Qt::KeepAspectRatio: rendering is centered and scaled as large as possible + within the target bounds while preserving aspect ratio. + \endlist + + \since 5.15 +*/ + +Qt::AspectRatioMode QSvgRenderer::aspectRatioMode() const +{ + Q_D(const QSvgRenderer); + if (d->render && d->render->preserveAspectRatio()) + return Qt::KeepAspectRatio; + return Qt::IgnoreAspectRatio; +} + +void QSvgRenderer::setAspectRatioMode(Qt::AspectRatioMode mode) +{ + Q_D(QSvgRenderer); + if (d->render) { + if (mode == Qt::KeepAspectRatio) + d->render->setPreserveAspectRatio(true); + else if (mode == Qt::IgnoreAspectRatio) + d->render->setPreserveAspectRatio(false); + } +} + +/*! \property QSvgRenderer::currentFrame \brief the current frame of the document's animation, or 0 if the document is not animated \internal @@ -437,7 +473,7 @@ void QSvgRenderer::setViewBox(const QRectF &viewbox) The transformation matrix of parent elements is not affecting the bounds of the element. - \sa matrixForElement() + \sa transformForElement() */ QRectF QSvgRenderer::boundsOnElement(const QString &id) const { @@ -471,8 +507,15 @@ bool QSvgRenderer::elementExists(const QString &id) const return exists; } +#if QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED /*! \since 4.2 + \deprecated + + Use transformForElement() instead. + Returns the transformation matrix for the element with the given \a id. The matrix is a product of @@ -486,11 +529,31 @@ bool QSvgRenderer::elementExists(const QString &id) const */ QMatrix QSvgRenderer::matrixForElement(const QString &id) const { + return transformForElement(id).toAffine(); +} +QT_WARNING_POP +#endif // QT_DEPRECATED_SINCE(5, 15) + +/*! + \since 5.15 + + Returns the transformation matrix for the element + with the given \a id. The matrix is a product of + the transformation of the element's parents. The transformation of + the element itself is not included. + + To find the bounding rectangle of the element in logical coordinates, + you can apply the matrix on the rectangle returned from boundsOnElement(). + + \sa boundsOnElement() +*/ +QTransform QSvgRenderer::transformForElement(const QString &id) const +{ Q_D(const QSvgRenderer); - QMatrix mat; + QTransform trans; if (d->render) - mat = d->render->matrixForElement(id); - return mat; + trans = d->render->transformForElement(id); + return trans; } QT_END_NAMESPACE diff --git a/src/svg/qsvgrenderer.h b/src/svg/qsvgrenderer.h index 4413509..3703b1c 100644 --- a/src/svg/qsvgrenderer.h +++ b/src/svg/qsvgrenderer.h @@ -56,6 +56,7 @@ QT_BEGIN_NAMESPACE class QSvgRendererPrivate; class QPainter; class QByteArray; +class QTransform; class Q_SVG_EXPORT QSvgRenderer : public QObject { @@ -64,6 +65,7 @@ class Q_SVG_EXPORT QSvgRenderer : public QObject Q_PROPERTY(QRectF viewBox READ viewBoxF WRITE setViewBox) Q_PROPERTY(int framesPerSecond READ framesPerSecond WRITE setFramesPerSecond) Q_PROPERTY(int currentFrame READ currentFrame WRITE setCurrentFrame) + Q_PROPERTY(Qt::AspectRatioMode aspectRatioMode READ aspectRatioMode WRITE setAspectRatioMode) public: QSvgRenderer(QObject *parent = nullptr); QSvgRenderer(const QString &filename, QObject *parent = nullptr); @@ -80,6 +82,9 @@ public: void setViewBox(const QRect &viewbox); void setViewBox(const QRectF &viewbox); + Qt::AspectRatioMode aspectRatioMode() const; + void setAspectRatioMode(Qt::AspectRatioMode mode); + bool animated() const; int framesPerSecond() const; void setFramesPerSecond(int num); @@ -89,7 +94,11 @@ public: QRectF boundsOnElement(const QString &id) const; bool elementExists(const QString &id) const; +#if QT_DEPRECATED_SINCE(5, 15) + QT_DEPRECATED_X("Use transformForElement()") QMatrix matrixForElement(const QString &id) const; +#endif // QT_DEPRECATED_SINCE(5, 15) + QTransform transformForElement(const QString &id) const; public Q_SLOTS: bool load(const QString &filename); diff --git a/src/svg/qsvgstyle.cpp b/src/svg/qsvgstyle.cpp index 6abedf3..924cca0 100644 --- a/src/svg/qsvgstyle.cpp +++ b/src/svg/qsvgstyle.cpp @@ -421,16 +421,16 @@ QBrush QSvgGradientStyle::brush(QPainter *, QSvgExtraStates &) QBrush b(*m_gradient); - if (!m_matrix.isIdentity()) - b.setMatrix(m_matrix); + if (!m_transform.isIdentity()) + b.setTransform(m_transform); return b; } -void QSvgGradientStyle::setMatrix(const QMatrix &mat) +void QSvgGradientStyle::setTransform(const QTransform &transform) { - m_matrix = mat; + m_transform = transform; } QSvgTransformStyle::QSvgTransformStyle(const QTransform &trans) diff --git a/src/svg/qsvgstyle_p.h b/src/svg/qsvgstyle_p.h index a8fb5ee..41d0e11 100644 --- a/src/svg/qsvgstyle_p.h +++ b/src/svg/qsvgstyle_p.h @@ -54,7 +54,7 @@ #include "QtGui/qpainter.h" #include "QtGui/qpen.h" #include "QtGui/qbrush.h" -#include "QtGui/qmatrix.h" +#include "QtGui/qtransform.h" #include "QtGui/qcolor.h" #include "QtGui/qfont.h" #include <qdebug.h> @@ -581,10 +581,10 @@ public: void resolveStops(); void resolveStops_helper(QStringList *visited); - void setMatrix(const QMatrix &matrix); - QMatrix qmatrix() const + void setTransform(const QTransform &transform); + QTransform qtransform() const { - return m_matrix; + return m_transform; } QGradient *qgradient() const @@ -605,7 +605,7 @@ public: QBrush brush(QPainter *, QSvgExtraStates &) override; private: QGradient *m_gradient; - QMatrix m_matrix; + QTransform m_transform; QSvgTinyDocument *m_doc; QString m_link; diff --git a/src/svg/qsvgtinydocument.cpp b/src/svg/qsvgtinydocument.cpp index 0877e41..b4b9526 100644 --- a/src/svg/qsvgtinydocument.cpp +++ b/src/svg/qsvgtinydocument.cpp @@ -48,6 +48,7 @@ #include "qbytearray.h" #include "qqueue.h" #include "qstack.h" +#include "qtransform.h" #include "qdebug.h" #ifndef QT_NO_COMPRESS @@ -335,6 +336,11 @@ void QSvgTinyDocument::setHeight(int len, bool percent) m_heightPercent = percent; } +void QSvgTinyDocument::setPreserveAspectRatio(bool on) +{ + m_preserveAspectRatio = on; +} + void QSvgTinyDocument::setViewBox(const QRectF &rect) { m_viewBox = rect; @@ -470,13 +476,13 @@ bool QSvgTinyDocument::elementExists(const QString &id) const return (node!=0); } -QMatrix QSvgTinyDocument::matrixForElement(const QString &id) const +QTransform QSvgTinyDocument::transformForElement(const QString &id) const { QSvgNode *node = scopeNode(id); if (!node) { qCDebug(lcSvgHandler, "Couldn't find node %s. Skipping rendering.", qPrintable(id)); - return QMatrix(); + return QTransform(); } QTransform t; @@ -488,7 +494,7 @@ QMatrix QSvgTinyDocument::matrixForElement(const QString &id) const node = node->parent(); } - return t.toAffine(); + return t; } int QSvgTinyDocument::currentFrame() const diff --git a/src/svg/qsvgtinydocument_p.h b/src/svg/qsvgtinydocument_p.h index 404587d..d4b92e8 100644 --- a/src/svg/qsvgtinydocument_p.h +++ b/src/svg/qsvgtinydocument_p.h @@ -67,6 +67,7 @@ QT_BEGIN_NAMESPACE class QPainter; class QByteArray; class QSvgFont; +class QTransform; class Q_SVG_PRIVATE_EXPORT QSvgTinyDocument : public QSvgStructureNode { @@ -88,6 +89,7 @@ public: bool heightPercent() const; bool preserveAspectRatio() const; + void setPreserveAspectRatio(bool on); QRectF viewBox() const; void setViewBox(const QRectF &rect); @@ -99,7 +101,7 @@ public: void draw(QPainter *p, const QString &id, const QRectF &bounds=QRectF()); - QMatrix matrixForElement(const QString &id) const; + QTransform transformForElement(const QString &id) const; QRectF boundsOnElement(const QString &id) const; bool elementExists(const QString &id) const; @@ -127,6 +129,7 @@ private: mutable bool m_implicitViewBox = true; mutable QRectF m_viewBox; + bool m_preserveAspectRatio = false; QHash<QString, QSvgRefCounter<QSvgFont> > m_fonts; QHash<QString, QSvgNode *> m_namedNodes; @@ -184,7 +187,7 @@ inline QRectF QSvgTinyDocument::viewBox() const inline bool QSvgTinyDocument::preserveAspectRatio() const { - return false; + return m_preserveAspectRatio; } inline int QSvgTinyDocument::currentElapsed() const diff --git a/src/svg/qsvgwidget.cpp b/src/svg/qsvgwidget.cpp index 4b86306..acc8cca 100644 --- a/src/svg/qsvgwidget.cpp +++ b/src/svg/qsvgwidget.cpp @@ -90,7 +90,7 @@ public: Constructs a new SVG display widget with the given \a parent. */ QSvgWidget::QSvgWidget(QWidget *parent) - : QWidget(*new QSvgWidgetPrivate, parent, 0) + : QWidget(*new QSvgWidgetPrivate, parent, {}) { d_func()->renderer = new QSvgRenderer(this); QObject::connect(d_func()->renderer, SIGNAL(repaintNeeded()), @@ -102,7 +102,7 @@ QSvgWidget::QSvgWidget(QWidget *parent) of the specified \a file. */ QSvgWidget::QSvgWidget(const QString &file, QWidget *parent) - : QWidget(*new QSvgWidgetPrivate, parent, 0) + : QWidget(*new QSvgWidgetPrivate, parent, {}) { d_func()->renderer = new QSvgRenderer(file, this); QObject::connect(d_func()->renderer, SIGNAL(repaintNeeded()), diff --git a/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp b/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp index ca05a3a..686c854 100644 --- a/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp +++ b/tests/auto/qsvgrenderer/tst_qsvgrenderer.cpp @@ -270,18 +270,17 @@ void tst_QSvgRenderer::testMapViewBoxToTarget() QCOMPARE(picture.boundingRect(), QRect(125, 125, 250, 250)); } -#if 0 // Requires keep-aspectratio feature { // Viewport and viewBox specified -> scale 500x500 square to 1000x750 while preserving aspect ratio gives 750x750 data = "<svg width=\"1000\" height=\"750\" viewBox=\"-250 -250 500 500\"><g><rect x=\"0\" y=\"0\" width=\"500\" height=\"500\" /></g></svg>"; QPicture picture; QPainter painter(&picture); QSvgRenderer rend(data); + rend.setAspectRatioMode(Qt::KeepAspectRatio); rend.render(&painter); painter.end(); QCOMPARE(picture.boundingRect(), QRect(500, 375, 750, 750)); } -#endif } void tst_QSvgRenderer::testRenderElement() @@ -564,15 +563,15 @@ void tst_QSvgRenderer::matrixForElement() const QPainter painter(&image); QSvgRenderer renderer(data); - compareTransforms(painter.worldTransform(), QTransform(renderer.matrixForElement(QLatin1String("ichi")))); + compareTransforms(painter.worldTransform(), renderer.transformForElement(QLatin1String("ichi"))); painter.translate(-3, 1); - compareTransforms(painter.worldTransform(), QTransform(renderer.matrixForElement(QLatin1String("ni")))); + compareTransforms(painter.worldTransform(), renderer.transformForElement(QLatin1String("ni"))); painter.rotate(45); - compareTransforms(painter.worldTransform(), QTransform(renderer.matrixForElement(QLatin1String("san")))); + compareTransforms(painter.worldTransform(), renderer.transformForElement(QLatin1String("san"))); painter.scale(4, 2); - compareTransforms(painter.worldTransform(), QTransform(renderer.matrixForElement(QLatin1String("yon")))); + compareTransforms(painter.worldTransform(), renderer.transformForElement(QLatin1String("yon"))); painter.setWorldTransform(QTransform(1, 2, 3, 4, 5, 6), true); - compareTransforms(painter.worldTransform(), QTransform(renderer.matrixForElement(QLatin1String("firkant")))); + compareTransforms(painter.worldTransform(), renderer.transformForElement(QLatin1String("firkant"))); } void tst_QSvgRenderer::boundsOnElement() const diff --git a/tests/libfuzzer/svg/qsvgrenderer/render/render.pro b/tests/libfuzzer/svg/qsvgrenderer/render/render.pro index be94755..4059899 100644 --- a/tests/libfuzzer/svg/qsvgrenderer/render/render.pro +++ b/tests/libfuzzer/svg/qsvgrenderer/render/render.pro @@ -1,3 +1,8 @@ QT += svg SOURCES += main.cpp -LIBS += -fsanitize=fuzzer +FUZZ_ENGINE = $$(LIB_FUZZING_ENGINE) +isEmpty(FUZZ_ENGINE) { + QMAKE_LFLAGS += -fsanitize=fuzzer +} else { + LIBS += $$FUZZ_ENGINE +} |