diff options
Diffstat (limited to 'src/widgets')
109 files changed, 604 insertions, 353 deletions
diff --git a/src/widgets/dialogs/qcolordialog.cpp b/src/widgets/dialogs/qcolordialog.cpp index c0bacd553d..a6b6df4045 100644 --- a/src/widgets/dialogs/qcolordialog.cpp +++ b/src/widgets/dialogs/qcolordialog.cpp @@ -57,6 +57,11 @@ #include "qpainter.h" #include "qpixmap.h" #include "qpushbutton.h" +#if QT_CONFIG(regularexpression) +#include <qregularexpression.h> +#else +#include <qregexp.h> +#endif #if QT_CONFIG(settings) #include "qsettings.h" #endif diff --git a/src/widgets/dialogs/qdialog.cpp b/src/widgets/dialogs/qdialog.cpp index caab6c16ba..5692a16bce 100644 --- a/src/widgets/dialogs/qdialog.cpp +++ b/src/widgets/dialogs/qdialog.cpp @@ -270,12 +270,11 @@ void QDialogPrivate::deletePlatformHelper() The most common way to display a modal dialog is to call its exec() function. When the user closes the dialog, exec() will - provide a useful \l{#return}{return value}. Typically, - to get the dialog to close and return the appropriate value, we - connect a default button, e.g. \uicontrol OK, to the accept() slot and a - \uicontrol Cancel button to the reject() slot. - Alternatively you can call the done() slot with \c Accepted or - \c Rejected. + provide a useful \l{#return}{return value}. To close the dialog + and return the appropriate value, you must connect a default button, + e.g. an \uicontrol OK button to the accept() slot and a + \uicontrol Cancel button to the reject() slot. Alternatively, you + can call the done() slot with \c Accepted or \c Rejected. An alternative is to call setModal(true) or setWindowModality(), then show(). Unlike exec(), show() returns control to the caller diff --git a/src/widgets/dialogs/qdialog_p.h b/src/widgets/dialogs/qdialog_p.h index 92634f6793..74f775a0bd 100644 --- a/src/widgets/dialogs/qdialog_p.h +++ b/src/widgets/dialogs/qdialog_p.h @@ -75,15 +75,15 @@ public: QDialogPrivate() : #if QT_CONFIG(pushbutton) - mainDef(0), + mainDef(nullptr), #endif - orientation(Qt::Horizontal),extension(0), doShowExtension(false), + orientation(Qt::Horizontal),extension(nullptr), doShowExtension(false), #if QT_CONFIG(sizegrip) - resizer(0), + resizer(nullptr), sizeGripEnabled(false), #endif - rescode(0), resetModalityTo(-1), wasModalitySet(true), eventLoop(0), - nativeDialogInUse(false), m_platformHelper(0), m_platformHelperCreated(false) + rescode(0), resetModalityTo(-1), wasModalitySet(true), eventLoop(nullptr), + nativeDialogInUse(false), m_platformHelper(nullptr), m_platformHelperCreated(false) {} ~QDialogPrivate(); @@ -140,14 +140,14 @@ class QAutoPointer { struct internal { void func() {} }; typedef void (internal::*RestrictedBool)(); public: - explicit QAutoPointer(T *t) Q_DECL_NOTHROW : o(t) {} + explicit QAutoPointer(T *t) noexcept : o(t) {} ~QAutoPointer() { delete o; } - T *operator->() const Q_DECL_NOTHROW { return get(); } - T *get() const Q_DECL_NOTHROW { return o; } + T *operator->() const noexcept { return get(); } + T *get() const noexcept { return o; } T &operator*() const { return *get(); } - operator RestrictedBool() const Q_DECL_NOTHROW { return o ? &internal::func : nullptr; } - bool operator!() const Q_DECL_NOTHROW { return !o; } + operator RestrictedBool() const noexcept { return o ? &internal::func : nullptr; } + bool operator!() const noexcept { return !o; } private: Q_DISABLE_COPY(QAutoPointer); }; diff --git a/src/widgets/dialogs/qerrormessage.cpp b/src/widgets/dialogs/qerrormessage.cpp index fd68f19680..51a3e080bf 100644 --- a/src/widgets/dialogs/qerrormessage.cpp +++ b/src/widgets/dialogs/qerrormessage.cpp @@ -322,8 +322,8 @@ bool QErrorMessagePrivate::nextPending() #else errors->setPlainText(message); #endif - currentMessage = qMove(message); - currentType = qMove(type); + currentMessage = std::move(message); + currentType = std::move(type); return true; } } diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp index f772eb1241..fcac12068d 100644 --- a/src/widgets/dialogs/qfiledialog.cpp +++ b/src/widgets/dialogs/qfiledialog.cpp @@ -77,6 +77,8 @@ #include <private/qwasmlocalfileaccess_p.h> #endif +#include <algorithm> + QT_BEGIN_NAMESPACE Q_GLOBAL_STATIC(QUrl, lastVisitedDir) @@ -3372,6 +3374,18 @@ void QFileDialogPrivate::_q_goHome() q->setDirectory(QDir::homePath()); } + +void QFileDialogPrivate::saveHistorySelection() +{ + if (qFileDialogUi.isNull() || currentHistoryLocation < 0 || currentHistoryLocation >= currentHistory.size()) + return; + auto &item = currentHistory[currentHistoryLocation]; + item.selection.clear(); + const auto selectedIndexes = qFileDialogUi->listView->selectionModel()->selectedRows(); + for (const auto &index : selectedIndexes) + item.selection.append(QPersistentModelIndex(index)); +} + /*! \internal @@ -3385,17 +3399,49 @@ void QFileDialogPrivate::_q_pathChanged(const QString &newPath) qFileDialogUi->sidebar->selectUrl(QUrl::fromLocalFile(newPath)); q->setHistory(qFileDialogUi->lookInCombo->history()); - if (currentHistoryLocation < 0 || currentHistory.value(currentHistoryLocation) != QDir::toNativeSeparators(newPath)) { + const QString newNativePath = QDir::toNativeSeparators(newPath); + + // equal paths indicate this was invoked by _q_navigateBack/Forward() + if (currentHistoryLocation < 0 || currentHistory.value(currentHistoryLocation).path != newNativePath) { + if (currentHistoryLocation >= 0) + saveHistorySelection(); while (currentHistoryLocation >= 0 && currentHistoryLocation + 1 < currentHistory.count()) { currentHistory.removeLast(); } - currentHistory.append(QDir::toNativeSeparators(newPath)); + currentHistory.append({newNativePath, PersistentModelIndexList()}); ++currentHistoryLocation; } qFileDialogUi->forwardButton->setEnabled(currentHistory.size() - currentHistoryLocation > 1); qFileDialogUi->backButton->setEnabled(currentHistoryLocation > 0); } +void QFileDialogPrivate::navigate(HistoryItem &historyItem) +{ + Q_Q(QFileDialog); + q->setDirectory(historyItem.path); + // Restore selection unless something has changed in the file system + if (qFileDialogUi.isNull() || historyItem.selection.isEmpty()) + return; + if (std::any_of(historyItem.selection.cbegin(), historyItem.selection.cend(), + [](const QPersistentModelIndex &i) { return !i.isValid(); })) { + historyItem.selection.clear(); + return; + } + + QAbstractItemView *view = q->viewMode() == QFileDialog::List + ? static_cast<QAbstractItemView *>(qFileDialogUi->listView) + : static_cast<QAbstractItemView *>(qFileDialogUi->treeView); + auto selectionModel = view->selectionModel(); + const QItemSelectionModel::SelectionFlags flags = QItemSelectionModel::Select + | QItemSelectionModel::Rows; + selectionModel->select(historyItem.selection.constFirst(), + flags | QItemSelectionModel::Clear | QItemSelectionModel::Current); + for (int i = 1, size = historyItem.selection.size(); i < size; ++i) + selectionModel->select(historyItem.selection.at(i), flags); + + view->scrollTo(historyItem.selection.constFirst()); +} + /*! \internal @@ -3403,11 +3449,9 @@ void QFileDialogPrivate::_q_pathChanged(const QString &newPath) */ void QFileDialogPrivate::_q_navigateBackward() { - Q_Q(QFileDialog); if (!currentHistory.isEmpty() && currentHistoryLocation > 0) { - --currentHistoryLocation; - QString previousHistory = currentHistory.at(currentHistoryLocation); - q->setDirectory(previousHistory); + saveHistorySelection(); + navigate(currentHistory[--currentHistoryLocation]); } } @@ -3418,11 +3462,9 @@ void QFileDialogPrivate::_q_navigateBackward() */ void QFileDialogPrivate::_q_navigateForward() { - Q_Q(QFileDialog); if (!currentHistory.isEmpty() && currentHistoryLocation < currentHistory.size() - 1) { - ++currentHistoryLocation; - QString nextHistory = currentHistory.at(currentHistoryLocation); - q->setDirectory(nextHistory); + saveHistorySelection(); + navigate(currentHistory[++currentHistoryLocation]); } } diff --git a/src/widgets/dialogs/qfiledialog_p.h b/src/widgets/dialogs/qfiledialog_p.h index 463c77aa23..dcf147348f 100644 --- a/src/widgets/dialogs/qfiledialog_p.h +++ b/src/widgets/dialogs/qfiledialog_p.h @@ -98,7 +98,7 @@ class QPlatformDialogHelper; struct QFileDialogArgs { - QFileDialogArgs() : parent(0), mode(QFileDialog::AnyFile) {} + QFileDialogArgs() : parent(nullptr), mode(QFileDialog::AnyFile) {} QWidget *parent; QString caption; @@ -116,6 +116,14 @@ class Q_WIDGETS_EXPORT QFileDialogPrivate : public QDialogPrivate Q_DECLARE_PUBLIC(QFileDialog) public: + using PersistentModelIndexList = QVector<QPersistentModelIndex>; + + struct HistoryItem + { + QString path; + PersistentModelIndexList selection; + }; + QFileDialogPrivate(); QPlatformFileDialogHelper *platformFileDialogHelper() const @@ -193,9 +201,11 @@ public: void retranslateWindowTitle(); void retranslateStrings(); void emitFilesSelected(const QStringList &files); + void saveHistorySelection(); void _q_goHome(); void _q_pathChanged(const QString &); + void navigate(HistoryItem &); void _q_navigateBackward(); void _q_navigateForward(); void _q_navigateToParent(); @@ -237,7 +247,7 @@ public: QString setWindowTitle; - QStringList currentHistory; + QList<HistoryItem> currentHistory; int currentHistoryLocation; QAction *renameAction; @@ -292,7 +302,7 @@ private: class QFileDialogLineEdit : public QLineEdit { public: - QFileDialogLineEdit(QWidget *parent = 0) : QLineEdit(parent), d_ptr(0){} + QFileDialogLineEdit(QWidget *parent = nullptr) : QLineEdit(parent), d_ptr(nullptr){} void setFileDialogPrivate(QFileDialogPrivate *d_pointer) {d_ptr = d_pointer; } void keyPressEvent(QKeyEvent *e) override; bool hideOnEsc; @@ -303,7 +313,7 @@ private: class QFileDialogComboBox : public QComboBox { public: - QFileDialogComboBox(QWidget *parent = 0) : QComboBox(parent), urlModel(0) {} + QFileDialogComboBox(QWidget *parent = nullptr) : QComboBox(parent), urlModel(nullptr) {} void setFileDialogPrivate(QFileDialogPrivate *d_pointer); void showPopup() override; void setHistory(const QStringList &paths); @@ -319,7 +329,7 @@ private: class QFileDialogListView : public QListView { public: - QFileDialogListView(QWidget *parent = 0); + QFileDialogListView(QWidget *parent = nullptr); void setFileDialogPrivate(QFileDialogPrivate *d_pointer); QSize sizeHint() const override; protected: diff --git a/src/widgets/dialogs/qfileinfogatherer_p.h b/src/widgets/dialogs/qfileinfogatherer_p.h index 134a14b7ce..795f60249f 100644 --- a/src/widgets/dialogs/qfileinfogatherer_p.h +++ b/src/widgets/dialogs/qfileinfogatherer_p.h @@ -166,7 +166,7 @@ Q_SIGNALS: void directoryLoaded(const QString &path); public: - explicit QFileInfoGatherer(QObject *parent = 0); + explicit QFileInfoGatherer(QObject *parent = nullptr); ~QFileInfoGatherer(); #if QT_CONFIG(filesystemwatcher) && defined(Q_OS_WIN) diff --git a/src/widgets/dialogs/qfilesystemmodel_p.h b/src/widgets/dialogs/qfilesystemmodel_p.h index 9c432e1ae6..d8f9f2b076 100644 --- a/src/widgets/dialogs/qfilesystemmodel_p.h +++ b/src/widgets/dialogs/qfilesystemmodel_p.h @@ -99,13 +99,13 @@ public: class QFileSystemNode { public: - explicit QFileSystemNode(const QString &filename = QString(), QFileSystemNode *p = 0) - : fileName(filename), populatedChildren(false), isVisible(false), dirtyChildrenIndex(-1), parent(p), info(0) {} + explicit QFileSystemNode(const QString &filename = QString(), QFileSystemNode *p = nullptr) + : fileName(filename), populatedChildren(false), isVisible(false), dirtyChildrenIndex(-1), parent(p), info(nullptr) {} ~QFileSystemNode() { qDeleteAll(children); delete info; - info = 0; - parent = 0; + info = nullptr; + parent = nullptr; } QString fileName; @@ -116,7 +116,7 @@ public: inline qint64 size() const { if (info && !info->isDir()) return info->size(); return 0; } inline QString type() const { if (info) return info->displayType; return QLatin1String(""); } inline QDateTime lastModified() const { if (info) return info->lastModified(); return QDateTime(); } - inline QFile::Permissions permissions() const { if (info) return info->permissions(); return 0; } + inline QFile::Permissions permissions() const { if (info) return info->permissions(); return nullptr; } inline bool isReadable() const { return ((permissions() & QFile::ReadUser) != 0); } inline bool isWritable() const { return ((permissions() & QFile::WriteUser) != 0); } inline bool isExecutable() const { return ((permissions() & QFile::ExeUser) != 0); } @@ -162,7 +162,7 @@ public: return info && (*info == fileInfo); } - inline bool hasInformation() const { return info != 0; } + inline bool hasInformation() const { return info != nullptr; } void populate(const QExtendedInformation &fileInfo) { if (!info) diff --git a/src/widgets/dialogs/qfscompleter_p.h b/src/widgets/dialogs/qfscompleter_p.h index 3b829d4a52..f5110a7622 100644 --- a/src/widgets/dialogs/qfscompleter_p.h +++ b/src/widgets/dialogs/qfscompleter_p.h @@ -64,8 +64,8 @@ QT_BEGIN_NAMESPACE */ class Q_WIDGETS_EXPORT QFSCompleter : public QCompleter { public: - explicit QFSCompleter(QFileSystemModel *model, QObject *parent = 0) - : QCompleter(model, parent), proxyModel(0), sourceModel(model) + explicit QFSCompleter(QFileSystemModel *model, QObject *parent = nullptr) + : QCompleter(model, parent), proxyModel(nullptr), sourceModel(model) { #if defined(Q_OS_WIN) setCaseSensitivity(Qt::CaseInsensitive); diff --git a/src/widgets/dialogs/qsidebar_p.h b/src/widgets/dialogs/qsidebar_p.h index 4a82f88878..6056f19452 100644 --- a/src/widgets/dialogs/qsidebar_p.h +++ b/src/widgets/dialogs/qsidebar_p.h @@ -67,7 +67,7 @@ class QFileSystemModel; class QSideBarDelegate : public QStyledItemDelegate { public: - QSideBarDelegate(QWidget *parent = 0) : QStyledItemDelegate(parent) {} + QSideBarDelegate(QWidget *parent = nullptr) : QStyledItemDelegate(parent) {} void initStyleOption(QStyleOptionViewItem *option, const QModelIndex &index) const override; }; @@ -82,7 +82,7 @@ public: EnabledRole = Qt::UserRole + 2 }; - QUrlModel(QObject *parent = 0); + QUrlModel(QObject *parent = nullptr); QStringList mimeTypes() const override; QMimeData *mimeData(const QModelIndexList &indexes) const override; @@ -127,7 +127,7 @@ Q_SIGNALS: void goToUrl(const QUrl &url); public: - QSidebar(QWidget *parent = 0); + QSidebar(QWidget *parent = nullptr); void setModelAndUrls(QFileSystemModel *model, const QList<QUrl> &newUrls); ~QSidebar(); diff --git a/src/widgets/dialogs/qwizard.cpp b/src/widgets/dialogs/qwizard.cpp index 88b187cd7f..f428114bbe 100644 --- a/src/widgets/dialogs/qwizard.cpp +++ b/src/widgets/dialogs/qwizard.cpp @@ -1595,23 +1595,25 @@ bool QWizardPrivate::handleAeroStyleChange() bool vistaMargins = false; if (isVistaThemeEnabled()) { + const int topOffset = vistaHelper->topOffset(); + const int topPadding = vistaHelper->topPadding(); if (isVistaThemeEnabled(QVistaHelper::VistaAero)) { if (isWindow) { vistaHelper->setDWMTitleBar(QVistaHelper::ExtendedTitleBar); q->installEventFilter(vistaHelper); } q->setMouseTracking(true); - antiFlickerWidget->move(0, vistaHelper->titleBarSize() + vistaHelper->topOffset()); + antiFlickerWidget->move(0, vistaHelper->titleBarSize() + topOffset); vistaHelper->backButton()->move( - 0, vistaHelper->topOffset() // ### should ideally work without the '+ 1' - - qMin(vistaHelper->topOffset(), vistaHelper->topPadding() + 1)); + 0, topOffset // ### should ideally work without the '+ 1' + - qMin(topOffset, topPadding + 1)); vistaMargins = true; vistaHelper->backButton()->show(); } else { if (isWindow) vistaHelper->setDWMTitleBar(QVistaHelper::NormalTitleBar); q->setMouseTracking(true); - antiFlickerWidget->move(0, vistaHelper->topOffset()); + antiFlickerWidget->move(0, topOffset); vistaHelper->backButton()->move(0, -1); // ### should ideally work with (0, 0) } if (isWindow) @@ -3257,7 +3259,11 @@ void QWizard::paintEvent(QPaintEvent * event) /*! \reimp */ +# if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +bool QWizard::nativeEvent(const QByteArray &eventType, void *message, qintptr *result) +# else bool QWizard::nativeEvent(const QByteArray &eventType, void *message, long *result) +# endif { #if QT_CONFIG(style_windowsvista) Q_D(QWizard); diff --git a/src/widgets/dialogs/qwizard.h b/src/widgets/dialogs/qwizard.h index 0dd837b197..ef71efa0cb 100644 --- a/src/widgets/dialogs/qwizard.h +++ b/src/widgets/dialogs/qwizard.h @@ -188,7 +188,11 @@ protected: void resizeEvent(QResizeEvent *event) override; void paintEvent(QPaintEvent *event) override; #if defined(Q_OS_WIN) || defined(Q_CLANG_QDOC) +# if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + bool nativeEvent(const QByteArray &eventType, void *message, qintptr *result) override; +# else bool nativeEvent(const QByteArray &eventType, void *message, long *result) override; +# endif #endif void done(int result) override; virtual void initializePage(int id); diff --git a/src/widgets/dialogs/qwizard_win.cpp b/src/widgets/dialogs/qwizard_win.cpp index aa9ad7f290..95f8f6a878 100644 --- a/src/widgets/dialogs/qwizard_win.cpp +++ b/src/widgets/dialogs/qwizard_win.cpp @@ -172,7 +172,7 @@ void QVistaHelper::updateCustomMargins(bool vistaMargins) const QMargins customMarginsDp = vistaMargins ? QMargins(0, -titleBarSizeDp(), 0, 0) : QMargins(); - const QVariant customMarginsV = qVariantFromValue(customMarginsDp); + const QVariant customMarginsV = QVariant::fromValue(customMarginsDp); // The dynamic property takes effect when creating the platform window. window->setProperty("_q_windowsCustomMargins", customMarginsV); // If a platform window exists, change via native interface. @@ -293,9 +293,9 @@ void QVistaHelper::drawTitleBar(QPainter *painter) int glowOffset = 0; if (vistaState() == VistaAero) { - textHeight += 2 * glowSize(); - textWidth += 2 * glowSize(); glowOffset = glowSize(); + textHeight += 2 * glowOffset; + textWidth += 2 * glowOffset; } const int titleLeft = (wizard->layoutDirection() == Qt::LeftToRight @@ -339,7 +339,11 @@ void QVistaHelper::setTitleBarIconAndCaptionVisible(bool visible) SetWindowThemeAttribute(handle, WTA_NONCLIENT, &opt, sizeof(WTA_OPTIONS)); } +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +bool QVistaHelper::winEvent(MSG* msg, qintptr *result) +#else bool QVistaHelper::winEvent(MSG* msg, long* result) +#endif { switch (msg->message) { case WM_NCHITTEST: { @@ -401,7 +405,11 @@ void QVistaHelper::mouseEvent(QEvent *event) } } +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +bool QVistaHelper::handleWinEvent(MSG *message, qintptr *result) +#else bool QVistaHelper::handleWinEvent(MSG *message, long *result) +#endif { if (message->message == WM_THEMECHANGED || message->message == WM_DWMCOMPOSITIONCHANGED) cachedVistaState = Dirty; @@ -509,7 +517,11 @@ bool QVistaHelper::eventFilter(QObject *obj, QEvent *event) if (event->type() == QEvent::MouseMove) { QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + qintptr result; +#else long result; +#endif MSG msg; msg.message = WM_NCHITTEST; msg.wParam = 0; @@ -523,7 +535,11 @@ bool QVistaHelper::eventFilter(QObject *obj, QEvent *event) QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event); if (mouseEvent->button() == Qt::LeftButton) { +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + qintptr result; +#else long result; +#endif MSG msg; msg.message = WM_NCHITTEST; msg.wParam = 0; @@ -538,7 +554,11 @@ bool QVistaHelper::eventFilter(QObject *obj, QEvent *event) QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event); if (mouseEvent->button() == Qt::LeftButton) { +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + qintptr result; +#else long result; +#endif MSG msg; msg.message = WM_NCHITTEST; msg.wParam = 0; diff --git a/src/widgets/dialogs/qwizard_win_p.h b/src/widgets/dialogs/qwizard_win_p.h index 02c5e52c2c..b3796e3f48 100644 --- a/src/widgets/dialogs/qwizard_win_p.h +++ b/src/widgets/dialogs/qwizard_win_p.h @@ -93,7 +93,11 @@ public: bool setDWMTitleBar(TitleBarChangeType type); void setTitleBarIconAndCaptionVisible(bool visible); void mouseEvent(QEvent *event); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + bool handleWinEvent(MSG *message, qintptr *result); +#else bool handleWinEvent(MSG *message, long *result); +#endif void resizeEvent(QResizeEvent *event); void paintEvent(QPaintEvent *event); QVistaBackButton *backButton() const { return backButton_; } @@ -130,7 +134,11 @@ private: void drawTitleBar(QPainter *painter); void setMouseCursor(QPoint pos); void collapseTopFrameStrut(); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + bool winEvent(MSG *message, qintptr *result); +#else bool winEvent(MSG *message, long *result); +#endif void mouseMoveEvent(QMouseEvent *event); void mousePressEvent(QMouseEvent *event); void mouseReleaseEvent(QMouseEvent *event); diff --git a/src/widgets/doc/snippets/timeline/main.cpp b/src/widgets/doc/snippets/timeline/main.cpp index 74aa749254..4dfa2400d0 100644 --- a/src/widgets/doc/snippets/timeline/main.cpp +++ b/src/widgets/doc/snippets/timeline/main.cpp @@ -48,7 +48,7 @@ ** ****************************************************************************/ -#include <QtGui> +#include <QtWidgets> #include <math.h> int main(int argv, char *args[]) @@ -68,7 +68,7 @@ int main(int argv, char *args[]) for (int i = 0; i < 200; ++i) animation->setPosAt(i / 200.0, QPointF(i, i)); - QGraphicsScene *scene = new QGraphicsScene(); + QGraphicsScene *scene = new QGraphicsScene; scene->setSceneRect(0, 0, 250, 250); scene->addItem(ball); diff --git a/src/widgets/effects/qgraphicseffect_p.h b/src/widgets/effects/qgraphicseffect_p.h index 2f3bd2f7fd..7e342a9f3c 100644 --- a/src/widgets/effects/qgraphicseffect_p.h +++ b/src/widgets/effects/qgraphicseffect_p.h @@ -80,11 +80,11 @@ public: QRectF boundingRect(Qt::CoordinateSystem coordinateSystem = Qt::LogicalCoordinates) const; QRect deviceRect() const; QPixmap pixmap(Qt::CoordinateSystem system = Qt::LogicalCoordinates, - QPoint *offset = 0, + QPoint *offset = nullptr, QGraphicsEffect::PixmapPadMode mode = QGraphicsEffect::PadToEffectiveBoundingRect) const; protected: - QGraphicsEffectSource(QGraphicsEffectSourcePrivate &dd, QObject *parent = 0); + QGraphicsEffectSource(QGraphicsEffectSourcePrivate &dd, QObject *parent = nullptr); private: Q_DECLARE_PRIVATE(QGraphicsEffectSource) @@ -125,7 +125,7 @@ public: virtual void draw(QPainter *p) = 0; virtual void update() = 0; virtual bool isPixmap() const = 0; - virtual QPixmap pixmap(Qt::CoordinateSystem system, QPoint *offset = 0, + virtual QPixmap pixmap(Qt::CoordinateSystem system, QPoint *offset = nullptr, QGraphicsEffect::PixmapPadMode mode = QGraphicsEffect::PadToTransparentBorder) const = 0; virtual void effectBoundingRectChanged() = 0; @@ -149,7 +149,7 @@ class Q_WIDGETS_EXPORT QGraphicsEffectPrivate : public QObjectPrivate { Q_DECLARE_PUBLIC(QGraphicsEffect) public: - QGraphicsEffectPrivate() : source(0), isEnabled(1) {} + QGraphicsEffectPrivate() : source(nullptr), isEnabled(1) {} ~QGraphicsEffectPrivate(); inline void setGraphicsEffectSource(QGraphicsEffectSource *newSource) diff --git a/src/widgets/effects/qpixmapfilter_p.h b/src/widgets/effects/qpixmapfilter_p.h index 0f582bde60..c56acb8a24 100644 --- a/src/widgets/effects/qpixmapfilter_p.h +++ b/src/widgets/effects/qpixmapfilter_p.h @@ -100,7 +100,7 @@ class Q_WIDGETS_EXPORT QPixmapConvolutionFilter : public QPixmapFilter Q_DECLARE_PRIVATE(QPixmapConvolutionFilter) public: - QPixmapConvolutionFilter(QObject *parent = 0); + QPixmapConvolutionFilter(QObject *parent = nullptr); ~QPixmapConvolutionFilter(); void setConvolutionKernel(const qreal *matrix, int rows, int columns); @@ -124,7 +124,7 @@ class Q_WIDGETS_EXPORT QPixmapBlurFilter : public QPixmapFilter Q_DECLARE_PRIVATE(QPixmapBlurFilter) public: - QPixmapBlurFilter(QObject *parent = 0); + QPixmapBlurFilter(QObject *parent = nullptr); ~QPixmapBlurFilter(); void setRadius(qreal radius); @@ -148,7 +148,7 @@ class Q_WIDGETS_EXPORT QPixmapColorizeFilter : public QPixmapFilter Q_DECLARE_PRIVATE(QPixmapColorizeFilter) public: - QPixmapColorizeFilter(QObject *parent = 0); + QPixmapColorizeFilter(QObject *parent = nullptr); ~QPixmapColorizeFilter(); void setColor(const QColor& color); @@ -168,7 +168,7 @@ class Q_WIDGETS_EXPORT QPixmapDropShadowFilter : public QPixmapFilter Q_DECLARE_PRIVATE(QPixmapDropShadowFilter) public: - QPixmapDropShadowFilter(QObject *parent = 0); + QPixmapDropShadowFilter(QObject *parent = nullptr); ~QPixmapDropShadowFilter(); QRectF boundingRectFor(const QRectF &rect) const override; diff --git a/src/widgets/graphicsview/qgraphicsanchorlayout_p.h b/src/widgets/graphicsview/qgraphicsanchorlayout_p.h index 699ca32bfe..b5f14948ac 100644 --- a/src/widgets/graphicsview/qgraphicsanchorlayout_p.h +++ b/src/widgets/graphicsview/qgraphicsanchorlayout_p.h @@ -89,7 +89,7 @@ struct AnchorVertex { : m_item(item), m_edge(edge), m_type(Normal) {} AnchorVertex() - : m_item(0), m_edge(Qt::AnchorPoint(0)), m_type(Normal) {} + : m_item(nullptr), m_edge(Qt::AnchorPoint(0)), m_type(Normal) {} #ifdef QT_DEBUG inline QString toString() const; @@ -123,18 +123,18 @@ struct AnchorData : public QSimplexVariable { }; AnchorData() - : QSimplexVariable(), from(0), to(0), + : QSimplexVariable(), from(nullptr), to(nullptr), minSize(0), prefSize(0), maxSize(0), minPrefSize(0), maxPrefSize(0), sizeAtMinimum(0), sizeAtPreferred(0), - sizeAtMaximum(0), item(0), graphicsAnchor(0), + sizeAtMaximum(0), item(nullptr), graphicsAnchor(nullptr), type(Normal), isLayoutAnchor(false), isCenterAnchor(false), orientation(0), dependency(Independent) {} virtual ~AnchorData(); virtual void updateChildrenSizes() {} - void refreshSizeHints(const QLayoutStyleInfo *styleInfo = 0); + void refreshSizeHints(const QLayoutStyleInfo *styleInfo = nullptr); #ifdef QT_DEBUG void dump(int indent = 2); @@ -402,7 +402,7 @@ public: static QGraphicsAnchorLayoutPrivate *get(QGraphicsAnchorLayout *q) { - return q ? q->d_func() : 0; + return q ? q->d_func() : nullptr; } static Qt::AnchorPoint oppositeEdge( @@ -443,7 +443,7 @@ public: Qt::AnchorPoint firstEdge, QGraphicsLayoutItem *secondItem, Qt::AnchorPoint secondEdge, - qreal *spacing = 0); + qreal *spacing = nullptr); // Helper for Anchor Manipulation methods void addAnchor_helper(QGraphicsLayoutItem *firstItem, diff --git a/src/widgets/graphicsview/qgraphicsgridlayoutengine_p.h b/src/widgets/graphicsview/qgraphicsgridlayoutengine_p.h index 370df9eed7..e98160e40f 100644 --- a/src/widgets/graphicsview/qgraphicsgridlayoutengine_p.h +++ b/src/widgets/graphicsview/qgraphicsgridlayoutengine_p.h @@ -68,7 +68,7 @@ class QGraphicsLayoutPrivate; class QGraphicsGridLayoutEngineItem : public QGridLayoutItem { public: QGraphicsGridLayoutEngineItem(QGraphicsLayoutItem *item, int row, int columns, int rowSpan = 1, int columnSpan = 1, - Qt::Alignment alignment = 0) + Qt::Alignment alignment = nullptr) : QGridLayoutItem(row, columns, rowSpan, columnSpan, alignment), q_layoutItem(item) {} virtual QLayoutPolicy::Policy sizePolicy(Qt::Orientation orientation) const override @@ -115,7 +115,7 @@ public: { const int index = indexOf(layoutItem); if (index < 0) - return 0; + return nullptr; return static_cast<QGraphicsGridLayoutEngineItem*>(q_items.at(index)); } diff --git a/src/widgets/graphicsview/qgraphicsitem_p.h b/src/widgets/graphicsview/qgraphicsitem_p.h index 54c25bf6e1..92d85f7125 100644 --- a/src/widgets/graphicsview/qgraphicsitem_p.h +++ b/src/widgets/graphicsview/qgraphicsitem_p.h @@ -78,13 +78,13 @@ public: typedef void (*ClearFunction)(QDeclarativeListProperty<T> *); QDeclarativeListProperty() - : object(0), data(0), append(0), count(0), at(0), clear(0), dummy1(0), dummy2(0) {} + : object(nullptr), data(nullptr), append(nullptr), count(nullptr), at(nullptr), clear(nullptr), dummy1(nullptr), dummy2(nullptr) {} QDeclarativeListProperty(QObject *o, QList<T *> &list) : object(o), data(&list), append(qlist_append), count(qlist_count), at(qlist_at), - clear(qlist_clear), dummy1(0), dummy2(0) {} + clear(qlist_clear), dummy1(nullptr), dummy2(nullptr) {} QDeclarativeListProperty(QObject *o, void *d, AppendFunction a, CountFunction c = 0, AtFunction t = 0, ClearFunction r = 0) - : object(o), data(d), append(a), count(c), at(t), clear(r), dummy1(0), dummy2(0) {} + : object(o), data(d), append(a), count(c), at(t), clear(r), dummy1(nullptr), dummy2(nullptr) {} bool operator==(const QDeclarativeListProperty &o) const { return object == o.object && @@ -198,8 +198,8 @@ public: || (ancestorFlags & AncestorIgnoresTransformations); } - void combineTransformToParent(QTransform *x, const QTransform *viewTransform = 0) const; - void combineTransformFromParent(QTransform *x, const QTransform *viewTransform = 0) const; + void combineTransformToParent(QTransform *x, const QTransform *viewTransform = nullptr) const; + void combineTransformFromParent(QTransform *x, const QTransform *viewTransform = nullptr) const; virtual void updateSceneTransformFromParent(); static bool movableAncestorIsSelected(const QGraphicsItem *item); @@ -232,7 +232,7 @@ public: void childrenBoundingRectHelper(QTransform *x, QRectF *rect, QGraphicsItem *topMostEffectItem); void initStyleOption(QStyleOptionGraphicsItem *option, const QTransform &worldTransform, const QRegion &exposedRegion, bool allItems = false) const; - QRectF effectiveBoundingRect(QGraphicsItem *topMostEffectItem = 0) const; + QRectF effectiveBoundingRect(QGraphicsItem *topMostEffectItem = nullptr) const; QRectF sceneEffectiveBoundingRect() const; QRectF effectiveBoundingRect(const QRectF &rect) const; @@ -408,8 +408,8 @@ public: void setFocusHelper(Qt::FocusReason focusReason, bool climb, bool focusFromHide); void clearFocusHelper(bool giveFocusToParent, bool hiddenByParentPanel); - void setSubFocus(QGraphicsItem *rootItem = 0, QGraphicsItem *stopItem = 0); - void clearSubFocus(QGraphicsItem *rootItem = 0, QGraphicsItem *stopItem = 0); + void setSubFocus(QGraphicsItem *rootItem = nullptr, QGraphicsItem *stopItem = nullptr); + void clearSubFocus(QGraphicsItem *rootItem = nullptr, QGraphicsItem *stopItem = nullptr); void resetFocusProxy(); virtual void subFocusItemChange(); virtual void focusScopeItemChange(bool isSubFocusItem); @@ -541,7 +541,7 @@ struct QGraphicsItemPrivate::TransformData onlyTransform(true) { } - QTransform computedFullTransform(QTransform *postmultiplyTransform = 0) const + QTransform computedFullTransform(QTransform *postmultiplyTransform = nullptr) const { if (onlyTransform) { if (!postmultiplyTransform || postmultiplyTransform->isIdentity()) @@ -595,12 +595,12 @@ class QGraphicsItemEffectSourcePrivate : public QGraphicsEffectSourcePrivate { public: QGraphicsItemEffectSourcePrivate(QGraphicsItem *i) - : QGraphicsEffectSourcePrivate(), item(i), info(0) + : QGraphicsEffectSourcePrivate(), item(i), info(nullptr) {} void detach() override { - item->d_ptr->graphicsEffect = 0; + item->d_ptr->graphicsEffect = nullptr; item->prepareGeometryChange(); } @@ -608,7 +608,7 @@ public: { return item; } const QWidget *widget() const override - { return 0; } + { return nullptr; } void update() override { item->d_ptr->updateDueToGraphicsEffect = true; @@ -628,7 +628,7 @@ public: } const QStyleOption *styleOption() const override - { return info ? info->option : 0; } + { return info ? info->option : nullptr; } QRect deviceRect() const override { @@ -644,7 +644,7 @@ public: QPixmap pixmap(Qt::CoordinateSystem system, QPoint *offset, QGraphicsEffect::PixmapPadMode mode) const override; - QRectF paddedEffectRect(Qt::CoordinateSystem system, QGraphicsEffect::PixmapPadMode mode, const QRectF &sourceRect, bool *unpadded = 0) const; + QRectF paddedEffectRect(Qt::CoordinateSystem system, QGraphicsEffect::PixmapPadMode mode, const QRectF &sourceRect, bool *unpadded = nullptr) const; QGraphicsItem *item; QGraphicsItemPaintInfo *info; diff --git a/src/widgets/graphicsview/qgraphicsitemanimation.cpp b/src/widgets/graphicsview/qgraphicsitemanimation.cpp index 78b91d5c39..ad77e2f260 100644 --- a/src/widgets/graphicsview/qgraphicsitemanimation.cpp +++ b/src/widgets/graphicsview/qgraphicsitemanimation.cpp @@ -115,7 +115,7 @@ public: QGraphicsItem *item; QPointF startPos; - QMatrix startMatrix; + QTransform startTransform; qreal step; @@ -294,23 +294,38 @@ QList<QPair<qreal, QPointF> > QGraphicsItemAnimation::posList() const return list; } +#if QT_DEPRECATED_SINCE(5, 14) /*! Returns the matrix used to transform the item at the specified \a step value. + + \obsolete Use transformAt() instead */ QMatrix QGraphicsItemAnimation::matrixAt(qreal step) const { check_step_valid(step, "matrixAt"); + return transformAt(step).toAffine(); +} +#endif + +/*! + Returns the transform used for the item at the specified \a step value. + + \since 5.14 +*/ +QTransform QGraphicsItemAnimation::transformAt(qreal step) const +{ + check_step_valid(step, "transformAt"); - QMatrix matrix; + QTransform transform; if (!d->rotation.isEmpty()) - matrix.rotate(rotationAt(step)); + transform.rotate(rotationAt(step)); if (!d->verticalScale.isEmpty()) - matrix.scale(horizontalScaleAt(step), verticalScaleAt(step)); + transform.scale(horizontalScaleAt(step), verticalScaleAt(step)); if (!d->verticalShear.isEmpty()) - matrix.shear(horizontalShearAt(step), verticalShearAt(step)); + transform.shear(horizontalShearAt(step), verticalShearAt(step)); if (!d->xTranslation.isEmpty()) - matrix.translate(xTranslationAt(step), yTranslationAt(step)); - return matrix; + transform.translate(xTranslationAt(step), yTranslationAt(step)); + return transform; } /*! @@ -542,7 +557,7 @@ void QGraphicsItemAnimation::setStep(qreal step) || !d->horizontalShear.isEmpty() || !d->xTranslation.isEmpty() || !d->yTranslation.isEmpty()) { - d->item->setMatrix(d->startMatrix * matrixAt(step)); + d->item->setTransform(d->startTransform * transformAt(step)); } } @@ -562,7 +577,7 @@ void QGraphicsItemAnimation::reset() if (!d->item) return; d->startPos = d->item->pos(); - d->startMatrix = d->item->matrix(); + d->startTransform = d->item->transform(); } #endif diff --git a/src/widgets/graphicsview/qgraphicsitemanimation.h b/src/widgets/graphicsview/qgraphicsitemanimation.h index f983bd8026..3051fb2e2b 100644 --- a/src/widgets/graphicsview/qgraphicsitemanimation.h +++ b/src/widgets/graphicsview/qgraphicsitemanimation.h @@ -51,6 +51,7 @@ class QGraphicsItem; class QMatrix; class QPointF; class QTimeLine; +class QTransform; template <class T1, class T2> struct QPair; class QGraphicsItemAnimationPrivate; @@ -71,7 +72,11 @@ public: QList<QPair<qreal, QPointF> > posList() const; void setPosAt(qreal step, const QPointF &pos); +#if QT_DEPRECATED_SINCE(5, 14) + QT_DEPRECATED_X("Use transformAt() instead") QMatrix matrixAt(qreal step) const; +#endif + QTransform transformAt(qreal step) const; qreal rotationAt(qreal step) const; QList<QPair<qreal, qreal> > rotationList() const; diff --git a/src/widgets/graphicsview/qgraphicslayout_p.h b/src/widgets/graphicsview/qgraphicslayout_p.h index 302ad1e116..0d91151e22 100644 --- a/src/widgets/graphicsview/qgraphicslayout_p.h +++ b/src/widgets/graphicsview/qgraphicslayout_p.h @@ -91,7 +91,7 @@ public: m_defaultSpacing[1] = style->pixelMetric(QStyle::PM_LayoutVerticalSpacing); } - inline void invalidate() { m_valid = false; m_style = 0; m_widget = 0; } + inline void invalidate() { m_valid = false; m_style = nullptr; m_widget = nullptr; } inline QStyle *style() const { return m_style; } inline QWidget *widget() const { return m_widget; } @@ -130,7 +130,7 @@ class Q_AUTOTEST_EXPORT QGraphicsLayoutPrivate : public QGraphicsLayoutItemPriva Q_DECLARE_PUBLIC(QGraphicsLayout) public: - QGraphicsLayoutPrivate() : QGraphicsLayoutItemPrivate(0, true), left(-1.0), top(-1.0), right(-1.0), bottom(-1.0), + QGraphicsLayoutPrivate() : QGraphicsLayoutItemPrivate(nullptr, true), left(-1.0), top(-1.0), right(-1.0), bottom(-1.0), activated(true) { } void reparentChildItems(QGraphicsItem *newParent); diff --git a/src/widgets/graphicsview/qgraphicslayoutstyleinfo_p.h b/src/widgets/graphicsview/qgraphicslayoutstyleinfo_p.h index c3af9f4554..9807efb26e 100644 --- a/src/widgets/graphicsview/qgraphicslayoutstyleinfo_p.h +++ b/src/widgets/graphicsview/qgraphicslayoutstyleinfo_p.h @@ -84,7 +84,7 @@ public: virtual void invalidate() override { - m_style = 0; + m_style = nullptr; QAbstractLayoutStyleInfo::invalidate(); } diff --git a/src/widgets/graphicsview/qgraphicsscene_p.h b/src/widgets/graphicsview/qgraphicsscene_p.h index a2d13436fc..7934359cee 100644 --- a/src/widgets/graphicsview/qgraphicsscene_p.h +++ b/src/widgets/graphicsview/qgraphicsscene_p.h @@ -226,7 +226,7 @@ public: void drawSubtreeRecursive(QGraphicsItem *item, QPainter *painter, const QTransform *const, QRegion *exposedRegion, QWidget *widget, qreal parentOpacity = qreal(1.0), - const QTransform *const effectTransform = 0); + const QTransform *const effectTransform = nullptr); void draw(QGraphicsItem *, QPainter *, const QTransform *const, const QTransform *const, QRegion *, QWidget *, qreal, const QTransform *const, bool, bool); @@ -312,9 +312,9 @@ public: void gestureTargetsAtHotSpots(const QSet<QGesture *> &gestures, Qt::GestureFlag flag, QHash<QGraphicsObject *, QSet<QGesture *> > *targets, - QSet<QGraphicsObject *> *itemsSet = 0, - QSet<QGesture *> *normal = 0, - QSet<QGesture *> *conflicts = 0); + QSet<QGraphicsObject *> *itemsSet = nullptr, + QSet<QGesture *> *normal = nullptr, + QSet<QGesture *> *conflicts = nullptr); void cancelGesturesForChildren(QGesture *original); void grabGesture(QGraphicsItem *, Qt::GestureType gesture); void ungrabGesture(QGraphicsItem *, Qt::GestureType gesture); diff --git a/src/widgets/graphicsview/qgraphicsscenebsptreeindex_p.h b/src/widgets/graphicsview/qgraphicsscenebsptreeindex_p.h index eb6bbbf49b..7e0e525a6b 100644 --- a/src/widgets/graphicsview/qgraphicsscenebsptreeindex_p.h +++ b/src/widgets/graphicsview/qgraphicsscenebsptreeindex_p.h @@ -74,7 +74,7 @@ class Q_AUTOTEST_EXPORT QGraphicsSceneBspTreeIndex : public QGraphicsSceneIndex Q_OBJECT Q_PROPERTY(int bspTreeDepth READ bspTreeDepth WRITE setBspTreeDepth) public: - QGraphicsSceneBspTreeIndex(QGraphicsScene *scene = 0); + QGraphicsSceneBspTreeIndex(QGraphicsScene *scene = nullptr); ~QGraphicsSceneBspTreeIndex(); QList<QGraphicsItem *> estimateItems(const QRectF &rect, Qt::SortOrder order) const override; diff --git a/src/widgets/graphicsview/qgraphicssceneindex_p.h b/src/widgets/graphicsview/qgraphicssceneindex_p.h index 86637e836b..b494c52671 100644 --- a/src/widgets/graphicsview/qgraphicssceneindex_p.h +++ b/src/widgets/graphicsview/qgraphicssceneindex_p.h @@ -77,7 +77,7 @@ class Q_AUTOTEST_EXPORT QGraphicsSceneIndex : public QObject Q_OBJECT public: - QGraphicsSceneIndex(QGraphicsScene *scene = 0); + QGraphicsSceneIndex(QGraphicsScene *scene = nullptr); virtual ~QGraphicsSceneIndex(); QGraphicsScene *scene() const; diff --git a/src/widgets/graphicsview/qgraphicsscenelinearindex_p.h b/src/widgets/graphicsview/qgraphicsscenelinearindex_p.h index 07d5d80ef1..ead52c1fb0 100644 --- a/src/widgets/graphicsview/qgraphicsscenelinearindex_p.h +++ b/src/widgets/graphicsview/qgraphicsscenelinearindex_p.h @@ -67,7 +67,7 @@ class Q_AUTOTEST_EXPORT QGraphicsSceneLinearIndex : public QGraphicsSceneIndex Q_OBJECT public: - QGraphicsSceneLinearIndex(QGraphicsScene *scene = 0) : QGraphicsSceneIndex(scene), m_numSortedElements(0) + QGraphicsSceneLinearIndex(QGraphicsScene *scene = nullptr) : QGraphicsSceneIndex(scene), m_numSortedElements(0) { } QList<QGraphicsItem *> items(Qt::SortOrder order = Qt::DescendingOrder) const override diff --git a/src/widgets/graphicsview/qgraphicstransform_p.h b/src/widgets/graphicsview/qgraphicstransform_p.h index e54ee9fb3c..05e12c3e64 100644 --- a/src/widgets/graphicsview/qgraphicstransform_p.h +++ b/src/widgets/graphicsview/qgraphicstransform_p.h @@ -66,7 +66,7 @@ public: Q_DECLARE_PUBLIC(QGraphicsTransform) QGraphicsTransformPrivate() - : QObjectPrivate(), item(0) {} + : QObjectPrivate(), item(nullptr) {} ~QGraphicsTransformPrivate(); QGraphicsItem *item; diff --git a/src/widgets/graphicsview/qgraphicswidget_p.h b/src/widgets/graphicsview/qgraphicswidget_p.h index 505a2a24c0..821f8c73f1 100644 --- a/src/widgets/graphicsview/qgraphicswidget_p.h +++ b/src/widgets/graphicsview/qgraphicswidget_p.h @@ -82,7 +82,7 @@ public: mutable qreal *margins; void ensureMargins() const; - void fixFocusChainBeforeReparenting(QGraphicsWidget *newParent, QGraphicsScene *oldScene, QGraphicsScene *newScene = 0); + void fixFocusChainBeforeReparenting(QGraphicsWidget *newParent, QGraphicsScene *oldScene, QGraphicsScene *newScene = nullptr); void setLayout_helper(QGraphicsLayout *l); // Layouts diff --git a/src/widgets/graphicsview/qsimplex_p.h b/src/widgets/graphicsview/qsimplex_p.h index 369f2f5f82..a69cef6115 100644 --- a/src/widgets/graphicsview/qsimplex_p.h +++ b/src/widgets/graphicsview/qsimplex_p.h @@ -82,7 +82,7 @@ struct QSimplexVariable */ struct QSimplexConstraint { - QSimplexConstraint() : constant(0), ratio(Equal), artificial(0) {} + QSimplexConstraint() : constant(0), ratio(Equal), artificial(nullptr) {} enum Ratio { LessOrEqual = 0, diff --git a/src/widgets/itemviews/qcolumnview_p.h b/src/widgets/itemviews/qcolumnview_p.h index 7b36b1f3da..c60579255e 100644 --- a/src/widgets/itemviews/qcolumnview_p.h +++ b/src/widgets/itemviews/qcolumnview_p.h @@ -74,7 +74,7 @@ QT_BEGIN_NAMESPACE class QColumnViewPreviewColumn : public QAbstractItemView { public: - explicit QColumnViewPreviewColumn(QWidget *parent) : QAbstractItemView(parent), previewWidget(0) { + explicit QColumnViewPreviewColumn(QWidget *parent) : QAbstractItemView(parent), previewWidget(nullptr) { } void setPreviewWidget(QWidget *widget) { @@ -186,7 +186,7 @@ class QColumnViewDelegate : public QItemDelegate { public: - explicit QColumnViewDelegate(QObject *parent = 0) : QItemDelegate(parent) {} + explicit QColumnViewDelegate(QObject *parent = nullptr) : QItemDelegate(parent) {} ~QColumnViewDelegate() {} void paint(QPainter *painter, diff --git a/src/widgets/itemviews/qcolumnviewgrip_p.h b/src/widgets/itemviews/qcolumnviewgrip_p.h index 5eb8012204..4311edbeb4 100644 --- a/src/widgets/itemviews/qcolumnviewgrip_p.h +++ b/src/widgets/itemviews/qcolumnviewgrip_p.h @@ -68,12 +68,12 @@ Q_SIGNALS: void gripMoved(int offset); public: - explicit QColumnViewGrip(QWidget *parent = 0); + explicit QColumnViewGrip(QWidget *parent = nullptr); ~QColumnViewGrip(); int moveGrip(int offset); protected: - QColumnViewGrip(QColumnViewGripPrivate &, QWidget *parent = 0, Qt::WindowFlags f = 0); + QColumnViewGrip(QColumnViewGripPrivate &, QWidget *parent = nullptr, Qt::WindowFlags f = nullptr); void paintEvent(QPaintEvent *event) override; void mouseDoubleClickEvent(QMouseEvent *event) override; void mouseMoveEvent(QMouseEvent *event) override; diff --git a/src/widgets/itemviews/qheaderview_p.h b/src/widgets/itemviews/qheaderview_p.h index d9fc1baec5..766adef36d 100644 --- a/src/widgets/itemviews/qheaderview_p.h +++ b/src/widgets/itemviews/qheaderview_p.h @@ -102,7 +102,7 @@ public: lastSectionLogicalIdx(-1), // Only trust when we stretch last section sectionIndicatorOffset(0), #if QT_CONFIG(label) - sectionIndicator(0), + sectionIndicator(nullptr), #endif globalResizeMode(QHeaderView::Interactive), sectionStartposRecalc(true), diff --git a/src/widgets/itemviews/qlistview_p.h b/src/widgets/itemviews/qlistview_p.h index c6810f8fdc..86331bb862 100644 --- a/src/widgets/itemviews/qlistview_p.h +++ b/src/widgets/itemviews/qlistview_p.h @@ -248,7 +248,7 @@ private: class QIconModeViewBase : public QCommonListViewBase { public: - QIconModeViewBase(QListView *q, QListViewPrivate *d) : QCommonListViewBase(q, d), interSectingVector(0) {} + QIconModeViewBase(QListView *q, QListViewPrivate *d) : QCommonListViewBase(q, d), interSectingVector(nullptr) {} QBspTree tree; QVector<QListViewItem> items; diff --git a/src/widgets/itemviews/qtableview_p.h b/src/widgets/itemviews/qtableview_p.h index d55462c28b..f629dfcd09 100644 --- a/src/widgets/itemviews/qtableview_p.h +++ b/src/widgets/itemviews/qtableview_p.h @@ -137,7 +137,7 @@ public: : showGrid(true), gridStyle(Qt::SolidLine), rowSectionAnchor(-1), columnSectionAnchor(-1), columnResizeTimerID(0), rowResizeTimerID(0), - horizontalHeader(0), verticalHeader(0), + horizontalHeader(nullptr), verticalHeader(nullptr), sortingEnabled(false), geometryRecursionBlock(false), visualCursor(QPoint()) { diff --git a/src/widgets/itemviews/qtreeview_p.h b/src/widgets/itemviews/qtreeview_p.h index 9666a9f8c2..836d8f0c2d 100644 --- a/src/widgets/itemviews/qtreeview_p.h +++ b/src/widgets/itemviews/qtreeview_p.h @@ -87,7 +87,7 @@ public: QTreeViewPrivate() : QAbstractItemViewPrivate(), - header(0), indent(20), lastViewedItem(0), defaultItemHeight(-1), + header(nullptr), indent(20), lastViewedItem(0), defaultItemHeight(-1), uniformRowHeights(false), rootDecoration(true), itemsExpandable(true), sortingEnabled(false), expandsOnDoubleClick(true), @@ -157,7 +157,7 @@ public: bool checkViewItems() const; #endif - int firstVisibleItem(int *offset = 0) const; + int firstVisibleItem(int *offset = nullptr) const; int lastVisibleItem(int firstVisual = -1, int offset = -1) const; int columnAt(int x) const; bool hasVisibleChildren( const QModelIndex& parent) const; diff --git a/src/widgets/itemviews/qtreewidget_p.h b/src/widgets/itemviews/qtreewidget_p.h index ee4a633468..81e7e86203 100644 --- a/src/widgets/itemviews/qtreewidget_p.h +++ b/src/widgets/itemviews/qtreewidget_p.h @@ -78,7 +78,7 @@ class QTreeModel : public QAbstractItemModel friend class QTreeWidgetItemIteratorPrivate; public: - explicit QTreeModel(int columns = 0, QTreeWidget *parent = 0); + explicit QTreeModel(int columns = 0, QTreeWidget *parent = nullptr); ~QTreeModel(); inline QTreeWidget *view() const @@ -140,7 +140,7 @@ public: { return createIndex(row, col, item); } protected: - QTreeModel(QTreeModelPrivate &, QTreeWidget *parent = 0); + QTreeModel(QTreeModelPrivate &, QTreeWidget *parent = nullptr); void emitDataChanged(QTreeWidgetItem *item, int column, const QVector<int> &roles); void beginInsertItems(QTreeWidgetItem *parent, int row, int count); void endInsertItems(); diff --git a/src/widgets/kernel/mac.pri b/src/widgets/kernel/mac.pri index f7e7aa869a..d21e5d4a74 100644 --- a/src/widgets/kernel/mac.pri +++ b/src/widgets/kernel/mac.pri @@ -1,4 +1 @@ -macos { - LIBS_PRIVATE += -framework AppKit -lz - *-mwerks:INCLUDEPATH += compat -} +macos: LIBS_PRIVATE += -framework AppKit -lz diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 0ab9ed6ec2..1d26fb6697 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -575,10 +575,6 @@ void QApplicationPrivate::init() initialize(); eventDispatcher->startingUp(); -#ifdef QT_EVAL - extern void qt_gui_eval_init(QCoreApplicationPrivate::Type); - qt_gui_eval_init(application_type); -#endif #ifndef QT_NO_ACCESSIBILITY // factory for accessible interfaces for widgets shipped with Qt QAccessible::installFactory(&qAccessibleFactory); diff --git a/src/widgets/kernel/qapplication_p.h b/src/widgets/kernel/qapplication_p.h index 133279f977..98eb9b73c6 100644 --- a/src/widgets/kernel/qapplication_p.h +++ b/src/widgets/kernel/qapplication_p.h @@ -128,10 +128,10 @@ public: void notifyWindowIconChanged() override; //modality - bool isWindowBlocked(QWindow *window, QWindow **blockingWindow = 0) const override; + bool isWindowBlocked(QWindow *window, QWindow **blockingWindow = nullptr) const override; static bool isBlockedByModal(QWidget *widget); static bool modalState(); - static bool tryModalHelper(QWidget *widget, QWidget **rettop = 0); + static bool tryModalHelper(QWidget *widget, QWidget **rettop = nullptr); #if 0 // Used to be included in Qt4 for Q_WS_MAC static QWidget *tryModalHelper_sys(QWidget *top); bool canQuit(); @@ -157,7 +157,7 @@ public: void openPopup(QWidget *popup); static void setFocusWidget(QWidget *focus, Qt::FocusReason reason); static QWidget *focusNextPrevChild_helper(QWidget *toplevel, bool next, - bool *wrappingOccurred = 0); + bool *wrappingOccurred = nullptr); #if QT_CONFIG(graphicsview) // Maintain a list of all scenes to ensure font and palette propagation to @@ -238,7 +238,7 @@ public: return window; if (const QWidget *nativeParent = widget->nativeParentWidget()) return nativeParent->windowHandle(); - return 0; + return nullptr; } #ifdef Q_OS_WIN diff --git a/src/widgets/kernel/qformlayout.cpp b/src/widgets/kernel/qformlayout.cpp index bd0ea2598a..9146ba84c8 100644 --- a/src/widgets/kernel/qformlayout.cpp +++ b/src/widgets/kernel/qformlayout.cpp @@ -783,7 +783,7 @@ void QFormLayoutPrivate::setupVerticalLayoutData(int width) vLayouts[vidx].expansive = expanding || (vLayouts[vidx].stretch > 0); vLayouts[vidx].empty = false; - if (vLayouts[vidx].stretch > 0) + if (vLayouts[vidx].expansive) addTopBottomStretch = false; if (vidx > 1) diff --git a/src/widgets/kernel/qgesture_p.h b/src/widgets/kernel/qgesture_p.h index 636103c1e1..cbf8d60892 100644 --- a/src/widgets/kernel/qgesture_p.h +++ b/src/widgets/kernel/qgesture_p.h @@ -111,7 +111,7 @@ class QPinchGesturePrivate : public QGesturePrivate public: QPinchGesturePrivate() - : totalChangeFlags(0), changeFlags(0), + : totalChangeFlags(nullptr), changeFlags(nullptr), totalScaleFactor(1), lastScaleFactor(1), scaleFactor(1), totalRotationAngle(0), lastRotationAngle(0), rotationAngle(0), isNewSequence(true) diff --git a/src/widgets/kernel/qlayout_p.h b/src/widgets/kernel/qlayout_p.h index 8a1b12a6be..8e1d773355 100644 --- a/src/widgets/kernel/qlayout_p.h +++ b/src/widgets/kernel/qlayout_p.h @@ -80,7 +80,7 @@ public: static QWidgetItem *createWidgetItem(const QLayout *layout, QWidget *widget); static QSpacerItem *createSpacerItem(const QLayout *layout, int w, int h, QSizePolicy::Policy hPolicy = QSizePolicy::Minimum, QSizePolicy::Policy vPolicy = QSizePolicy::Minimum); - virtual QLayoutItem* replaceAt(int index, QLayoutItem *newitem) { Q_UNUSED(index); Q_UNUSED(newitem); return 0; } + virtual QLayoutItem* replaceAt(int index, QLayoutItem *newitem) { Q_UNUSED(index); Q_UNUSED(newitem); return nullptr; } static QWidgetItemFactoryMethod widgetItemFactoryMethod; static QSpacerItemFactoryMethod spacerItemFactoryMethod; diff --git a/src/widgets/kernel/qlayoutengine_p.h b/src/widgets/kernel/qlayoutengine_p.h index 812fa7cf3b..948c2424e6 100644 --- a/src/widgets/kernel/qlayoutengine_p.h +++ b/src/widgets/kernel/qlayoutengine_p.h @@ -105,9 +105,9 @@ Q_WIDGETS_EXPORT QSize qSmartMinSize(const QWidgetItem *i); Q_WIDGETS_EXPORT QSize qSmartMinSize(const QWidget *w); Q_WIDGETS_EXPORT QSize qSmartMaxSize(const QSize &sizeHint, const QSize &minSize, const QSize &maxSize, - const QSizePolicy &sizePolicy, Qt::Alignment align = 0); -Q_WIDGETS_EXPORT QSize qSmartMaxSize(const QWidgetItem *i, Qt::Alignment align = 0); -Q_WIDGETS_EXPORT QSize qSmartMaxSize(const QWidget *w, Qt::Alignment align = 0); + const QSizePolicy &sizePolicy, Qt::Alignment align = nullptr); +Q_WIDGETS_EXPORT QSize qSmartMaxSize(const QWidgetItem *i, Qt::Alignment align = nullptr); +Q_WIDGETS_EXPORT QSize qSmartMaxSize(const QWidget *w, Qt::Alignment align = nullptr); Q_WIDGETS_EXPORT int qSmartSpacing(const QLayout *layout, QStyle::PixelMetric pm); diff --git a/src/widgets/kernel/qlayoutitem.cpp b/src/widgets/kernel/qlayoutitem.cpp index 9e6d1c5eac..0aab0bb06d 100644 --- a/src/widgets/kernel/qlayoutitem.cpp +++ b/src/widgets/kernel/qlayoutitem.cpp @@ -502,6 +502,17 @@ void QWidgetItem::setGeometry(const QRect &rect) else if (!(align & Qt::AlignTop)) y = y + (r.height() - s.height()) / 2; + // Make sure we don't move outside of the parent, e.g when styles demand + // surplus space that exceeds the available margins (f.ex macOS with QGroupBox) + if (x < 0) { + s.rwidth() += x; + x = 0; + } + if (y < 0) { + s.rheight() += y; + y = 0; + } + wid->setGeometry(x, y, s.width(), s.height()); } diff --git a/src/widgets/kernel/qsizepolicy.cpp b/src/widgets/kernel/qsizepolicy.cpp index b5a0cd3940..54bf8fe0dc 100644 --- a/src/widgets/kernel/qsizepolicy.cpp +++ b/src/widgets/kernel/qsizepolicy.cpp @@ -232,7 +232,7 @@ QT_BEGIN_NAMESPACE Returns the control type associated with the widget for which this size policy applies. */ -QSizePolicy::ControlType QSizePolicy::controlType() const Q_DECL_NOTHROW +QSizePolicy::ControlType QSizePolicy::controlType() const noexcept { return QSizePolicy::ControlType(1 << bits.ctype); } @@ -253,7 +253,7 @@ QSizePolicy::ControlType QSizePolicy::controlType() const Q_DECL_NOTHROW \sa QStyle::layoutSpacing() */ -void QSizePolicy::setControlType(ControlType type) Q_DECL_NOTHROW +void QSizePolicy::setControlType(ControlType type) noexcept { bits.ctype = toControlTypeFieldValue(type); } diff --git a/src/widgets/kernel/qsizepolicy.h b/src/widgets/kernel/qsizepolicy.h index dba742dec5..f26923eeb0 100644 --- a/src/widgets/kernel/qsizepolicy.h +++ b/src/widgets/kernel/qsizepolicy.h @@ -65,7 +65,7 @@ QT_BEGIN_NAMESPACE class QVariant; class QSizePolicy; -Q_DECL_CONST_FUNCTION inline uint qHash(QSizePolicy key, uint seed = 0) Q_DECL_NOTHROW; +Q_DECL_CONST_FUNCTION inline uint qHash(QSizePolicy key, uint seed = 0) noexcept; class Q_WIDGETS_EXPORT QSizePolicy { @@ -110,60 +110,60 @@ public: Q_DECLARE_FLAGS(ControlTypes, ControlType) Q_FLAG(ControlTypes) - QT_SIZEPOLICY_CONSTEXPR QSizePolicy() Q_DECL_NOTHROW : data(0) { } + QT_SIZEPOLICY_CONSTEXPR QSizePolicy() noexcept : data(0) { } #if defined(Q_COMPILER_UNIFORM_INIT) && !defined(Q_QDOC) - QT_SIZEPOLICY_CONSTEXPR QSizePolicy(Policy horizontal, Policy vertical, ControlType type = DefaultType) Q_DECL_NOTHROW + QT_SIZEPOLICY_CONSTEXPR QSizePolicy(Policy horizontal, Policy vertical, ControlType type = DefaultType) noexcept : bits{0, 0, quint32(horizontal), quint32(vertical), type == DefaultType ? 0 : toControlTypeFieldValue(type), 0, 0, 0} {} #else - QSizePolicy(Policy horizontal, Policy vertical, ControlType type = DefaultType) Q_DECL_NOTHROW + QSizePolicy(Policy horizontal, Policy vertical, ControlType type = DefaultType) noexcept : data(0) { bits.horPolicy = horizontal; bits.verPolicy = vertical; setControlType(type); } #endif // uniform-init - QT_SIZEPOLICY_CONSTEXPR Policy horizontalPolicy() const Q_DECL_NOTHROW { return static_cast<Policy>(bits.horPolicy); } - QT_SIZEPOLICY_CONSTEXPR Policy verticalPolicy() const Q_DECL_NOTHROW { return static_cast<Policy>(bits.verPolicy); } - ControlType controlType() const Q_DECL_NOTHROW; + QT_SIZEPOLICY_CONSTEXPR Policy horizontalPolicy() const noexcept { return static_cast<Policy>(bits.horPolicy); } + QT_SIZEPOLICY_CONSTEXPR Policy verticalPolicy() const noexcept { return static_cast<Policy>(bits.verPolicy); } + ControlType controlType() const noexcept; - Q_DECL_RELAXED_CONSTEXPR void setHorizontalPolicy(Policy d) Q_DECL_NOTHROW { bits.horPolicy = d; } - Q_DECL_RELAXED_CONSTEXPR void setVerticalPolicy(Policy d) Q_DECL_NOTHROW { bits.verPolicy = d; } - void setControlType(ControlType type) Q_DECL_NOTHROW; + Q_DECL_RELAXED_CONSTEXPR void setHorizontalPolicy(Policy d) noexcept { bits.horPolicy = d; } + Q_DECL_RELAXED_CONSTEXPR void setVerticalPolicy(Policy d) noexcept { bits.verPolicy = d; } + void setControlType(ControlType type) noexcept; - QT_SIZEPOLICY_CONSTEXPR Qt::Orientations expandingDirections() const Q_DECL_NOTHROW { + QT_SIZEPOLICY_CONSTEXPR Qt::Orientations expandingDirections() const noexcept { return ( (verticalPolicy() & ExpandFlag) ? Qt::Vertical : Qt::Orientations() ) | ( (horizontalPolicy() & ExpandFlag) ? Qt::Horizontal : Qt::Orientations() ) ; } - Q_DECL_RELAXED_CONSTEXPR void setHeightForWidth(bool b) Q_DECL_NOTHROW { bits.hfw = b; } - QT_SIZEPOLICY_CONSTEXPR bool hasHeightForWidth() const Q_DECL_NOTHROW { return bits.hfw; } - Q_DECL_RELAXED_CONSTEXPR void setWidthForHeight(bool b) Q_DECL_NOTHROW { bits.wfh = b; } - QT_SIZEPOLICY_CONSTEXPR bool hasWidthForHeight() const Q_DECL_NOTHROW { return bits.wfh; } + Q_DECL_RELAXED_CONSTEXPR void setHeightForWidth(bool b) noexcept { bits.hfw = b; } + QT_SIZEPOLICY_CONSTEXPR bool hasHeightForWidth() const noexcept { return bits.hfw; } + Q_DECL_RELAXED_CONSTEXPR void setWidthForHeight(bool b) noexcept { bits.wfh = b; } + QT_SIZEPOLICY_CONSTEXPR bool hasWidthForHeight() const noexcept { return bits.wfh; } - QT_SIZEPOLICY_CONSTEXPR bool operator==(const QSizePolicy& s) const Q_DECL_NOTHROW { return data == s.data; } - QT_SIZEPOLICY_CONSTEXPR bool operator!=(const QSizePolicy& s) const Q_DECL_NOTHROW { return data != s.data; } + QT_SIZEPOLICY_CONSTEXPR bool operator==(const QSizePolicy& s) const noexcept { return data == s.data; } + QT_SIZEPOLICY_CONSTEXPR bool operator!=(const QSizePolicy& s) const noexcept { return data != s.data; } - friend Q_DECL_CONST_FUNCTION uint qHash(QSizePolicy key, uint seed) Q_DECL_NOTHROW { return qHash(key.data, seed); } + friend Q_DECL_CONST_FUNCTION uint qHash(QSizePolicy key, uint seed) noexcept { return qHash(key.data, seed); } operator QVariant() const; - QT_SIZEPOLICY_CONSTEXPR int horizontalStretch() const Q_DECL_NOTHROW { return static_cast<int>(bits.horStretch); } - QT_SIZEPOLICY_CONSTEXPR int verticalStretch() const Q_DECL_NOTHROW { return static_cast<int>(bits.verStretch); } + QT_SIZEPOLICY_CONSTEXPR int horizontalStretch() const noexcept { return static_cast<int>(bits.horStretch); } + QT_SIZEPOLICY_CONSTEXPR int verticalStretch() const noexcept { return static_cast<int>(bits.verStretch); } Q_DECL_RELAXED_CONSTEXPR void setHorizontalStretch(int stretchFactor) { bits.horStretch = static_cast<quint32>(qBound(0, stretchFactor, 255)); } Q_DECL_RELAXED_CONSTEXPR void setVerticalStretch(int stretchFactor) { bits.verStretch = static_cast<quint32>(qBound(0, stretchFactor, 255)); } - QT_SIZEPOLICY_CONSTEXPR bool retainSizeWhenHidden() const Q_DECL_NOTHROW { return bits.retainSizeWhenHidden; } - Q_DECL_RELAXED_CONSTEXPR void setRetainSizeWhenHidden(bool retainSize) Q_DECL_NOTHROW { bits.retainSizeWhenHidden = retainSize; } + QT_SIZEPOLICY_CONSTEXPR bool retainSizeWhenHidden() const noexcept { return bits.retainSizeWhenHidden; } + Q_DECL_RELAXED_CONSTEXPR void setRetainSizeWhenHidden(bool retainSize) noexcept { bits.retainSizeWhenHidden = retainSize; } - Q_DECL_RELAXED_CONSTEXPR void transpose() Q_DECL_NOTHROW { *this = transposed(); } + Q_DECL_RELAXED_CONSTEXPR void transpose() noexcept { *this = transposed(); } Q_REQUIRED_RESULT #ifndef Q_QDOC QT_SIZEPOLICY_CONSTEXPR_AND_UNIFORM_INIT #endif - QSizePolicy transposed() const Q_DECL_NOTHROW + QSizePolicy transposed() const noexcept { return QSizePolicy(bits.transposed()); } @@ -173,11 +173,11 @@ private: friend Q_WIDGETS_EXPORT QDataStream &operator<<(QDataStream &, const QSizePolicy &); friend Q_WIDGETS_EXPORT QDataStream &operator>>(QDataStream &, QSizePolicy &); #endif - QT_SIZEPOLICY_CONSTEXPR QSizePolicy(int i) Q_DECL_NOTHROW : data(i) { } + QT_SIZEPOLICY_CONSTEXPR QSizePolicy(int i) noexcept : data(i) { } struct Bits; - QT_SIZEPOLICY_CONSTEXPR explicit QSizePolicy(Bits b) Q_DECL_NOTHROW : bits(b) { } + QT_SIZEPOLICY_CONSTEXPR explicit QSizePolicy(Bits b) noexcept : bits(b) { } - static Q_DECL_RELAXED_CONSTEXPR quint32 toControlTypeFieldValue(ControlType type) Q_DECL_NOTHROW + static Q_DECL_RELAXED_CONSTEXPR quint32 toControlTypeFieldValue(ControlType type) noexcept { /* The control type is a flag type, with values 0x1, 0x2, 0x4, 0x8, 0x10, @@ -207,7 +207,7 @@ private: quint32 retainSizeWhenHidden : 1; QT_SIZEPOLICY_CONSTEXPR_AND_UNIFORM_INIT - Bits transposed() const Q_DECL_NOTHROW + Bits transposed() const noexcept { return {verStretch, // \ swap horStretch, // / diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 89a8a7be0f..74b18d9991 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -1348,11 +1348,6 @@ void QWidget::create(WId window, bool initializeWindow, bool destroyOldWindow) if (!isWindow() && parentWidget() && parentWidget()->testAttribute(Qt::WA_DropSiteRegistered)) setAttribute(Qt::WA_DropSiteRegistered, true); -#ifdef QT_EVAL - extern void qt_eval_init_widget(QWidget *w); - qt_eval_init_widget(this); -#endif - // need to force the resting of the icon after changing parents if (testAttribute(Qt::WA_SetWindowIcon)) d->setWindowIcon_sys(); @@ -6059,13 +6054,7 @@ QString qt_setWindowTitle_helperHelper(const QString &title, const QWidget *widg { Q_ASSERT(widget); -#ifdef QT_EVAL - extern QString qt_eval_adapt_window_title(const QString &title); - QString cap = qt_eval_adapt_window_title(title); -#else QString cap = title; -#endif - if (cap.isEmpty()) return cap; @@ -10165,7 +10154,11 @@ void QWidget::hideEvent(QHideEvent *) \endtable */ +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +bool QWidget::nativeEvent(const QByteArray &eventType, void *message, qintptr *result) +#else bool QWidget::nativeEvent(const QByteArray &eventType, void *message, long *result) +#endif { Q_UNUSED(eventType); Q_UNUSED(message); diff --git a/src/widgets/kernel/qwidget.h b/src/widgets/kernel/qwidget.h index 4e5ef5a111..aec3eee639 100644 --- a/src/widgets/kernel/qwidget.h +++ b/src/widgets/kernel/qwidget.h @@ -648,7 +648,12 @@ protected: virtual void showEvent(QShowEvent *event); virtual void hideEvent(QHideEvent *event); + +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + virtual bool nativeEvent(const QByteArray &eventType, void *message, qintptr *result); +#else virtual bool nativeEvent(const QByteArray &eventType, void *message, long *result); +#endif // Misc. protected functions virtual void changeEvent(QEvent *); diff --git a/src/widgets/kernel/qwidget_p.h b/src/widgets/kernel/qwidget_p.h index 797963b931..90c4c2a945 100644 --- a/src/widgets/kernel/qwidget_p.h +++ b/src/widgets/kernel/qwidget_p.h @@ -146,7 +146,7 @@ public: inline operator bool() const { - return (0 != m_ptr); + return (nullptr != m_ptr); } private: @@ -411,7 +411,7 @@ public: void render(QPaintDevice *target, const QPoint &targetOffset, const QRegion &sourceRegion, QWidget::RenderFlags renderFlags); void drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QPoint &offset, int flags, - QPainter *sharedPainter = 0, QWidgetBackingStore *backingStore = 0); + QPainter *sharedPainter = nullptr, QWidgetBackingStore *backingStore = nullptr); void sendPaintEvent(const QRegion &toBePainted); @@ -428,7 +428,7 @@ public: QRegion clipRegion() const; void setSystemClip(QPaintEngine *paintEngine, qreal devicePixelRatio, const QRegion ®ion); void subtractOpaqueChildren(QRegion &rgn, const QRect &clipRect) const; - void subtractOpaqueSiblings(QRegion &source, bool *hasDirtySiblingsAbove = 0, + void subtractOpaqueSiblings(QRegion &source, bool *hasDirtySiblingsAbove = nullptr, bool alsoNonOpaque = false) const; void clipToEffectiveMask(QRegion ®ion) const; void updateIsOpaque(); @@ -525,7 +525,7 @@ public: void getLayoutItemMargins(int *left, int *top, int *right, int *bottom) const; void setLayoutItemMargins(int left, int top, int right, int bottom); - void setLayoutItemMargins(QStyle::SubElement element, const QStyleOption *opt = 0); + void setLayoutItemMargins(QStyle::SubElement element, const QStyleOption *opt = nullptr); void updateContentsRect(); QMargins safeAreaMargins() const; @@ -555,7 +555,7 @@ public: QGraphicsProxyWidget *ancestorProxy = widget->d_func()->nearestGraphicsProxyWidget(widget); //It's embedded if it has an ancestor if (ancestorProxy) { - if (!bypassGraphicsProxyWidget(widget) && ancestorProxy->scene() != 0) { + if (!bypassGraphicsProxyWidget(widget) && ancestorProxy->scene() != nullptr) { // One view, let be smart and return the viewport rect then the popup is aligned if (ancestorProxy->scene()->views().size() == 1) { QGraphicsView *view = ancestorProxy->scene()->views().at(0); @@ -586,7 +586,7 @@ public: } inline void restoreRedirected() - { redirectDev = 0; } + { redirectDev = nullptr; } inline void enforceNativeChildren() { @@ -652,7 +652,7 @@ public: QOpenGLContext *shareContext() const; - virtual QObject *focusObject() { return 0; } + virtual QObject *focusObject() { return nullptr; } #ifndef QT_NO_OPENGL virtual GLuint textureId() const { return 0; } @@ -660,7 +660,7 @@ public: Q_Q(QWidget); return q->testAttribute(Qt::WA_AlwaysStackOnTop) ? QPlatformTextureList::StacksOnTop - : QPlatformTextureList::Flags(0); + : QPlatformTextureList::Flags(nullptr); } virtual QImage grabFramebuffer() { return QImage(); } virtual void beginBackingStorePainting() { } @@ -904,7 +904,7 @@ struct QWidgetPaintContext { inline QWidgetPaintContext(QPaintDevice *d, const QRegion &r, const QPoint &o, int f, QPainter *p, QWidgetBackingStore *b) - : pdev(d), rgn(r), offset(o), flags(f), sharedPainter(p), backingStore(b), painter(0) {} + : pdev(d), rgn(r), offset(o), flags(f), sharedPainter(p), backingStore(b), painter(nullptr) {} QPaintDevice *pdev; QRegion rgn; @@ -920,14 +920,14 @@ class QWidgetEffectSourcePrivate : public QGraphicsEffectSourcePrivate { public: QWidgetEffectSourcePrivate(QWidget *widget) - : QGraphicsEffectSourcePrivate(), m_widget(widget), context(0), updateDueToGraphicsEffect(false) + : QGraphicsEffectSourcePrivate(), m_widget(widget), context(nullptr), updateDueToGraphicsEffect(false) {} void detach() override - { m_widget->d_func()->graphicsEffect = 0; } + { m_widget->d_func()->graphicsEffect = nullptr; } const QGraphicsItem *graphicsItem() const override - { return 0; } + { return nullptr; } const QWidget *widget() const override { return m_widget; } @@ -953,7 +953,7 @@ public: } const QStyleOption *styleOption() const override - { return 0; } + { return nullptr; } QRect deviceRect() const override { return m_widget->window()->rect(); } @@ -983,14 +983,14 @@ inline QTLWExtra *QWidgetPrivate::topData() const inline QTLWExtra *QWidgetPrivate::maybeTopData() const { - return extra ? extra->topextra : 0; + return extra ? extra->topextra : nullptr; } inline QPainter *QWidgetPrivate::sharedPainter() const { Q_Q(const QWidget); QTLWExtra *x = q->window()->d_func()->maybeTopData(); - return x ? x->sharedPainter : 0; + return x ? x->sharedPainter : nullptr; } inline void QWidgetPrivate::setSharedPainter(QPainter *painter) @@ -1011,7 +1011,7 @@ inline QWidgetBackingStore *QWidgetPrivate::maybeBackingStore() const { Q_Q(const QWidget); QTLWExtra *x = q->window()->d_func()->maybeTopData(); - return x ? x->backingStoreTracker.data() : 0; + return x ? x->backingStoreTracker.data() : nullptr; } inline QWidgetWindow *QWidgetPrivate::windowHandle() const diff --git a/src/widgets/kernel/qwidgetbackingstore.cpp b/src/widgets/kernel/qwidgetbackingstore.cpp index 0481dffda8..595beeaf47 100644 --- a/src/widgets/kernel/qwidgetbackingstore.cpp +++ b/src/widgets/kernel/qwidgetbackingstore.cpp @@ -310,12 +310,6 @@ bool QWidgetBackingStore::bltRect(const QRect &rect, int dx, int dy, QWidget *wi return store->scroll(tlwRect, dx, dy); } -void QWidgetBackingStore::releaseBuffer() -{ - if (store) - store->resize(QSize()); -} - /*! Prepares the window surface to paint a\ toClean region of the \a widget and updates the BeginPaintInfo struct accordingly. diff --git a/src/widgets/kernel/qwidgetbackingstore_p.h b/src/widgets/kernel/qwidgetbackingstore_p.h index 4d15ab138e..9409ba7832 100644 --- a/src/widgets/kernel/qwidgetbackingstore_p.h +++ b/src/widgets/kernel/qwidgetbackingstore_p.h @@ -109,7 +109,7 @@ public: void sync(QWidget *exposedWidget, const QRegion &exposedRegion); void sync(); - void flush(QWidget *widget = 0); + void flush(QWidget *widget = nullptr); QBackingStore *backingStore() const { return store; } @@ -149,14 +149,13 @@ private: void doSync(); bool bltRect(const QRect &rect, int dx, int dy, QWidget *widget); - void releaseBuffer(); void beginPaint(QRegion &toClean, QWidget *widget, QBackingStore *backingStore, BeginPaintInfo *returnInfo, bool toCleanIsInTopLevelCoordinates = true); void endPaint(const QRegion &cleaned, QBackingStore *backingStore, BeginPaintInfo *beginPaintInfo); - QRegion dirtyRegion(QWidget *widget = 0) const; - QRegion staticContents(QWidget *widget = 0, const QRect &withinClipRect = QRect()) const; + QRegion dirtyRegion(QWidget *widget = nullptr) const; + QRegion staticContents(QWidget *widget = nullptr, const QRect &withinClipRect = QRect()) const; void markDirtyOnScreen(const QRegion &dirtyOnScreen, QWidget *widget, const QPoint &topLevelOffset); diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp index fbc71cd0ea..5bcf885dfe 100644 --- a/src/widgets/kernel/qwidgetwindow.cpp +++ b/src/widgets/kernel/qwidgetwindow.cpp @@ -106,6 +106,7 @@ public: if (QWidget *widget = q->widget()) QWidgetPrivate::get(widget)->updateContentsRect(); } + bool allowClickThrough(const QPoint &) const override; }; QRectF QWidgetWindowPrivate::closestAcceptableGeometry(const QRectF &rect) const @@ -221,6 +222,12 @@ static inline bool shouldBePropagatedToWidget(QEvent *event) } } +bool QWidgetWindowPrivate::allowClickThrough(const QPoint &globalPos) const +{ + QWidget *w = QApplication::widgetAt(globalPos); + return w && !w->testAttribute(Qt::WA_MacNoClickThrough); +} + bool QWidgetWindow::event(QEvent *event) { if (!m_widget) @@ -1018,7 +1025,11 @@ void QWidgetWindow::handleWindowStateChangedEvent(QWindowStateChangeEvent *event } } +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +bool QWidgetWindow::nativeEvent(const QByteArray &eventType, void *message, qintptr *result) +#else bool QWidgetWindow::nativeEvent(const QByteArray &eventType, void *message, long *result) +#endif { return m_widget->nativeEvent(eventType, message, result); } diff --git a/src/widgets/kernel/qwidgetwindow_p.h b/src/widgets/kernel/qwidgetwindow_p.h index 0728135467..80a345465d 100644 --- a/src/widgets/kernel/qwidgetwindow_p.h +++ b/src/widgets/kernel/qwidgetwindow_p.h @@ -103,7 +103,11 @@ protected: #endif void handleExposeEvent(QExposeEvent *); void handleWindowStateChangedEvent(QWindowStateChangeEvent *event); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + bool nativeEvent(const QByteArray &eventType, void *message, qintptr *result) override; +#else bool nativeEvent(const QByteArray &eventType, void *message, long *result) override; +#endif #if QT_CONFIG(tabletevent) void handleTabletEvent(QTabletEvent *); #endif diff --git a/src/widgets/kernel/qwindowcontainer_p.h b/src/widgets/kernel/qwindowcontainer_p.h index a8754232a8..c6de168c10 100644 --- a/src/widgets/kernel/qwindowcontainer_p.h +++ b/src/widgets/kernel/qwindowcontainer_p.h @@ -64,7 +64,7 @@ class Q_WIDGETS_EXPORT QWindowContainer : public QWidget Q_DECLARE_PRIVATE(QWindowContainer) public: - explicit QWindowContainer(QWindow *embeddedWindow, QWidget *parent = 0, Qt::WindowFlags f = 0); + explicit QWindowContainer(QWindow *embeddedWindow, QWidget *parent = nullptr, Qt::WindowFlags f = nullptr); ~QWindowContainer(); QWindow *containedWindow() const; diff --git a/src/widgets/statemachine/qbasickeyeventtransition_p.h b/src/widgets/statemachine/qbasickeyeventtransition_p.h index 7e1b978bba..f23c078570 100644 --- a/src/widgets/statemachine/qbasickeyeventtransition_p.h +++ b/src/widgets/statemachine/qbasickeyeventtransition_p.h @@ -63,11 +63,11 @@ class Q_AUTOTEST_EXPORT QBasicKeyEventTransition : public QAbstractTransition { Q_OBJECT public: - QBasicKeyEventTransition(QState *sourceState = 0); - QBasicKeyEventTransition(QEvent::Type type, int key, QState *sourceState = 0); + QBasicKeyEventTransition(QState *sourceState = nullptr); + QBasicKeyEventTransition(QEvent::Type type, int key, QState *sourceState = nullptr); QBasicKeyEventTransition(QEvent::Type type, int key, Qt::KeyboardModifiers modifierMask, - QState *sourceState = 0); + QState *sourceState = nullptr); ~QBasicKeyEventTransition(); QEvent::Type eventType() const; diff --git a/src/widgets/statemachine/qbasicmouseeventtransition_p.h b/src/widgets/statemachine/qbasicmouseeventtransition_p.h index 132e223535..dd619d189c 100644 --- a/src/widgets/statemachine/qbasicmouseeventtransition_p.h +++ b/src/widgets/statemachine/qbasicmouseeventtransition_p.h @@ -65,9 +65,9 @@ class Q_AUTOTEST_EXPORT QBasicMouseEventTransition : public QAbstractTransition { Q_OBJECT public: - QBasicMouseEventTransition(QState *sourceState = 0); + QBasicMouseEventTransition(QState *sourceState = nullptr); QBasicMouseEventTransition(QEvent::Type type, Qt::MouseButton button, - QState *sourceState = 0); + QState *sourceState = nullptr); ~QBasicMouseEventTransition(); QEvent::Type eventType() const; diff --git a/src/widgets/styles/qcommonstyle_p.h b/src/widgets/styles/qcommonstyle_p.h index 296f89ce5f..4860dfe4c9 100644 --- a/src/widgets/styles/qcommonstyle_p.h +++ b/src/widgets/styles/qcommonstyle_p.h @@ -71,7 +71,7 @@ class Q_WIDGETS_EXPORT QCommonStylePrivate : public QStylePrivate public: inline QCommonStylePrivate() : #if QT_CONFIG(itemviews) - cachedOption(0), + cachedOption(nullptr), #endif animationFps(30) { } diff --git a/src/widgets/styles/qfusionstyle_p.h b/src/widgets/styles/qfusionstyle_p.h index e67e792727..cbefe3e1af 100644 --- a/src/widgets/styles/qfusionstyle_p.h +++ b/src/widgets/styles/qfusionstyle_p.h @@ -72,28 +72,28 @@ public: QPalette standardPalette () const override; void drawPrimitive(PrimitiveElement elem, const QStyleOption *option, - QPainter *painter, const QWidget *widget = 0) const override; + QPainter *painter, const QWidget *widget = nullptr) const override; void drawControl(ControlElement ce, const QStyleOption *option, QPainter *painter, const QWidget *widget) const override; - int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, const QWidget *widget = 0) const override; + int pixelMetric(PixelMetric metric, const QStyleOption *option = nullptr, const QWidget *widget = nullptr) const override; void drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget) const override; - QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget = 0) const override; + QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget = nullptr) const override; QSize sizeFromContents(ContentsType type, const QStyleOption *option, const QSize &size, const QWidget *widget) const override; SubControl hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, - const QPoint &pt, const QWidget *w = 0) const override; + const QPoint &pt, const QWidget *w = nullptr) const override; QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget) const override; QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt) const override; - int styleHint(StyleHint hint, const QStyleOption *option = 0, const QWidget *widget = 0, - QStyleHintReturn *returnData = 0) const override; + int styleHint(StyleHint hint, const QStyleOption *option = nullptr, const QWidget *widget = nullptr, + QStyleHintReturn *returnData = nullptr) const override; QRect itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap) const override; - QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option = 0, - const QWidget *widget = 0) const override; + QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option = nullptr, + const QWidget *widget = nullptr) const override; QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, - const QWidget *widget = 0) const override; + const QWidget *widget = nullptr) const override; void drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, const QPixmap &pixmap) const override; void drawItemText(QPainter *painter, const QRect &rect, diff --git a/src/widgets/styles/qpixmapstyle_p.h b/src/widgets/styles/qpixmapstyle_p.h index 590434d95e..d32631a527 100644 --- a/src/widgets/styles/qpixmapstyle_p.h +++ b/src/widgets/styles/qpixmapstyle_p.h @@ -147,7 +147,7 @@ public: void drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = nullptr) const override; void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *option, - QPainter *painter, const QWidget *widget=0) const override; + QPainter *painter, const QWidget *widget=nullptr) const override; QSize sizeFromContents(ContentsType type, const QStyleOption *option, const QSize &contentsSize, const QWidget *widget = nullptr) const override; diff --git a/src/widgets/styles/qproxystyle_p.h b/src/widgets/styles/qproxystyle_p.h index 2343a03e2a..2321f0fed0 100644 --- a/src/widgets/styles/qproxystyle_p.h +++ b/src/widgets/styles/qproxystyle_p.h @@ -67,7 +67,7 @@ public: void ensureBaseStyle() const; private: QProxyStylePrivate() : - QCommonStylePrivate(), baseStyle(0) {} + QCommonStylePrivate(), baseStyle(nullptr) {} mutable QPointer <QStyle> baseStyle; }; diff --git a/src/widgets/styles/qstyle.h b/src/widgets/styles/qstyle.h index 5ee37bd8e9..ee234457f5 100644 --- a/src/widgets/styles/qstyle.h +++ b/src/widgets/styles/qstyle.h @@ -832,6 +832,13 @@ public: SP_MediaVolume, SP_MediaVolumeMuted, SP_LineEditClearButton, + SP_DialogYesToAllButton, + SP_DialogNoToAllButton, + SP_DialogSaveAllButton, + SP_DialogAbortButton, + SP_DialogRetryButton, + SP_DialogIgnoreButton, + SP_RestoreDefaultsButton, // do not add any values below/greater than this SP_CustomBase = 0xf0000000 }; diff --git a/src/widgets/styles/qstyle_p.h b/src/widgets/styles/qstyle_p.h index 5bbde5fe17..7942cafaf7 100644 --- a/src/widgets/styles/qstyle_p.h +++ b/src/widgets/styles/qstyle_p.h @@ -66,7 +66,7 @@ class QStylePrivate: public QObjectPrivate Q_DECLARE_PUBLIC(QStyle) public: inline QStylePrivate() - : layoutSpacingIndex(-1), proxyStyle(0) {} + : layoutSpacingIndex(-1), proxyStyle(nullptr) {} static bool useFullScreenForPopup(); diff --git a/src/widgets/styles/qstylehelper_p.h b/src/widgets/styles/qstylehelper_p.h index d79dfe4288..fe052b8984 100644 --- a/src/widgets/styles/qstylehelper_p.h +++ b/src/widgets/styles/qstylehelper_p.h @@ -89,11 +89,11 @@ namespace QStyleHelper Q_WIDGETS_EXPORT bool isInstanceOf(QObject *obj, QAccessible::Role role); Q_WIDGETS_EXPORT bool hasAncestor(QObject *obj, QAccessible::Role role); #endif - Q_WIDGETS_EXPORT QColor backgroundColor(const QPalette &pal, const QWidget* widget = 0); + Q_WIDGETS_EXPORT QColor backgroundColor(const QPalette &pal, const QWidget* widget = nullptr); enum WidgetSizePolicy { SizeLarge = 0, SizeSmall = 1, SizeMini = 2, SizeDefault = -1 }; - Q_WIDGETS_EXPORT WidgetSizePolicy widgetSizePolicy(const QWidget *w, const QStyleOption *opt = 0); + Q_WIDGETS_EXPORT WidgetSizePolicy widgetSizePolicy(const QWidget *w, const QStyleOption *opt = nullptr); } diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index fc4efa18fb..9c744000bd 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -851,7 +851,7 @@ QHash<QStyle::SubControl, QRect> QStyleSheetStyle::titleBarLayout(const QWidget info.rule = subRule; info.offset = offsets[where]; info.where = where; - infos.append(qMove(info)); + infos.append(std::move(info)); offsets[where] += info.width; } @@ -4093,6 +4093,11 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q if (subRule.hasFont) p->setFont(subRule.font); boxCopy.rect = subRule.contentsRect(opt->rect); + if (subRule.hasImage()) { + // the image is already drawn with CE_ToolBoxTabShape, adjust rect here + const int iconExtent = proxy()->pixelMetric(QStyle::PM_SmallIconSize, box, w); + boxCopy.rect.setLeft(boxCopy.rect.left() + iconExtent); + } QWindowsStyle::drawControl(ce, &boxCopy, p , w); if (subRule.hasFont) p->setFont(oldFont); diff --git a/src/widgets/styles/qstylesheetstyle_p.h b/src/widgets/styles/qstylesheetstyle_p.h index 9c4b87fc32..c5266558af 100644 --- a/src/widgets/styles/qstylesheetstyle_p.h +++ b/src/widgets/styles/qstylesheetstyle_p.h @@ -82,40 +82,40 @@ public: ~QStyleSheetStyle(); void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p, - const QWidget *w = 0) const override; + const QWidget *w = nullptr) const override; void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, - const QWidget *w = 0) const override; + const QWidget *w = nullptr) const override; void drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, const QPixmap &pixmap) const override; void drawItemText(QPainter *painter, const QRect& rect, int alignment, const QPalette &pal, bool enabled, const QString& text, QPalette::ColorRole textRole = QPalette::NoRole) const override; void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, - const QWidget *w = 0) const override; + const QWidget *w = nullptr) const override; QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *option) const override; SubControl hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, - const QPoint &pt, const QWidget *w = 0) const override; + const QPoint &pt, const QWidget *w = nullptr) const override; QRect itemPixmapRect(const QRect &rect, int alignment, const QPixmap &pixmap) const override; QRect itemTextRect(const QFontMetrics &metrics, const QRect &rect, int alignment, bool enabled, const QString &text) const override; - int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, const QWidget *widget = 0) const override; + int pixelMetric(PixelMetric metric, const QStyleOption *option = nullptr, const QWidget *widget = nullptr) const override; void polish(QWidget *widget) override; void polish(QApplication *app) override; void polish(QPalette &pal) override; QSize sizeFromContents(ContentsType ct, const QStyleOption *opt, - const QSize &contentsSize, const QWidget *widget = 0) const override; + const QSize &contentsSize, const QWidget *widget = nullptr) const override; QPalette standardPalette() const override; - QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *opt = 0, - const QWidget *widget = 0) const override; - QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *option = 0, - const QWidget *w = 0 ) const override; + QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *opt = nullptr, + const QWidget *widget = nullptr) const override; + QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *option = nullptr, + const QWidget *w = nullptr ) const override; int layoutSpacing(QSizePolicy::ControlType control1, QSizePolicy::ControlType control2, - Qt::Orientation orientation, const QStyleOption *option = 0, - const QWidget *widget = 0) const override; - int styleHint(StyleHint sh, const QStyleOption *opt = 0, const QWidget *w = 0, - QStyleHintReturn *shret = 0) const override; - QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget = 0) const override; + Qt::Orientation orientation, const QStyleOption *option = nullptr, + const QWidget *widget = nullptr) const override; + int styleHint(StyleHint sh, const QStyleOption *opt = nullptr, const QWidget *w = nullptr, + QStyleHintReturn *shret = nullptr) const override; + QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget = nullptr) const override; QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, - const QWidget *w = 0) const override; + const QWidget *w = nullptr) const override; // These functions are called from QApplication/QWidget. Be careful. QStyle *baseStyle() const; diff --git a/src/widgets/styles/qwindowsstyle.cpp b/src/widgets/styles/qwindowsstyle.cpp index 4e450813cb..7b5da9bfa8 100644 --- a/src/widgets/styles/qwindowsstyle.cpp +++ b/src/widgets/styles/qwindowsstyle.cpp @@ -802,8 +802,10 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPen oldPen = p->pen(); p->setPen(QPen(opt->palette.shadow().color(), 0)); QRectF rect = opt->rect; - rect.adjust(QStyleHelper::dpiScaled(0.5), QStyleHelper::dpiScaled(0.5), - QStyleHelper::dpiScaled(-1.5), QStyleHelper::dpiScaled(-1.5)); + const qreal topLevelAdjustment = QStyleHelper::dpiScaled(0.5); + const qreal bottomRightAdjustment = QStyleHelper::dpiScaled(-1.5); + rect.adjust(topLevelAdjustment, topLevelAdjustment, + bottomRightAdjustment, bottomRightAdjustment); p->drawRect(rect); p->setPen(oldPen); break; diff --git a/src/widgets/styles/qwindowsstyle_p.h b/src/widgets/styles/qwindowsstyle_p.h index 47816ff651..b5f0bd68a1 100644 --- a/src/widgets/styles/qwindowsstyle_p.h +++ b/src/widgets/styles/qwindowsstyle_p.h @@ -77,25 +77,25 @@ public: void polish(QPalette &) override; void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, - const QWidget *w = 0) const override; + const QWidget *w = nullptr) const override; void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, - const QWidget *w = 0) const override; - QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget = 0) const override; + const QWidget *w = nullptr) const override; + QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget = nullptr) const override; void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p, - const QWidget *w = 0) const override; + const QWidget *w = nullptr) const override; QSize sizeFromContents(ContentsType ct, const QStyleOption *opt, - const QSize &contentsSize, const QWidget *widget = 0) const override; + const QSize &contentsSize, const QWidget *widget = nullptr) const override; - int pixelMetric(PixelMetric pm, const QStyleOption *option = 0, const QWidget *widget = 0) const override; + int pixelMetric(PixelMetric pm, const QStyleOption *option = nullptr, const QWidget *widget = nullptr) const override; - int styleHint(StyleHint hint, const QStyleOption *opt = 0, const QWidget *widget = 0, - QStyleHintReturn *returnData = 0) const override; + int styleHint(StyleHint hint, const QStyleOption *opt = nullptr, const QWidget *widget = nullptr, + QStyleHintReturn *returnData = nullptr) const override; QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, - const QWidget *widget = 0) const override; + const QWidget *widget = nullptr) const override; - QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option = 0, - const QWidget *widget = 0) const override; + QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option = nullptr, + const QWidget *widget = nullptr) const override; protected: bool eventFilter(QObject *o, QEvent *e) override; diff --git a/src/widgets/styles/qwindowsstyle_p_p.h b/src/widgets/styles/qwindowsstyle_p_p.h index 67fa6a2f86..e6ea809f11 100644 --- a/src/widgets/styles/qwindowsstyle_p_p.h +++ b/src/widgets/styles/qwindowsstyle_p_p.h @@ -69,9 +69,9 @@ public: enum { InvalidMetric = -23576 }; QWindowsStylePrivate(); - static int pixelMetricFromSystemDp(QStyle::PixelMetric pm, const QStyleOption *option = 0, const QWidget *widget = 0); + static int pixelMetricFromSystemDp(QStyle::PixelMetric pm, const QStyleOption *option = nullptr, const QWidget *widget = nullptr); static int fixedPixelMetric(QStyle::PixelMetric pm); - static qreal devicePixelRatio(const QWidget *widget = 0) + static qreal devicePixelRatio(const QWidget *widget = nullptr) { return widget ? widget->devicePixelRatioF() : QWindowsStylePrivate::appDevicePixelRatio(); } static qreal nativeMetricScaleFactor(const QWidget *widget = nullptr); diff --git a/src/widgets/util/qcompleter_p.h b/src/widgets/util/qcompleter_p.h index 21dddf446e..a52e63a6e2 100644 --- a/src/widgets/util/qcompleter_p.h +++ b/src/widgets/util/qcompleter_p.h @@ -75,7 +75,7 @@ class QCompleterPrivate : public QObjectPrivate public: QCompleterPrivate(); ~QCompleterPrivate() { delete popup; } - void init(QAbstractItemModel *model = 0); + void init(QAbstractItemModel *model = nullptr); QPointer<QWidget> widget; QCompletionModel *proxy; diff --git a/src/widgets/util/qflickgesture_p.h b/src/widgets/util/qflickgesture_p.h index d5ace887ae..0b47516047 100644 --- a/src/widgets/util/qflickgesture_p.h +++ b/src/widgets/util/qflickgesture_p.h @@ -71,7 +71,7 @@ class Q_WIDGETS_EXPORT QFlickGesture : public QGesture Q_DECLARE_PRIVATE(QFlickGesture) public: - QFlickGesture(QObject *receiver, Qt::MouseButton button, QObject *parent = 0); + QFlickGesture(QObject *receiver, Qt::MouseButton button, QObject *parent = nullptr); ~QFlickGesture(); friend class QFlickGestureRecognizer; diff --git a/src/widgets/util/qundostack_p.h b/src/widgets/util/qundostack_p.h index 04bc381114..05c9e0d27e 100644 --- a/src/widgets/util/qundostack_p.h +++ b/src/widgets/util/qundostack_p.h @@ -80,7 +80,7 @@ class QUndoStackPrivate : public QObjectPrivate { Q_DECLARE_PUBLIC(QUndoStack) public: - QUndoStackPrivate() : index(0), clean_index(0), group(0), undo_limit(0) {} + QUndoStackPrivate() : index(0), clean_index(0), group(nullptr), undo_limit(0) {} QList<QUndoCommand*> command_list; QList<QUndoCommand*> macro_stack; @@ -98,7 +98,7 @@ class QUndoAction : public QAction { Q_OBJECT public: - explicit QUndoAction(const QString &prefix, QObject *parent = 0); + explicit QUndoAction(const QString &prefix, QObject *parent = nullptr); void setTextFormat(const QString &textFormat, const QString &defaultText); public Q_SLOTS: void setPrefixedText(const QString &text); diff --git a/src/widgets/widgets.pro b/src/widgets/widgets.pro index e556cb8b10..6f807e1696 100644 --- a/src/widgets/widgets.pro +++ b/src/widgets/widgets.pro @@ -32,8 +32,6 @@ qtConfig(graphicseffect) { QMAKE_LIBS += $$QMAKE_LIBS_GUI -contains(DEFINES,QT_EVAL):include($$QT_SOURCE_TREE/src/corelib/eval.pri) - QMAKE_DYNAMIC_LIST_FILE = $$PWD/QtWidgets.dynlist # Code coverage with TestCocoon diff --git a/src/widgets/widgets/qabstractslider_p.h b/src/widgets/widgets/qabstractslider_p.h index 419ce2ba07..1b8c76c7ec 100644 --- a/src/widgets/widgets/qabstractslider_p.h +++ b/src/widgets/widgets/qabstractslider_p.h @@ -134,7 +134,7 @@ public: inline void setAdjustedSliderPosition(int position) { Q_Q(QAbstractSlider); - if (q->style()->styleHint(QStyle::SH_Slider_StopMouseOverSlider, 0, q)) { + if (q->style()->styleHint(QStyle::SH_Slider_StopMouseOverSlider, nullptr, q)) { if ((position > pressValue - 2 * pageStep) && (position < pressValue + 2 * pageStep)) { repeatAction = QAbstractSlider::SliderNoAction; q->setSliderPosition(pressValue); diff --git a/src/widgets/widgets/qabstractspinbox.cpp b/src/widgets/widgets/qabstractspinbox.cpp index 6edefaa311..c617525c45 100644 --- a/src/widgets/widgets/qabstractspinbox.cpp +++ b/src/widgets/widgets/qabstractspinbox.cpp @@ -252,7 +252,7 @@ QString QAbstractSpinBox::text() const All values are displayed with the prefix and suffix (if set), \e except for the special value, which only shows the special value - text. This special text is passed in the QSpinBox::valueChanged() + text. This special text is passed in the QSpinBox::textChanged() signal that passes a QString. To turn off the special-value text display, call this function @@ -342,18 +342,18 @@ void QAbstractSpinBox::setReadOnly(bool enable) \since 4.3 If keyboard tracking is enabled (the default), the spinbox - emits the valueChanged() signal while the new value is being - entered from the keyboard. + emits the valueChanged() and textChanged() signals while the + new value is being entered from the keyboard. E.g. when the user enters the value 600 by typing 6, 0, and 0, the spinbox emits 3 signals with the values 6, 60, and 600 respectively. If keyboard tracking is disabled, the spinbox doesn't emit the - valueChanged() signal while typing. It emits the signal later, - when the return key is pressed, when keyboard focus is lost, or - when other spinbox functionality is used, e.g. pressing an arrow - key. + valueChanged() and textChanged() signals while typing. It emits + the signals later, when the return key is pressed, when keyboard + focus is lost, or when other spinbox functionality is used, e.g. + pressing an arrow key. */ bool QAbstractSpinBox::keyboardTracking() const @@ -2030,8 +2030,8 @@ QVariant operator+(const QVariant &arg1, const QVariant &arg2) #if QT_CONFIG(datetimeparser) case QVariant::DateTime: { QDateTime a2 = arg2.toDateTime(); - QDateTime a1 = arg1.toDateTime().addDays(QDATETIMEEDIT_DATETIME_MIN.daysTo(a2)); - a1.setTime(a1.time().addMSecs(QTime().msecsTo(a2.time()))); + QDateTime a1 = arg1.toDateTime().addDays(QDATETIMEEDIT_DATE_MIN.daysTo(a2.date())); + a1.setTime(a1.time().addMSecs(a2.time().msecsSinceStartOfDay())); ret = QVariant(a1); break; } @@ -2093,11 +2093,11 @@ QVariant operator*(const QVariant &arg1, double multiplier) #if QT_CONFIG(datetimeparser) case QVariant::DateTime: { double days = QDATETIMEEDIT_DATE_MIN.daysTo(arg1.toDateTime().date()) * multiplier; - int daysInt = (int)days; + const qint64 daysInt = qint64(days); days -= daysInt; - long msecs = (long)((QDATETIMEEDIT_TIME_MIN.msecsTo(arg1.toDateTime().time()) * multiplier) - + (days * (24 * 3600 * 1000))); - ret = QDateTime(QDate().addDays(int(days)), QTime().addMSecs(msecs)); + qint64 msecs = qint64(arg1.toDateTime().time().msecsSinceStartOfDay() * multiplier + + days * (24 * 3600 * 1000)); + ret = QDateTime(QDATETIMEEDIT_DATE_MIN.addDays(daysInt), QTime::fromMSecsSinceStartOfDay(msecs)); break; } #endif // datetimeparser @@ -2127,8 +2127,8 @@ double operator/(const QVariant &arg1, const QVariant &arg2) case QVariant::DateTime: a1 = QDATETIMEEDIT_DATE_MIN.daysTo(arg1.toDate()); a2 = QDATETIMEEDIT_DATE_MIN.daysTo(arg2.toDate()); - a1 += (double)QDATETIMEEDIT_TIME_MIN.msecsTo(arg1.toDateTime().time()) / (long)(3600 * 24 * 1000); - a2 += (double)QDATETIMEEDIT_TIME_MIN.msecsTo(arg2.toDateTime().time()) / (long)(3600 * 24 * 1000); + a1 += arg1.toDateTime().time().msecsSinceStartOfDay() / (36e5 * 24); + a2 += arg2.toDateTime().time().msecsSinceStartOfDay() / (36e5 * 24); break; #endif // datetimeparser default: break; diff --git a/src/widgets/widgets/qabstractspinbox_p.h b/src/widgets/widgets/qabstractspinbox_p.h index fce88e43f4..ad169fde19 100644 --- a/src/widgets/widgets/qabstractspinbox_p.h +++ b/src/widgets/widgets/qabstractspinbox_p.h @@ -97,7 +97,7 @@ public: void init(); void reset(); void updateState(bool up, bool fromKeyboard = false); - QString stripped(const QString &text, int *pos = 0) const; + QString stripped(const QString &text, int *pos = nullptr) const; bool specialValue() const; virtual QVariant getZeroVariant() const; virtual void setRange(const QVariant &min, const QVariant &max); diff --git a/src/widgets/widgets/qcalendarwidget.cpp b/src/widgets/widgets/qcalendarwidget.cpp index 47c5267c73..510b34cb18 100644 --- a/src/widgets/widgets/qcalendarwidget.cpp +++ b/src/widgets/widgets/qcalendarwidget.cpp @@ -827,9 +827,9 @@ class StaticDayOfWeekAssociativeArray { bool contained[7]; T data[7]; - static Q_DECL_CONSTEXPR int day2idx(Qt::DayOfWeek day) Q_DECL_NOTHROW { return int(day) - 1; } // alt: day % 7 + static Q_DECL_CONSTEXPR int day2idx(Qt::DayOfWeek day) noexcept { return int(day) - 1; } // alt: day % 7 public: - Q_DECL_CONSTEXPR StaticDayOfWeekAssociativeArray() Q_DECL_NOEXCEPT_EXPR(noexcept(T())) + Q_DECL_CONSTEXPR StaticDayOfWeekAssociativeArray() noexcept(noexcept(T())) #ifdef Q_COMPILER_CONSTEXPR : contained{}, data{} // arrays require uniform initialization #else @@ -837,17 +837,17 @@ public: #endif {} - Q_DECL_CONSTEXPR bool contains(Qt::DayOfWeek day) const Q_DECL_NOTHROW { return contained[day2idx(day)]; } - Q_DECL_CONSTEXPR const T &value(Qt::DayOfWeek day) const Q_DECL_NOTHROW { return data[day2idx(day)]; } + Q_DECL_CONSTEXPR bool contains(Qt::DayOfWeek day) const noexcept { return contained[day2idx(day)]; } + Q_DECL_CONSTEXPR const T &value(Qt::DayOfWeek day) const noexcept { return data[day2idx(day)]; } - Q_DECL_RELAXED_CONSTEXPR T &operator[](Qt::DayOfWeek day) Q_DECL_NOTHROW + Q_DECL_RELAXED_CONSTEXPR T &operator[](Qt::DayOfWeek day) noexcept { const int idx = day2idx(day); contained[idx] = true; return data[idx]; } - Q_DECL_RELAXED_CONSTEXPR void insert(Qt::DayOfWeek day, T v) Q_DECL_NOTHROW + Q_DECL_RELAXED_CONSTEXPR void insert(Qt::DayOfWeek day, T v) noexcept { operator[](day).swap(v); } diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index 9a403e8eef..17090efb56 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -1360,7 +1360,13 @@ void QComboBoxPrivate::emitActivated(const QModelIndex &index) return; QString text(itemText(index)); emit q->activated(index.row()); + emit q->textActivated(text); +#if QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED emit q->activated(text); +QT_WARNING_POP +#endif } void QComboBoxPrivate::_q_emitHighlighted(const QModelIndex &index) @@ -1370,7 +1376,13 @@ void QComboBoxPrivate::_q_emitHighlighted(const QModelIndex &index) return; QString text(itemText(index)); emit q->highlighted(index.row()); + emit q->textHighlighted(text); +#if QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED emit q->highlighted(text); +QT_WARNING_POP +#endif } void QComboBoxPrivate::_q_emitCurrentIndexChanged(const QModelIndex &index) diff --git a/src/widgets/widgets/qcombobox.h b/src/widgets/widgets/qcombobox.h index 64fbebb3c5..6a87a675a4 100644 --- a/src/widgets/widgets/qcombobox.h +++ b/src/widgets/widgets/qcombobox.h @@ -220,15 +220,21 @@ public Q_SLOTS: Q_SIGNALS: void editTextChanged(const QString &); void activated(int index); - void activated(const QString &); + void textActivated(const QString &); void highlighted(int index); - void highlighted(const QString &); + void textHighlighted(const QString &); void currentIndexChanged(int index); + void currentTextChanged(const QString &); #if QT_DEPRECATED_SINCE(5, 13) QT_DEPRECATED_X("Use currentTextChanged() instead") void currentIndexChanged(const QString &); #endif - void currentTextChanged(const QString &); +#if QT_DEPRECATED_SINCE(5, 15) + QT_DEPRECATED_X("Use textActivated() instead") + void activated(const QString &); + QT_DEPRECATED_X("Use textHighlighted() instead") + void highlighted(const QString &); +#endif protected: void focusInEvent(QFocusEvent *e) override; diff --git a/src/widgets/widgets/qcombobox_p.h b/src/widgets/widgets/qcombobox_p.h index 71404964da..eadb21628f 100644 --- a/src/widgets/widgets/qcombobox_p.h +++ b/src/widgets/widgets/qcombobox_p.h @@ -86,7 +86,7 @@ class QComboBoxListView : public QListView { Q_OBJECT public: - QComboBoxListView(QComboBox *cmb = 0) : combo(cmb) {} + QComboBoxListView(QComboBox *cmb = nullptr) : combo(cmb) {} protected: void resizeEvent(QResizeEvent *event) override @@ -331,7 +331,7 @@ protected: QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override { if (isSeparator(index)) { - int pm = mCombo->style()->pixelMetric(QStyle::PM_DefaultFrameWidth, 0, mCombo); + int pm = mCombo->style()->pixelMetric(QStyle::PM_DefaultFrameWidth, nullptr, mCombo); return QSize(pm, pm); } return QItemDelegate::sizeHint(option, index); diff --git a/src/widgets/widgets/qdatetimeedit_p.h b/src/widgets/widgets/qdatetimeedit_p.h index 1ebc98dedf..c05e7d9b48 100644 --- a/src/widgets/widgets/qdatetimeedit_p.h +++ b/src/widgets/widgets/qdatetimeedit_p.h @@ -123,7 +123,7 @@ public: static QDateTimeEdit::Sections convertSections(QDateTimeParser::Sections s); static QDateTimeEdit::Section convertToPublic(QDateTimeParser::Section s); - void initCalendarPopup(QCalendarWidget *cw = 0); + void initCalendarPopup(QCalendarWidget *cw = nullptr); void positionCalendarPopup(); QDateTimeEdit::Sections sections; @@ -145,7 +145,7 @@ class QCalendarPopup : public QWidget { Q_OBJECT public: - explicit QCalendarPopup(QWidget *parent = 0, QCalendarWidget *cw = 0); + explicit QCalendarPopup(QWidget *parent = nullptr, QCalendarWidget *cw = nullptr); QDate selectedDate() { return verifyCalendarInstance()->selectedDate(); } void setDate(const QDate &date); void setDateRange(const QDate &min, const QDate &max); diff --git a/src/widgets/widgets/qdialogbuttonbox.cpp b/src/widgets/widgets/qdialogbuttonbox.cpp index 26b86f80be..28f6cdc7bd 100644 --- a/src/widgets/widgets/qdialogbuttonbox.cpp +++ b/src/widgets/widgets/qdialogbuttonbox.cpp @@ -387,12 +387,25 @@ QPushButton *QDialogButtonBoxPrivate::createButton(QDialogButtonBox::StandardBut icon = QStyle::SP_DialogNoButton; break; case QDialogButtonBox::YesToAll: + icon = QStyle::SP_DialogYesToAllButton; + break; case QDialogButtonBox::NoToAll: + icon = QStyle::SP_DialogNoToAllButton; + break; case QDialogButtonBox::SaveAll: + icon = QStyle::SP_DialogSaveAllButton; + break; case QDialogButtonBox::Abort: + icon = QStyle::SP_DialogAbortButton; + break; case QDialogButtonBox::Retry: + icon = QStyle::SP_DialogRetryButton; + break; case QDialogButtonBox::Ignore: + icon = QStyle::SP_DialogIgnoreButton; + break; case QDialogButtonBox::RestoreDefaults: + icon = QStyle::SP_RestoreDefaultsButton; break; case QDialogButtonBox::NoButton: return 0; diff --git a/src/widgets/widgets/qdockarealayout_p.h b/src/widgets/widgets/qdockarealayout_p.h index 49bd157179..ab9c0c476c 100644 --- a/src/widgets/widgets/qdockarealayout_p.h +++ b/src/widgets/widgets/qdockarealayout_p.h @@ -89,7 +89,7 @@ struct QDockAreaLayoutItem { enum ItemFlags { NoFlags = 0, GapItem = 1, KeepSize = 2 }; - explicit QDockAreaLayoutItem(QLayoutItem *_widgetItem = 0); + explicit QDockAreaLayoutItem(QLayoutItem *_widgetItem = nullptr); explicit QDockAreaLayoutItem(QDockAreaLayoutInfo *_subinfo); explicit QDockAreaLayoutItem(QPlaceHolderItem *_placeHolderItem); QDockAreaLayoutItem(const QDockAreaLayoutItem &other); diff --git a/src/widgets/widgets/qdockwidget_p.h b/src/widgets/widgets/qdockwidget_p.h index e224ba7143..bc6ac86c45 100644 --- a/src/widgets/widgets/qdockwidget_p.h +++ b/src/widgets/widgets/qdockwidget_p.h @@ -138,7 +138,7 @@ class Q_WIDGETS_EXPORT QDockWidgetLayout : public QLayout { Q_OBJECT public: - QDockWidgetLayout(QWidget *parent = 0); + QDockWidgetLayout(QWidget *parent = nullptr); ~QDockWidgetLayout(); void addItem(QLayoutItem *item) override; QLayoutItem *itemAt(int index) const override; @@ -196,15 +196,15 @@ inline QLayoutItem *QDockWidgetItem::dockWidgetChildItem() const { if (QDockWidgetLayout *layout = dockWidgetLayout()) return layout->itemForRole(QDockWidgetLayout::Content); - return 0; + return nullptr; } inline QDockWidgetLayout *QDockWidgetItem::dockWidgetLayout() const { QWidget *w = const_cast<QDockWidgetItem*>(this)->widget(); - if (w != 0) + if (w != nullptr) return qobject_cast<QDockWidgetLayout*>(w->layout()); - return 0; + return nullptr; } QT_END_NAMESPACE diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp index ad3d372bd3..02aa703289 100644 --- a/src/widgets/widgets/qlineedit.cpp +++ b/src/widgets/widgets/qlineedit.cpp @@ -315,7 +315,7 @@ QString QLineEdit::text() const void QLineEdit::setText(const QString& text) { Q_D(QLineEdit); - d->control->setText(text); + d->setText(text); } /*! @@ -1483,8 +1483,11 @@ bool QLineEdit::event(QEvent * e) } else if (e->type() == QEvent::LeaveEditFocus) { d->setCursorVisible(false); d->control->setCursorBlinkEnabled(false); - if (d->control->hasAcceptableInput() || d->control->fixup()) + if (d->edited && (d->control->hasAcceptableInput() + || d->control->fixup())) { emit editingFinished(); + d->edited = false; + } } } #endif @@ -1891,7 +1894,6 @@ void QLineEdit::focusInEvent(QFocusEvent *e) /*!\reimp */ - void QLineEdit::focusOutEvent(QFocusEvent *e) { Q_D(QLineEdit); @@ -1914,8 +1916,10 @@ void QLineEdit::focusOutEvent(QFocusEvent *e) #endif if (reason != Qt::PopupFocusReason || !(QApplication::activePopupWidget() && QApplication::activePopupWidget()->parentWidget() == this)) { - if (hasAcceptableInput() || d->control->fixup()) + if (d->edited && (hasAcceptableInput() || d->control->fixup())) { emit editingFinished(); + d->edited = false; + } } #ifdef QT_KEYPAD_NAVIGATION d->control->setCancelText(QString()); diff --git a/src/widgets/widgets/qlineedit_p.cpp b/src/widgets/widgets/qlineedit_p.cpp index 2a5a0c34dc..21e70db0ac 100644 --- a/src/widgets/widgets/qlineedit_p.cpp +++ b/src/widgets/widgets/qlineedit_p.cpp @@ -127,6 +127,7 @@ void QLineEditPrivate::_q_handleWindowActivate() void QLineEditPrivate::_q_textEdited(const QString &text) { Q_Q(QLineEdit); + edited = true; emit q->textEdited(text); #if QT_CONFIG(completer) if (control->completer() @@ -272,6 +273,12 @@ void QLineEditPrivate::setCursorVisible(bool visible) q->update(); } +void QLineEditPrivate::setText(const QString& text) +{ + edited = true; + control->setText(text); +} + void QLineEditPrivate::updatePasswordEchoEditing(bool editing) { Q_Q(QLineEdit); diff --git a/src/widgets/widgets/qlineedit_p.h b/src/widgets/widgets/qlineedit_p.h index 12a2f1ddfd..3f98aab901 100644 --- a/src/widgets/widgets/qlineedit_p.h +++ b/src/widgets/widgets/qlineedit_p.h @@ -85,7 +85,7 @@ class Q_AUTOTEST_EXPORT QLineEditIconButton : public QToolButton Q_OBJECT Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity) public: - explicit QLineEditIconButton(QWidget *parent = 0); + explicit QLineEditIconButton(QWidget *parent = nullptr); qreal opacity() const { return m_opacity; } void setOpacity(qreal value); @@ -134,7 +134,7 @@ public: }; struct SideWidgetEntry { - explicit SideWidgetEntry(QWidget *w = 0, QAction *a = 0, int _flags = 0) : widget(w), action(a), flags(_flags) {} + explicit SideWidgetEntry(QWidget *w = nullptr, QAction *a = nullptr, int _flags = 0) : widget(w), action(a), flags(_flags) {} QWidget *widget; QAction *action; @@ -151,7 +151,7 @@ public: QLineEditPrivate() : control(0), frame(1), contextMenuEnabled(1), cursorVisible(0), - dragEnabled(0), clickCausedFocus(0), hscroll(0), vscroll(0), + dragEnabled(0), clickCausedFocus(0), edited(0), hscroll(0), vscroll(0), alignment(Qt::AlignLeading | Qt::AlignVCenter), leftTextMargin(0), topTextMargin(0), rightTextMargin(0), bottomTextMargin(0), lastTextSize(0), mouseYThreshold(0) @@ -176,6 +176,7 @@ public: bool inSelection(int x) const; QRect cursorRect() const; void setCursorVisible(bool visible); + void setText(const QString& text); void updatePasswordEchoEditing(bool); @@ -202,6 +203,7 @@ public: uint cursorVisible : 1; uint dragEnabled : 1; uint clickCausedFocus : 1; + uint edited : 1; int hscroll; int vscroll; uint alignment; diff --git a/src/widgets/widgets/qmainwindowlayout_p.h b/src/widgets/widgets/qmainwindowlayout_p.h index a375d856bb..7cdb8ead2f 100644 --- a/src/widgets/widgets/qmainwindowlayout_p.h +++ b/src/widgets/widgets/qmainwindowlayout_p.h @@ -122,7 +122,7 @@ template <typename Layout> QCursor QMainWindowLayoutSeparatorHelper<Layout>::separatorCursor(const QList<int> &path) { const QDockAreaLayoutInfo *info = layout()->dockAreaLayoutInfo()->info(path); - Q_ASSERT(info != 0); + Q_ASSERT(info != nullptr); if (path.size() == 1) { // is this the "top-level" separator which separates a dock area // from the central widget? switch (path.first()) { @@ -334,7 +334,7 @@ class QDockWidgetGroupWindow : public QWidget { Q_OBJECT public: - explicit QDockWidgetGroupWindow(QWidget* parent = 0, Qt::WindowFlags f = 0) + explicit QDockWidgetGroupWindow(QWidget* parent = nullptr, Qt::WindowFlags f = nullptr) : QWidget(parent, f) {} QDockAreaLayoutInfo *layoutInfo() const; const QDockAreaLayoutInfo *tabLayoutInfo() const; @@ -430,7 +430,7 @@ public: bool isValid() const; QLayoutItem *plug(const QList<int> &path); - QLayoutItem *unplug(const QList<int> &path, QMainWindowLayoutState *savedState = 0); + QLayoutItem *unplug(const QList<int> &path, QMainWindowLayoutState *savedState = nullptr); void saveState(QDataStream &stream) const; bool checkFormat(QDataStream &stream); diff --git a/src/widgets/widgets/qmdiarea.cpp b/src/widgets/widgets/qmdiarea.cpp index feea7cd050..0ce561860e 100644 --- a/src/widgets/widgets/qmdiarea.cpp +++ b/src/widgets/widgets/qmdiarea.cpp @@ -1988,9 +1988,11 @@ QMdiSubWindow *QMdiArea::addSubWindow(QWidget *widget, Qt::WindowFlags windowFla Q_ASSERT(child->testAttribute(Qt::WA_DeleteOnClose)); } + d->appendChild(child); + if (childFocus) childFocus->setFocus(); - d->appendChild(child); + return child; } diff --git a/src/widgets/widgets/qmdiarea_p.h b/src/widgets/widgets/qmdiarea_p.h index fd00118ec6..0a6368044a 100644 --- a/src/widgets/widgets/qmdiarea_p.h +++ b/src/widgets/widgets/qmdiarea_p.h @@ -183,7 +183,7 @@ public: int tabToPreviousTimerId; // Slots. - void _q_deactivateAllWindows(QMdiSubWindow *aboutToActivate = 0); + void _q_deactivateAllWindows(QMdiSubWindow *aboutToActivate = nullptr); void _q_processWindowStateChanged(Qt::WindowStates oldState, Qt::WindowStates newState); void _q_currentTabChanged(int index); void _q_closeTab(int index); @@ -198,7 +198,7 @@ public: void activateCurrentWindow(); void activateHighlightedWindow(); void emitWindowActivated(QMdiSubWindow *child); - void resetActiveWindow(QMdiSubWindow *child = 0); + void resetActiveWindow(QMdiSubWindow *child = nullptr); void updateActiveWindow(int removedIndex, bool activeRemoved); void updateScrollBars(); void internalRaise(QMdiSubWindow *child) const; diff --git a/src/widgets/widgets/qmdisubwindow_p.h b/src/widgets/widgets/qmdisubwindow_p.h index 719984c8d4..d3513b6708 100644 --- a/src/widgets/widgets/qmdisubwindow_p.h +++ b/src/widgets/widgets/qmdisubwindow_p.h @@ -78,7 +78,7 @@ template<typename T> class ControlElement : public T { public: - ControlElement(QMdiSubWindow *child) : T(child, 0) + ControlElement(QMdiSubWindow *child) : T(child, nullptr) { Q_ASSERT(child); mdiChild = child; @@ -88,7 +88,7 @@ public: { if (classname && strcmp(classname, "ControlElement") == 0) return this; - return 0; + return nullptr; } QPointer<QMdiSubWindow> mdiChild; @@ -102,7 +102,7 @@ public: #if QT_CONFIG(menubar) void showButtonsInMenuBar(QMenuBar *menuBar); - void removeButtonsFromMenuBar(QMenuBar *menuBar = 0); + void removeButtonsFromMenuBar(QMenuBar *menuBar = nullptr); QMenuBar *menuBar() const { return m_menuBar; } #endif void updateWindowIcon(const QIcon &windowIcon); @@ -331,7 +331,7 @@ public: inline bool autoRaise() const { Q_Q(const QMdiSubWindow); - return q->style()->styleHint(QStyle::SH_TitleBar_AutoRaise, 0, q); + return q->style()->styleHint(QStyle::SH_TitleBar_AutoRaise, nullptr, q); } inline bool isResizeOperation() const diff --git a/src/widgets/widgets/qmenu_p.h b/src/widgets/widgets/qmenu_p.h index 1821181535..ef152cd71b 100644 --- a/src/widgets/widgets/qmenu_p.h +++ b/src/widgets/widgets/qmenu_p.h @@ -135,9 +135,9 @@ public: void initialize(QMenu *menu) { m_menu = menu; - m_uni_directional = menu->style()->styleHint(QStyle::SH_Menu_SubMenuUniDirection, 0, menu); - m_uni_dir_fail_at_count = short(menu->style()->styleHint(QStyle::SH_Menu_SubMenuUniDirectionFailCount, 0, menu)); - m_select_other_actions = menu->style()->styleHint(QStyle::SH_Menu_SubMenuSloppySelectOtherActions, 0 , menu); + m_uni_directional = menu->style()->styleHint(QStyle::SH_Menu_SubMenuUniDirection, nullptr, menu); + m_uni_dir_fail_at_count = short(menu->style()->styleHint(QStyle::SH_Menu_SubMenuUniDirectionFailCount, nullptr, menu)); + m_select_other_actions = menu->style()->styleHint(QStyle::SH_Menu_SubMenuSloppySelectOtherActions, nullptr , menu); m_timeout = short(menu->style()->styleHint(QStyle::SH_Menu_SubMenuSloppyCloseTimeout)); m_discard_state_when_entering_parent = menu->style()->styleHint(QStyle::SH_Menu_SubMenuResetWhenReenteringParent); m_dont_start_time_on_leave = menu->style()->styleHint(QStyle::SH_Menu_SubMenuDontStartSloppyOnLeave); @@ -378,7 +378,7 @@ public: } void stop() { - action = 0; + action = nullptr; timer.stop(); } diff --git a/src/widgets/widgets/qmenubar_p.h b/src/widgets/widgets/qmenubar_p.h index c276a4512d..e3db16d190 100644 --- a/src/widgets/widgets/qmenubar_p.h +++ b/src/widgets/widgets/qmenubar_p.h @@ -65,9 +65,9 @@ class QMenuBarPrivate : public QWidgetPrivate { Q_DECLARE_PUBLIC(QMenuBar) public: - QMenuBarPrivate() : itemsDirty(0), currentAction(0), mouseDown(0), + QMenuBarPrivate() : itemsDirty(0), currentAction(nullptr), mouseDown(0), closePopupMode(0), defaultPopDown(1), popupState(0), keyboardState(0), altPressed(0), - doChildEffects(false), platformMenuBar(0) + doChildEffects(false), platformMenuBar(nullptr) { } ~QMenuBarPrivate() diff --git a/src/widgets/widgets/qscrollarea_p.h b/src/widgets/widgets/qscrollarea_p.h index fa2e0241cf..2bdf9ed596 100644 --- a/src/widgets/widgets/qscrollarea_p.h +++ b/src/widgets/widgets/qscrollarea_p.h @@ -65,7 +65,7 @@ class QScrollAreaPrivate: public QAbstractScrollAreaPrivate Q_DECLARE_PUBLIC(QScrollArea) public: - QScrollAreaPrivate(): resizable(false), alignment(0){} + QScrollAreaPrivate(): resizable(false), alignment(nullptr){} void updateScrollBars(); void updateWidgetPosition(); QPointer<QWidget> widget; diff --git a/src/widgets/widgets/qspinbox.cpp b/src/widgets/widgets/qspinbox.cpp index 7d454c6359..97a3a12336 100644 --- a/src/widgets/widgets/qspinbox.cpp +++ b/src/widgets/widgets/qspinbox.cpp @@ -128,9 +128,10 @@ public: manually. The spin box supports integer values but can be extended to use different strings with validate(), textFromValue() and valueFromText(). - Every time the value changes QSpinBox emits two valueChanged() signals, - one providing an int and the other a QString. The QString overload - provides the value with both prefix() and suffix(). + Every time the value changes QSpinBox emits valueChanged() and + textChanged() signals, the former providing a int and the latter + a QString. The textChanged() signal provides the value with both + prefix() and suffix(). The current value can be fetched with value() and set with setValue(). Clicking the up/down buttons or using the keyboard accelerator's @@ -183,12 +184,23 @@ public: */ /*! + \fn void QSpinBox::textChanged(const QString &text) + \since 5.14 + + This signal is emitted whenever the spin box's text is changed. + The new text is passed in \a text with prefix() and suffix(). +*/ + +#if QT_DEPRECATED_SINCE(5, 14) +/*! \fn void QSpinBox::valueChanged(const QString &text) \overload + \obsolete Use textChanged(QString) instead The new value is passed in \a text with prefix() and suffix(). */ +#endif /*! Constructs a spin box with 0 as minimum value and 99 as maximum value, a @@ -594,9 +606,9 @@ void QSpinBox::fixup(QString &input) const values but can be extended to use different strings with validate(), textFromValue() and valueFromText(). - Every time the value changes QDoubleSpinBox emits two - valueChanged() signals, one taking providing a double and the other - a QString. The QString overload provides the value with both + Every time the value changes QDoubleSpinBox emits valueChanged() and + textChanged() signals, the former providing a double and the latter + a QString. The textChanged() signal provides the value with both prefix() and suffix(). The current value can be fetched with value() and set with setValue(). @@ -644,12 +656,23 @@ void QSpinBox::fixup(QString &input) const */ /*! + \fn void QDoubleSpinBox::textChanged(const QString &text) + \since 5.14 + + This signal is emitted whenever the spin box's text is changed. + The new text is passed in \a text with prefix() and suffix(). +*/ + +#if QT_DEPRECATED_SINCE(5, 14) +/*! \fn void QDoubleSpinBox::valueChanged(const QString &text); \overload + \obsolete Use textChanged(QString) instead The new value is passed in \a text with prefix() and suffix(). */ +#endif /*! Constructs a spin box with 0.0 as minimum value and 99.99 as maximum value, @@ -1072,7 +1095,13 @@ void QSpinBoxPrivate::emitSignals(EmitPolicy ep, const QVariant &old) if (ep != NeverEmit) { pendingEmit = false; if (ep == AlwaysEmit || value != old) { +#if QT_DEPRECATED_SINCE(5, 14) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED emit q->valueChanged(edit->displayText()); +QT_WARNING_POP +#endif + emit q->textChanged(edit->displayText()); emit q->valueChanged(value.toInt()); } } @@ -1223,7 +1252,13 @@ void QDoubleSpinBoxPrivate::emitSignals(EmitPolicy ep, const QVariant &old) if (ep != NeverEmit) { pendingEmit = false; if (ep == AlwaysEmit || value != old) { +#if QT_DEPRECATED_SINCE(5, 14) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED emit q->valueChanged(edit->displayText()); +QT_WARNING_POP +#endif + emit q->textChanged(edit->displayText()); emit q->valueChanged(value.toDouble()); } } diff --git a/src/widgets/widgets/qspinbox.h b/src/widgets/widgets/qspinbox.h index d2eac903fb..762dd4a46a 100644 --- a/src/widgets/widgets/qspinbox.h +++ b/src/widgets/widgets/qspinbox.h @@ -106,7 +106,11 @@ public Q_SLOTS: Q_SIGNALS: void valueChanged(int); + void textChanged(const QString &); +#if QT_DEPRECATED_SINCE(5, 14) + QT_DEPRECATED_X("Use textChanged(QString) instead") void valueChanged(const QString &); +#endif private: Q_DISABLE_COPY(QSpinBox) @@ -168,7 +172,11 @@ public Q_SLOTS: Q_SIGNALS: void valueChanged(double); + void textChanged(const QString &); +#if QT_DEPRECATED_SINCE(5, 14) + QT_DEPRECATED_X("Use textChanged(QString) instead") void valueChanged(const QString &); +#endif private: Q_DISABLE_COPY(QDoubleSpinBox) diff --git a/src/widgets/widgets/qsplitter_p.h b/src/widgets/widgets/qsplitter_p.h index f0d621004f..871406a51d 100644 --- a/src/widgets/widgets/qsplitter_p.h +++ b/src/widgets/widgets/qsplitter_p.h @@ -70,7 +70,7 @@ public: QWidget *widget; QSplitterHandle *handle; - QSplitterLayoutStruct() : sizer(-1), collapsed(false), collapsible(Default), widget(0), handle(0) {} + QSplitterLayoutStruct() : sizer(-1), collapsed(false), collapsible(Default), widget(nullptr), handle(nullptr) {} ~QSplitterLayoutStruct() { delete handle; } int getWidgetSize(Qt::Orientation orient); int getHandleSize(Qt::Orientation orient); @@ -84,7 +84,7 @@ class QSplitterPrivate : public QFramePrivate public: QSplitterPrivate() : #if QT_CONFIG(rubberband) - rubberBand(0), + rubberBand(nullptr), #endif opaque(true), firstShow(true), childrenCollapsible(true), compatMode(false), handleWidth(-1), blockChildAdd(false), opaqueResizeSet(false) {} @@ -140,7 +140,7 @@ class QSplitterHandlePrivate : public QWidgetPrivate { Q_DECLARE_PUBLIC(QSplitterHandle) public: - QSplitterHandlePrivate() : s(0), orient(Qt::Horizontal), mouseOffset(0), opaq(false), hover(false), pressed(false) {} + QSplitterHandlePrivate() : s(nullptr), orient(Qt::Horizontal), mouseOffset(0), opaq(false), hover(false), pressed(false) {} inline int pick(const QPoint &pos) const { return orient == Qt::Horizontal ? pos.x() : pos.y(); } diff --git a/src/widgets/widgets/qtabbar_p.h b/src/widgets/widgets/qtabbar_p.h index 9b798e89c9..458d486b10 100644 --- a/src/widgets/widgets/qtabbar_p.h +++ b/src/widgets/widgets/qtabbar_p.h @@ -92,7 +92,7 @@ public: drawBase(true), scrollOffset(0), hoverIndex(-1), elideModeSetByUser(false), useScrollButtonsSetByUser(false), expanding(true), closeButtonOnTabs(false), selectionBehaviorOnRemove(QTabBar::SelectRightTab), paintWithOffsets(true), movable(false), dragInProgress(false), documentMode(false), autoHide(false), changeCurrentOnDrag(false), - switchTabCurrentIndex(-1), switchTabTimerId(0), movingTab(0) + switchTabCurrentIndex(-1), switchTabTimerId(0), movingTab(nullptr) #if 0 // Used to be included in Qt4 for Q_WS_MAC , previousPressedIndex(-1) #endif @@ -182,7 +182,7 @@ public: int indexAtPos(const QPoint &p) const; - inline bool isAnimated() const { Q_Q(const QTabBar); return q->style()->styleHint(QStyle::SH_Widget_Animation_Duration, 0, q) > 0; } + inline bool isAnimated() const { Q_Q(const QTabBar); return q->style()->styleHint(QStyle::SH_Widget_Animation_Duration, nullptr, q) > 0; } inline bool validIndex(int index) const { return index >= 0 && index < tabList.count(); } void setCurrentNextEnabledIndex(int offset); diff --git a/src/widgets/widgets/qtextedit.cpp b/src/widgets/widgets/qtextedit.cpp index 0ae63f2dd5..9e134493b5 100644 --- a/src/widgets/widgets/qtextedit.cpp +++ b/src/widgets/widgets/qtextedit.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2019 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtWidgets module of the Qt Toolkit. @@ -1213,6 +1213,13 @@ QString QTextEdit::toHtml() const } #endif +#if QT_CONFIG(textmarkdownreader) +void QTextEdit::setMarkdown(const QString &text) +{ + Q_D(const QTextEdit); + d->control->setMarkdown(text); +} +#endif /*! \reimp */ diff --git a/src/widgets/widgets/qtextedit.h b/src/widgets/widgets/qtextedit.h index 3aa23aaace..f20bd936c4 100644 --- a/src/widgets/widgets/qtextedit.h +++ b/src/widgets/widgets/qtextedit.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2019 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtWidgets module of the Qt Toolkit. @@ -238,6 +238,9 @@ public Q_SLOTS: #ifndef QT_NO_TEXTHTMLPARSER void setHtml(const QString &text); #endif +#if QT_CONFIG(textmarkdownreader) + void setMarkdown(const QString &text); +#endif void setText(const QString &text); #ifndef QT_NO_CLIPBOARD diff --git a/src/widgets/widgets/qtoolbar_p.h b/src/widgets/widgets/qtoolbar_p.h index 4db75762c8..8cb5850903 100644 --- a/src/widgets/widgets/qtoolbar_p.h +++ b/src/widgets/widgets/qtoolbar_p.h @@ -73,7 +73,7 @@ public: : explicitIconSize(false), explicitToolButtonStyle(false), movable(true), floatable(true), allowedAreas(Qt::AllToolBarAreas), orientation(Qt::Horizontal), toolButtonStyle(Qt::ToolButtonIconOnly), - layout(0), state(0) + layout(nullptr), state(nullptr) #ifdef Q_OS_OSX , macWindowDragging(false) #endif diff --git a/src/widgets/widgets/qtoolbararealayout_p.h b/src/widgets/widgets/qtoolbararealayout_p.h index 17747ef29b..5df95a3038 100644 --- a/src/widgets/widgets/qtoolbararealayout_p.h +++ b/src/widgets/widgets/qtoolbararealayout_p.h @@ -69,7 +69,7 @@ class QStyleOptionToolBar; class QToolBarAreaLayoutItem { public: - QToolBarAreaLayoutItem(QLayoutItem *item = 0) + QToolBarAreaLayoutItem(QLayoutItem *item = nullptr) : widgetItem(item), pos(0), size(-1), preferredSize(-1), gap(false) {} bool skip() const; diff --git a/src/widgets/widgets/qtoolbarlayout_p.h b/src/widgets/widgets/qtoolbarlayout_p.h index a788d30450..b5dc121b93 100644 --- a/src/widgets/widgets/qtoolbarlayout_p.h +++ b/src/widgets/widgets/qtoolbarlayout_p.h @@ -79,7 +79,7 @@ class QToolBarLayout : public QLayout Q_OBJECT public: - QToolBarLayout(QWidget *parent = 0); + QToolBarLayout(QWidget *parent = nullptr); ~QToolBarLayout(); void addItem(QLayoutItem *item) override; diff --git a/src/widgets/widgets/qwidgetlinecontrol_p.h b/src/widgets/widgets/qwidgetlinecontrol_p.h index f4df95865d..940a17714f 100644 --- a/src/widgets/widgets/qwidgetlinecontrol_p.h +++ b/src/widgets/widgets/qwidgetlinecontrol_p.h @@ -91,7 +91,7 @@ public: m_dragEnabled(0), m_echoMode(0), m_textDirty(0), m_selDirty(0), m_validInput(1), m_blinkStatus(0), m_blinkEnabled(false), m_blinkTimer(0), m_deleteAllTimer(0), m_ascent(0), m_maxLength(32767), m_lastCursorPos(-1), - m_tripleClickTimer(0), m_maskData(0), m_modifiedState(0), m_undoState(0), + m_tripleClickTimer(0), m_maskData(nullptr), m_modifiedState(0), m_undoState(0), m_selstart(0), m_selend(0), m_passwordEchoEditing(false) , m_passwordEchoTimer(0) , m_passwordMaskDelay(-1) @@ -103,7 +103,7 @@ public: , m_passwordMaskDelayOverride(-1) #endif , m_keyboardScheme(0) - , m_accessibleObject(0) + , m_accessibleObject(nullptr) { init(txt); } diff --git a/src/widgets/widgets/qwidgetresizehandler_p.h b/src/widgets/widgets/qwidgetresizehandler_p.h index 89bc759cc2..df3ac7cb8a 100644 --- a/src/widgets/widgets/qwidgetresizehandler_p.h +++ b/src/widgets/widgets/qwidgetresizehandler_p.h @@ -73,7 +73,7 @@ public: Any = Move|Resize }; - explicit QWidgetResizeHandler(QWidget *parent, QWidget *cw = 0); + explicit QWidgetResizeHandler(QWidget *parent, QWidget *cw = nullptr); void setActive(bool b) { setActive(Any, b); } void setActive(Action ac, bool b); bool isActive() const { return isActive(Any); } diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp index 711c4bfd2a..5744d43cbf 100644 --- a/src/widgets/widgets/qwidgettextcontrol.cpp +++ b/src/widgets/widgets/qwidgettextcontrol.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2019 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtWidgets module of the Qt Toolkit. @@ -491,6 +491,11 @@ void QWidgetTextControlPrivate::setContent(Qt::TextFormat format, const QString formatCursor.select(QTextCursor::Document); formatCursor.setCharFormat(charFormatForInsertion); formatCursor.endEditBlock(); +#if QT_CONFIG(textmarkdownreader) + } else if (format == Qt::MarkdownText) { + doc->setMarkdown(text); + doc->setUndoRedoEnabled(false); +#endif } else { #ifndef QT_NO_TEXTHTMLPARSER doc->setHtml(text); @@ -1194,6 +1199,14 @@ void QWidgetTextControl::setPlainText(const QString &text) d->setContent(Qt::PlainText, text); } +#if QT_CONFIG(textmarkdownreader) +void QWidgetTextControl::setMarkdown(const QString &text) +{ + Q_D(QWidgetTextControl); + d->setContent(Qt::MarkdownText, text); +} +#endif + void QWidgetTextControl::setHtml(const QString &text) { Q_D(QWidgetTextControl); diff --git a/src/widgets/widgets/qwidgettextcontrol_p.h b/src/widgets/widgets/qwidgettextcontrol_p.h index 202ba36454..4c9e47dfc9 100644 --- a/src/widgets/widgets/qwidgettextcontrol_p.h +++ b/src/widgets/widgets/qwidgettextcontrol_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2019 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtWidgets module of the Qt Toolkit. @@ -97,9 +97,9 @@ class Q_WIDGETS_EXPORT QWidgetTextControl : public QInputControl Q_PROPERTY(bool openExternalLinks READ openExternalLinks WRITE setOpenExternalLinks) Q_PROPERTY(bool ignoreUnusedNavigationEvents READ ignoreUnusedNavigationEvents WRITE setIgnoreUnusedNavigationEvents) public: - explicit QWidgetTextControl(QObject *parent = 0); - explicit QWidgetTextControl(const QString &text, QObject *parent = 0); - explicit QWidgetTextControl(QTextDocument *doc, QObject *parent = 0); + explicit QWidgetTextControl(QObject *parent = nullptr); + explicit QWidgetTextControl(const QString &text, QObject *parent = nullptr); + explicit QWidgetTextControl(QTextDocument *doc, QObject *parent = nullptr); virtual ~QWidgetTextControl(); void setDocument(QTextDocument *document); @@ -116,12 +116,12 @@ public: void setCurrentCharFormat(const QTextCharFormat &format); QTextCharFormat currentCharFormat() const; - bool find(const QString &exp, QTextDocument::FindFlags options = 0); + bool find(const QString &exp, QTextDocument::FindFlags options = nullptr); #ifndef QT_NO_REGEXP - bool find(const QRegExp &exp, QTextDocument::FindFlags options = 0); + bool find(const QRegExp &exp, QTextDocument::FindFlags options = nullptr); #endif #if QT_CONFIG(regularexpression) - bool find(const QRegularExpression &exp, QTextDocument::FindFlags options = 0); + bool find(const QRegularExpression &exp, QTextDocument::FindFlags options = nullptr); #endif QString toPlainText() const; @@ -194,6 +194,9 @@ public: public Q_SLOTS: void setPlainText(const QString &text); +#if QT_CONFIG(textmarkdownreader) + void setMarkdown(const QString &text); +#endif void setHtml(const QString &text); #ifndef QT_NO_CLIPBOARD @@ -243,11 +246,11 @@ public: QPalette palette() const; void setPalette(const QPalette &pal); - virtual void processEvent(QEvent *e, const QMatrix &matrix, QWidget *contextWidget = 0); - void processEvent(QEvent *e, const QPointF &coordinateOffset = QPointF(), QWidget *contextWidget = 0); + virtual void processEvent(QEvent *e, const QMatrix &matrix, QWidget *contextWidget = nullptr); + void processEvent(QEvent *e, const QPointF &coordinateOffset = QPointF(), QWidget *contextWidget = nullptr); // control methods - void drawContents(QPainter *painter, const QRectF &rect = QRectF(), QWidget *widget = 0); + void drawContents(QPainter *painter, const QRectF &rect = QRectF(), QWidget *widget = nullptr); void setFocus(bool focus, Qt::FocusReason = Qt::OtherFocusReason); diff --git a/src/widgets/widgets/qwidgettextcontrol_p_p.h b/src/widgets/widgets/qwidgettextcontrol_p_p.h index 232dab180f..6ccdfafe2b 100644 --- a/src/widgets/widgets/qwidgettextcontrol_p_p.h +++ b/src/widgets/widgets/qwidgettextcontrol_p_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2019 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtWidgets module of the Qt Toolkit. @@ -89,9 +89,9 @@ public: void createAutoBulletList(); void init(Qt::TextFormat format = Qt::RichText, const QString &text = QString(), - QTextDocument *document = 0); + QTextDocument *document = nullptr); void setContent(Qt::TextFormat format = Qt::RichText, const QString &text = QString(), - QTextDocument *document = 0); + QTextDocument *document = nullptr); void startDrag(); void paste(const QMimeData *source); |