diff options
author | hjk <qthjk@ovi.com> | 2012-12-04 12:34:19 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-12-06 12:25:09 +0100 |
commit | 166e66496114975b9580e489b16963191fd4f600 (patch) | |
tree | fea7f51ef2ad93dd2f440429d29894ae795d2673 /examples/svg/network | |
parent | 0f146689e6fb53762123c3e8a44fc6c8e71492ba (diff) | |
download | qtsvg-166e66496114975b9580e489b16963191fd4f600.tar.gz |
Centralize and fixup qtsvg example sources install targets
This follows suit with aeb036e in qtbase.
Change-Id: I2e64dcce15b3b39f98395df5627cf0839debdf99
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
Diffstat (limited to 'examples/svg/network')
-rw-r--r-- | examples/svg/network/bearercloud/bearercloud.cpp | 196 | ||||
-rw-r--r-- | examples/svg/network/bearercloud/bearercloud.h | 80 | ||||
-rw-r--r-- | examples/svg/network/bearercloud/bearercloud.pro | 18 | ||||
-rw-r--r-- | examples/svg/network/bearercloud/bluetooth.svg | 24 | ||||
-rw-r--r-- | examples/svg/network/bearercloud/cell.svg | 25 | ||||
-rw-r--r-- | examples/svg/network/bearercloud/cloud.cpp | 385 | ||||
-rw-r--r-- | examples/svg/network/bearercloud/cloud.h | 98 | ||||
-rw-r--r-- | examples/svg/network/bearercloud/gprs.svg | 199 | ||||
-rw-r--r-- | examples/svg/network/bearercloud/icons.qrc | 11 | ||||
-rwxr-xr-x | examples/svg/network/bearercloud/lan.svg | 33 | ||||
-rw-r--r-- | examples/svg/network/bearercloud/main.cpp | 88 | ||||
-rw-r--r-- | examples/svg/network/bearercloud/umts.svg | 200 | ||||
-rw-r--r-- | examples/svg/network/bearercloud/unknown.svg | 76 | ||||
-rw-r--r-- | examples/svg/network/bearercloud/wlan.svg | 151 | ||||
-rw-r--r-- | examples/svg/network/network.pro | 3 |
15 files changed, 1587 insertions, 0 deletions
diff --git a/examples/svg/network/bearercloud/bearercloud.cpp b/examples/svg/network/bearercloud/bearercloud.cpp new file mode 100644 index 0000000..02b6c50 --- /dev/null +++ b/examples/svg/network/bearercloud/bearercloud.cpp @@ -0,0 +1,196 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Digia Plc and its Subsidiary(-ies) 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 <QDateTime> +#include <QHostInfo> + +#include <QDebug> + +#include <math.h> + +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif + +//! [0] +BearerCloud::BearerCloud(QObject *parent) +: QGraphicsScene(parent), timerId(0) +{ + setSceneRect(-300, -300, 600, 600); + + qsrand(QDateTime::currentDateTime().toTime_t()); + + offset[QNetworkConfiguration::Active] = 2 * M_PI * qrand() / RAND_MAX; + 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 *) +{ + QList<Cloud *> clouds; + foreach (QGraphicsItem *item, items()) { + if (Cloud *cloud = qgraphicsitem_cast<Cloud *>(item)) + clouds << cloud; + } + + foreach (Cloud *cloud, clouds) + cloud->calculateForces(); + + bool cloudsMoved = false; + foreach (Cloud *cloud, clouds) + cloudsMoved |= cloud->advance(); + + 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) +{ + foreach (const QNetworkConfiguration::StateFlags &state, configStates.uniqueKeys()) + configStates.remove(state, config.identifier()); + + Cloud *item = configurations.take(config.identifier()); + + item->setFinalScale(0.0); + item->setDeleteAfterAnimation(true); + + cloudMoved(); +} +//! [3] + +//! [4] +void BearerCloud::configurationChanged(const QNetworkConfiguration &config) +{ + foreach (const QNetworkConfiguration::StateFlags &state, configStates.uniqueKeys()) + configStates.remove(state, config.identifier()); + + configStates.insert(config.state(), config.identifier()); + + cloudMoved(); +} +//! [4] + +//! [1] +void BearerCloud::updateConfigurations() +{ + QList<QNetworkConfiguration> allConfigurations = manager.allConfigurations(); + + while (!allConfigurations.isEmpty()) + configurationAdded(allConfigurations.takeFirst()); + + cloudMoved(); +} +//! [1] + diff --git a/examples/svg/network/bearercloud/bearercloud.h b/examples/svg/network/bearercloud/bearercloud.h new file mode 100644 index 0000000..cd8e45e --- /dev/null +++ b/examples/svg/network/bearercloud/bearercloud.h @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Digia Plc and its Subsidiary(-ies) 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); + +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 new file mode 100644 index 0000000..723c8c7 --- /dev/null +++ b/examples/svg/network/bearercloud/bearercloud.pro @@ -0,0 +1,18 @@ +HEADERS = bearercloud.h \ + cloud.h + +SOURCES = main.cpp \ + bearercloud.cpp \ + cloud.cpp + +RESOURCES = icons.qrc + +TARGET = bearercloud + +QT = core gui widgets network svg + +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 new file mode 100644 index 0000000..32e2fa3 --- /dev/null +++ b/examples/svg/network/bearercloud/bluetooth.svg @@ -0,0 +1,24 @@ +<?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 new file mode 100644 index 0000000..7519868 --- /dev/null +++ b/examples/svg/network/bearercloud/cell.svg @@ -0,0 +1,25 @@ +<?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 new file mode 100644 index 0000000..0531ad2 --- /dev/null +++ b/examples/svg/network/bearercloud/cloud.cpp @@ -0,0 +1,385 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Digia Plc and its Subsidiary(-ies) 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); +#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)) + setFlag(ItemSendsGeometryChanges); +#endif + 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; + foreach (QGraphicsItem *item, scene()->items()) { + // 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::advance() +{ + 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; + +#if !defined(Q_OS_WINCE) + 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); +#else + Q_UNUSED(state); +#endif +} +//! [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 new file mode 100644 index 0000000..1756b81 --- /dev/null +++ b/examples/svg/network/bearercloud/cloud.h @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Digia Plc and its Subsidiary(-ies) 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 { return Type; } + + void setFinalScale(qreal factor); + void setDeleteAfterAnimation(bool deleteAfter); + + void calculateForces(); + + bool advance(); + QRectF boundingRect() const; + void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *); + + static qreal getRadiusForState(QNetworkConfiguration::StateFlags state); + +protected: + QVariant itemChange(GraphicsItemChange change, const QVariant &value); + void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event); + +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 new file mode 100644 index 0000000..4a992c1 --- /dev/null +++ b/examples/svg/network/bearercloud/gprs.svg @@ -0,0 +1,199 @@ +<?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 new file mode 100644 index 0000000..7dea1f2 --- /dev/null +++ b/examples/svg/network/bearercloud/icons.qrc @@ -0,0 +1,11 @@ +<!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 new file mode 100755 index 0000000..4f7f63d --- /dev/null +++ b/examples/svg/network/bearercloud/lan.svg @@ -0,0 +1,33 @@ +<?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 new file mode 100644 index 0000000..b81bca8 --- /dev/null +++ b/examples/svg/network/bearercloud/main.cpp @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Digia Plc and its Subsidiary(-ies) 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 *) { + fitInView(sceneRect(), Qt::KeepAspectRatio); + } +#ifdef Q_OS_WINCE + void hideEvent(QHideEvent *) { + qApp->quit(); + } +#endif +}; + +CloudView::CloudView(QGraphicsScene *scene) +: QGraphicsView(scene) +{ + setRenderHints(QPainter::TextAntialiasing | QPainter::Antialiasing | + QPainter::SmoothPixmapTransform); +#if defined (Q_OS_WINCE) + setWindowState(Qt::WindowMaximized); +#endif +} + +#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 new file mode 100644 index 0000000..c1b372e --- /dev/null +++ b/examples/svg/network/bearercloud/umts.svg @@ -0,0 +1,200 @@ +<?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 new file mode 100644 index 0000000..fd10298 --- /dev/null +++ b/examples/svg/network/bearercloud/unknown.svg @@ -0,0 +1,76 @@ +<?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 new file mode 100644 index 0000000..8b86089 --- /dev/null +++ b/examples/svg/network/bearercloud/wlan.svg @@ -0,0 +1,151 @@ +<?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 new file mode 100644 index 0000000..6cf6c42 --- /dev/null +++ b/examples/svg/network/network.pro @@ -0,0 +1,3 @@ +TEMPLATE = subdirs +!contains(QT_CONFIG, no-widgets): SUBDIRS += bearercloud +QT+=widgets |