diff options
Diffstat (limited to 'src/gui/kernel')
-rw-r--r-- | src/gui/kernel/qcursor.cpp | 78 | ||||
-rw-r--r-- | src/gui/kernel/qcursor.h | 15 | ||||
-rw-r--r-- | src/gui/kernel/qevent.cpp | 4 | ||||
-rw-r--r-- | src/gui/kernel/qguiapplication.cpp | 15 | ||||
-rw-r--r-- | src/gui/kernel/qguivariant.cpp | 65 | ||||
-rw-r--r-- | src/gui/kernel/qinternalmimedata.cpp | 13 | ||||
-rw-r--r-- | src/gui/kernel/qkeysequence.cpp | 2 | ||||
-rw-r--r-- | src/gui/kernel/qopenglcontext.cpp | 2 | ||||
-rw-r--r-- | src/gui/kernel/qpalette.cpp | 2 |
9 files changed, 149 insertions, 47 deletions
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); } /*! |