diff options
-rw-r--r-- | .qmake.conf | 2 | ||||
-rw-r--r-- | doc/src/examples/bearercloud.qdoc | 6 | ||||
-rw-r--r-- | examples/svg/network/bearercloud/bearercloud.cpp | 11 | ||||
-rw-r--r-- | examples/svg/opengl/framebufferobject/glwidget.cpp | 37 | ||||
-rw-r--r-- | src/plugins/iconengines/svgiconengine/qsvgiconengine.cpp | 8 | ||||
-rw-r--r-- | src/plugins/iconengines/svgiconengine/qsvgiconengine.h | 1 | ||||
-rw-r--r-- | src/svg/qsvghandler.cpp | 2 | ||||
-rw-r--r-- | tests/auto/qicon_svg/tst_qicon_svg.cpp | 23 |
8 files changed, 55 insertions, 35 deletions
diff --git a/.qmake.conf b/.qmake.conf index e795316..08b8470 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.9.3 +MODULE_VERSION = 5.10.0 diff --git a/doc/src/examples/bearercloud.qdoc b/doc/src/examples/bearercloud.qdoc index 86ccb13..e4a21f1 100644 --- a/doc/src/examples/bearercloud.qdoc +++ b/doc/src/examples/bearercloud.qdoc @@ -68,9 +68,9 @@ \section1 Setting the Scene - When constructing the scene we first calculate some random offsets using the global qsand() - and qrand() functions. We will use these offsets to scatter the initial position of new Cloud - objects. + 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. diff --git a/examples/svg/network/bearercloud/bearercloud.cpp b/examples/svg/network/bearercloud/bearercloud.cpp index 5b817e7..610764a 100644 --- a/examples/svg/network/bearercloud/bearercloud.cpp +++ b/examples/svg/network/bearercloud/bearercloud.cpp @@ -53,16 +53,12 @@ #include <QGraphicsTextItem> #include <QTimer> -#include <QDateTime> #include <QHostInfo> +#include <QRandomGenerator> #include <QDebug> -#include <math.h> - -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif +#include <qmath.h> //! [0] BearerCloud::BearerCloud(QObject *parent) @@ -70,9 +66,8 @@ BearerCloud::BearerCloud(QObject *parent) { setSceneRect(-300, -300, 600, 600); - qsrand(QDateTime::currentDateTime().toTime_t()); - offset[QNetworkConfiguration::Active] = 2 * M_PI * qrand() / RAND_MAX; + 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; diff --git a/examples/svg/opengl/framebufferobject/glwidget.cpp b/examples/svg/opengl/framebufferobject/glwidget.cpp index f778918..a3c0d51 100644 --- a/examples/svg/opengl/framebufferobject/glwidget.cpp +++ b/examples/svg/opengl/framebufferobject/glwidget.cpp @@ -49,10 +49,9 @@ ****************************************************************************/ #include <QtGui/QImage> +#include <qmath.h> #include "glwidget.h" -#include <math.h> - #ifndef GL_MULTISAMPLE #define GL_MULTISAMPLE 0x809D #endif @@ -295,8 +294,6 @@ void GLWidget::restoreGLState() glPopAttrib(); } -#define PI 3.14159 - void GLWidget::timerEvent(QTimerEvent *) { if (QApplication::mouseButtons() != 0) @@ -309,31 +306,27 @@ void GLWidget::timerEvent(QTimerEvent *) else if (!scale_in && scale < .5f) scale_in = true; - scale = scale_in ? scale + scale*0.01f : scale-scale*0.01f; + scale *= scale_in ? 1.01f : 0.99f; rot_z += 0.3f; rot_x += 0.1f; - int dx, dy; // disturbance point - float s, v, W, t; - int i, j; - static float wt[128][128]; + static float wt = 0.0; + wt += 0.1f; + const int width = logo.width(); + const int dx = width >> 1, dy = dx; // disturbance point + const float W = .3f; + const float v = -4; // wave speed const int AMP = 5; - dx = dy = width >> 1; - - W = .3f; - v = -4; // wave speed - - for (i = 0; i < width; ++i) { - for ( j = 0; j < width; ++j) { - s = sqrt((double) ((j - dx) * (j - dx) + (i - dy) * (i - dy))); - wt[i][j] += 0.1f; - t = s / v; + for (int i = 0; i < width; ++i) { + for (int j = 0; j < width; ++j) { + const float s = hypot(j - dx, i - dy); + const double raw = AMP * sin(2 * M_PI * W * (wt + s / v)); if (s != 0) - wave[i*width + j] = AMP * sin(2 * PI * W * (wt[i][j] + t)) / (0.2*(s + 2)); + wave[i * width + j] = raw / (0.2 * (s + 2)); else - wave[i*width + j] = AMP * sin(2 * PI * W * (wt[i][j] + t)); - } + wave[i * width + j] = raw; + } } } diff --git a/src/plugins/iconengines/svgiconengine/qsvgiconengine.cpp b/src/plugins/iconengines/svgiconengine/qsvgiconengine.cpp index 2644326..734f4bb 100644 --- a/src/plugins/iconengines/svgiconengine/qsvgiconengine.cpp +++ b/src/plugins/iconengines/svgiconengine/qsvgiconengine.cpp @@ -375,6 +375,14 @@ bool QSvgIconEngine::write(QDataStream &out) const return true; } +void QSvgIconEngine::virtual_hook(int id, void *data) +{ + if (id == QIconEngine::IsNullHook) { + *reinterpret_cast<bool*>(data) = d->svgFiles.isEmpty() && !d->addedPixmaps; + } + QIconEngine::virtual_hook(id, data); +} + QT_END_NAMESPACE #endif // QT_NO_SVGRENDERER diff --git a/src/plugins/iconengines/svgiconengine/qsvgiconengine.h b/src/plugins/iconengines/svgiconengine/qsvgiconengine.h index cf4f255..672828c 100644 --- a/src/plugins/iconengines/svgiconengine/qsvgiconengine.h +++ b/src/plugins/iconengines/svgiconengine/qsvgiconengine.h @@ -70,6 +70,7 @@ public: bool read(QDataStream &in) override; bool write(QDataStream &out) const override; + void virtual_hook(int id, void *data) override; private: QSharedDataPointer<QSvgIconEnginePrivate> d; }; diff --git a/src/svg/qsvghandler.cpp b/src/svg/qsvghandler.cpp index 022afb6..6c0e742 100644 --- a/src/svg/qsvghandler.cpp +++ b/src/svg/qsvghandler.cpp @@ -2201,7 +2201,7 @@ static inline QSvgNode::DisplayMode displayStringToEnum(const QString &str) return QSvgNode::TableMode; } else if (str == QLatin1String("inline-table")) { return QSvgNode::InlineTableMode; - } else if (str == QLatin1String("table-row")) { + } else if (str == QLatin1String("table-row-group")) { return QSvgNode::TableRowGroupMode; } else if (str == QLatin1String("table-header-group")) { return QSvgNode::TableHeaderGroupMode; diff --git a/tests/auto/qicon_svg/tst_qicon_svg.cpp b/tests/auto/qicon_svg/tst_qicon_svg.cpp index 2271f21..170ec37 100644 --- a/tests/auto/qicon_svg/tst_qicon_svg.cpp +++ b/tests/auto/qicon_svg/tst_qicon_svg.cpp @@ -43,6 +43,8 @@ private slots: void svgActualSize(); void svg(); void availableSizes(); + void isNull(); + private: QString prefix; @@ -139,5 +141,26 @@ void tst_QIcon_Svg::availableSizes() } } +void tst_QIcon_Svg::isNull() +{ + { + //checks that an invalid file results in the icon being null + QIcon icon(prefix + "nonExistentFile.svg"); + QVERIFY(icon.isNull()); + } + { + //valid svg, we're not null + QIcon icon(prefix + "heart.svg"); + QVERIFY(!icon.isNull()); + } + { + //invalid svg, but a pixmap added means we're not null + QIcon icon(prefix + "nonExistentFile.svg"); + icon.addFile(prefix + "image.png", QSize(32,32)); + QVERIFY(!icon.isNull()); + } + +} + QTEST_MAIN(tst_QIcon_Svg) #include "tst_qicon_svg.moc" |