diff options
Diffstat (limited to 'src/widgets')
20 files changed, 195 insertions, 211 deletions
diff --git a/src/widgets/dialogs/qprogressdialog.cpp b/src/widgets/dialogs/qprogressdialog.cpp index b5cc630bfe..662504fc25 100644 --- a/src/widgets/dialogs/qprogressdialog.cpp +++ b/src/widgets/dialogs/qprogressdialog.cpp @@ -849,7 +849,7 @@ void QProgressDialog::forceShow() \since 4.5 \overload - Opens the dialog and connects its accepted() signal to the slot specified + Opens the dialog and connects its canceled() signal to the slot specified by \a receiver and \a member. The signal will be disconnected from the slot when the dialog is closed. diff --git a/src/widgets/doc/snippets/code/doc_src_examples_dropsite.qdoc b/src/widgets/doc/snippets/code/doc_src_examples_dropsite.qdoc index 923362e909..e9d2a94a59 100644 --- a/src/widgets/doc/snippets/code/doc_src_examples_dropsite.qdoc +++ b/src/widgets/doc/snippets/code/doc_src_examples_dropsite.qdoc @@ -39,5 +39,7 @@ ****************************************************************************/ //! [0] +\code foreach(variable, container) +\endcode //! [0] diff --git a/src/widgets/graphicsview/qgraphicsscene.cpp b/src/widgets/graphicsview/qgraphicsscene.cpp index 41d4fc925a..bccdb1fbaa 100644 --- a/src/widgets/graphicsview/qgraphicsscene.cpp +++ b/src/widgets/graphicsview/qgraphicsscene.cpp @@ -5451,13 +5451,13 @@ bool QGraphicsScene::focusNextPrevChild(bool next) */ /*! - \fn QGraphicsScene::focusChanged(QGraphicsItem *newFocusItem, QGraphicsItem *oldFocusItem, Qt::FocusReason reason) + \fn QGraphicsScene::focusItemChanged(QGraphicsItem *newFocusItem, QGraphicsItem *oldFocusItem, Qt::FocusReason reason) This signal is emitted by QGraphicsScene whenever focus changes in the scene (i.e., when an item gains or loses input focus, or when focus passes from one item to another). You can connect to this signal if you need to keep track of when other items gain input focus. It is - particularily useful for implementing virtual keyboards, input methods, + particularly useful for implementing virtual keyboards, input methods, and cursor items. \a oldFocusItem is a pointer to the item that previously had focus, or diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index c01b535067..9e221c1bf4 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -3277,30 +3277,6 @@ bool QApplication::notify(QObject *receiver, QEvent *e) } break; #endif - - case QEvent::TouchUpdate: - case QEvent::TouchEnd: - { - QWidget *widget = static_cast<QWidget *>(receiver); - QTouchEvent *touchEvent = static_cast<QTouchEvent *>(e); - const bool acceptTouchEvents = widget->testAttribute(Qt::WA_AcceptTouchEvents); - - if (e->type() != QEvent::TouchUpdate && acceptTouchEvents && e->spontaneous()) { - const QPoint localPos = touchEvent->touchPoints()[0].pos().toPoint(); - QApplicationPrivate::giveFocusAccordingToFocusPolicy(widget, e, localPos); - } - - touchEvent->setTarget(widget); - touchEvent->setAccepted(acceptTouchEvents); - - res = acceptTouchEvents && d->notify_helper(widget, touchEvent); - - // If the touch event wasn't accepted, synthesize a mouse event and see if the widget wants it. - if (!touchEvent->isAccepted() && QGuiApplicationPrivate::synthesizeMouseFromTouchEventsEnabled()) - res = d->translateTouchToMouse(widget, touchEvent); - break; - } - case QEvent::TouchBegin: // Note: TouchUpdate and TouchEnd events are never propagated { @@ -3321,15 +3297,6 @@ bool QApplication::notify(QObject *receiver, QEvent *e) touchEvent->setAccepted(acceptTouchEvents); QPointer<QWidget> p = widget; res = acceptTouchEvents && d->notify_helper(widget, touchEvent); - - // If the touch event wasn't accepted, synthesize a mouse event and see if the widget wants it. - if (!touchEvent->isAccepted() && QGuiApplicationPrivate::synthesizeMouseFromTouchEventsEnabled()) { - res = d->translateTouchToMouse(widget, touchEvent); - eventAccepted = touchEvent->isAccepted(); - if (eventAccepted) - break; - } - eventAccepted = touchEvent->isAccepted(); if (p.isNull()) { // widget was deleted @@ -3892,67 +3859,6 @@ QWidget *QApplicationPrivate::findClosestTouchPointTarget(QTouchDevice *device, return static_cast<QWidget *>(closestTarget); } -class WidgetAttributeSaver -{ -public: - explicit WidgetAttributeSaver(QWidget *widget, Qt::WidgetAttribute attribute, bool forcedValue) - : m_widget(widget), - m_attribute(attribute), - m_savedValue(widget->testAttribute(attribute)) - { - widget->setAttribute(attribute, forcedValue); - } - - ~WidgetAttributeSaver() - { - m_widget->setAttribute(m_attribute, m_savedValue); - } - -private: - QWidget * const m_widget; - const Qt::WidgetAttribute m_attribute; - const bool m_savedValue; -}; - -bool QApplicationPrivate::translateTouchToMouse(QWidget *widget, QTouchEvent *event) -{ - Q_FOREACH (const QTouchEvent::TouchPoint &p, event->touchPoints()) { - const QEvent::Type eventType = (p.state() & Qt::TouchPointPressed) ? QEvent::MouseButtonPress - : (p.state() & Qt::TouchPointReleased) ? QEvent::MouseButtonRelease - : (p.state() & Qt::TouchPointMoved) ? QEvent::MouseMove - : QEvent::None; - - if (eventType == QEvent::None) - continue; - - const QPoint pos = widget->mapFromGlobal(p.screenPos().toPoint()); - - QMouseEvent mouseEvent(eventType, pos, p.screenPos().toPoint(), - Qt::LeftButton, - (eventType == QEvent::MouseButtonRelease) ? Qt::NoButton : Qt::LeftButton, - event->modifiers()); - mouseEvent.setAccepted(true); - mouseEvent.setTimestamp(event->timestamp()); - - // Make sure our synthesized mouse event doesn't propagate - // we want to control the propagation ourself to get a chance to - // deliver a proper touch event higher up in the hierarchy if that - // widget doesn't pick up the mouse event either. - WidgetAttributeSaver saver(widget, Qt::WA_NoMousePropagation, true); - - // Note it has to be a spontaneous event if we want the focus management - // and input method support to behave properly. Quite some of the code - // related to those aspect check for the spontaneous flag. - const bool res = QCoreApplication::sendSpontaneousEvent(widget, &mouseEvent); - event->setAccepted(mouseEvent.isAccepted()); - - if (mouseEvent.isAccepted()) - return res; - } - - return false; -} - bool QApplicationPrivate::translateRawTouchEvent(QWidget *window, QTouchDevice *device, const QList<QTouchEvent::TouchPoint> &touchPoints, diff --git a/src/widgets/kernel/qapplication.h b/src/widgets/kernel/qapplication.h index 9cd18d5cd9..e72fe29bdb 100644 --- a/src/widgets/kernel/qapplication.h +++ b/src/widgets/kernel/qapplication.h @@ -112,7 +112,7 @@ public: QT_DEPRECATED static inline void setGraphicsSystem(const QString &) {} #endif -#ifdef Q_NO_USING_KEYWORD +#if defined(Q_NO_USING_KEYWORD) && !defined(Q_QDOC) static QPalette palette() { return QGuiApplication::palette(); } #else using QGuiApplication::palette; diff --git a/src/widgets/kernel/qapplication_p.h b/src/widgets/kernel/qapplication_p.h index 93c9ffe002..0284a613d4 100644 --- a/src/widgets/kernel/qapplication_p.h +++ b/src/widgets/kernel/qapplication_p.h @@ -285,7 +285,6 @@ public: QWidget *findClosestTouchPointTarget(QTouchDevice *device, const QPointF &screenPos); void appendTouchPoint(const QTouchEvent::TouchPoint &touchPoint); void removeTouchPoint(int touchPointId); - bool translateTouchToMouse(QWidget *widget, QTouchEvent *event); static bool translateRawTouchEvent(QWidget *widget, QTouchDevice *device, const QList<QTouchEvent::TouchPoint> &touchPoints, diff --git a/src/widgets/kernel/qformlayout.cpp b/src/widgets/kernel/qformlayout.cpp index c1d3e95e7a..239e1ce1e2 100644 --- a/src/widgets/kernel/qformlayout.cpp +++ b/src/widgets/kernel/qformlayout.cpp @@ -1683,7 +1683,7 @@ QWidget *QFormLayout::labelForField(QWidget *field) const Q_D(const QFormLayout); int row; - ItemRole role; + ItemRole role = LabelRole; getWidgetPosition(field, &row, &role); diff --git a/src/widgets/kernel/qopenglwidget.cpp b/src/widgets/kernel/qopenglwidget.cpp index a5f81a9df8..e05c03d952 100644 --- a/src/widgets/kernel/qopenglwidget.cpp +++ b/src/widgets/kernel/qopenglwidget.cpp @@ -44,6 +44,7 @@ #include <QtWidgets/private/qwidget_p.h> #include <QOpenGLFramebufferObject> +#include <QOpenGLFunctions> #include <QWindow> #include <qpa/qplatformwindow.h> #include <QDebug> @@ -144,9 +145,10 @@ void QOpenGLWidget::paintGL() void QOpenGLWidget::updateGL() { + Q_D(QOpenGLWidget); makeCurrent(); paintGL(); - glFlush(); + d->context.functions()->glFlush(); doneCurrent(); update(); } @@ -163,15 +165,16 @@ void QOpenGLWidget::resizeEvent(QResizeEvent *) delete d->fbo; // recreate when resized d->fbo = new QOpenGLFramebufferObject(size()); d->fbo->bind(); - glBindTexture(GL_TEXTURE_2D, d->fbo->texture()); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); + QOpenGLFunctions *funcs = d->context.functions(); + funcs->glBindTexture(GL_TEXTURE_2D, d->fbo->texture()); + funcs->glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + funcs->glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + funcs->glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + funcs->glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); resizeGL(width(), height()); paintGL(); - glFlush(); + funcs->glFlush(); } void QOpenGLWidget::paintEvent(QPaintEvent *) diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index c52e0d47ce..ab045dd604 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -9600,6 +9600,23 @@ void QWidget::setParent(QWidget *parent) setParent((QWidget*)parent, windowFlags() & ~Qt::WindowType_Mask); } +#ifndef QT_NO_OPENGL +static void sendWindowChangeToTextureChildrenRecursively(QWidget *widget) +{ + QWidgetPrivate *d = QWidgetPrivate::get(widget); + if (d->renderToTexture) { + QEvent e(QEvent::WindowChangeInternal); + QApplication::sendEvent(widget, &e); + } + + for (int i = 0; i < d->children.size(); ++i) { + QWidget *w = qobject_cast<QWidget *>(d->children.at(i)); + if (w && !w->isWindow() && !w->isHidden() && QWidgetPrivate::get(w)->textureChildSeen) + sendWindowChangeToTextureChildrenRecursively(w); + } +} +#endif + /*! \overload @@ -9724,6 +9741,12 @@ void QWidget::setParent(QWidget *parent, Qt::WindowFlags f) QEvent e(QEvent::ParentChange); QApplication::sendEvent(this, &e); } +#ifndef QT_NO_OPENGL + //renderToTexture widgets also need to know when their top-level window changes + if (d->textureChildSeen && oldtlw != window()) { + sendWindowChangeToTextureChildrenRecursively(this); + } +#endif if (!wasCreated) { if (isWindow() || parentWidget()->isVisible()) @@ -9892,7 +9915,7 @@ void QWidget::repaint(const QRect &rect) QTLWExtra *tlwExtra = window()->d_func()->maybeTopData(); if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore) { tlwExtra->inRepaint = true; - tlwExtra->backingStoreTracker->markDirty(rect, this, true); + tlwExtra->backingStoreTracker->markDirty(rect, this, QWidgetBackingStore::UpdateNow); tlwExtra->inRepaint = false; } } else { @@ -9921,7 +9944,7 @@ void QWidget::repaint(const QRegion &rgn) QTLWExtra *tlwExtra = window()->d_func()->maybeTopData(); if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore) { tlwExtra->inRepaint = true; - tlwExtra->backingStoreTracker->markDirty(rgn, this, true); + tlwExtra->backingStoreTracker->markDirty(rgn, this, QWidgetBackingStore::UpdateNow); tlwExtra->inRepaint = false; } } else { diff --git a/src/widgets/kernel/qwidget_qpa.cpp b/src/widgets/kernel/qwidget_qpa.cpp index c2260b6e7d..88a08060c1 100644 --- a/src/widgets/kernel/qwidget_qpa.cpp +++ b/src/widgets/kernel/qwidget_qpa.cpp @@ -524,7 +524,10 @@ void QWidgetPrivate::show_sys() return; } - QApplication::postEvent(q, new QUpdateLaterEvent(q->rect())); + if (renderToTexture && !q->isWindow()) + QApplication::postEvent(q->parentWidget(), new QUpdateLaterEvent(q->geometry())); + else + QApplication::postEvent(q, new QUpdateLaterEvent(q->rect())); if (!q->isWindow() && !q->testAttribute(Qt::WA_NativeWindow)) return; @@ -546,12 +549,6 @@ void QWidgetPrivate::show_sys() window->resize(geomRect.size()); } - if (QBackingStore *store = q->backingStore()) { - if (store->size() != geomRect.size()) { - store->resize(geomRect.size()); - } - } - #ifndef QT_NO_CURSOR qt_qpa_set_cursor(q, false); // Needed in case cursor was set before show #endif @@ -588,7 +585,10 @@ void QWidgetPrivate::hide_sys() if (!q->isWindow()) { QWidget *p = q->parentWidget(); if (p &&p->isVisible()) { - invalidateBuffer(q->rect()); + if (renderToTexture) + p->d_func()->invalidateBuffer(q->geometry()); + else + invalidateBuffer(q->rect()); } } else { invalidateBuffer(q->rect()); @@ -663,6 +663,11 @@ void QWidgetPrivate::raise_sys() Q_Q(QWidget); if (q->isWindow() || q->testAttribute(Qt::WA_NativeWindow)) { q->windowHandle()->raise(); + } else if (renderToTexture) { + if (QWidget *p = q->parentWidget()) { + setDirtyOpaqueRegion(); + p->d_func()->invalidateBuffer(effectiveRectFor(q->geometry())); + } } } @@ -751,21 +756,21 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove) QPoint posInNativeParent = q->mapTo(q->nativeParentWidget(),QPoint()); q->windowHandle()->setGeometry(QRect(posInNativeParent,r.size())); } - const QWidgetBackingStore *bs = maybeBackingStore(); - if (bs && bs->store) { - if (isResize) - bs->store->resize(r.size()); - } if (needsShow) show_sys(); } if (!q->isWindow()) { - if (isMove && !isResize) + if (renderToTexture) { + QRegion updateRegion(q->geometry()); + updateRegion += QRect(oldPos, olds); + q->parentWidget()->d_func()->invalidateBuffer(updateRegion); + } else if (isMove && !isResize) { moveRect(QRect(oldPos, olds), x - oldPos.x(), y - oldPos.y()); - else + } else { invalidateBuffer_resizeHelper(oldPos, olds); + } } } @@ -939,6 +944,23 @@ void QWidgetPrivate::createTLSysExtra() void QWidgetPrivate::deleteTLSysExtra() { if (extra && extra->topextra) { + //the qplatformbackingstore may hold a reference to the window, so the backingstore + //needs to be deleted first. If the backingstore holds GL resources, we need to + // make the context current here, since the platform bs does not have a reference + // to the widget. + +#ifndef QT_NO_OPENGL + if (textureChildSeen && extra->topextra->shareContext) + extra->topextra->shareContext->makeCurrent(extra->topextra->window); +#endif + extra->topextra->backingStoreTracker.destroy(); + delete extra->topextra->backingStore; + extra->topextra->backingStore = 0; +#ifndef QT_NO_OPENGL + if (textureChildSeen && extra->topextra->shareContext) + extra->topextra->shareContext->doneCurrent(); +#endif + //the toplevel might have a context with a "qglcontext associated with it. We need to //delete the qglcontext before we delete the qplatformopenglcontext. //One unfortunate thing about this is that we potentially create a glContext just to @@ -950,10 +972,6 @@ void QWidgetPrivate::deleteTLSysExtra() delete extra->topextra->window; extra->topextra->window = 0; - extra->topextra->backingStoreTracker.destroy(); - delete extra->topextra->backingStore; - extra->topextra->backingStore = 0; - #ifndef QT_NO_OPENGL delete extra->topextra->shareContext; extra->topextra->shareContext = 0; diff --git a/src/widgets/kernel/qwidgetbackingstore.cpp b/src/widgets/kernel/qwidgetbackingstore.cpp index 43e2ccdf0b..221e6825ed 100644 --- a/src/widgets/kernel/qwidgetbackingstore.cpp +++ b/src/widgets/kernel/qwidgetbackingstore.cpp @@ -443,17 +443,21 @@ QRegion QWidgetBackingStore::staticContents(QWidget *parent, const QRect &within return region; } -void QWidgetBackingStore::sendUpdateRequest(QWidget *widget, bool updateImmediately) +void QWidgetBackingStore::sendUpdateRequest(QWidget *widget, UpdateTime updateTime) { if (!widget) return; - if (updateImmediately) { - QEvent event(QEvent::UpdateRequest); - QApplication::sendEvent(widget, &event); - } else { + switch (updateTime) { + case UpdateLater: updateRequestSent = true; QApplication::postEvent(widget, new QEvent(QEvent::UpdateRequest), Qt::LowEventPriority); + break; + case UpdateNow: { + QEvent event(QEvent::UpdateRequest); + QApplication::sendEvent(widget, &event); + break; + } } } @@ -461,17 +465,17 @@ void QWidgetBackingStore::sendUpdateRequest(QWidget *widget, bool updateImmediat Marks the region of the widget as dirty (if not already marked as dirty) and posts an UpdateRequest event to the top-level widget (if not already posted). - If updateImmediately is true, the event is sent immediately instead of posted. + If updateTime is UpdateNow, the event is sent immediately instead of posted. - If invalidateBuffer is true, all widgets intersecting with the region will be dirty. + If bufferState is BufferInvalid, all widgets intersecting with the region will be dirty. If the widget paints directly on screen, the event is sent to the widget - instead of the top-level widget, and invalidateBuffer is completely ignored. + instead of the top-level widget, and bufferState is completely ignored. ### Qt 4.6: Merge into a template function (after MSVC isn't supported anymore). */ -void QWidgetBackingStore::markDirty(const QRegion &rgn, QWidget *widget, bool updateImmediately, - bool invalidateBuffer) +void QWidgetBackingStore::markDirty(const QRegion &rgn, QWidget *widget, + UpdateTime updateTime, BufferState bufferState) { Q_ASSERT(tlw->d_func()->extra); Q_ASSERT(tlw->d_func()->extra->topextra); @@ -487,44 +491,44 @@ void QWidgetBackingStore::markDirty(const QRegion &rgn, QWidget *widget, bool up if (widget->d_func()->paintOnScreen()) { if (widget->d_func()->dirty.isEmpty()) { widget->d_func()->dirty = rgn; - sendUpdateRequest(widget, updateImmediately); + sendUpdateRequest(widget, updateTime); return; } else if (qt_region_strictContains(widget->d_func()->dirty, widget->rect())) { - if (updateImmediately) - sendUpdateRequest(widget, updateImmediately); + if (updateTime == UpdateNow) + sendUpdateRequest(widget, updateTime); return; // Already dirty. } const bool eventAlreadyPosted = !widget->d_func()->dirty.isEmpty(); widget->d_func()->dirty += rgn; - if (!eventAlreadyPosted || updateImmediately) - sendUpdateRequest(widget, updateImmediately); + if (!eventAlreadyPosted || updateTime == UpdateNow) + sendUpdateRequest(widget, updateTime); return; } //### FIXME fullUpdatePending seems to be always false???? if (fullUpdatePending) { - if (updateImmediately) - sendUpdateRequest(tlw, updateImmediately); + if (updateTime == UpdateNow) + sendUpdateRequest(tlw, updateTime); return; } const QPoint offset = widget->mapTo(tlw, QPoint()); if (QWidgetPrivate::get(widget)->renderToTexture) { - if (!updateRequestSent || updateImmediately) - sendUpdateRequest(tlw, updateImmediately); + if (!updateRequestSent || updateTime == UpdateNow) + sendUpdateRequest(tlw, updateTime); return; } const QRect widgetRect = widget->d_func()->effectiveRectFor(widget->rect()); if (qt_region_strictContains(dirty, widgetRect.translated(offset))) { - if (updateImmediately) - sendUpdateRequest(tlw, updateImmediately); + if (updateTime == UpdateNow) + sendUpdateRequest(tlw, updateTime); return; // Already dirty. } - if (invalidateBuffer) { + if (bufferState == BufferInvalid) { const bool eventAlreadyPosted = !dirty.isEmpty() || updateRequestSent; #ifndef QT_NO_GRAPHICSEFFECT if (widget->d_func()->graphicsEffect) @@ -532,14 +536,14 @@ void QWidgetBackingStore::markDirty(const QRegion &rgn, QWidget *widget, bool up else #endif //QT_NO_GRAPHICSEFFECT dirty += rgn.translated(offset); - if (!eventAlreadyPosted || updateImmediately) - sendUpdateRequest(tlw, updateImmediately); + if (!eventAlreadyPosted || updateTime == UpdateNow) + sendUpdateRequest(tlw, updateTime); return; } if (dirtyWidgets.isEmpty()) { addDirtyWidget(widget, rgn); - sendUpdateRequest(tlw, updateImmediately); + sendUpdateRequest(tlw, updateTime); return; } @@ -556,8 +560,8 @@ void QWidgetBackingStore::markDirty(const QRegion &rgn, QWidget *widget, bool up addDirtyWidget(widget, rgn); } - if (updateImmediately) - sendUpdateRequest(tlw, updateImmediately); + if (updateTime == UpdateNow) + sendUpdateRequest(tlw, updateTime); } /*! @@ -567,8 +571,8 @@ void QWidgetBackingStore::markDirty(const QRegion &rgn, QWidget *widget, bool up ### Qt 4.6: Merge into a template function (after MSVC isn't supported anymore). */ -void QWidgetBackingStore::markDirty(const QRect &rect, QWidget *widget, bool updateImmediately, - bool invalidateBuffer) +void QWidgetBackingStore::markDirty(const QRect &rect, QWidget *widget, + UpdateTime updateTime, BufferState bufferState) { Q_ASSERT(tlw->d_func()->extra); Q_ASSERT(tlw->d_func()->extra->topextra); @@ -584,30 +588,30 @@ void QWidgetBackingStore::markDirty(const QRect &rect, QWidget *widget, bool upd if (widget->d_func()->paintOnScreen()) { if (widget->d_func()->dirty.isEmpty()) { widget->d_func()->dirty = QRegion(rect); - sendUpdateRequest(widget, updateImmediately); + sendUpdateRequest(widget, updateTime); return; } else if (qt_region_strictContains(widget->d_func()->dirty, rect)) { - if (updateImmediately) - sendUpdateRequest(widget, updateImmediately); + if (updateTime == UpdateNow) + sendUpdateRequest(widget, updateTime); return; // Already dirty. } const bool eventAlreadyPosted = !widget->d_func()->dirty.isEmpty(); widget->d_func()->dirty += rect; - if (!eventAlreadyPosted || updateImmediately) - sendUpdateRequest(widget, updateImmediately); + if (!eventAlreadyPosted || updateTime == UpdateNow) + sendUpdateRequest(widget, updateTime); return; } if (fullUpdatePending) { - if (updateImmediately) - sendUpdateRequest(tlw, updateImmediately); + if (updateTime == UpdateNow) + sendUpdateRequest(tlw, updateTime); return; } if (QWidgetPrivate::get(widget)->renderToTexture) { - if (!updateRequestSent || updateImmediately) - sendUpdateRequest(tlw, updateImmediately); + if (!updateRequestSent || updateTime == UpdateNow) + sendUpdateRequest(tlw, updateTime); return; } @@ -615,22 +619,22 @@ void QWidgetBackingStore::markDirty(const QRect &rect, QWidget *widget, bool upd const QRect widgetRect = widget->d_func()->effectiveRectFor(rect); const QRect translatedRect(widgetRect.translated(widget->mapTo(tlw, QPoint()))); if (qt_region_strictContains(dirty, translatedRect)) { - if (updateImmediately) - sendUpdateRequest(tlw, updateImmediately); + if (updateTime == UpdateNow) + sendUpdateRequest(tlw, updateTime); return; // Already dirty } - if (invalidateBuffer) { + if (bufferState == BufferInvalid) { const bool eventAlreadyPosted = !dirty.isEmpty(); dirty += translatedRect; - if (!eventAlreadyPosted || updateImmediately) - sendUpdateRequest(tlw, updateImmediately); + if (!eventAlreadyPosted || updateTime == UpdateNow) + sendUpdateRequest(tlw, updateTime); return; } if (dirtyWidgets.isEmpty()) { addDirtyWidget(widget, rect); - sendUpdateRequest(tlw, updateImmediately); + sendUpdateRequest(tlw, updateTime); return; } @@ -641,8 +645,8 @@ void QWidgetBackingStore::markDirty(const QRect &rect, QWidget *widget, bool upd addDirtyWidget(widget, rect); } - if (updateImmediately) - sendUpdateRequest(tlw, updateImmediately); + if (updateTime == UpdateNow) + sendUpdateRequest(tlw, updateTime); } /*! @@ -936,7 +940,7 @@ void QWidgetBackingStore::sync(QWidget *exposedWidget, const QRegion &exposedReg } // Nothing to repaint. - if (!isDirty()) { + if (!isDirty() && store->size().isValid()) { qt_flush(exposedWidget, exposedRegion, store, tlw, tlwOffset, widgetTextures); return; } @@ -1031,7 +1035,7 @@ void QWidgetBackingStore::doSync() const QRect tlwRect(topLevelRect()); const QRect surfaceGeometry(tlwRect.topLeft(), store->size()); if ((fullUpdatePending || inTopLevelResize || surfaceGeometry.size() != tlwRect.size()) && !updatesDisabled) { - if (hasStaticContents()) { + if (hasStaticContents() && !store->size().isEmpty() ) { // Repaint existing dirty area and newly visible area. const QRect clipRect(0, 0, surfaceGeometry.width(), surfaceGeometry.height()); const QRegion staticRegion(staticContents(0, clipRect)); @@ -1346,7 +1350,8 @@ void QWidgetPrivate::invalidateBuffer(const QRegion &rgn) if (wrgn.isEmpty()) return; - tlwExtra->backingStoreTracker->markDirty(wrgn, q, false, true); + tlwExtra->backingStoreTracker->markDirty(wrgn, q, + QWidgetBackingStore::UpdateLater, QWidgetBackingStore::BufferInvalid); } /*! @@ -1370,7 +1375,8 @@ void QWidgetPrivate::invalidateBuffer(const QRect &rect) return; if (graphicsEffect || !extra || !extra->hasMask) { - tlwExtra->backingStoreTracker->markDirty(wRect, q, false, true); + tlwExtra->backingStoreTracker->markDirty(wRect, q, + QWidgetBackingStore::UpdateLater, QWidgetBackingStore::BufferInvalid); return; } @@ -1379,7 +1385,8 @@ void QWidgetPrivate::invalidateBuffer(const QRect &rect) if (wRgn.isEmpty()) return; - tlwExtra->backingStoreTracker->markDirty(wRgn, q, false, true); + tlwExtra->backingStoreTracker->markDirty(wRgn, q, + QWidgetBackingStore::UpdateLater, QWidgetBackingStore::BufferInvalid); } void QWidgetPrivate::repaint_sys(const QRegion &rgn) diff --git a/src/widgets/kernel/qwidgetbackingstore_p.h b/src/widgets/kernel/qwidgetbackingstore_p.h index e362ee4ac1..473e9deef4 100644 --- a/src/widgets/kernel/qwidgetbackingstore_p.h +++ b/src/widgets/kernel/qwidgetbackingstore_p.h @@ -93,6 +93,16 @@ private: class Q_AUTOTEST_EXPORT QWidgetBackingStore { public: + enum UpdateTime { + UpdateNow, + UpdateLater + }; + + enum BufferState{ + BufferValid, + BufferInvalid + }; + QWidgetBackingStore(QWidget *t); ~QWidgetBackingStore(); @@ -112,10 +122,10 @@ public: } // ### Qt 4.6: Merge into a template function (after MSVC isn't supported anymore). - void markDirty(const QRegion &rgn, QWidget *widget, bool updateImmediately = false, - bool invalidateBuffer = false); - void markDirty(const QRect &rect, QWidget *widget, bool updateImmediately = false, - bool invalidateBuffer = false); + void markDirty(const QRegion &rgn, QWidget *widget, UpdateTime updateTime = UpdateLater, + BufferState bufferState = BufferValid); + void markDirty(const QRect &rect, QWidget *widget, UpdateTime updateTime = UpdateLater, + BufferState bufferState = BufferValid); private: QWidget *tlw; @@ -134,7 +144,7 @@ private: QPlatformTextureListWatcher *textureListWatcher; - void sendUpdateRequest(QWidget *widget, bool updateImmediately); + void sendUpdateRequest(QWidget *widget, UpdateTime updateTime); static bool flushPaint(QWidget *widget, const QRegion &rgn); static void unflushPaint(QWidget *widget, const QRegion &rgn); diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp index 3cc48b442d..e50736d6b8 100644 --- a/src/widgets/kernel/qwidgetwindow.cpp +++ b/src/widgets/kernel/qwidgetwindow.cpp @@ -59,6 +59,7 @@ Q_WIDGETS_EXPORT extern bool qt_tab_all_widgets(); QWidget *qt_button_down = 0; // widget got last button-down static QWidget *qt_tablet_target = 0; +static QWidget *qt_tablet_target_window = 0; // popup control QWidget *qt_popup_down = 0; // popup that contains the pressed widget @@ -103,8 +104,10 @@ QWidgetWindow::QWidgetWindow(QWidget *widget) QWidgetWindow::~QWidgetWindow() { - if (m_widget == qt_tablet_target) + if (m_widget == qt_tablet_target_window) { qt_tablet_target = 0; + qt_tablet_target_window = 0; + } } #ifndef QT_NO_ACCESSIBILITY @@ -774,6 +777,7 @@ void QWidgetWindow::handleTabletEvent(QTabletEvent *event) widget = m_widget; qt_tablet_target = widget; + qt_tablet_target_window = m_widget; } if (qt_tablet_target) { @@ -786,8 +790,10 @@ void QWidgetWindow::handleTabletEvent(QTabletEvent *event) QGuiApplication::sendSpontaneousEvent(qt_tablet_target, &ev); } - if (event->type() == QEvent::TabletRelease) + if (event->type() == QEvent::TabletRelease) { qt_tablet_target = 0; + qt_tablet_target_window = 0; + } } #endif // QT_NO_TABLETEVENT diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp index 149a5c6674..c4bc5a5e96 100644 --- a/src/widgets/styles/qfusionstyle.cpp +++ b/src/widgets/styles/qfusionstyle.cpp @@ -1026,7 +1026,7 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio break; case CE_Splitter: { - // Dont draw handle for single pixel splitters + // Don't draw handle for single pixel splitters if (option->rect.width() > 1 && option->rect.height() > 1) { //draw grips if (option->state & State_Horizontal) { diff --git a/src/widgets/styles/qgtkstyle.cpp b/src/widgets/styles/qgtkstyle.cpp index 105aefb14c..9ad0484bc2 100644 --- a/src/widgets/styles/qgtkstyle.cpp +++ b/src/widgets/styles/qgtkstyle.cpp @@ -1032,7 +1032,7 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element, case PE_FrameFocusRect: { QRect frameRect = option->rect.adjusted(1, 1, -2, -2); // ### this mess should move to subcontrolrect if (qobject_cast<const QAbstractItemView*>(widget)) { - // Dont draw anything + // Don't draw anything } else if (qobject_cast<const QTabBar*>(widget)) { GtkWidget *gtkNotebook = d->gtkWidget("GtkNotebook"); style = d->gtk_widget_get_style(gtkNotebook); diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index d8530bca1e..53568f3c53 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -5024,7 +5024,7 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex int oldState = styleObject->property("_q_stylestate").toInt(); 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 = !opt->activeSubControls && !(slider->state & State_On); @@ -5827,12 +5827,6 @@ QRect QMacStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *op switch (sc) { case SC_ComboBoxEditField:{ ret = QMacStylePrivate::comboboxEditBounds(combo->rect, bdi); - // hack to posistion the edit feld correctly for QDateTimeEdits - // in calendarPopup mode. - if (qobject_cast<const QDateTimeEdit *>(widget)) { - ret.moveTop(ret.top() - 2); - ret.setHeight(ret.height() +1); - } break; } case SC_ComboBoxArrow:{ ret = QMacStylePrivate::comboboxEditBounds(combo->rect, bdi); diff --git a/src/widgets/styles/qstyle.cpp b/src/widgets/styles/qstyle.cpp index da9b5da2a5..7568ba4e6e 100644 --- a/src/widgets/styles/qstyle.cpp +++ b/src/widgets/styles/qstyle.cpp @@ -1585,14 +1585,28 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, \table \header \li Contents Type \li QStyleOption Subclass - \row \li \l CT_PushButton \li \l QStyleOptionButton - \row \li \l CT_CheckBox \li \l QStyleOptionButton - \row \li \l CT_RadioButton \li \l QStyleOptionButton - \row \li \l CT_ToolButton \li \l QStyleOptionToolButton - \row \li \l CT_ComboBox \li \l QStyleOptionComboBox - \row \li \l CT_Splitter \li \l QStyleOption - \row \li \l CT_ProgressBar \li \l QStyleOptionProgressBar - \row \li \l CT_MenuItem \li \l QStyleOptionMenuItem + \row \li \l CT_CheckBox \li \l QStyleOptionButton + \row \li \l CT_ComboBox \li \l QStyleOptionComboBox + \row \li \l CT_GroupBox \li \l QStyleOptionGroupBox + \row \li \l CT_HeaderSection \li \l QStyleOptionHeader + \row \li \l CT_ItemViewItem \li \l QStyleOptionViewItem + \row \li \l CT_LineEdit \li \l QStyleOptionFrame + \row \li \l CT_MdiControls \li \l QStyleOptionComplex + \row \li \l CT_Menu \li \l QStyleOption + \row \li \l CT_MenuItem \li \l QStyleOptionMenuItem + \row \li \l CT_MenuBar \li \l QStyleOptionMenuItem + \row \li \l CT_MenuBarItem \li \l QStyleOptionMenuItem + \row \li \l CT_ProgressBar \li \l QStyleOptionProgressBar + \row \li \l CT_PushButton \li \l QStyleOptionButton + \row \li \l CT_RadioButton \li \l QStyleOptionButton + \row \li \l CT_ScrollBar \li \l QStyleOptionSlider + \row \li \l CT_SizeGrip \li \l QStyleOption + \row \li \l CT_Slider \li \l QStyleOptionSlider + \row \li \l CT_SpinBox \li \l QStyleOptionSpinBox + \row \li \l CT_Splitter \li \l QStyleOption + \row \li \l CT_TabBarTab \li \l QStyleOptionTab + \row \li \l CT_TabWidget \li \l QStyleOptionTabWidgetFrame + \row \li \l CT_ToolButton \li \l QStyleOptionToolButton \endtable \sa ContentsType, QStyleOption diff --git a/src/widgets/styles/qwindowsvistastyle.cpp b/src/widgets/styles/qwindowsvistastyle.cpp index 6c7b71bd74..3d77e39ce8 100644 --- a/src/widgets/styles/qwindowsvistastyle.cpp +++ b/src/widgets/styles/qwindowsvistastyle.cpp @@ -1206,11 +1206,13 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption if (!proxy()->styleHint(SH_UnderlineShortcut, mbi, widget)) alignment |= Qt::TextHideMnemonic; - //The rect adjustment is a workaround for the menu not really filling its background. - XPThemeData theme(widget, painter, - QWindowsXPStylePrivate::MenuTheme, - MENU_BARBACKGROUND, 0, option->rect.adjusted(-1, 0, 2, 1)); - d->drawBackground(theme); + if (widget) { // Not needed for QtQuick Controls + //The rect adjustment is a workaround for the menu not really filling its background. + XPThemeData theme(widget, painter, + QWindowsXPStylePrivate::MenuTheme, + MENU_BARBACKGROUND, 0, option->rect.adjusted(-1, 0, 2, 1)); + d->drawBackground(theme); + } int stateId = MBI_NORMAL; if (disabled) @@ -1281,7 +1283,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption } QRect vCheckRect = visualRect(option->direction, menuitem->rect, QRect(menuitem->rect.x(), - menuitem->rect.y(), checkcol - 6, menuitem->rect.height())); + menuitem->rect.y(), checkcol - (3 + menuitem->rect.x()), menuitem->rect.height())); if (act) { stateId = dis ? MBI_DISABLED : MBI_HOT; diff --git a/src/widgets/widgets/qdatetimeedit.cpp b/src/widgets/widgets/qdatetimeedit.cpp index 7a723c5f1f..770c954c2a 100644 --- a/src/widgets/widgets/qdatetimeedit.cpp +++ b/src/widgets/widgets/qdatetimeedit.cpp @@ -993,7 +993,7 @@ QSize QDateTimeEdit::sizeHint() const QSize hint(w, h); -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC if (d->calendarPopupEnabled()) { QStyleOptionComboBox opt; d->cachedSizeHint = style()->sizeFromContents(QStyle::CT_ComboBox, &opt, hint, this); diff --git a/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm b/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm index a94273c574..965e9301e9 100644 --- a/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm +++ b/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm @@ -164,7 +164,7 @@ NSView *QMacCocoaViewContainer::cocoaView() const } /*! - Sets the NSView to contain to be \a cocoaViewToWrap and retains it. If this + Sets \a view as the NSView to contain and retains it. If this container already had a view set, it will release the previously set view. */ void QMacCocoaViewContainer::setCocoaView(NSView *view) |