diff options
Diffstat (limited to 'src/gui')
46 files changed, 262 insertions, 144 deletions
diff --git a/src/gui/accessible/qaccessible.cpp b/src/gui/accessible/qaccessible.cpp index 7922d6fb06..a789e65284 100644 --- a/src/gui/accessible/qaccessible.cpp +++ b/src/gui/accessible/qaccessible.cpp @@ -2029,7 +2029,7 @@ QAccessibleTextInterface::~QAccessibleTextInterface() \fn void QAccessibleTextInterface::selection(int selectionIndex, int *startOffset, int *endOffset) const Returns a selection. The size of the selection is returned in \a startOffset and \a endOffset. - If there is no selection both \a startOffset and \a endOffset are 0. + If there is no selection both \a startOffset and \a endOffset are \nullptr. The accessibility APIs support multiple selections. For most widgets though, only one selection is supported with \a selectionIndex equal to 0. diff --git a/src/gui/doc/snippets/code/src_gui_kernel_qapplication.cpp b/src/gui/doc/snippets/code/src_gui_kernel_qapplication.cpp index f1f51c0582..138d0dfa1b 100644 --- a/src/gui/doc/snippets/code/src_gui_kernel_qapplication.cpp +++ b/src/gui/doc/snippets/code/src_gui_kernel_qapplication.cpp @@ -91,7 +91,7 @@ int main(int argc, char *argv[]) //! [3] QSize MyWidget::sizeHint() const { - return QSize(80, 25).expandedTo(QApplication::globalStrut()); + return QSize(80, 25); } //! [3] diff --git a/src/gui/doc/src/qtgui.qdoc b/src/gui/doc/src/qtgui.qdoc index 392b6040cb..f8a3ce84aa 100644 --- a/src/gui/doc/src/qtgui.qdoc +++ b/src/gui/doc/src/qtgui.qdoc @@ -62,7 +62,7 @@ \include module-use.qdocinc using qt module \quotefile overview/using-qt-gui.cmake - See also the \l[QtDoc]{Build with CMake} overview. + See also the \l{Build with CMake} overview. \section2 Building with qmake diff --git a/src/gui/image/qbitmap.cpp b/src/gui/image/qbitmap.cpp index 455045eb57..a44f7151b1 100644 --- a/src/gui/image/qbitmap.cpp +++ b/src/gui/image/qbitmap.cpp @@ -218,7 +218,7 @@ QBitmap::~QBitmap() */ QBitmap::operator QVariant() const { - return QVariant(QVariant::Bitmap, this); + return QVariant(QMetaType::QBitmap, this); } static QBitmap makeBitmap(QImage &&image, Qt::ImageConversionFlags flags) diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp index 19be066d23..38285dd827 100644 --- a/src/gui/image/qicon.cpp +++ b/src/gui/image/qicon.cpp @@ -782,7 +782,7 @@ QIcon &QIcon::operator=(const QIcon &other) */ QIcon::operator QVariant() const { - return QVariant(QVariant::Icon, this); + return QVariant(QMetaType::QIcon, this); } /*! \fn int QIcon::serialNumber() const diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 08b1373f96..74dc81e365 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -1067,7 +1067,7 @@ int QImage::devType() const */ QImage::operator QVariant() const { - return QVariant(QVariant::Image, this); + return QVariant(QMetaType::QImage, this); } /*! @@ -3649,8 +3649,8 @@ QImage QImage::fromData(const uchar *data, int size, const char *format) /*! Saves the image to the file with the given \a fileName, using the given image file \a format and \a quality factor. If \a format is - 0, QImage will attempt to guess the format by looking at \a fileName's - suffix. + \nullptr, QImage will attempt to guess the format by looking at + \a fileName's suffix. The \a quality factor must be in the range 0 to 100 or -1. Specify 0 to obtain small compressed files, 100 for large uncompressed diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp index 3fce64cb20..adadba2057 100644 --- a/src/gui/image/qpixmap.cpp +++ b/src/gui/image/qpixmap.cpp @@ -402,7 +402,7 @@ QPixmap &QPixmap::operator=(const QPixmap &pixmap) */ QPixmap::operator QVariant() const { - return QVariant(QVariant::Pixmap, this); + return QVariant(QMetaType::QPixmap, this); } /*! @@ -813,8 +813,8 @@ bool QPixmap::loadFromData(const uchar *buf, uint len, const char *format, Qt::I 0 to obtain small compressed files, 100 for large uncompressed files, and -1 to use the default settings. - If \a format is 0, an image format will be chosen from \a fileName's - suffix. + If \a format is \nullptr, an image format will be chosen from + \a fileName's suffix. \sa {QPixmap#Reading and Writing Image Files}{Reading and Writing Image Files} diff --git a/src/gui/itemmodels/qstandarditemmodel.cpp b/src/gui/itemmodels/qstandarditemmodel.cpp index 9bdc22b49e..fc9424763e 100644 --- a/src/gui/itemmodels/qstandarditemmodel.cpp +++ b/src/gui/itemmodels/qstandarditemmodel.cpp @@ -926,7 +926,7 @@ void QStandardItem::setData(const QVariant &value, int role) for (it = d->values.begin(); it != d->values.end(); ++it) { if ((*it).role == role) { if (value.isValid()) { - if ((*it).value.type() == value.type() && (*it).value == value) + if ((*it).value.userType() == value.userType() && (*it).value == value) return; (*it).value = value; } else { diff --git a/src/gui/kernel/qcursor.cpp b/src/gui/kernel/qcursor.cpp index f5a794b642..7f6fdafbd0 100644 --- a/src/gui/kernel/qcursor.cpp +++ b/src/gui/kernel/qcursor.cpp @@ -325,7 +325,7 @@ QDataStream &operator<<(QDataStream &s, const QCursor &c) if (isPixmap) s << c.pixmap(); else - s << *c.bitmap() << *c.mask(); + s << c.bitmap(Qt::ReturnByValue) << c.mask(Qt::ReturnByValue); s << c.hotSpot(); } return s; @@ -565,7 +565,12 @@ void QCursor::setShape(Qt::CursorShape shape) } } +#if QT_DEPRECATED_SINCE(5, 15) /*! + \deprecated + + New code should use the other overload which returns QBitmap by-value. + Returns the cursor bitmap, or \nullptr if it is one of the standard cursors. */ @@ -577,6 +582,10 @@ const QBitmap *QCursor::bitmap() const } /*! + \deprecated + + New code should use the other overload which returns QBitmap by-value. + Returns the cursor bitmap mask, or \nullptr if it is one of the standard cursors. */ @@ -587,6 +596,71 @@ const QBitmap *QCursor::mask() const QCursorData::initialize(); return d->bmm; } +#endif // QT_DEPRECATED_SINCE(5, 15) + +/*! + \since 5.15 + + Returns the cursor bitmap, or a null bitmap if it is one of the + standard cursors. + + Previously, Qt provided a version of \c bitmap() which returned the bitmap + by-pointer. That version is now deprecated. To maintain compatibility + with old code, you can explicitly differentiate between the by-pointer + function and the by-value function: + + \code + const QBitmap *bmpPtr = cursor->bitmap(); + QBitmap bmpVal = cursor->bitmap(Qt::ReturnByValue); + \endcode + + If you disable the deprecated version using the QT_DISABLE_DEPRECATED_BEFORE + macro, then you can omit \c Qt::ReturnByValue as shown below: + + \code + QBitmap bmpVal = cursor->bitmap(); + \endcode +*/ +QBitmap QCursor::bitmap(Qt::ReturnByValue_t) const +{ + if (!QCursorData::initialized) + QCursorData::initialize(); + if (d->bm) + return *(d->bm); + return QBitmap(); +} + +/*! + \since 5.15 + + Returns the cursor bitmap mask, or a null bitmap if it is one of the + standard cursors. + + Previously, Qt provided a version of \c mask() which returned the bitmap + by-pointer. That version is now deprecated. To maintain compatibility + with old code, you can explicitly differentiate between the by-pointer + function and the by-value function: + + \code + const QBitmap *bmpPtr = cursor->mask(); + QBitmap bmpVal = cursor->mask(Qt::ReturnByValue); + \endcode + + If you disable the deprecated version using the QT_DISABLE_DEPRECATED_BEFORE + macro, then you can omit \c Qt::ReturnByValue as shown below: + + \code + QBitmap bmpVal = cursor->mask(); + \endcode +*/ +QBitmap QCursor::mask(Qt::ReturnByValue_t) const +{ + if (!QCursorData::initialized) + QCursorData::initialize(); + if (d->bmm) + return *(d->bmm); + return QBitmap(); +} /*! Returns the cursor pixmap. This is only valid if the cursor is a @@ -657,7 +731,7 @@ QCursor &QCursor::operator=(const QCursor &c) */ QCursor::operator QVariant() const { - return QVariant(QVariant::Cursor, this); + return QVariant(QMetaType::QCursor, this); } #ifndef QT_NO_DEBUG_STREAM diff --git a/src/gui/kernel/qcursor.h b/src/gui/kernel/qcursor.h index 7966e35840..7a11fe59ee 100644 --- a/src/gui/kernel/qcursor.h +++ b/src/gui/kernel/qcursor.h @@ -97,8 +97,19 @@ public: Qt::CursorShape shape() const; void setShape(Qt::CursorShape newShape); - const QBitmap *bitmap() const; - const QBitmap *mask() const; +#if QT_DEPRECATED_SINCE(5, 15) + QT_DEPRECATED_VERSION_X(5, 15, "Use the other overload which returns QBitmap by-value") + const QBitmap *bitmap() const; // ### Qt 7: Remove function + + QT_DEPRECATED_VERSION_X(5, 15, "Use the other overload which returns QBitmap by-value") + const QBitmap *mask() const; // ### Qt 7: Remove function + + QBitmap bitmap(Qt::ReturnByValue_t) const; + QBitmap mask(Qt::ReturnByValue_t) const; +#else + QBitmap bitmap(Qt::ReturnByValue_t = Qt::ReturnByValue) const; // ### Qt 7: Remove arg + QBitmap mask(Qt::ReturnByValue_t = Qt::ReturnByValue) const; // ### Qt 7: Remove arg +#endif // QT_DEPRECATED_SINCE(5, 15) QPixmap pixmap() const; QPoint hotSpot() const; diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index e36080eee2..5a71475dc9 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -946,7 +946,7 @@ QWheelEvent::~QWheelEvent() \li or scrolling has ended and the distance did not change anymore (Qt::ScrollEnd). \endlist - \see pixelDelta() + \sa pixelDelta() */ /*! @@ -3355,7 +3355,7 @@ QWhatsThisClickedEvent::~QWhatsThisClickedEvent() \a action is the action that is changed, added, or removed. If \a type is ActionAdded, the action is to be inserted before the - action \a before. If \a before is 0, the action is appended. + action \a before. If \a before is \nullptr, the action is appended. */ QActionEvent::QActionEvent(int type, QGuiAction *action, QGuiAction *before) : QEvent(static_cast<QEvent::Type>(type)), act(action), bef(before) diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index d72cc2df79..a723ca6e7f 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -592,6 +592,21 @@ static QWindowGeometrySpecification windowGeometrySpecification = Q_WINDOW_GEOME \list \li \c {altgr}, detect the key \c {AltGr} found on some keyboards as Qt::GroupSwitchModifier (since Qt 5.12). + \li \c {darkmode=[1|2]} controls how Qt responds to the activation + of the \e{Dark Mode for applications} introduced in Windows 10 + 1903 (since Qt 5.15). + + A value of 1 causes Qt to switch the window borders to black + when \e{Dark Mode for applications} is activated and no High + Contrast Theme is in use. This is intended for applications + that implement their own theming. + + A value of 2 will in addition cause the Windows Vista style to + be deactivated and switch to the Windows style using a + simplified palette in dark mode. This is currently + experimental pending the introduction of new style that + properly adapts to dark mode. + \li \c {dialogs=[xp|none]}, \c xp uses XP-style native dialogs and \c none disables them. diff --git a/src/gui/kernel/qguivariant.cpp b/src/gui/kernel/qguivariant.cpp index 0f29633222..94296dd6fc 100644 --- a/src/gui/kernel/qguivariant.cpp +++ b/src/gui/kernel/qguivariant.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtGui module of the Qt Toolkit. @@ -41,6 +41,7 @@ #include "qbitmap.h" #include "qbrush.h" #include "qcolor.h" +#include "qcolorspace.h" #include "qcursor.h" #include "qfont.h" #include "qimage.h" @@ -180,25 +181,25 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) { switch (t) { - case QVariant::ByteArray: - if (d->type == QVariant::Color) { + case QMetaType::QByteArray: + if (d->type == QMetaType::QColor) { const QColor *c = v_cast<QColor>(d); *static_cast<QByteArray *>(result) = c->name(c->alpha() != 255 ? QColor::HexArgb : QColor::HexRgb).toLatin1(); return true; } break; - case QVariant::String: { + case QMetaType::QString: { QString *str = static_cast<QString *>(result); switch (d->type) { #if QT_CONFIG(shortcut) - case QVariant::KeySequence: + case QMetaType::QKeySequence: *str = (*v_cast<QKeySequence>(d)).toString(QKeySequence::NativeText); return true; #endif - case QVariant::Font: + case QMetaType::QFont: *str = v_cast<QFont>(d)->toString(); return true; - case QVariant::Color: { + case QMetaType::QColor: { const QColor *c = v_cast<QColor>(d); *str = c->name(c->alpha() != 255 ? QColor::HexArgb : QColor::HexRgb); return true; @@ -208,85 +209,85 @@ static bool convert(const QVariant::Private *d, int t, } break; } - case QVariant::Pixmap: - if (d->type == QVariant::Image) { + case QMetaType::QPixmap: + if (d->type == QMetaType::QImage) { *static_cast<QPixmap *>(result) = QPixmap::fromImage(*v_cast<QImage>(d)); return true; - } else if (d->type == QVariant::Bitmap) { + } else if (d->type == QMetaType::QBitmap) { *static_cast<QPixmap *>(result) = *v_cast<QBitmap>(d); return true; - } else if (d->type == QVariant::Brush) { + } else if (d->type == QMetaType::QBrush) { if (v_cast<QBrush>(d)->style() == Qt::TexturePattern) { *static_cast<QPixmap *>(result) = v_cast<QBrush>(d)->texture(); return true; } } break; - case QVariant::Image: - if (d->type == QVariant::Pixmap) { + case QMetaType::QImage: + if (d->type == QMetaType::QPixmap) { *static_cast<QImage *>(result) = v_cast<QPixmap>(d)->toImage(); return true; - } else if (d->type == QVariant::Bitmap) { + } else if (d->type == QMetaType::QBitmap) { *static_cast<QImage *>(result) = v_cast<QBitmap>(d)->toImage(); return true; } break; - case QVariant::Bitmap: - if (d->type == QVariant::Pixmap) { + case QMetaType::QBitmap: + if (d->type == QMetaType::QPixmap) { *static_cast<QBitmap *>(result) = *v_cast<QPixmap>(d); return true; - } else if (d->type == QVariant::Image) { + } else if (d->type == QMetaType::QImage) { *static_cast<QBitmap *>(result) = QBitmap::fromImage(*v_cast<QImage>(d)); return true; } break; #if QT_CONFIG(shortcut) - case QVariant::Int: - if (d->type == QVariant::KeySequence) { + case QMetaType::Int: + if (d->type == QMetaType::QKeySequence) { const QKeySequence &seq = *v_cast<QKeySequence>(d); *static_cast<int *>(result) = seq.isEmpty() ? 0 : seq[0]; return true; } break; #endif - case QVariant::Font: - if (d->type == QVariant::String) { + case QMetaType::QFont: + if (d->type == QMetaType::QString) { QFont *f = static_cast<QFont *>(result); f->fromString(*v_cast<QString>(d)); return true; } break; - case QVariant::Color: - if (d->type == QVariant::String) { + case QMetaType::QColor: + if (d->type == QMetaType::QString) { static_cast<QColor *>(result)->setNamedColor(*v_cast<QString>(d)); return static_cast<QColor *>(result)->isValid(); - } else if (d->type == QVariant::ByteArray) { + } else if (d->type == QMetaType::QByteArray) { static_cast<QColor *>(result)->setNamedColor(QLatin1String(*v_cast<QByteArray>(d))); return true; - } else if (d->type == QVariant::Brush) { + } else if (d->type == QMetaType::QBrush) { if (v_cast<QBrush>(d)->style() == Qt::SolidPattern) { *static_cast<QColor *>(result) = v_cast<QBrush>(d)->color(); return true; } } break; - case QVariant::Brush: - if (d->type == QVariant::Color) { + case QMetaType::QBrush: + if (d->type == QMetaType::QColor) { *static_cast<QBrush *>(result) = QBrush(*v_cast<QColor>(d)); return true; - } else if (d->type == QVariant::Pixmap) { + } else if (d->type == QMetaType::QPixmap) { *static_cast<QBrush *>(result) = QBrush(*v_cast<QPixmap>(d)); return true; } break; #if QT_CONFIG(shortcut) - case QVariant::KeySequence: { + case QMetaType::QKeySequence: { QKeySequence *seq = static_cast<QKeySequence *>(result); switch (d->type) { - case QVariant::String: + case QMetaType::QString: *seq = QKeySequence(*v_cast<QString>(d)); return true; - case QVariant::Int: + case QMetaType::Int: *seq = QKeySequence(d->data.i); return true; default: @@ -296,7 +297,7 @@ static bool convert(const QVariant::Private *d, int t, } #endif #ifndef QT_NO_ICON - case QVariant::Icon: { + case QMetaType::QIcon: { if (ok) *ok = false; return false; diff --git a/src/gui/kernel/qinternalmimedata.cpp b/src/gui/kernel/qinternalmimedata.cpp index 8f4da1afb5..d5cdc743ee 100644 --- a/src/gui/kernel/qinternalmimedata.cpp +++ b/src/gui/kernel/qinternalmimedata.cpp @@ -112,22 +112,23 @@ QVariant QInternalMimeData::retrieveData(const QString &mimeType, QVariant::Type { QVariant data = retrieveData_sys(mimeType, type); if (mimeType == QLatin1String("application/x-qt-image")) { - if (data.isNull() || (data.type() == QVariant::ByteArray && data.toByteArray().isEmpty())) { + if (data.isNull() || (data.userType() == QMetaType::QByteArray && data.toByteArray().isEmpty())) { // try to find an image QStringList imageFormats = imageReadMimeFormats(); for (int i = 0; i < imageFormats.size(); ++i) { data = retrieveData_sys(imageFormats.at(i), type); - if (data.isNull() || (data.type() == QVariant::ByteArray && data.toByteArray().isEmpty())) + if (data.isNull() || (data.userType() == QMetaType::QByteArray && data.toByteArray().isEmpty())) continue; break; } } + int typeId = type; // we wanted some image type, but all we got was a byte array. Convert it to an image. - if (data.type() == QVariant::ByteArray - && (type == QVariant::Image || type == QVariant::Pixmap || type == QVariant::Bitmap)) + if (data.userType() == QMetaType::QByteArray + && (typeId == QMetaType::QImage || typeId == QMetaType::QPixmap || typeId == QMetaType::QBitmap)) data = QImage::fromData(data.toByteArray()); - } else if (mimeType == QLatin1String("application/x-color") && data.type() == QVariant::ByteArray) { + } else if (mimeType == QLatin1String("application/x-color") && data.userType() == QMetaType::QByteArray) { QColor c; QByteArray ba = data.toByteArray(); if (ba.size() == 8) { @@ -140,7 +141,7 @@ QVariant QInternalMimeData::retrieveData(const QString &mimeType, QVariant::Type } else { qWarning("Qt: Invalid color format"); } - } else if (data.type() != type && data.type() == QVariant::ByteArray) { + } else if (data.userType() != int(type) && data.userType() == QMetaType::QByteArray) { // try to use mime data's internal conversion stuf. QInternalMimeData *that = const_cast<QInternalMimeData *>(this); that->setData(mimeType, data.toByteArray()); diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp index d5bdf1f15b..57a89bb8c2 100644 --- a/src/gui/kernel/qkeysequence.cpp +++ b/src/gui/kernel/qkeysequence.cpp @@ -1402,7 +1402,7 @@ QKeySequence::SequenceMatch QKeySequence::matches(const QKeySequence &seq) const */ QKeySequence::operator QVariant() const { - return QVariant(QVariant::KeySequence, this); + return QVariant(QMetaType::QKeySequence, this); } /*! \fn QKeySequence::operator int () const diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp index ab71434c13..fbaff74561 100644 --- a/src/gui/kernel/qopenglcontext.cpp +++ b/src/gui/kernel/qopenglcontext.cpp @@ -942,7 +942,7 @@ GLuint QOpenGLContext::defaultFramebufferObject() const The latter may happen if the surface is not exposed, or the graphics hardware is not available due to e.g. the application being suspended. - If \a surface is 0 this is equivalent to calling doneCurrent(). + If \a surface is \nullptr this is equivalent to calling doneCurrent(). Avoid calling this function from a different thread than the one the QOpenGLContext instance lives in. If you wish to use QOpenGLContext from a diff --git a/src/gui/kernel/qpalette.cpp b/src/gui/kernel/qpalette.cpp index e31ce00e14..f6180be8a8 100644 --- a/src/gui/kernel/qpalette.cpp +++ b/src/gui/kernel/qpalette.cpp @@ -725,7 +725,7 @@ QPalette &QPalette::operator=(const QPalette &p) */ QPalette::operator QVariant() const { - return QVariant(QVariant::Palette, this); + return QVariant(QMetaType::QPalette, this); } /*! diff --git a/src/gui/math3d/qmatrix4x4.cpp b/src/gui/math3d/qmatrix4x4.cpp index ad4cdfdbf4..6666eb037f 100644 --- a/src/gui/math3d/qmatrix4x4.cpp +++ b/src/gui/math3d/qmatrix4x4.cpp @@ -2007,7 +2007,7 @@ void QMatrix4x4::optimize() */ QMatrix4x4::operator QVariant() const { - return QVariant(QVariant::Matrix4x4, this); + return QVariant(QMetaType::QMatrix4x4, this); } #ifndef QT_NO_DEBUG_STREAM diff --git a/src/gui/math3d/qquaternion.cpp b/src/gui/math3d/qquaternion.cpp index 899ec12eb3..5f15949c5b 100644 --- a/src/gui/math3d/qquaternion.cpp +++ b/src/gui/math3d/qquaternion.cpp @@ -983,7 +983,7 @@ QQuaternion QQuaternion::nlerp */ QQuaternion::operator QVariant() const { - return QVariant(QVariant::Quaternion, this); + return QVariant(QMetaType::QQuaternion, this); } #ifndef QT_NO_DEBUG_STREAM diff --git a/src/gui/math3d/qvector2d.cpp b/src/gui/math3d/qvector2d.cpp index c04f8b1cbf..5f651cf376 100644 --- a/src/gui/math3d/qvector2d.cpp +++ b/src/gui/math3d/qvector2d.cpp @@ -531,7 +531,7 @@ QVector4D QVector2D::toVector4D() const */ QVector2D::operator QVariant() const { - return QVariant(QVariant::Vector2D, this); + return QVariant(QMetaType::QVector2D, this); } #ifndef QT_NO_DEBUG_STREAM diff --git a/src/gui/math3d/qvector3d.cpp b/src/gui/math3d/qvector3d.cpp index 4f72c1da66..08c3de99d2 100644 --- a/src/gui/math3d/qvector3d.cpp +++ b/src/gui/math3d/qvector3d.cpp @@ -706,7 +706,7 @@ QVector4D QVector3D::toVector4D() const */ QVector3D::operator QVariant() const { - return QVariant(QVariant::Vector3D, this); + return QVariant(QMetaType::QVector3D, this); } /*! diff --git a/src/gui/math3d/qvector4d.cpp b/src/gui/math3d/qvector4d.cpp index 3a68bd6cb7..070ea7454e 100644 --- a/src/gui/math3d/qvector4d.cpp +++ b/src/gui/math3d/qvector4d.cpp @@ -608,7 +608,7 @@ QVector3D QVector4D::toVector3DAffine() const */ QVector4D::operator QVariant() const { - return QVariant(QVariant::Vector4D, this); + return QVariant(QMetaType::QVector4D, this); } #ifndef QT_NO_DEBUG_STREAM diff --git a/src/gui/painting/qbrush.cpp b/src/gui/painting/qbrush.cpp index 83032bdc4f..e84916e063 100644 --- a/src/gui/painting/qbrush.cpp +++ b/src/gui/painting/qbrush.cpp @@ -672,7 +672,7 @@ QBrush &QBrush::operator=(const QBrush &b) */ QBrush::operator QVariant() const { - return QVariant(QVariant::Brush, this); + return QVariant(QMetaType::QBrush, this); } /*! diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp index c567b25468..e544fce70e 100644 --- a/src/gui/painting/qcolor.cpp +++ b/src/gui/painting/qcolor.cpp @@ -2940,7 +2940,7 @@ bool QColor::operator!=(const QColor &color) const noexcept */ QColor::operator QVariant() const { - return QVariant(QVariant::Color, this); + return QVariant(QMetaType::QColor, this); } /*! \internal diff --git a/src/gui/painting/qcolorspace.cpp b/src/gui/painting/qcolorspace.cpp index 0fb0e9ee33..7ebd5f1bf4 100644 --- a/src/gui/painting/qcolorspace.cpp +++ b/src/gui/painting/qcolorspace.cpp @@ -744,6 +744,15 @@ QColorTransform QColorSpace::transformationToColorSpace(const QColorSpace &color return d_ptr->transformationToColorSpace(colorspace.d_ptr); } +/*! + Returns the color space as a QVariant. + \since 5.15 +*/ +QColorSpace::operator QVariant() const +{ + return QVariant(QMetaType::QColorSpace, this); +} + /***************************************************************************** QColorSpace stream functions *****************************************************************************/ diff --git a/src/gui/painting/qcolorspace.h b/src/gui/painting/qcolorspace.h index e6bc62d58a..08c9944301 100644 --- a/src/gui/painting/qcolorspace.h +++ b/src/gui/painting/qcolorspace.h @@ -44,6 +44,7 @@ #include <QtGui/qcolortransform.h> #include <QtCore/qobjectdefs.h> #include <QtCore/qshareddata.h> +#include <QtCore/qvariant.h> QT_BEGIN_NAMESPACE @@ -125,6 +126,7 @@ public: QColorTransform transformationToColorSpace(const QColorSpace &colorspace) const; + operator QVariant() const; private: Q_DECLARE_PRIVATE(QColorSpace) diff --git a/src/gui/painting/qmatrix.cpp b/src/gui/painting/qmatrix.cpp index b1f01332b6..890b0079de 100644 --- a/src/gui/painting/qmatrix.cpp +++ b/src/gui/painting/qmatrix.cpp @@ -1087,7 +1087,7 @@ QMatrix &QMatrix::operator=(const QMatrix &matrix) noexcept */ QMatrix::operator QVariant() const { - return QVariant(QVariant::Matrix, this); + return QVariant(QMetaType::QMatrix, this); } Q_GUI_EXPORT QPainterPath operator *(const QPainterPath &p, const QMatrix &m) diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index bc65ed56e3..10920c38fe 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -342,7 +342,7 @@ QRasterPaintEnginePrivate::QRasterPaintEnginePrivate() : */ /*! - \fn Type QRasterPaintEngine::type() const + \fn QPaintEngine::Type QRasterPaintEngine::type() const \reimp */ diff --git a/src/gui/painting/qpen.cpp b/src/gui/painting/qpen.cpp index 1a940443d1..01e581d2ed 100644 --- a/src/gui/painting/qpen.cpp +++ b/src/gui/painting/qpen.cpp @@ -408,7 +408,7 @@ QPen &QPen::operator=(const QPen &p) noexcept */ QPen::operator QVariant() const { - return QVariant(QVariant::Pen, this); + return QVariant(QMetaType::QPen, this); } /*! diff --git a/src/gui/painting/qpolygon.cpp b/src/gui/painting/qpolygon.cpp index 3bf6004fcc..20337477b7 100644 --- a/src/gui/painting/qpolygon.cpp +++ b/src/gui/painting/qpolygon.cpp @@ -716,7 +716,7 @@ QPolygon QPolygonF::toPolygon() const */ QPolygon::operator QVariant() const { - return QVariant(QVariant::Polygon, this); + return QVariant(QMetaType::QPolygon, this); } /***************************************************************************** diff --git a/src/gui/painting/qregion.cpp b/src/gui/painting/qregion.cpp index 783b02fb93..44ee038194 100644 --- a/src/gui/painting/qregion.cpp +++ b/src/gui/painting/qregion.cpp @@ -599,7 +599,7 @@ QRegion& QRegion::operator^=(const QRegion &r) */ QRegion::operator QVariant() const { - return QVariant(QVariant::Region, this); + return QVariant(QMetaType::QRegion, this); } /*! diff --git a/src/gui/painting/qtransform.cpp b/src/gui/painting/qtransform.cpp index d75b66c50b..279a817ff1 100644 --- a/src/gui/painting/qtransform.cpp +++ b/src/gui/painting/qtransform.cpp @@ -2155,7 +2155,7 @@ QTransform::TransformationType QTransform::type() const */ QTransform::operator QVariant() const { - return QVariant(QVariant::Transform, this); + return QVariant(QMetaType::QTransform, this); } diff --git a/src/gui/rhi/qrhi.cpp b/src/gui/rhi/qrhi.cpp index d2c8ae104e..a9c6835687 100644 --- a/src/gui/rhi/qrhi.cpp +++ b/src/gui/rhi/qrhi.cpp @@ -2361,7 +2361,7 @@ QRhiResource::Type QRhiRenderPassDescriptor::resourceType() const /*! \return a pointer to a backend-specific QRhiNativeHandles subclass, such as - QRhiVulkanRenderPassNativeHandles. The returned value is null when exposing + QRhiVulkanRenderPassNativeHandles. The returned value is \nullptr when exposing the underlying native resources is not supported by the backend. \sa QRhiVulkanRenderPassNativeHandles @@ -4933,7 +4933,7 @@ void QRhiCommandBuffer::dispatch(int x, int y, int z) /*! \return a pointer to a backend-specific QRhiNativeHandles subclass, such as - QRhiVulkanCommandBufferNativeHandles. The returned value is null when + QRhiVulkanCommandBufferNativeHandles. The returned value is \nullptr when exposing the underlying native resources is not supported by, or not applicable to, the backend. diff --git a/src/gui/rhi/qrhivulkan.cpp b/src/gui/rhi/qrhivulkan.cpp index f4c72d2cca..e7faa0cadd 100644 --- a/src/gui/rhi/qrhivulkan.cpp +++ b/src/gui/rhi/qrhivulkan.cpp @@ -1351,8 +1351,8 @@ bool QRhiVulkan::recreateSwapChain(QRhiSwapChain *swapChain) quint32 actualSwapChainBufferCount = 0; err = vkGetSwapchainImagesKHR(dev, swapChainD->sc, &actualSwapChainBufferCount, nullptr); - if (err != VK_SUCCESS || actualSwapChainBufferCount < 2) { - qWarning("Failed to get swapchain images: %d (count=%u)", err, actualSwapChainBufferCount); + if (err != VK_SUCCESS || actualSwapChainBufferCount == 0) { + qWarning("Failed to get swapchain images: %d", err); return false; } @@ -1528,7 +1528,8 @@ void QRhiVulkan::releaseSwapChainResources(QRhiSwapChain *swapChain) QRhi::FrameOpResult QRhiVulkan::beginFrame(QRhiSwapChain *swapChain, QRhi::BeginFrameFlags flags) { QVkSwapChain *swapChainD = QRHI_RES(QVkSwapChain, swapChain); - QVkSwapChain::FrameResources &frame(swapChainD->frameRes[swapChainD->currentFrameSlot]); + const int frameResIndex = swapChainD->bufferCount > 1 ? swapChainD->currentFrameSlot : 0; + QVkSwapChain::FrameResources &frame(swapChainD->frameRes[frameResIndex]); QRhiProfilerPrivate *rhiP = profilerPrivateOrNull(); if (!frame.imageAcquired) { @@ -1571,7 +1572,7 @@ QRhi::FrameOpResult QRhiVulkan::beginFrame(QRhiSwapChain *swapChain, QRhi::Begin // will make B wait for A's frame 0 commands, so if a resource is written // in B's frame or when B checks for pending resource releases, that won't // mess up A's in-flight commands (as they are not in flight anymore). - waitCommandCompletion(int(swapChainD->currentFrameSlot)); + waitCommandCompletion(frameResIndex); // Now is the time to read the timestamps for the previous frame for this slot. if (frame.timestampQueryIndex >= 0) { @@ -1606,7 +1607,7 @@ QRhi::FrameOpResult QRhiVulkan::beginFrame(QRhiSwapChain *swapChain, QRhi::Begin // when profiling is enabled, pick a free query (pair) from the pool int timestampQueryIdx = -1; - if (profilerPrivateOrNull()) { + if (profilerPrivateOrNull() && swapChainD->bufferCount > 1) { // no timestamps if not having at least 2 frames in flight for (int i = 0; i < timestampQueryPoolMap.count(); ++i) { if (!timestampQueryPoolMap.testBit(i)) { timestampQueryPoolMap.setBit(i); @@ -1648,7 +1649,8 @@ QRhi::FrameOpResult QRhiVulkan::endFrame(QRhiSwapChain *swapChain, QRhi::EndFram recordPrimaryCommandBuffer(&swapChainD->cbWrapper); - QVkSwapChain::FrameResources &frame(swapChainD->frameRes[swapChainD->currentFrameSlot]); + int frameResIndex = swapChainD->bufferCount > 1 ? swapChainD->currentFrameSlot : 0; + QVkSwapChain::FrameResources &frame(swapChainD->frameRes[frameResIndex]); QVkSwapChain::ImageResources &image(swapChainD->imageRes[swapChainD->currentImageIndex]); if (image.lastUse != QVkSwapChain::ImageResources::ScImageUseRender) { @@ -1860,7 +1862,8 @@ QRhi::FrameOpResult QRhiVulkan::endAndSubmitPrimaryCommandBuffer(VkCommandBuffer void QRhiVulkan::waitCommandCompletion(int frameSlot) { for (QVkSwapChain *sc : qAsConst(swapchains)) { - QVkSwapChain::FrameResources &frame(sc->frameRes[frameSlot]); + const int frameResIndex = sc->bufferCount > 1 ? frameSlot : 0; + QVkSwapChain::FrameResources &frame(sc->frameRes[frameResIndex]); if (frame.cmdFenceWaitable) { df->vkWaitForFences(dev, 1, &frame.cmdFence, VK_TRUE, UINT64_MAX); df->vkResetFences(dev, 1, &frame.cmdFence); diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp index c0b0071e4d..a12eb98528 100644 --- a/src/gui/text/qcssparser.cpp +++ b/src/gui/text/qcssparser.cpp @@ -707,7 +707,7 @@ static Qt::Alignment parseAlignment(const QCss::Value *values, int count) static ColorData parseColorValue(QCss::Value v) { if (v.type == Value::Identifier || v.type == Value::String) { - v.variant.convert(QVariant::Color); + v.variant.convert(QMetaType::QColor); v.type = Value::Color; } @@ -1143,7 +1143,7 @@ static bool setFontSizeFromValue(QCss::Value value, QFont *font, int *fontSizeAd } else if (s.endsWith(QLatin1String("px"), Qt::CaseInsensitive)) { s.chop(2); value.variant = s; - if (value.variant.convert(QVariant::Int)) { + if (value.variant.convert(QMetaType::Int)) { font->setPixelSize(value.variant.toInt()); valid = true; } @@ -1420,9 +1420,9 @@ QColor Declaration::colorValue(const QPalette &pal) const return QColor(); if (d->parsed.isValid()) { - if (d->parsed.type() == QVariant::Color) + if (d->parsed.userType() == QMetaType::QColor) return qvariant_cast<QColor>(d->parsed); - if (d->parsed.type() == QVariant::Int) + if (d->parsed.userType() == QMetaType::Int) return pal.color((QPalette::ColorRole)(d->parsed.toInt())); } @@ -1442,9 +1442,9 @@ QBrush Declaration::brushValue(const QPalette &pal) const return QBrush(); if (d->parsed.isValid()) { - if (d->parsed.type() == QVariant::Brush) + if (d->parsed.userType() == QMetaType::QBrush) return qvariant_cast<QBrush>(d->parsed); - if (d->parsed.type() == QVariant::Int) + if (d->parsed.userType() == QMetaType::Int) return pal.color((QPalette::ColorRole)(d->parsed.toInt())); } @@ -1469,9 +1469,9 @@ void Declaration::brushValues(QBrush *c, const QPalette &pal) const needParse = 0; QList<QVariant> v = d->parsed.toList(); for (i = 0; i < qMin(v.count(), 4); i++) { - if (v.at(i).type() == QVariant::Brush) { + if (v.at(i).userType() == QMetaType::QBrush) { c[i] = qvariant_cast<QBrush>(v.at(i)); - } else if (v.at(i).type() == QVariant::Int) { + } else if (v.at(i).userType() == QMetaType::Int) { c[i] = pal.color((QPalette::ColorRole)(v.at(i).toInt())); } else { needParse |= (1<<i); @@ -1598,7 +1598,7 @@ void Declaration::colorValues(QColor *c, const QPalette &pal) const if (d->parsed.isValid()) { QList<QVariant> v = d->parsed.toList(); for (i = 0; i < qMin(d->values.count(), 4); i++) { - if (v.at(i).type() == QVariant::Color) { + if (v.at(i).userType() == QMetaType::QColor) { c[i] = qvariant_cast<QColor>(v.at(i)); } else { c[i] = pal.color((QPalette::ColorRole)(v.at(i).toInt())); @@ -2723,7 +2723,7 @@ bool Parser::parseTerm(Value *value) switch (lookup()) { case NUMBER: value->type = Value::Number; - value->variant.convert(QVariant::Double); + value->variant.convert(QMetaType::Double); break; case PERCENTAGE: value->type = Value::Percentage; diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp index 9ede90d8de..8f0d7d9d38 100644 --- a/src/gui/text/qfont.cpp +++ b/src/gui/text/qfont.cpp @@ -1353,8 +1353,8 @@ QFont::StyleHint QFont::styleHint() const \value NoAntialias don't antialias the fonts. \value NoSubpixelAntialias avoid subpixel antialiasing on the fonts if possible. \value PreferAntialias antialias if possible. - \value OpenGLCompatible forces the use of OpenGL compatible - fonts. + \value OpenGLCompatible This style strategy has been deprecated. All fonts are + OpenGL-compatible by default. \value NoFontMerging If the font selected for a certain writing system does not contain a character requested to draw, then Qt automatically chooses a similar looking font that contains the character. The NoFontMerging flag disables this feature. @@ -1373,8 +1373,8 @@ QFont::StyleHint QFont::styleHint() const \value PreferQuality prefer the best quality font. The font matcher will use the nearest standard point size that the font supports. - \value ForceIntegerMetrics forces the use of integer values in font engines that support fractional - font metrics. + \value ForceIntegerMetrics This style strategy has been deprecated. Use \l QFontMetrics to + retrieve rounded font metrics. */ /*! @@ -1753,7 +1753,7 @@ bool QFont::operator!=(const QFont &f) const */ QFont::operator QVariant() const { - return QVariant(QVariant::Font, this); + return QVariant(QMetaType::QFont, this); } /*! diff --git a/src/gui/text/qfont.h b/src/gui/text/qfont.h index 683aa3bf65..e5734679ed 100644 --- a/src/gui/text/qfont.h +++ b/src/gui/text/qfont.h @@ -80,8 +80,10 @@ public: PreferQuality = 0x0040, PreferAntialias = 0x0080, NoAntialias = 0x0100, - OpenGLCompatible = 0x0200, - ForceIntegerMetrics = 0x0400, +#if QT_DEPRECATED_SINCE(5, 15) + OpenGLCompatible Q_DECL_ENUMERATOR_DEPRECATED = 0x0200, + ForceIntegerMetrics Q_DECL_ENUMERATOR_DEPRECATED = 0x0400, +#endif NoSubpixelAntialias = 0x0800, PreferNoShaping = 0x1000, NoFontMerging = 0x8000 diff --git a/src/gui/text/qfontmetrics.cpp b/src/gui/text/qfontmetrics.cpp index de9cae0c91..73fcc4bc78 100644 --- a/src/gui/text/qfontmetrics.cpp +++ b/src/gui/text/qfontmetrics.cpp @@ -161,7 +161,7 @@ QFontMetrics::QFontMetrics(const QFont &font) Constructs a font metrics object for \a font and \a paintdevice. The font metrics will be compatible with the paintdevice passed. - If the \a paintdevice is 0, the metrics will be screen-compatible, + If the \a paintdevice is \nullptr, the metrics will be screen-compatible, ie. the metrics you get if you use the font for drawing text on a \l{QWidget}{widgets} or \l{QPixmap}{pixmaps}, not on a QPicture or QPrinter. @@ -1154,7 +1154,7 @@ QFontMetricsF::QFontMetricsF(const QFont &font) Constructs a font metrics object for \a font and \a paintdevice. The font metrics will be compatible with the paintdevice passed. - If the \a paintdevice is 0, the metrics will be screen-compatible, + If the \a paintdevice is \nullptr, the metrics will be screen-compatible, ie. the metrics you get if you use the font for drawing text on a \l{QWidget}{widgets} or \l{QPixmap}{pixmaps}, not on a QPicture or QPrinter. diff --git a/src/gui/text/qplatformfontdatabase.cpp b/src/gui/text/qplatformfontdatabase.cpp index 02e25bb6af..48ba8987f3 100644 --- a/src/gui/text/qplatformfontdatabase.cpp +++ b/src/gui/text/qplatformfontdatabase.cpp @@ -82,7 +82,7 @@ void QPlatformFontDatabase::registerQPF2Font(const QByteArray &dataArray, void * if (!fontName.isEmpty() && pixelSize) { QFont::Weight fontWeight = QFont::Normal; - if (weight.type() == QVariant::Int || weight.type() == QVariant::UInt) + if (weight.userType() == QMetaType::Int || weight.userType() == QMetaType::UInt) fontWeight = QFont::Weight(weight.toInt()); QFont::Style fontStyle = static_cast<QFont::Style>(style.toInt()); diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp index 2d7f2bb844..46cfc79643 100644 --- a/src/gui/text/qtextdocument.cpp +++ b/src/gui/text/qtextdocument.cpp @@ -2234,7 +2234,7 @@ QVariant QTextDocument::loadResource(int type, const QUrl &name) } if (!r.isNull()) { - if (type == ImageResource && r.type() == QVariant::ByteArray) { + if (type == ImageResource && r.userType() == QMetaType::QByteArray) { if (qApp->thread() != QThread::currentThread()) { // must use images in non-GUI threads QImage image; @@ -3049,12 +3049,12 @@ QString QTextHtmlExporter::findUrlForImage(const QTextDocument *doc, qint64 cach for (; it != priv->cachedResources.constEnd(); ++it) { const QVariant &v = it.value(); - if (v.type() == QVariant::Image && !isPixmap) { + if (v.userType() == QMetaType::QImage && !isPixmap) { if (qvariant_cast<QImage>(v).cacheKey() == cacheKey) break; } - if (v.type() == QVariant::Pixmap && isPixmap) { + if (v.userType() == QMetaType::QPixmap && isPixmap) { if (qvariant_cast<QPixmap>(v).cacheKey() == cacheKey) break; } diff --git a/src/gui/text/qtextdocumentlayout.cpp b/src/gui/text/qtextdocumentlayout.cpp index e21a8d8d52..9d70873590 100644 --- a/src/gui/text/qtextdocumentlayout.cpp +++ b/src/gui/text/qtextdocumentlayout.cpp @@ -248,7 +248,7 @@ public: if (v.isNull()) { return cellPadding; } else { - Q_ASSERT(v.userType() == QVariant::Double || v.userType() == QMetaType::Float); + Q_ASSERT(v.userType() == QMetaType::Double || v.userType() == QMetaType::Float); return QFixed::fromReal(v.toReal() * deviceScale); } } diff --git a/src/gui/text/qtextformat.cpp b/src/gui/text/qtextformat.cpp index e3bd49a15e..10b8ade117 100644 --- a/src/gui/text/qtextformat.cpp +++ b/src/gui/text/qtextformat.cpp @@ -144,7 +144,7 @@ QT_BEGIN_NAMESPACE */ QTextLength::operator QVariant() const { - return QVariant(QVariant::TextLength, this); + return QVariant(QMetaType::QTextLength, this); } #ifndef QT_NO_DATASTREAM @@ -288,20 +288,20 @@ static inline uint variantHash(const QVariant &variant) { // simple and fast hash functions to differentiate between type and value switch (variant.userType()) { // sorted by occurrence frequency - case QVariant::String: return qHash(variant.toString()); - case QVariant::Double: return qHash(variant.toDouble()); - case QVariant::Int: return 0x811890 + variant.toInt(); - case QVariant::Brush: + case QMetaType::QString: return qHash(variant.toString()); + case QMetaType::Double: return qHash(variant.toDouble()); + case QMetaType::Int: return 0x811890 + variant.toInt(); + case QMetaType::QBrush: return 0x01010101 + hash(qvariant_cast<QBrush>(variant)); - case QVariant::Bool: return 0x371818 + variant.toBool(); - case QVariant::Pen: return 0x02020202 + hash(qvariant_cast<QPen>(variant)); - case QVariant::List: + case QMetaType::Bool: return 0x371818 + variant.toBool(); + case QMetaType::QPen: return 0x02020202 + hash(qvariant_cast<QPen>(variant)); + case QMetaType::QVariantList: return 0x8377 + qvariant_cast<QVariantList>(variant).count(); - case QVariant::Color: return hash(qvariant_cast<QColor>(variant)); - case QVariant::TextLength: + case QMetaType::QColor: return hash(qvariant_cast<QColor>(variant)); + case QMetaType::QTextLength: return 0x377 + hash(qvariant_cast<QTextLength>(variant).rawValue()); case QMetaType::Float: return qHash(variant.toFloat()); - case QVariant::Invalid: return 0; + case QMetaType::UnknownType: return 0; default: break; } return qHash(variant.typeName()); @@ -874,7 +874,7 @@ QTextFormat::~QTextFormat() */ QTextFormat::operator QVariant() const { - return QVariant(QVariant::TextFormat, this); + return QVariant(QMetaType::QTextFormat, this); } /*! @@ -984,7 +984,7 @@ bool QTextFormat::boolProperty(int propertyId) const if (!d) return false; const QVariant prop = d->property(propertyId); - if (prop.userType() != QVariant::Bool) + if (prop.userType() != QMetaType::Bool) return false; return prop.toBool(); } @@ -1004,7 +1004,7 @@ int QTextFormat::intProperty(int propertyId) const if (!d) return def; const QVariant prop = d->property(propertyId); - if (prop.userType() != QVariant::Int) + if (prop.userType() != QMetaType::Int) return def; return prop.toInt(); } @@ -1022,7 +1022,7 @@ qreal QTextFormat::doubleProperty(int propertyId) const if (!d) return 0.; const QVariant prop = d->property(propertyId); - if (prop.userType() != QVariant::Double && prop.userType() != QMetaType::Float) + if (prop.userType() != QMetaType::Double && prop.userType() != QMetaType::Float) return 0.; return qvariant_cast<qreal>(prop); } @@ -1040,7 +1040,7 @@ QString QTextFormat::stringProperty(int propertyId) const if (!d) return QString(); const QVariant prop = d->property(propertyId); - if (prop.userType() != QVariant::String) + if (prop.userType() != QMetaType::QString) return QString(); return prop.toString(); } @@ -1058,7 +1058,7 @@ QColor QTextFormat::colorProperty(int propertyId) const if (!d) return QColor(); const QVariant prop = d->property(propertyId); - if (prop.userType() != QVariant::Color) + if (prop.userType() != QMetaType::QColor) return QColor(); return qvariant_cast<QColor>(prop); } @@ -1076,7 +1076,7 @@ QPen QTextFormat::penProperty(int propertyId) const if (!d) return QPen(Qt::NoPen); const QVariant prop = d->property(propertyId); - if (prop.userType() != QVariant::Pen) + if (prop.userType() != QMetaType::QPen) return QPen(Qt::NoPen); return qvariant_cast<QPen>(prop); } @@ -1094,7 +1094,7 @@ QBrush QTextFormat::brushProperty(int propertyId) const if (!d) return QBrush(Qt::NoBrush); const QVariant prop = d->property(propertyId); - if (prop.userType() != QVariant::Brush) + if (prop.userType() != QMetaType::QBrush) return QBrush(Qt::NoBrush); return qvariant_cast<QBrush>(prop); } @@ -1126,13 +1126,13 @@ QVector<QTextLength> QTextFormat::lengthVectorProperty(int propertyId) const if (!d) return vector; const QVariant prop = d->property(propertyId); - if (prop.userType() != QVariant::List) + if (prop.userType() != QMetaType::QVariantList) return vector; QList<QVariant> propertyList = prop.toList(); for (int i=0; i<propertyList.size(); ++i) { QVariant var = propertyList.at(i); - if (var.userType() == QVariant::TextLength) + if (var.userType() == QMetaType::QTextLength) vector.append(qvariant_cast<QTextLength>(var)); } @@ -1222,7 +1222,7 @@ int QTextFormat::objectIndex() const if (!d) return -1; const QVariant prop = d->property(ObjectIndex); - if (prop.userType() != QVariant::Int) // #### + if (prop.userType() != QMetaType::Int) // #### return -1; return prop.toInt(); } @@ -1859,9 +1859,9 @@ void QTextCharFormat::setUnderlineStyle(UnderlineStyle style) QString QTextCharFormat::anchorName() const { QVariant prop = property(AnchorName); - if (prop.userType() == QVariant::StringList) + if (prop.userType() == QMetaType::QStringList) return prop.toStringList().value(0); - else if (prop.userType() != QVariant::String) + else if (prop.userType() != QMetaType::QString) return QString(); return prop.toString(); } @@ -1878,9 +1878,9 @@ QString QTextCharFormat::anchorName() const QStringList QTextCharFormat::anchorNames() const { QVariant prop = property(AnchorName); - if (prop.userType() == QVariant::StringList) + if (prop.userType() == QMetaType::QStringList) return prop.toStringList(); - else if (prop.userType() != QVariant::String) + else if (prop.userType() != QMetaType::QString) return QStringList(); return QStringList(prop.toString()); } diff --git a/src/gui/text/qtexthtmlparser.cpp b/src/gui/text/qtexthtmlparser.cpp index 3b9f2d253e..f003544391 100644 --- a/src/gui/text/qtexthtmlparser.cpp +++ b/src/gui/text/qtexthtmlparser.cpp @@ -1451,19 +1451,19 @@ void QTextHtmlParserNode::applyBackgroundImage(const QString &url, const QTextDo if (QCoreApplication::instance()->thread() != QThread::currentThread()) { // must use images in non-GUI threads - if (val.type() == QVariant::Image) { + if (val.userType() == QMetaType::QImage) { QImage image = qvariant_cast<QImage>(val); charFormat.setBackground(image); - } else if (val.type() == QVariant::ByteArray) { + } else if (val.userType() == QMetaType::QByteArray) { QImage image; if (image.loadFromData(val.toByteArray())) { charFormat.setBackground(image); } } } else { - if (val.type() == QVariant::Image || val.type() == QVariant::Pixmap) { + if (val.userType() == QMetaType::QImage || val.userType() == QMetaType::QPixmap) { charFormat.setBackground(qvariant_cast<QPixmap>(val)); - } else if (val.type() == QVariant::ByteArray) { + } else if (val.userType() == QMetaType::QByteArray) { QPixmap pm; if (pm.loadFromData(val.toByteArray())) { charFormat.setBackground(pm); @@ -1907,9 +1907,9 @@ void QTextHtmlParser::importStyleSheet(const QString &href) QVariant res = resourceProvider->resource(QTextDocument::StyleSheetResource, href); QString css; - if (res.type() == QVariant::String) { + if (res.userType() == QMetaType::QString) { css = res.toString(); - } else if (res.type() == QVariant::ByteArray) { + } else if (res.userType() == QMetaType::QByteArray) { // #### detect @charset css = QString::fromUtf8(res.toByteArray()); } diff --git a/src/gui/text/qtextimagehandler.cpp b/src/gui/text/qtextimagehandler.cpp index 14018f34da..0d87a2135d 100644 --- a/src/gui/text/qtextimagehandler.cpp +++ b/src/gui/text/qtextimagehandler.cpp @@ -88,9 +88,9 @@ static QPixmap getPixmap(QTextDocument *doc, const QTextImageFormat &format, con qreal sourcePixelRatio = 1.0; name = resolveFileName(name, &url, devicePixelRatio, &sourcePixelRatio); const QVariant data = doc->resource(QTextDocument::ImageResource, url); - if (data.type() == QVariant::Pixmap || data.type() == QVariant::Image) { + if (data.userType() == QMetaType::QPixmap || data.userType() == QMetaType::QImage) { pm = qvariant_cast<QPixmap>(data); - } else if (data.type() == QVariant::ByteArray) { + } else if (data.userType() == QMetaType::QByteArray) { pm.loadFromData(data.toByteArray()); } @@ -170,9 +170,9 @@ static QImage getImage(QTextDocument *doc, const QTextImageFormat &format, const qreal sourcePixelRatio = 1.0; name = resolveFileName(name, &url, devicePixelRatio, &sourcePixelRatio); const QVariant data = doc->resource(QTextDocument::ImageResource, url); - if (data.type() == QVariant::Image) { + if (data.userType() == QMetaType::QImage) { image = qvariant_cast<QImage>(data); - } else if (data.type() == QVariant::ByteArray) { + } else if (data.userType() == QMetaType::QByteArray) { image.loadFromData(data.toByteArray()); } diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index fc256d72f3..02c42eaf03 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -350,7 +350,7 @@ QTextLayout::QTextLayout(const QString& text) \a font. All the metric and layout calculations will be done in terms of - the paint device, \a paintdevice. If \a paintdevice is 0 the + the paint device, \a paintdevice. If \a paintdevice is \nullptr the calculations will be done in screen metrics. */ diff --git a/src/gui/text/qtextodfwriter.cpp b/src/gui/text/qtextodfwriter.cpp index 408e3ec167..155ec43c50 100644 --- a/src/gui/text/qtextodfwriter.cpp +++ b/src/gui/text/qtextodfwriter.cpp @@ -455,9 +455,9 @@ void QTextOdfWriter::writeInlineCharacter(QXmlStreamWriter &writer, const QTextF name.prepend(QLatin1String("qrc")); QUrl url = QUrl(name); const QVariant variant = m_document->resource(QTextDocument::ImageResource, url); - if (variant.type() == QVariant::Image) { + if (variant.userType() == QMetaType::QImage) { image = qvariant_cast<QImage>(variant); - } else if (variant.type() == QVariant::ByteArray) { + } else if (variant.userType() == QMetaType::QByteArray) { data = variant.toByteArray(); QBuffer buffer(&data); |