From ce2fc51914f809369d5096e7a0621229dd9eaef9 Mon Sep 17 00:00:00 2001 From: Michal Klocek Date: Mon, 30 Sep 2019 15:27:19 +0200 Subject: Add check for global share context for QOpenGLWidget initialize Fixes: QTBUG-78863 Change-Id: I678f66a2057fb9c98863e19eb09042306e72f68a Reviewed-by: Laszlo Agocs --- src/widgets/kernel/qopenglwidget.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/kernel/qopenglwidget.cpp b/src/widgets/kernel/qopenglwidget.cpp index 374ea53726..a88054a0d0 100644 --- a/src/widgets/kernel/qopenglwidget.cpp +++ b/src/widgets/kernel/qopenglwidget.cpp @@ -788,10 +788,12 @@ void QOpenGLWidgetPrivate::initialize() if (initialized) return; - // Get our toplevel's context with which we will share in order to make the - // texture usable by the underlying window's backingstore. + // If no global shared context get our toplevel's context with which we + // will share in order to make the texture usable by the underlying window's backingstore. QWidget *tlw = q->window(); - QOpenGLContext *shareContext = get(tlw)->shareContext(); + QOpenGLContext *shareContext = qt_gl_global_share_context(); + if (!shareContext) + shareContext = get(tlw)->shareContext(); // If shareContext is null, showing content on-screen will not work. // However, offscreen rendering and grabFramebuffer() will stay fully functional. -- cgit v1.2.3 From b6ce61f486a06ded273d518d871906f9a53ab7c1 Mon Sep 17 00:00:00 2001 From: Kari Hormi Date: Mon, 7 Oct 2019 16:21:33 +0300 Subject: Fix text not rendering properly after setAlignment call Sometimes when setAlignment is called, the text stops rendering correctly at some point. Adding relayoutDocument call to setAlignment fixes the problem. Fixes: QTBUG-78728 Change-Id: Iab1cf161f0c8d700804448733338c813b5bf9762 Reviewed-by: Ville Voutilainen --- src/widgets/widgets/qtextedit.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/widgets') diff --git a/src/widgets/widgets/qtextedit.cpp b/src/widgets/widgets/qtextedit.cpp index 0ae63f2dd5..2b3a46ae56 100644 --- a/src/widgets/widgets/qtextedit.cpp +++ b/src/widgets/widgets/qtextedit.cpp @@ -746,6 +746,7 @@ void QTextEdit::setAlignment(Qt::Alignment a) QTextCursor cursor = d->control->textCursor(); cursor.mergeBlockFormat(fmt); d->control->setTextCursor(cursor); + d->relayoutDocument(); } /*! -- cgit v1.2.3 From f7cb11d6f12f7bb353640637719292b95fd21438 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 7 Oct 2019 13:59:13 +0200 Subject: QWidget: Answer question raised in fixme comment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a comment for fixme comment added in f1268d137ea7839b320c84314d0c2265f5a629ba. Change-Id: I08cd104442b13925be2aa5a48e64e391c9903099 Reviewed-by: Tor Arne Vestbø --- src/widgets/kernel/qwidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/widgets') diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index b70a03b311..588bed0366 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -7669,7 +7669,7 @@ void QWidget::show() else if (defaultState == Qt::WindowMaximized) showMaximized(); else - setVisible(true); // FIXME: Why not showNormal(), like QWindow::show()? + setVisible(true); // Don't call showNormal() as not to clobber Qt::Window(Max/Min)imized } /*! \internal -- cgit v1.2.3 From f1dd6addda908185f497d299d706b88977dea858 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Wed, 2 Oct 2019 12:19:11 +0200 Subject: Make QTextBlockFormat::MarkerType an enum class This came up during API review. Change-Id: I9198e1eb96db0c21e46a226a032919bb62d3ca66 Reviewed-by: Giuseppe D'Angelo --- src/widgets/widgets/qtextedit.cpp | 2 +- src/widgets/widgets/qwidgettextcontrol.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/widgets/qtextedit.cpp b/src/widgets/widgets/qtextedit.cpp index 0702603648..dd2ea3f18f 100644 --- a/src/widgets/widgets/qtextedit.cpp +++ b/src/widgets/widgets/qtextedit.cpp @@ -237,7 +237,7 @@ void QTextEditPrivate::_q_hoveredBlockWithMarkerChanged(const QTextBlock &block) Qt::CursorShape cursor = cursorToRestoreAfterHover; if (block.isValid() && !q->isReadOnly()) { QTextBlockFormat::MarkerType marker = block.blockFormat().marker(); - if (marker != QTextBlockFormat::NoMarker) { + if (marker != QTextBlockFormat::MarkerType::NoMarker) { if (viewport->cursor().shape() != Qt::PointingHandCursor) cursorToRestoreAfterHover = viewport->cursor().shape(); cursor = Qt::PointingHandCursor; diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp index fdbaf29dd8..094c59a0c9 100644 --- a/src/widgets/widgets/qwidgettextcontrol.cpp +++ b/src/widgets/widgets/qwidgettextcontrol.cpp @@ -1810,11 +1810,11 @@ void QWidgetTextControlPrivate::mouseReleaseEvent(QEvent *e, Qt::MouseButton but if (markerBlock == blockWithMarkerUnderMouse) { auto fmt = blockWithMarkerUnderMouse.blockFormat(); switch (fmt.marker()) { - case QTextBlockFormat::Unchecked : - fmt.setMarker(QTextBlockFormat::Checked); + case QTextBlockFormat::MarkerType::Unchecked : + fmt.setMarker(QTextBlockFormat::MarkerType::Checked); break; - case QTextBlockFormat::Checked: - fmt.setMarker(QTextBlockFormat::Unchecked); + case QTextBlockFormat::MarkerType::Checked: + fmt.setMarker(QTextBlockFormat::MarkerType::Unchecked); break; default: break; -- cgit v1.2.3 From 65fcd8524da628c99e8cd28f983f0c17fbe157f0 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Tue, 8 Oct 2019 16:25:08 +0200 Subject: QAbstractScrollArea: when used as a popup, apply regular popup behavior MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QWidget::mousePressEvent is documented to implement the closing of popups if the widget is a popup. QAbstractScrollArea is one of the QWidget subclasses that might be used as a popup as well, so instead of just ignoring mousePressEvents, pass the event on to the QWidget implementation for regular popup handling. Change-Id: I05f77a334945f3c167f729f30bc022599230379b Fixes: QTBUG-60885 Reviewed-by: Tor Arne Vestbø Reviewed-by: Paul Olav Tvete --- src/widgets/widgets/qabstractscrollarea.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/widgets') diff --git a/src/widgets/widgets/qabstractscrollarea.cpp b/src/widgets/widgets/qabstractscrollarea.cpp index b295e66574..d2372a7be9 100644 --- a/src/widgets/widgets/qabstractscrollarea.cpp +++ b/src/widgets/widgets/qabstractscrollarea.cpp @@ -1144,11 +1144,14 @@ void QAbstractScrollArea::paintEvent(QPaintEvent*) mouse press events for the viewport() widget. The event is passed in \a e. + The default implementation calls QWidget::mousePressEvent() for + default popup handling. + \sa QWidget::mousePressEvent() */ void QAbstractScrollArea::mousePressEvent(QMouseEvent *e) { - e->ignore(); + QWidget::mousePressEvent(e); } /*! -- cgit v1.2.3 From 81a790969395feff73fa600908822765e97424e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Thu, 3 Oct 2019 15:04:16 +0200 Subject: Fusion Style: Use high-dpi pixmaps Pass the QWindow as context to QIcon::pixmap(), which enables it to return high-dpi pixmaps when needed. Fixes: QTBUG-74100 Change-Id: I4556f0a98df8b6ba65376778379a03eb8c470d00 Reviewed-by: Friedemann Kleint --- src/widgets/styles/qfusionstyle.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp index ba2b6b0ed9..b58dc1660a 100644 --- a/src/widgets/styles/qfusionstyle.cpp +++ b/src/widgets/styles/qfusionstyle.cpp @@ -88,6 +88,7 @@ #include #include #include +#include QT_BEGIN_NAMESPACE @@ -364,6 +365,11 @@ static void qt_fusion_draw_mdibutton(QPainter *painter, const QStyleOptionTitleB painter->drawPoint(tmp.right() , tmp.bottom() - 1); } +static QWindow *qt_getWindow(const QWidget *widget) +{ + return widget ? QWidgetPrivate::get(widget)->windowHandle(QWidgetPrivate::WindowHandleMode::Closest) : nullptr; +} + /* \internal */ @@ -995,7 +1001,7 @@ void QFusionStyle::drawPrimitive(PrimitiveElement elem, d->tabBarcloseButtonIcon = proxy()->standardIcon(SP_DialogCloseButton, option, widget); if ((option->state & State_Enabled) && (option->state & State_MouseOver)) proxy()->drawPrimitive(PE_PanelButtonCommand, option, painter, widget); - QPixmap pixmap = d->tabBarcloseButtonIcon.pixmap(QSize(16, 16), QIcon::Normal, QIcon::On); + QPixmap pixmap = d->tabBarcloseButtonIcon.pixmap(qt_getWindow(widget), QSize(16, 16), QIcon::Normal, QIcon::On); proxy()->drawItemPixmap(painter, option->rect, Qt::AlignCenter, pixmap); } break; @@ -1035,7 +1041,7 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio if (!cb->currentIcon.isNull()) { QIcon::Mode mode = cb->state & State_Enabled ? QIcon::Normal : QIcon::Disabled; - QPixmap pixmap = cb->currentIcon.pixmap(cb->iconSize, mode); + QPixmap pixmap = cb->currentIcon.pixmap(qt_getWindow(widget), cb->iconSize, mode); QRect iconRect(editRect); iconRect.setWidth(cb->iconSize.width() + 4); iconRect = alignedRect(cb->direction, @@ -1647,9 +1653,9 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio iconSize = combo->iconSize(); #endif if (checked) - pixmap = menuItem->icon.pixmap(iconSize, mode, QIcon::On); + pixmap = menuItem->icon.pixmap(qt_getWindow(widget), iconSize, mode, QIcon::On); else - pixmap = menuItem->icon.pixmap(iconSize, mode); + pixmap = menuItem->icon.pixmap(qt_getWindow(widget), iconSize, mode); const int pixw = pixmap.width() / pixmap.devicePixelRatio(); const int pixh = pixmap.height() / pixmap.devicePixelRatio(); @@ -1783,7 +1789,7 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio if (button->state & State_On) state = QIcon::On; - QPixmap pixmap = button->icon.pixmap(button->iconSize, mode, state); + QPixmap pixmap = button->icon.pixmap(qt_getWindow(widget), button->iconSize, mode, state); int w = pixmap.width() / pixmap.devicePixelRatio(); int h = pixmap.height() / pixmap.devicePixelRatio(); -- cgit v1.2.3 From 1748dc3e2d2367f9f01666212a22e6b1dde5dc89 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Mon, 7 Oct 2019 16:09:37 +0200 Subject: QGroupBox: always disable children in a checkable, unchecked groupbox The childEvent handler sets the enabled property of children as they are added to the groupbox, but applications might later enable children and check/uncheck the groupbox's checkbox in undefined order. In that case, we would end up with enabled children inside a conceptually disabled groupbox (the groupbox's checkbox represents the logical "disabled" state), which breaks documented QWidget::enabled rules. To make sure that all children are disabled as per the state of the groupbox, we need to run that logic once the UI has been set up, and before it becomes visible. This is what polishing is for, so listen for that event in addition and handle it the same way as adding (which duplicates things, but keeps existing code that might depend on things being updated as they are added working). Adds the case to the existing enabledChildPropagation test case. [ChangeLog][QWidget][QGroupBox] Always disable children of a checkable, unchecked group box before showing. Change-Id: I978bd27b6f1a3f54ec745faeea529a98d0d93619 Fixes: QTBUG-25938 Reviewed-by: Shawn Rutledge --- src/widgets/widgets/qgroupbox.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/widgets/qgroupbox.cpp b/src/widgets/widgets/qgroupbox.cpp index 69eac1ebf7..eec794562a 100644 --- a/src/widgets/widgets/qgroupbox.cpp +++ b/src/widgets/widgets/qgroupbox.cpp @@ -389,9 +389,13 @@ bool QGroupBox::event(QEvent *e) void QGroupBox::childEvent(QChildEvent *c) { Q_D(QGroupBox); - if (c->type() != QEvent::ChildAdded || !c->child()->isWidgetType()) + /* + Children might have been enabled after being added to the group box, in which case + the childEvent handler ran too early, and we need to disabled children again. + */ + if (!(c->added() || c->polished()) || !c->child()->isWidgetType()) return; - QWidget *w = (QWidget*)c->child(); + QWidget *w = static_cast(c->child()); if (w->isWindow()) return; if (d->checkable) { -- cgit v1.2.3