From ad81f5720c4f4a1dac099cbe2f9d47ed3a9025b0 Mon Sep 17 00:00:00 2001 From: Caroline Chao Date: Sat, 12 Apr 2014 15:09:49 +0200 Subject: Examples: Use yr.no API for the embedded/weatherinfo example Since the google API is no longer available Task-number: QTBUG-38041 Change-Id: I8ef91a047cade27856579cf871efb5e10afd2350 Reviewed-by: Mitch Curtis Reviewed-by: Shawn Rutledge --- examples/svg/embedded/weatherinfo/weatherinfo.cpp | 411 +++++++++++++--------- 1 file changed, 252 insertions(+), 159 deletions(-) diff --git a/examples/svg/embedded/weatherinfo/weatherinfo.cpp b/examples/svg/embedded/weatherinfo/weatherinfo.cpp index 3425819..2de7afc 100644 --- a/examples/svg/embedded/weatherinfo/weatherinfo.cpp +++ b/examples/svg/embedded/weatherinfo/weatherinfo.cpp @@ -44,6 +44,11 @@ #include #include +#define GET_DATA_ATTR(val) xml.attributes().value(val).toString() +#define GET_DATETIME(val) QDateTime::fromString(val, "yyyy-MM-ddThh:mm:ss") +#define FORMAT_TEMPERATURE(val) val + QChar(176) + "C" +#define TEXTCOLOR palette().color(QPalette::WindowText) + class WeatherInfo: public QMainWindow { Q_OBJECT @@ -56,6 +61,8 @@ private: QGraphicsRectItem *m_statusItem; QGraphicsTextItem *m_temperatureItem; QGraphicsTextItem *m_conditionItem; + QGraphicsTextItem *m_cityItem; + QGraphicsTextItem *m_copyright; QGraphicsSvgItem *m_iconItem; QList m_forecastItems; QList m_dayItems; @@ -82,9 +89,9 @@ public: QStringList cities; cities << "Oslo"; cities << "Berlin"; - cities << "Brisbane"; + cities << "Moscow"; cities << "Helsinki"; - cities << "San Diego"; + cities << "Santa Clara"; for (int i = 0; i < cities.count(); ++i) { QAction *action = new QAction(cities[i], this); connect(action, SIGNAL(triggered()), SLOT(chooseCity())); @@ -100,15 +107,26 @@ public: private slots: void delayedInit() { - request("Oslo"); + request("http://www.yr.no/place/Norge/Oslo/Oslo/Oslo/varsel.xml"); } private slots: void chooseCity() { QAction *action = qobject_cast(sender()); - if (action) - request(action->text()); + if (action) { + if (action->text() == "Oslo") { + request("http://www.yr.no/place/Norge/Oslo/Oslo/Oslo/varsel.xml"); + } else if (action->text() == "Berlin") { + request("http://www.yr.no/place/Germany/Berlin/Berlin/varsel.xml"); + } else if (action->text() == "Moscow") { + request("http://www.yr.no/place/Russia/Moscow/Moscow/varsel.xml"); + } else if (action->text() == "Helsinki") { + request("http://www.yr.no/place/Finland/Southern_Finland/Helsinki/varsel.xml"); + } else if (action->text() == "Santa Clara") { + request("http://www.yr.no/place/United_States/California/Santa_Clara/varsel.xml"); + } + } } void handleNetworkData(QNetworkReply *networkReply) { @@ -145,17 +163,23 @@ private slots: private: void setupScene() { - - QColor textColor = palette().color(QPalette::WindowText); QFont textFont = font(); textFont.setBold(true); - textFont.setPointSize(textFont.pointSize() * 2); + textFont.setPointSize(static_cast(textFont.pointSize() * 1.5)); m_temperatureItem = m_scene.addText(QString(), textFont); - m_temperatureItem->setDefaultTextColor(textColor); + m_temperatureItem->setDefaultTextColor(TEXTCOLOR); m_conditionItem = m_scene.addText(QString(), textFont); - m_conditionItem->setDefaultTextColor(textColor); + m_conditionItem->setDefaultTextColor(TEXTCOLOR); + + m_cityItem = m_scene.addText(QString(), textFont); + m_cityItem->setDefaultTextColor(TEXTCOLOR); + + m_copyright = m_scene.addText(QString()); + m_copyright->setDefaultTextColor(TEXTCOLOR); + m_copyright->setOpenExternalLinks(true); + m_copyright->setTextInteractionFlags(Qt::TextBrowserInteraction); m_iconItem = new QGraphicsSvgItem; m_scene.addItem(m_iconItem); @@ -166,6 +190,7 @@ private: m_temperatureItem->setParentItem(m_statusItem); m_conditionItem->setParentItem(m_statusItem); m_iconItem->setParentItem(m_statusItem); + m_copyright->setParentItem(m_statusItem); connect(&m_timeLine, SIGNAL(frameChanged(int)), SLOT(animate(int))); m_timeLine.setDuration(1100); @@ -174,12 +199,7 @@ private: } void request(const QString &location) { - QUrl url("http://www.google.com/ig/api"); - QUrlQuery query; - query.addQueryItem("hl", "en"); - query.addQueryItem("weather", location); - url.setQuery(query); - + QUrl url(location); m_manager.get(QNetworkRequest(url)); city = QString(); @@ -188,63 +208,44 @@ private: QString extractIcon(const QString &data) { if (m_icons.isEmpty()) { - m_icons["mostly_cloudy"] = "weather-few-clouds"; - m_icons["cloudy"] = "weather-overcast"; - m_icons["mostly_sunny"] = "weather-sunny-very-few-clouds"; - m_icons["partly_cloudy"] = "weather-sunny-very-few-clouds"; - m_icons["sunny"] = "weather-sunny"; - m_icons["flurries"] = "weather-snow"; - m_icons["fog"] = "weather-fog"; - m_icons["haze"] = "weather-haze"; - m_icons["icy"] = "weather-icy"; - m_icons["sleet"] = "weather-sleet"; - m_icons["chance_of_sleet"] = "weather-sleet"; - m_icons["snow"] = "weather-snow"; - m_icons["chance_of_snow"] = "weather-snow"; - m_icons["mist"] = "weather-showers"; - m_icons["rain"] = "weather-showers"; - m_icons["chance_of_rain"] = "weather-showers"; - m_icons["storm"] = "weather-storm"; - m_icons["chance_of_storm"] = "weather-storm"; - m_icons["thunderstorm"] = "weather-thundershower"; - m_icons["chance_of_tstorm"] = "weather-thundershower"; + m_icons["Partly cloudy"] = "weather-few-clouds"; + m_icons["Cloudy"] = "weather-overcast"; + m_icons["Fair"] = "weather-sunny-very-few-clouds"; + m_icons["Sun"] = "weather-sunny"; + m_icons["Sun/clear sky"] = "weather-sunny"; + m_icons["Clear sky"] = "weather-sunny"; + m_icons["Snow showers"] = "weather-snow"; + m_icons["Snow"] = "weather-snow"; + m_icons["Fog"] = "weather-fog"; + m_icons["Sleet"] = "weather-sleet"; + m_icons["Sleet showers"] = "weather-sleet"; + m_icons["Rain showers"] = "weather-showers"; + m_icons["Rain"] = "weather-showers"; + m_icons["Heavy rain"] = "weather-showers"; + m_icons["Rain showers with thunder"] = "weather-thundershower"; + m_icons["Rain and thunder"] = "weather-thundershower"; + m_icons["Sleet and thunder"] = "weather-thundershower"; + m_icons["Heavy rain and thunder"] = "weather-thundershower"; + m_icons["Snow and thunder"] = "weather-thundershower"; + m_icons["Sleet showers and thunder"] = "weather-thundershower"; + m_icons["Snow showers and thunder"] = "weather-thundershower"; } - QRegExp regex("([\\w]+).gif$"); - if (regex.indexIn(data) != -1) { - QString i = regex.cap(); - i = i.left(i.length() - 4); - QString name = m_icons.value(i); - if (!name.isEmpty()) { - name.prepend(":/icons/"); - name.append(".svg"); - return name; - } + QString name = m_icons.value(data); + if (!name.isEmpty()) { + name.prepend(":/icons/"); + name.append(".svg"); + return name; } return QString(); } - static QString toCelcius(QString t, QString unit) { - bool ok = false; - int degree = t.toInt(&ok); - if (!ok) - return QString(); - if (unit != "SI") - degree = ((degree - 32) * 5 + 8)/ 9; - return QString::number(degree) + QChar(176); - } - - -#define GET_DATA_ATTR xml.attributes().value("data").toString() - void digest(const QString &data) { - - QColor textColor = palette().color(QPalette::WindowText); - QString unitSystem; - delete m_iconItem; m_iconItem = new QGraphicsSvgItem(); m_scene.addItem(m_iconItem); m_iconItem->setParentItem(m_statusItem); + m_conditionItem->setPlainText(QString()); + qDeleteAll(m_dayItems); qDeleteAll(m_conditionItems); qDeleteAll(m_rangeItems); @@ -255,102 +256,181 @@ private: m_forecastItems.clear(); QXmlStreamReader xml(data); + + bool foundCurrentForecast = false; while (!xml.atEnd()) { xml.readNext(); if (xml.tokenType() == QXmlStreamReader::StartElement) { - if (xml.name() == "city") { - city = GET_DATA_ATTR; - setWindowTitle(city); - } - if (xml.name() == "unit_system") - unitSystem = xml.attributes().value("data").toString(); - // Parse current weather conditions - if (xml.name() == "current_conditions") { + if (xml.name() == "location") { while (!xml.atEnd()) { xml.readNext(); - if (xml.name() == "current_conditions") - break; if (xml.tokenType() == QXmlStreamReader::StartElement) { - if (xml.name() == "condition") { - m_conditionItem->setPlainText(GET_DATA_ATTR); - } - if (xml.name() == "icon") { - QString name = extractIcon(GET_DATA_ATTR); - if (!name.isEmpty()) { - delete m_iconItem; - m_iconItem = new QGraphicsSvgItem(name); - m_scene.addItem(m_iconItem); - m_iconItem->setParentItem(m_statusItem); - } - } - if (xml.name() == "temp_c") { - QString s = GET_DATA_ATTR + QChar(176); - m_temperatureItem->setPlainText(s); + if (xml.name() == "name") { + city = xml.readElementText(); + m_cityItem->setPlainText(city); + setWindowTitle(city); + xml.skipCurrentElement(); + break; } } } - } - // Parse and collect the forecast conditions - if (xml.name() == "forecast_conditions") { - QGraphicsTextItem *dayItem = 0; - QGraphicsSvgItem *statusItem = 0; - QString lowT, highT; + } else if (xml.name() == "credit") { while (!xml.atEnd()) { xml.readNext(); - if (xml.name() == "forecast_conditions") { - if (dayItem && statusItem && - !lowT.isEmpty() && !highT.isEmpty()) { - m_dayItems << dayItem; - m_conditionItems << statusItem; - QString txt = highT + '/' + lowT; - QGraphicsTextItem* rangeItem; - rangeItem = m_scene.addText(txt); - rangeItem->setDefaultTextColor(textColor); - m_rangeItems << rangeItem; - QGraphicsRectItem *box; - box = m_scene.addRect(0, 0, 10, 10); - box->setPen(Qt::NoPen); - box->setBrush(Qt::NoBrush); - m_forecastItems << box; - dayItem->setParentItem(box); - statusItem->setParentItem(box); - rangeItem->setParentItem(box); - } else { - delete dayItem; - delete statusItem; + if (xml.tokenType() == QXmlStreamReader::StartElement) { + if (xml.name() == "link") { + m_copyright->setHtml(QString("%1 (source)").arg(GET_DATA_ATTR("text")).arg(GET_DATA_ATTR("url"))); + xml.skipCurrentElement(); + break; } - break; } + } + } else if (xml.name() == "tabular") { + while (!xml.atEnd()) { + xml.readNext(); if (xml.tokenType() == QXmlStreamReader::StartElement) { - if (xml.name() == "day_of_week") { - QString s = GET_DATA_ATTR; - dayItem = m_scene.addText(s.left(3)); - dayItem->setDefaultTextColor(textColor); - } - if (xml.name() == "icon") { - QString name = extractIcon(GET_DATA_ATTR); - if (!name.isEmpty()) { - statusItem = new QGraphicsSvgItem(name); - m_scene.addItem(statusItem); + if (xml.name() == "time") { + if (!foundCurrentForecast) { + QString temperature; + QString symbol; + getSymbolTemp(xml, symbol, temperature); + if (!symbol.isEmpty()) { + delete m_iconItem; + m_iconItem = new QGraphicsSvgItem(symbol); + m_scene.addItem(m_iconItem); + m_iconItem->setParentItem(m_statusItem); + } + QString s = FORMAT_TEMPERATURE(temperature); + m_temperatureItem->setPlainText(s); + foundCurrentForecast = true; + } else { + createNewDay(xml); } + } - if (xml.name() == "low") - lowT = toCelcius(GET_DATA_ATTR, unitSystem); - if (xml.name() == "high") - highT = toCelcius(GET_DATA_ATTR, unitSystem); } } + } else if (xml.name() != "weatherdata" && xml.name() != "forecast" && xml.name() != "credit"){ + xml.skipCurrentElement(); } - } } + + + + m_timeLine.stop(); layoutItems(); animate(0); m_timeLine.start(); } + void createNewDay(QXmlStreamReader &xml) { + QGraphicsTextItem *dayItem = 0; + QString lowT; + QString highT; + QString period = GET_DATA_ATTR("period"); + QString datetime; + if (period == "0") + datetime = GET_DATA_ATTR("to"); + else + datetime = GET_DATA_ATTR("from"); + QString temperature; + QString symbol; + getSymbolTemp(xml, symbol, temperature); + lowT = highT = temperature; + QDateTime date = GET_DATETIME(datetime); + dayItem = m_scene.addText(date.date().toString("ddd")); + dayItem->setDefaultTextColor(TEXTCOLOR); + + // check for other info same day + bool saved = false; + while (!xml.atEnd()) { + xml.readNext(); + if (xml.tokenType() == QXmlStreamReader::StartElement) { + if (xml.name() == "time") { + QString period = GET_DATA_ATTR("period"); + // save data if new day starts + if (period == "0") { + saveDayItem(dayItem, lowT, highT, symbol); + createNewDay(xml); + saved = true; + } else { + updateDay(xml, lowT, highT, symbol, period == "2"); + } + } + } + } + if (!saved)// last Item + saveDayItem(dayItem, lowT, highT, symbol); + } + + void updateDay(QXmlStreamReader &xml, QString &lowT, QString &highT, QString &symbolToShow, bool updateSymbol) { + QString temperature; + QString symbol; + getSymbolTemp(xml, symbol, temperature); + if (lowT.toFloat() > temperature.toFloat()) + lowT = temperature; + if (highT.toFloat() < temperature.toFloat()) + highT = temperature; + if (updateSymbol) + symbolToShow = symbol; + } + + void saveDayItem(QGraphicsTextItem *dayItem, QString lowT, QString highT, QString symbolToShow) { + QGraphicsSvgItem *statusItem = 0; + if (!symbolToShow.isEmpty()) { + statusItem = new QGraphicsSvgItem(symbolToShow); + m_scene.addItem(statusItem); + } + if (m_dayItems.count() < 4 && dayItem && statusItem && // Show 4 days + !lowT.isEmpty() && !highT.isEmpty()) { + m_dayItems << dayItem; + m_conditionItems << statusItem; + QString txt = FORMAT_TEMPERATURE(lowT) + '/' + FORMAT_TEMPERATURE(highT); + QGraphicsTextItem* rangeItem; + rangeItem = m_scene.addText(txt); + rangeItem->setDefaultTextColor(TEXTCOLOR); + m_rangeItems << rangeItem; + QGraphicsRectItem *box; + box = m_scene.addRect(0, 0, 10, 10); + box->setPen(Qt::NoPen); + box->setBrush(Qt::NoBrush); + m_forecastItems << box; + dayItem->setParentItem(box); + statusItem->setParentItem(box); + rangeItem->setParentItem(box); + } else { + delete dayItem; + delete statusItem; + } + } + + void getSymbolTemp(QXmlStreamReader &xml, QString &symbol, QString &temp) { + bool foundIcon = false; + bool foundTemp = false; + while (!xml.atEnd()) { + xml.readNext(); + if (xml.tokenType() == QXmlStreamReader::StartElement) { + if (xml.name() == "symbol") { + QString condition = GET_DATA_ATTR("name"); + symbol = extractIcon(condition); + if (m_conditionItem->toPlainText().isEmpty()) + m_conditionItem->setPlainText(condition); + foundIcon = true; + } + if (xml.name() == "temperature") { + temp = GET_DATA_ATTR("value"); + foundTemp = true; + } + if (foundIcon && foundTemp) + break; + } + } + } + + void layoutItems() { m_scene.setSceneRect(0, 0, width() - 1, height() - 1); m_view->centerOn(width() / 2, height() / 2); @@ -361,30 +441,36 @@ private: } void layoutItemsLandscape() { - m_statusItem->setRect(0, 0, width() / 2 - 1, height() - 1); + qreal statusItemWidth = width() / 2 - 1; + m_statusItem->setRect(0, 0, statusItemWidth, height() - 1); + + m_temperatureItem->setPos(10, 2); + qreal wtemp = m_temperatureItem->boundingRect().width(); + qreal h1 = m_conditionItem->boundingRect().height(); + m_conditionItem->setPos(wtemp + 20, 2); + + m_copyright->setTextWidth(statusItemWidth); + + qreal wcity = m_cityItem->boundingRect().width(); + m_cityItem->setPos(statusItemWidth - wcity - 1, 2);; + + qreal h2 = m_copyright->boundingRect().height(); + m_copyright->setPos(0, height() - h2); if (!m_iconItem->boundingRect().isEmpty()) { - qreal dim = qMin(width() * 0.6, height() * 0.8); - qreal pad = (height() - dim) / 2; - qreal sw = dim / m_iconItem->boundingRect().width(); - qreal sh = dim / m_iconItem->boundingRect().height(); + qreal sizeLeft = qMin(statusItemWidth, height() - h2 - h1 - 10); + qreal sw = sizeLeft / m_iconItem->boundingRect().width(); + qreal sh = sizeLeft / m_iconItem->boundingRect().height(); m_iconItem->setTransform(QTransform().scale(sw, sh)); - m_iconItem->setPos(1, pad); + m_iconItem->setPos(statusItemWidth/2 - sizeLeft/2, h1 + 5); } - m_temperatureItem->setPos(2, 2); - qreal h = m_conditionItem->boundingRect().height(); - m_conditionItem->setPos(10, height() - h); - if (m_dayItems.count()) { qreal left = width() * 0.6; - qreal h = height() / m_dayItems.count(); - QFont textFont = font(); - textFont.setPixelSize(static_cast(h * 0.3)); qreal statusWidth = 0; qreal rangeWidth = 0; + qreal h = height() / m_dayItems.count(); for (int i = 0; i < m_dayItems.count(); ++i) { - m_dayItems[i]->setFont(textFont); QRectF brect = m_dayItems[i]->boundingRect(); statusWidth = qMax(statusWidth, brect.width()); brect = m_rangeItems[i]->boundingRect(); @@ -416,23 +502,22 @@ private: } void layoutItemsPortrait() { + qreal statusItemWidth = width() - 1; + m_statusItem->setRect(0, 0, statusItemWidth, height() / 2 - 1); - m_statusItem->setRect(0, 0, width() - 1, height() / 2 - 1); + m_temperatureItem->setPos(10, 2); + qreal wtemp = m_temperatureItem->boundingRect().width(); + qreal h1 = m_conditionItem->boundingRect().height(); + m_conditionItem->setPos(wtemp + 20, 2); - if (!m_iconItem->boundingRect().isEmpty()) { - qreal dim = qMin(width() * 0.8, height() * 0.4); - qreal ofsy = (height() / 2 - dim) / 2; - qreal ofsx = (width() - dim) / 3; - qreal sw = dim / m_iconItem->boundingRect().width(); - qreal sh = dim / m_iconItem->boundingRect().height(); - m_iconItem->setTransform(QTransform().scale(sw, sh)); - m_iconItem->setPos(ofsx, ofsy); - } + m_copyright->setTextWidth(statusItemWidth); + + qreal wcity = m_cityItem->boundingRect().width(); + m_cityItem->setPos(statusItemWidth - wcity - 1, 2);; - m_temperatureItem->setPos(2, 2); - qreal ch = m_conditionItem->boundingRect().height(); - qreal cw = m_conditionItem->boundingRect().width(); - m_conditionItem->setPos(width() - cw , height() / 2 - ch - 20); + m_copyright->setTextWidth(statusItemWidth); + qreal h2 = m_copyright->boundingRect().height(); + m_copyright->setPos(0, height() - h2); if (m_dayItems.count()) { qreal top = height() * 0.5; @@ -452,6 +537,14 @@ private: qreal boxh = statusHeight + rangeHeight + dim; qreal pad = (height() - top - boxh) / 2; + if (!m_iconItem->boundingRect().isEmpty()) { + qreal sizeLeft = qMin(statusItemWidth - 10, height() - top - 10); + qreal sw = sizeLeft / m_iconItem->boundingRect().width(); + qreal sh = sizeLeft / m_iconItem->boundingRect().height(); + m_iconItem->setTransform(QTransform().scale(sw, sh)); + m_iconItem->setPos(statusItemWidth/2 - sizeLeft/2, h1 + 5); + } + for (int i = 0; i < m_dayItems.count(); ++i) { qreal base = w * i; m_forecastItems[i]->setPos(base, top); -- cgit v1.2.1 From 6839117ea9870d56dc6b640fc9e2c270f036616d Mon Sep 17 00:00:00 2001 From: Sergio Ahumada Date: Thu, 17 Apr 2014 17:30:01 +0200 Subject: Bump MODULE_VERSION to 5.3.1 Change-Id: I413b22c01336204543d0c3f2ae65a58c456bd96e Reviewed-by: Oswald Buddenhagen --- .qmake.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.qmake.conf b/.qmake.conf index 88d13d1..d170e6d 100644 --- a/.qmake.conf +++ b/.qmake.conf @@ -2,4 +2,4 @@ load(qt_build_config) CONFIG += qt_example_installs CONFIG += warning_clean -MODULE_VERSION = 5.3.0 +MODULE_VERSION = 5.3.1 -- cgit v1.2.1 From bbf16bd90285658571bc30161e9687e0cc40e387 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Fri, 2 May 2014 10:55:14 +0200 Subject: Let svg plugins extend svg module svg plugins are by default not linked together with QtGui since its usage is rare. But when the pro file contains Qt += svg, then its the opposite; The application is likely to need the svg plugins. Many of the examples shipped with the SDK fails building on iOS (e.g accelbubble) because of this. Change-Id: I83873d5405fde2b3d38e836057d55fcc2ceb9b6c Reviewed-by: Oswald Buddenhagen --- src/plugins/iconengines/svgiconengine/svgiconengine.pro | 2 +- src/plugins/imageformats/svg/svg.pro | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/iconengines/svgiconengine/svgiconengine.pro b/src/plugins/iconengines/svgiconengine/svgiconengine.pro index cf09d14..2b27b3d 100644 --- a/src/plugins/iconengines/svgiconengine/svgiconengine.pro +++ b/src/plugins/iconengines/svgiconengine/svgiconengine.pro @@ -1,7 +1,7 @@ TARGET = qsvgicon PLUGIN_TYPE = iconengines -PLUGIN_EXTENDS = - +PLUGIN_EXTENDS = svg PLUGIN_CLASS_NAME = QSvgIconPlugin load(qt_plugin) diff --git a/src/plugins/imageformats/svg/svg.pro b/src/plugins/imageformats/svg/svg.pro index 9536c0b..26324af 100644 --- a/src/plugins/imageformats/svg/svg.pro +++ b/src/plugins/imageformats/svg/svg.pro @@ -1,7 +1,7 @@ TARGET = qsvg PLUGIN_TYPE = imageformats -PLUGIN_EXTENDS = - +PLUGIN_EXTENDS = svg PLUGIN_CLASS_NAME = QSvgPlugin load(qt_plugin) -- cgit v1.2.1 From 24aedcb90a6f274c6329ccfcd0ab83f7e1d0ec7d Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 16 May 2014 09:47:39 +0200 Subject: Remove dependency of the SVG icon engine plugin on QtWidgets. Use the virtual QGuiApplicationPrivate::applyQIconStyleHelper() introduced by commit 6c06e14a49773ce5572935864ed6b9be219c6103 in qtbase to adapt the icon according to the style. Change-Id: I7c429f818c012c58118c64cc3b20a87fcb712877 Reviewed-by: Olivier Goffart --- src/plugins/iconengines/iconengines.pro | 2 +- src/plugins/iconengines/svgiconengine/qsvgiconengine.cpp | 12 ++++-------- src/plugins/iconengines/svgiconengine/svgiconengine.pro | 2 +- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/plugins/iconengines/iconengines.pro b/src/plugins/iconengines/iconengines.pro index e7d1871..21bb8a7 100644 --- a/src/plugins/iconengines/iconengines.pro +++ b/src/plugins/iconengines/iconengines.pro @@ -1,3 +1,3 @@ TEMPLATE = subdirs -qtHaveModule(widgets): SUBDIRS += svgiconengine +SUBDIRS += svgiconengine diff --git a/src/plugins/iconengines/svgiconengine/qsvgiconengine.cpp b/src/plugins/iconengines/svgiconengine/qsvgiconengine.cpp index 1f47dfe..383881f 100644 --- a/src/plugins/iconengines/svgiconengine/qsvgiconengine.cpp +++ b/src/plugins/iconengines/svgiconengine/qsvgiconengine.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the plugins of the Qt Toolkit. @@ -46,12 +46,10 @@ #include "qpixmap.h" #include "qsvgrenderer.h" #include "qpixmapcache.h" -#include "qstyle.h" -#include "qapplication.h" -#include "qstyleoption.h" #include "qfileinfo.h" #include #include "qdebug.h" +#include QT_BEGIN_NAMESPACE @@ -178,10 +176,8 @@ QPixmap QSvgIconEngine::pixmap(const QSize &size, QIcon::Mode mode, renderer.render(&p); p.end(); pm = QPixmap::fromImage(img); - if (qobject_cast(QCoreApplication::instance())) { - QStyleOption opt(0); - opt.palette = QGuiApplication::palette(); - QPixmap generated = QApplication::style()->generatedIconPixmap(mode, pm, &opt); + if (qobject_cast(QCoreApplication::instance())) { + const QPixmap generated = QGuiApplicationPrivate::instance()->applyQIconStyleHelper(mode, pm); if (!generated.isNull()) pm = generated; } diff --git a/src/plugins/iconengines/svgiconengine/svgiconengine.pro b/src/plugins/iconengines/svgiconengine/svgiconengine.pro index 2b27b3d..516142b 100644 --- a/src/plugins/iconengines/svgiconengine/svgiconengine.pro +++ b/src/plugins/iconengines/svgiconengine/svgiconengine.pro @@ -9,4 +9,4 @@ HEADERS += qsvgiconengine.h SOURCES += main.cpp \ qsvgiconengine.cpp OTHER_FILES += qsvgiconengine.json -QT += xml svg gui +QT += svg core-private gui-private -- cgit v1.2.1 From 35a2f0880831d38c60d2b4820dac808f48f6f3a8 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Mon, 19 May 2014 15:34:22 +0200 Subject: Remove obsolete dependency on QtXml A while a go, QtSvg was changed to use the QXmlStream* classes from QtCore. Now, only tests/auto/qsvggenerator is left with a QtXml dependency. This patch also reverts commit b719b93770393bbf20251e1dffc70498061e612c Change-Id: I67417a27aa66a2db6d1985cad73e5bab806ad7d2 Reviewed-by: Thiago Macieira --- examples/svg/svgviewer/svgviewer.pro | 2 +- src/plugins/imageformats/svg/svg.pro | 2 +- src/svg/svg.pro | 6 ------ tests/auto/qicon_svg/qicon_svg.pro | 2 +- tests/auto/qsvgdevice/qsvgdevice.pro | 2 +- 5 files changed, 4 insertions(+), 10 deletions(-) diff --git a/examples/svg/svgviewer/svgviewer.pro b/examples/svg/svgviewer/svgviewer.pro index eb2088c..157af4d 100644 --- a/examples/svg/svgviewer/svgviewer.pro +++ b/examples/svg/svgviewer/svgviewer.pro @@ -4,7 +4,7 @@ RESOURCES = svgviewer.qrc SOURCES = main.cpp \ mainwindow.cpp \ svgview.cpp -QT += widgets svg xml +QT += widgets svg qtHaveModule(opengl): QT += opengl diff --git a/src/plugins/imageformats/svg/svg.pro b/src/plugins/imageformats/svg/svg.pro index 26324af..ce1881f 100644 --- a/src/plugins/imageformats/svg/svg.pro +++ b/src/plugins/imageformats/svg/svg.pro @@ -8,4 +8,4 @@ load(qt_plugin) HEADERS += qsvgiohandler.h SOURCES += main.cpp \ qsvgiohandler.cpp -QT += xml svg +QT += svg diff --git a/src/svg/svg.pro b/src/svg/svg.pro index e868e61..f2906ce 100644 --- a/src/svg/svg.pro +++ b/src/svg/svg.pro @@ -53,9 +53,3 @@ contains(QT_CONFIG, system-zlib) { else: \ INCLUDEPATH += $$[QT_INSTALL_HEADERS/src]/QtZlib } - -ANDROID_LIB_DEPENDENCIES = \ - lib/libQt5Xml.so - -ANDROID_BUNDLED_FILES += \ - lib/libQt5Xml.so diff --git a/tests/auto/qicon_svg/qicon_svg.pro b/tests/auto/qicon_svg/qicon_svg.pro index 87e26be..643717c 100644 --- a/tests/auto/qicon_svg/qicon_svg.pro +++ b/tests/auto/qicon_svg/qicon_svg.pro @@ -6,7 +6,7 @@ SOURCES += tst_qicon_svg.cpp RESOURCES = tst_qicon_svg.qrc wince* { - QT += xml svg + QT += svg DEPLOYMENT_PLUGIN += qsvg } TESTDATA += icons/* diff --git a/tests/auto/qsvgdevice/qsvgdevice.pro b/tests/auto/qsvgdevice/qsvgdevice.pro index d423faa..4be7c44 100644 --- a/tests/auto/qsvgdevice/qsvgdevice.pro +++ b/tests/auto/qsvgdevice/qsvgdevice.pro @@ -1,5 +1,5 @@ TARGET = tst_qsvgdevice CONFIG += testcase SOURCES += tst_qsvgdevice.cpp -QT += xml testlib widgets gui-private +QT += testlib widgets gui-private DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 -- cgit v1.2.1