diff options
Diffstat (limited to 'src/widgets')
-rw-r--r-- | src/widgets/dialogs/qfilesystemmodel.cpp | 2 | ||||
-rw-r--r-- | src/widgets/dialogs/qinputdialog.cpp | 3 | ||||
-rw-r--r-- | src/widgets/dialogs/qinputdialog.h | 11 | ||||
-rw-r--r-- | src/widgets/graphicsview/qgraphicsitem.cpp | 17 | ||||
-rw-r--r-- | src/widgets/itemviews/qdirmodel.cpp | 2 | ||||
-rw-r--r-- | src/widgets/kernel/qwidget.cpp | 6 | ||||
-rw-r--r-- | src/widgets/styles/qcommonstyle.cpp | 9 | ||||
-rw-r--r-- | src/widgets/styles/qfusionstyle.cpp | 2 | ||||
-rw-r--r-- | src/widgets/styles/qstyle.cpp | 2 | ||||
-rw-r--r-- | src/widgets/styles/qstyle.h | 2 | ||||
-rw-r--r-- | src/widgets/styles/qstyleoption.cpp | 2 | ||||
-rw-r--r-- | src/widgets/styles/qwindowsstyle.cpp | 2 | ||||
-rw-r--r-- | src/widgets/widgets/qcombobox.cpp | 23 | ||||
-rw-r--r-- | src/widgets/widgets/qcombobox.h | 5 | ||||
-rw-r--r-- | src/widgets/widgets/qlabel.cpp | 4 | ||||
-rw-r--r-- | src/widgets/widgets/qlabel.h | 8 | ||||
-rw-r--r-- | src/widgets/widgets/qpushbutton.cpp | 11 | ||||
-rw-r--r-- | src/widgets/widgets/qpushbutton.h | 1 | ||||
-rw-r--r-- | src/widgets/widgets/qsizegrip.cpp | 16 | ||||
-rw-r--r-- | src/widgets/widgets/qtextedit.cpp | 1 |
20 files changed, 103 insertions, 26 deletions
diff --git a/src/widgets/dialogs/qfilesystemmodel.cpp b/src/widgets/dialogs/qfilesystemmodel.cpp index a723c3a955..d516b1b312 100644 --- a/src/widgets/dialogs/qfilesystemmodel.cpp +++ b/src/widgets/dialogs/qfilesystemmodel.cpp @@ -797,7 +797,7 @@ QString QFileSystemModelPrivate::time(const QModelIndex &index) const if (!index.isValid()) return QString(); #if QT_CONFIG(datestring) - return node(index)->lastModified().toString(Qt::SystemLocaleDate); + return QLocale::system().toString(node(index)->lastModified(), QLocale::ShortFormat); #else Q_UNUSED(index); return QString(); diff --git a/src/widgets/dialogs/qinputdialog.cpp b/src/widgets/dialogs/qinputdialog.cpp index 1cb4be0682..eeb0613d79 100644 --- a/src/widgets/dialogs/qinputdialog.cpp +++ b/src/widgets/dialogs/qinputdialog.cpp @@ -1349,6 +1349,7 @@ int QInputDialog::getInt(QWidget *parent, const QString &title, const QString &l \sa getText(), getDouble(), getItem(), getMultiLineText() */ +#if QT_DEPRECATED_SINCE(5, 15) /*! Static convenience function to get a floating point number from the user. @@ -1380,7 +1381,7 @@ double QInputDialog::getDouble(QWidget *parent, const QString &title, const QStr { return QInputDialog::getDouble(parent, title, label, value, min, max, decimals, ok, flags, 1.0); } - +#endif /*! \overload Static convenience function to get a floating point number from the user. diff --git a/src/widgets/dialogs/qinputdialog.h b/src/widgets/dialogs/qinputdialog.h index c3a5e59d53..ca893172f9 100644 --- a/src/widgets/dialogs/qinputdialog.h +++ b/src/widgets/dialogs/qinputdialog.h @@ -176,13 +176,24 @@ public: static int getInt(QWidget *parent, const QString &title, const QString &label, int value = 0, int minValue = -2147483647, int maxValue = 2147483647, int step = 1, bool *ok = nullptr, Qt::WindowFlags flags = Qt::WindowFlags()); + +#if QT_DEPRECATED_SINCE(5, 15) + QT_DEPRECATED_X("This overload is deprecated. Use the overload that takes step as a final argument") static double getDouble(QWidget *parent, const QString &title, const QString &label, double value = 0, double minValue = -2147483647, double maxValue = 2147483647, int decimals = 1, bool *ok = nullptr, Qt::WindowFlags flags = Qt::WindowFlags()); +#endif +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + static double getDouble(QWidget *parent, const QString &title, const QString &label, double value = 0, + double minValue = -2147483647, double maxValue = 2147483647, + int decimals = 1, bool *ok = nullptr, Qt::WindowFlags flags = Qt::WindowFlags(), + double step = 1); +#else // ### Qt 6: merge overloads static double getDouble(QWidget *parent, const QString &title, const QString &label, double value, double minValue, double maxValue, int decimals, bool *ok, Qt::WindowFlags flags, double step); +#endif #if QT_DEPRECATED_SINCE(5, 0) QT_DEPRECATED static inline int getInteger(QWidget *parent, const QString &title, const QString &label, int value = 0, diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp index 26f5a3baf2..db5c53a48a 100644 --- a/src/widgets/graphicsview/qgraphicsitem.cpp +++ b/src/widgets/graphicsview/qgraphicsitem.cpp @@ -2326,12 +2326,17 @@ void QGraphicsItem::setCursor(const QCursor &cursor) view->viewport()->setMouseTracking(true); // Note: Some of this logic is duplicated in QGraphicsView's mouse events. if (view->underMouse()) { - const auto itemsUnderCursor = view->items(view->mapFromGlobal(QCursor::pos())); - for (QGraphicsItem *itemUnderCursor : itemsUnderCursor) { - if (itemUnderCursor->hasCursor()) { - QMetaObject::invokeMethod(view, "_q_setViewportCursor", - Q_ARG(QCursor, itemUnderCursor->cursor())); - break; + const QPoint viewPoint = view->mapFromGlobal(QCursor::pos()); + const QPointF cursorPos = mapFromScene(view->mapToScene(viewPoint)); + // the cursor can only change if the current item is under the mouse + if (boundingRect().contains(cursorPos)) { + const auto itemsUnderCursor = view->items(viewPoint); + for (QGraphicsItem *itemUnderCursor : itemsUnderCursor) { + if (itemUnderCursor->hasCursor()) { + QMetaObject::invokeMethod(view, "_q_setViewportCursor", + Q_ARG(QCursor, itemUnderCursor->cursor())); + break; + } } } break; diff --git a/src/widgets/itemviews/qdirmodel.cpp b/src/widgets/itemviews/qdirmodel.cpp index 0d387d7def..8d1538a213 100644 --- a/src/widgets/itemviews/qdirmodel.cpp +++ b/src/widgets/itemviews/qdirmodel.cpp @@ -1321,7 +1321,7 @@ QString QDirModelPrivate::type(const QModelIndex &index) const QString QDirModelPrivate::time(const QModelIndex &index) const { #if QT_CONFIG(datestring) - return node(index)->info.lastModified().toString(Qt::LocalDate); + return QLocale::system().toString(node(index)->info.lastModified(), QLocale::ShortFormat); #else Q_UNUSED(index); return QString(); diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 25ca732c9e..397fb345c2 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -2347,7 +2347,9 @@ QWidget *QWidget::find(WId id) */ WId QWidget::winId() const { - if (!testAttribute(Qt::WA_WState_Created) || !internalWinId()) { + if (!data->in_destructor + && (!testAttribute(Qt::WA_WState_Created) || !internalWinId())) + { #ifdef ALIEN_DEBUG qDebug() << "QWidget::winId: creating native window for" << this; #endif @@ -6306,7 +6308,7 @@ void QWidget::setFocus(Qt::FocusReason reason) previousProxyFocus = topData->proxyWidget->widget()->focusWidget(); if (previousProxyFocus && previousProxyFocus->focusProxy()) previousProxyFocus = previousProxyFocus->focusProxy(); - if (previousProxyFocus == this && !topData->proxyWidget->d_func()->proxyIsGivingFocus) + if (previousProxyFocus == f && !topData->proxyWidget->d_func()->proxyIsGivingFocus) return; } } diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index 1e5830d216..f4a53c9dfe 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -1350,6 +1350,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, QRect ir = btn->rect; QStyleOptionButton newBtn = *btn; newBtn.rect = QRect(ir.right() - mbi + 2, ir.height()/2 - mbi/2 + 3, mbi - 6, mbi - 6); + newBtn.rect = visualRect(btn->direction, br, newBtn.rect); proxy()->drawPrimitive(PE_IndicatorArrowDown, &newBtn, p, widget); } } @@ -1378,7 +1379,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, int iconSpacing = 4;//### 4 is currently hardcoded in QPushButton::sizeHint() if (!button->text.isEmpty()) { int textWidth = button->fontMetrics.boundingRect(opt->rect, tf, button->text).width(); - labelWidth += (textWidth + iconSpacing); + labelWidth += (textWidth + iconSpacing * 2); } QRect iconRect = QRect(textRect.x() + (textRect.width() - labelWidth) / 2, @@ -2465,6 +2466,12 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt, r = visualRect(opt->direction, opt->rect, r); } break; + case SE_PushButtonBevel: + { + r = opt->rect; + r = visualRect(opt->direction, opt->rect, r); + } + break; case SE_CheckBoxIndicator: { int h = proxy()->pixelMetric(PM_IndicatorHeight, opt, widget); diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp index c4bc52aa87..2b59e5736b 100644 --- a/src/widgets/styles/qfusionstyle.cpp +++ b/src/widgets/styles/qfusionstyle.cpp @@ -2416,7 +2416,7 @@ void QFusionStyle::drawComplexControl(ComplexControl control, const QStyleOption QStyle::State oldState = static_cast<QStyle::State>(qvariant_cast<QStyle::State::Int>(styleObject->property("_q_stylestate"))); uint oldActiveControls = styleObject->property("_q_stylecontrols").toUInt(); - // a scrollbar is transient when the the scrollbar itself and + // a scrollbar is transient when the scrollbar itself and // its sibling are both inactive (ie. not pressed/hovered/moved) bool transient = !option->activeSubControls && !(option->state & State_On); diff --git a/src/widgets/styles/qstyle.cpp b/src/widgets/styles/qstyle.cpp index 1110cc3323..4ac0a11a36 100644 --- a/src/widgets/styles/qstyle.cpp +++ b/src/widgets/styles/qstyle.cpp @@ -1011,6 +1011,7 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, \value SE_PushButtonFocusRect Area for the focus rect (usually larger than the contents rect). \value SE_PushButtonLayoutItem Area that counts for the parent layout. + \value SE_PushButtonBevel Area used for the bevel of the button. \value SE_CheckBoxIndicator Area for the state indicator (e.g., check mark). \value SE_CheckBoxContents Area for the label (text or pixmap). @@ -1119,6 +1120,7 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, \header \li Sub Element \li QStyleOption Subclass \row \li \l SE_PushButtonContents \li \l QStyleOptionButton \row \li \l SE_PushButtonFocusRect \li \l QStyleOptionButton + \row \li \l SE_PushButtonBevel \li \l QStyleOptionButton \row \li \l SE_CheckBoxIndicator \li \l QStyleOptionButton \row \li \l SE_CheckBoxContents \li \l QStyleOptionButton \row \li \l SE_CheckBoxFocusRect \li \l QStyleOptionButton diff --git a/src/widgets/styles/qstyle.h b/src/widgets/styles/qstyle.h index b51bcbe8d6..f37604e0fa 100644 --- a/src/widgets/styles/qstyle.h +++ b/src/widgets/styles/qstyle.h @@ -355,6 +355,8 @@ public: SE_TabBarScrollRightButton, SE_TabBarTearIndicatorRight, + SE_PushButtonBevel, + // do not add any values below/greater than this SE_CustomBase = 0xf0000000 }; diff --git a/src/widgets/styles/qstyleoption.cpp b/src/widgets/styles/qstyleoption.cpp index 5a2ca2f2e7..bf365585d4 100644 --- a/src/widgets/styles/qstyleoption.cpp +++ b/src/widgets/styles/qstyleoption.cpp @@ -1646,7 +1646,7 @@ QStyleOptionProgressBar::QStyleOptionProgressBar(int version) the default orentation is Qt::Horizontal \deprecated - Use the QStyle::State_Horizontal flag instead (in the the QStyleOption::state member). + Use the QStyle::State_Horizontal flag instead (in the QStyleOption::state member). \sa QProgressBar::orientation */ diff --git a/src/widgets/styles/qwindowsstyle.cpp b/src/widgets/styles/qwindowsstyle.cpp index 105eba370a..8eb24d7557 100644 --- a/src/widgets/styles/qwindowsstyle.cpp +++ b/src/widgets/styles/qwindowsstyle.cpp @@ -2136,7 +2136,7 @@ void QWindowsStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComp #if QT_CONFIG(combobox) case CC_ComboBox: if (const QStyleOptionComboBox *cmb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) { - QBrush editBrush = cmb->palette.brush(QPalette::Base); + QBrush editBrush = cmb->palette.brush(QPalette::Button); if ((cmb->subControls & SC_ComboBoxFrame)) { if (cmb->frame) { QPalette shadePal = opt->palette; diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index b249608ccc..3cfa213245 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -940,6 +940,8 @@ QStyleOptionComboBox QComboBoxPrivateContainer::comboStyleOption() const changes either through user interaction or programmatically. The item's \a index is passed or -1 if the combobox becomes empty or the currentIndex was reset. + + \obsolete Use currentIndexChanged(int index, const QString &text) instead */ /*! @@ -949,6 +951,18 @@ QStyleOptionComboBox QComboBoxPrivateContainer::comboStyleOption() const This signal is sent whenever the currentIndex in the combobox changes either through user interaction or programmatically. The item's \a text is passed. + + \obsolete Use currentIndexChanged(int index, const QString &text) instead +*/ + +/*! + \fn void QComboBox::currentIndexChanged(int index, const QString &text) + \since 5.15 + + This signal is sent whenever the currentIndex in the combobox + changes either through user interaction or programmatically. The + item's \a index is passed or -1 if the combobox becomes empty or + the currentIndex was reset. The item's \a text is also passed. */ /*! @@ -1421,13 +1435,14 @@ void QComboBoxPrivate::_q_emitCurrentIndexChanged(const QModelIndex &index) { Q_Q(QComboBox); const QString text = itemText(index); - emit q->currentIndexChanged(index.row()); -#if QT_DEPRECATED_SINCE(5, 13) +#if QT_DEPRECATED_SINCE(5, 15) QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED + emit q->currentIndexChanged(index.row()); emit q->currentIndexChanged(text); QT_WARNING_POP #endif + emit q->currentIndexChanged(index.row(), text); // signal lineEdit.textChanged already connected to signal currentTextChanged, so don't emit double here if (!lineEdit) emit q->currentTextChanged(text); @@ -3099,12 +3114,14 @@ void QComboBox::changeEvent(QEvent *e) d->updateViewContainerPaletteAndOpacity(); break; } - case QEvent::FontChange: + case QEvent::FontChange: { d->sizeHint = QSize(); // invalidate size hint d->viewContainer()->setFont(font()); + d->viewContainer()->itemView()->doItemsLayout(); if (d->lineEdit) d->updateLineEditGeometry(); break; + } default: break; } diff --git a/src/widgets/widgets/qcombobox.h b/src/widgets/widgets/qcombobox.h index 19bdf39233..56386a4b8c 100644 --- a/src/widgets/widgets/qcombobox.h +++ b/src/widgets/widgets/qcombobox.h @@ -230,8 +230,13 @@ Q_SIGNALS: void textActivated(const QString &); void highlighted(int index); void textHighlighted(const QString &); +#if QT_DEPRECATED_SINCE(5, 15) + QT_DEPRECATED_VERSION_X_5_15("Use currentIndexChanged(int, const QString &) instead") void currentIndexChanged(int index); + QT_DEPRECATED_VERSION_X_5_15("Use currentIndexChanged(int, const QString &) instead") void currentIndexChanged(const QString &); +#endif + void currentIndexChanged(int index, const QString &text); void currentTextChanged(const QString &); protected: diff --git a/src/widgets/widgets/qlabel.cpp b/src/widgets/widgets/qlabel.cpp index 147ab9b855..a0b5bdd39f 100644 --- a/src/widgets/widgets/qlabel.cpp +++ b/src/widgets/widgets/qlabel.cpp @@ -226,7 +226,7 @@ const QPicture *QLabel::picture() const \endcode */ -QPicture QLabel::picture(Qt::ReturnByValue_t) const +QPicture QLabel::picture(Qt::ReturnByValueConstant) const { Q_D(const QLabel); if (d->picture) @@ -442,7 +442,7 @@ const QPixmap *QLabel::pixmap() const /*! \since 5.15 */ -QPixmap QLabel::pixmap(Qt::ReturnByValue_t) const +QPixmap QLabel::pixmap(Qt::ReturnByValueConstant) const { Q_D(const QLabel); if (d->pixmap) diff --git a/src/widgets/widgets/qlabel.h b/src/widgets/widgets/qlabel.h index 288022a71e..c9552efd8a 100644 --- a/src/widgets/widgets/qlabel.h +++ b/src/widgets/widgets/qlabel.h @@ -77,9 +77,9 @@ public: QT_DEPRECATED_VERSION_X(5, 15, "Use the other overload which returns QPixmap by-value") const QPixmap *pixmap() const; // ### Qt 7: Remove function - QPixmap pixmap(Qt::ReturnByValue_t) const; + QPixmap pixmap(Qt::ReturnByValueConstant) const; #else - QPixmap pixmap(Qt::ReturnByValue_t = Qt::ReturnByValue) const; // ### Qt 7: Remove arg + QPixmap pixmap(Qt::ReturnByValueConstant = Qt::ReturnByValue) const; // ### Qt 7: Remove arg #endif // QT_DEPRECATED_SINCE(5,15) #ifndef QT_NO_PICTURE @@ -87,9 +87,9 @@ public: QT_DEPRECATED_VERSION_X(5, 15, "Use the other overload which returns QPicture by-value") const QPicture *picture() const; // ### Qt 7: Remove function - QPicture picture(Qt::ReturnByValue_t) const; + QPicture picture(Qt::ReturnByValueConstant) const; # else - QPicture picture(Qt::ReturnByValue_t = Qt::ReturnByValue) const; // ### Qt 7: Remove arg + QPicture picture(Qt::ReturnByValueConstant = Qt::ReturnByValue) const; // ### Qt 7: Remove arg # endif // QT_DEPRECATED_SINCE(5,15) #endif #if QT_CONFIG(movie) diff --git a/src/widgets/widgets/qpushbutton.cpp b/src/widgets/widgets/qpushbutton.cpp index b0d3ba51f9..3d075bf92f 100644 --- a/src/widgets/widgets/qpushbutton.cpp +++ b/src/widgets/widgets/qpushbutton.cpp @@ -509,6 +509,17 @@ void QPushButton::focusOutEvent(QFocusEvent *e) #endif } +/*! + \reimp +*/ +bool QPushButton::hitButton(const QPoint &pos) const +{ + QStyleOptionButton option; + initStyleOption(&option); + const QRect bevel = style()->subElementRect(QStyle::SE_PushButtonBevel, &option, this); + return bevel.contains(pos); +} + #if QT_CONFIG(menu) /*! Associates the popup menu \a menu with this push button. This diff --git a/src/widgets/widgets/qpushbutton.h b/src/widgets/widgets/qpushbutton.h index b02ba63d07..283dfe2c61 100644 --- a/src/widgets/widgets/qpushbutton.h +++ b/src/widgets/widgets/qpushbutton.h @@ -94,6 +94,7 @@ protected: void focusInEvent(QFocusEvent *) override; void focusOutEvent(QFocusEvent *) override; void initStyleOption(QStyleOptionButton *option) const; + bool hitButton(const QPoint &pos) const override; QPushButton(QPushButtonPrivate &dd, QWidget* parent = nullptr); public: diff --git a/src/widgets/widgets/qsizegrip.cpp b/src/widgets/widgets/qsizegrip.cpp index 2a4b4a0ad4..95a4beeb57 100644 --- a/src/widgets/widgets/qsizegrip.cpp +++ b/src/widgets/widgets/qsizegrip.cpp @@ -260,6 +260,17 @@ void QSizeGrip::paintEvent(QPaintEvent *event) parameter. */ +static Qt::Edges edgesFromCorner(Qt::Corner corner) +{ + switch (corner) { + case Qt::TopLeftCorner: return Qt::TopEdge | Qt::LeftEdge; + case Qt::TopRightCorner: return Qt::TopEdge | Qt::RightEdge; + case Qt::BottomLeftCorner: return Qt::BottomEdge | Qt::LeftEdge; + case Qt::BottomRightCorner: return Qt::BottomEdge | Qt::RightEdge; + } + return Qt::Edges{}; +} + void QSizeGrip::mousePressEvent(QMouseEvent * e) { if (e->button() != Qt::LeftButton) { @@ -281,8 +292,9 @@ void QSizeGrip::mousePressEvent(QMouseEvent * e) && !tlw->testAttribute(Qt::WA_DontShowOnScreen) && !tlw->hasHeightForWidth()) { QPlatformWindow *platformWindow = tlw->windowHandle()->handle(); - const QPoint topLevelPos = mapTo(tlw, e->pos()); - d->m_platformSizeGrip = platformWindow && platformWindow->startSystemResize(topLevelPos, d->m_corner); + const Qt::Edges edges = edgesFromCorner(d->m_corner); + if (!QGuiApplication::platformName().contains(QStringLiteral("xcb"))) // ### FIXME QTBUG-69716 + d->m_platformSizeGrip = platformWindow && platformWindow->startSystemResize(edges); } if (d->m_platformSizeGrip) diff --git a/src/widgets/widgets/qtextedit.cpp b/src/widgets/widgets/qtextedit.cpp index 913ca6ec16..8ddda78f7d 100644 --- a/src/widgets/widgets/qtextedit.cpp +++ b/src/widgets/widgets/qtextedit.cpp @@ -1272,6 +1272,7 @@ QString QTextEdit::toHtml() const The default is \c MarkdownDialectGitHub. \sa plainText, html, QTextDocument::toMarkdown(), QTextDocument::setMarkdown() + \since 5.14 */ #endif |