diff options
author | Liang Qi <liang.qi@theqtcompany.com> | 2016-02-11 12:57:10 +0000 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2016-02-11 12:57:10 +0000 |
commit | 321658d288b8f790ecfe5ab5198bf6c0d27f0f73 (patch) | |
tree | 24a4be4408ad31f82f4f1c3374c66dd986148844 /src/widgets | |
parent | 7e85e7ced7079d620ae73f8664a68530992c6af1 (diff) | |
parent | d456f87ece0323982b7601047712545ab95426ad (diff) |
Merge "Merge remote-tracking branch 'origin/5.6' into dev" into refs/staging/dev
Diffstat (limited to 'src/widgets')
-rw-r--r-- | src/widgets/dialogs/qsidebar.cpp | 1 | ||||
-rw-r--r-- | src/widgets/dialogs/qwizard.h | 2 | ||||
-rw-r--r-- | src/widgets/graphicsview/qgraphicswidget.cpp | 1 | ||||
-rw-r--r-- | src/widgets/kernel/qapplication.cpp | 3 | ||||
-rw-r--r-- | src/widgets/kernel/qwidget.cpp | 23 | ||||
-rw-r--r-- | src/widgets/kernel/qwidgetbackingstore.cpp | 6 | ||||
-rw-r--r-- | src/widgets/styles/qwindowsvistastyle.cpp | 48 | ||||
-rw-r--r-- | src/widgets/styles/qwindowsxpstyle.cpp | 38 | ||||
-rw-r--r-- | src/widgets/styles/qwindowsxpstyle_p_p.h | 1 | ||||
-rw-r--r-- | src/widgets/widgets/qdatetimeedit.cpp | 6 | ||||
-rw-r--r-- | src/widgets/widgets/qdockarealayout.cpp | 5 | ||||
-rw-r--r-- | src/widgets/widgets/qdockwidget.cpp | 2 |
12 files changed, 73 insertions, 63 deletions
diff --git a/src/widgets/dialogs/qsidebar.cpp b/src/widgets/dialogs/qsidebar.cpp index df1e61be1c..2e884e238d 100644 --- a/src/widgets/dialogs/qsidebar.cpp +++ b/src/widgets/dialogs/qsidebar.cpp @@ -466,6 +466,7 @@ void QSidebar::removeEntry() QList<QModelIndex> idxs = selectionModel()->selectedIndexes(); QList<QPersistentModelIndex> indexes; const int numIndexes = idxs.count(); + indexes.reserve(numIndexes); for (int i = 0; i < numIndexes; i++) indexes.append(idxs.at(i)); diff --git a/src/widgets/dialogs/qwizard.h b/src/widgets/dialogs/qwizard.h index 4049bd10f2..a188833ef3 100644 --- a/src/widgets/dialogs/qwizard.h +++ b/src/widgets/dialogs/qwizard.h @@ -188,7 +188,7 @@ protected: void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE; void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; #ifdef Q_OS_WIN - bool nativeEvent(const QByteArray &eventType, void * message, long * result); + bool nativeEvent(const QByteArray &eventType, void *message, long *result) Q_DECL_OVERRIDE; #endif void done(int result) Q_DECL_OVERRIDE; virtual void initializePage(int id); diff --git a/src/widgets/graphicsview/qgraphicswidget.cpp b/src/widgets/graphicsview/qgraphicswidget.cpp index 7f76ceedfd..bb6d867280 100644 --- a/src/widgets/graphicsview/qgraphicswidget.cpp +++ b/src/widgets/graphicsview/qgraphicswidget.cpp @@ -313,6 +313,7 @@ void QGraphicsWidget::resize(const QSizeF &size) \fn void QGraphicsWidget::resize(qreal w, qreal h) \overload + Constructs a resize with the given \c width (\a w) and \c height (\a h). This convenience function is equivalent to calling resize(QSizeF(w, h)). \sa setGeometry(), setTransform() diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index c431e0bcd6..ebdbdbd3e6 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -3154,9 +3154,8 @@ bool QApplication::notify(QObject *receiver, QEvent *e) case QEvent::KeyRelease: { bool isWidget = receiver->isWidgetType(); - bool isGraphicsWidget = false; #ifndef QT_NO_GRAPHICSVIEW - isGraphicsWidget = !isWidget && qobject_cast<QGraphicsWidget *>(receiver); + const bool isGraphicsWidget = !isWidget && qobject_cast<QGraphicsWidget *>(receiver); #endif QKeyEvent* key = static_cast<QKeyEvent*>(e); bool def = key->isAccepted(); diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index d123bba1d9..7e2e02b58e 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -6443,13 +6443,13 @@ bool QWidget::hasFocus() const const QWidget* w = this; while (w->d_func()->extra && w->d_func()->extra->focus_proxy) w = w->d_func()->extra->focus_proxy; - if (QWidget *window = w->window()) { #ifndef QT_NO_GRAPHICSVIEW + if (QWidget *window = w->window()) { QWExtra *e = window->d_func()->extra; if (e && e->proxyWidget && e->proxyWidget->hasFocus() && window->focusWidget() == w) return true; -#endif } +#endif // !QT_NO_GRAPHICSVIEW return (QApplication::focusWidget() == w); } @@ -7946,8 +7946,11 @@ void QWidgetPrivate::show_sys() invalidateBuffer(q->rect()); q->setAttribute(Qt::WA_Mapped); // add our window the modal window list (native dialogs) - if ((q->isWindow() && (!extra || !extra->proxyWidget)) - && q->windowModality() != Qt::NonModal && window) { + if (window && q->isWindow() +#ifndef QT_NO_GRAPHICSVIEW + && (!extra || !extra->proxyWidget) +#endif + && q->windowModality() != Qt::NonModal) { QGuiApplicationPrivate::showModalWindow(window); } return; @@ -8081,8 +8084,11 @@ void QWidgetPrivate::hide_sys() if (q->testAttribute(Qt::WA_DontShowOnScreen)) { q->setAttribute(Qt::WA_Mapped, false); // remove our window from the modal window list (native dialogs) - if ((q->isWindow() && (!extra || !extra->proxyWidget)) - && q->windowModality() != Qt::NonModal && window) { + if (window && q->isWindow() +#ifndef QT_NO_GRAPHICSVIEW + && (!extra || !extra->proxyWidget) +#endif + && q->windowModality() != Qt::NonModal) { QGuiApplicationPrivate::hideModalWindow(window); } // do not return here, if window non-zero, we must hide it @@ -12875,9 +12881,8 @@ void QWidget::setMask(const QRegion &newMask) void QWidgetPrivate::setMask_sys(const QRegion ®ion) { Q_Q(QWidget); - if (const QWindow *window = q->windowHandle()) - if (QPlatformWindow *platformWindow = window->handle()) - platformWindow->setMask(QHighDpi::toNativeLocalRegion(region, window)); + if (QWindow *window = q->windowHandle()) + window->setMask(region); } /*! diff --git a/src/widgets/kernel/qwidgetbackingstore.cpp b/src/widgets/kernel/qwidgetbackingstore.cpp index e6dc579f67..38b23ec439 100644 --- a/src/widgets/kernel/qwidgetbackingstore.cpp +++ b/src/widgets/kernel/qwidgetbackingstore.cpp @@ -1248,13 +1248,15 @@ void QWidgetBackingStore::doSync() // OpenGL content changes. Check if we have such widgets in the special // dirty list. QVarLengthArray<QWidget *, 16> paintPending; - for (int i = 0; i < dirtyRenderToTextureWidgets.count(); ++i) { + const int numPaintPending = dirtyRenderToTextureWidgets.count(); + paintPending.reserve(numPaintPending); + for (int i = 0; i < numPaintPending; ++i) { QWidget *w = dirtyRenderToTextureWidgets.at(i); paintPending << w; resetWidget(w); } dirtyRenderToTextureWidgets.clear(); - for (int i = 0; i < paintPending.count(); ++i) { + for (int i = 0; i < numPaintPending; ++i) { QWidget *w = paintPending[i]; w->d_func()->sendPaintEvent(w->rect()); if (w != tlw) { diff --git a/src/widgets/styles/qwindowsvistastyle.cpp b/src/widgets/styles/qwindowsvistastyle.cpp index 3136118cdd..c8ecc3f192 100644 --- a/src/widgets/styles/qwindowsvistastyle.cpp +++ b/src/widgets/styles/qwindowsvistastyle.cpp @@ -219,6 +219,26 @@ void QWindowsVistaAnimation::paint(QPainter *painter, const QStyleOption *option painter->drawImage(option->rect, currentImage()); } +static inline bool supportsStateTransition(QStyle::PrimitiveElement element, + const QStyleOption *option, + const QWidget *widget) +{ + bool result = false; + switch (element) { + case QStyle::PE_IndicatorRadioButton: + case QStyle::PE_IndicatorCheckBox: + result = true; + break; + // QTBUG-40634, do not animate when color is set in palette for PE_PanelLineEdit. + case QStyle::PE_FrameLineEdit: + result = !QWindowsXPStylePrivate::isLineEditBaseColorSet(option, widget); + break; + default: + break; + } + return result; +} + /*! \internal @@ -249,6 +269,7 @@ void QWindowsVistaAnimation::paint(QPainter *painter, const QStyleOption *option starting image for the hover transition. */ + void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const { @@ -265,11 +286,7 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt QRect oldRect; QRect newRect; - /* widgets that support state transitions : */ - if ( element == PE_FrameLineEdit - || element == PE_IndicatorRadioButton - || element == PE_IndicatorCheckBox) - { + if (supportsStateTransition(element, option, widget)) { // Retrieve and update the dynamic properties tracking // the previous state of the widget: QObject *styleObject = option->styleObject; @@ -504,26 +521,9 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt case PE_PanelLineEdit: if (const QStyleOptionFrame *panel = qstyleoption_cast<const QStyleOptionFrame *>(option)) { - QBrush bg; - bool usePalette = false; bool isEnabled = option->state & State_Enabled; - uint resolve_mask = panel->palette.resolve(); - if (widget) { - // Since spin box includes a line edit we need to resolve the palette mask also from - // the parent, as while the color is always correct on the palette supplied by panel, - // the mask can still be empty. If either mask specifies custom base color, use that. -#ifndef QT_NO_SPINBOX - if (QAbstractSpinBox *spinbox = qobject_cast<QAbstractSpinBox*>(widget->parentWidget())) - resolve_mask |= spinbox->palette().resolve(); -#endif // QT_NO_SPINBOX - } - if (resolve_mask & (1 << QPalette::Base)) { - // Base color is set for this widget, so use it - bg = panel->palette.brush(QPalette::Base); - usePalette = true; - } - if (usePalette) { - painter->fillRect(panel->rect, bg); + if (QWindowsXPStylePrivate::isLineEditBaseColorSet(option, widget)) { + painter->fillRect(panel->rect, panel->palette.brush(QPalette::Base)); } else { int partId = EP_BACKGROUND; int stateId = EBS_NORMAL; diff --git a/src/widgets/styles/qwindowsxpstyle.cpp b/src/widgets/styles/qwindowsxpstyle.cpp index 7529bcaafb..fecfb02782 100644 --- a/src/widgets/styles/qwindowsxpstyle.cpp +++ b/src/widgets/styles/qwindowsxpstyle.cpp @@ -377,6 +377,22 @@ bool QWindowsXPStylePrivate::isItemViewDelegateLineEdit(const QWidget *widget) && parent2->inherits("QAbstractItemView"); } +// Returns whether base color is set for this widget +bool QWindowsXPStylePrivate::isLineEditBaseColorSet(const QStyleOption *option, const QWidget *widget) +{ + uint resolveMask = option->palette.resolve(); + if (widget) { + // Since spin box includes a line edit we need to resolve the palette mask also from + // the parent, as while the color is always correct on the palette supplied by panel, + // the mask can still be empty. If either mask specifies custom base color, use that. +#ifndef QT_NO_SPINBOX + if (const QAbstractSpinBox *spinbox = qobject_cast<QAbstractSpinBox*>(widget->parentWidget())) + resolveMask |= spinbox->palette().resolve(); +#endif // QT_NO_SPINBOX + } + return (resolveMask & (1 << QPalette::Base)) != 0; +} + /*! \internal This function will always return a valid window handle, and might create a limbo widget to do so. @@ -1606,30 +1622,12 @@ case PE_Frame: themeNumber = QWindowsXPStylePrivate::EditTheme; partId = EP_EDITTEXT; noBorder = true; - QBrush bg; - bool usePalette = false; bool isEnabled = flags & State_Enabled; - uint resolve_mask = panel->palette.resolve(); - -#ifndef QT_NO_SPINBOX - // Since spin box includes a line edit we need to resolve the palette mask also from - // the parent, as while the color is always correct on the palette supplied by panel, - // the mask can still be empty. If either mask specifies custom base color, use that. - if (widget) { - if (QAbstractSpinBox *spinbox = qobject_cast<QAbstractSpinBox*>(widget->parentWidget())) - resolve_mask |= spinbox->palette().resolve(); - } -#endif // QT_NO_SPINBOX - if (resolve_mask & (1 << QPalette::Base)) { - // Base color is set for this widget, so use it - bg = panel->palette.brush(QPalette::Base); - usePalette = true; - } stateId = isEnabled ? ETS_NORMAL : ETS_DISABLED; - if (usePalette) { - p->fillRect(panel->rect, bg); + if (QWindowsXPStylePrivate::isLineEditBaseColorSet(option, widget)) { + p->fillRect(panel->rect, panel->palette.brush(QPalette::Base)); } else { XPThemeData theme(0, p, themeNumber, partId, stateId, rect); if (!theme.isValid()) { diff --git a/src/widgets/styles/qwindowsxpstyle_p_p.h b/src/widgets/styles/qwindowsxpstyle_p_p.h index b88e171e99..7daef62ce0 100644 --- a/src/widgets/styles/qwindowsxpstyle_p_p.h +++ b/src/widgets/styles/qwindowsxpstyle_p_p.h @@ -421,6 +421,7 @@ public: static QString themeName(int theme); static inline bool hasTheme(int theme) { return theme >= 0 && theme < NThemes && m_themes[theme]; } static bool isItemViewDelegateLineEdit(const QWidget *widget); + static bool isLineEditBaseColorSet(const QStyleOption *option, const QWidget *widget); QIcon dockFloat, dockClose; diff --git a/src/widgets/widgets/qdatetimeedit.cpp b/src/widgets/widgets/qdatetimeedit.cpp index 2efccdeaf2..c3f9198598 100644 --- a/src/widgets/widgets/qdatetimeedit.cpp +++ b/src/widgets/widgets/qdatetimeedit.cpp @@ -879,7 +879,7 @@ void QDateTimeEdit::setDisplayFormat(const QString &format) d->displayFormat.clear(); for (int i=d->sectionNodes.size() - 1; i>=0; --i) { d->displayFormat += d->separators.at(i + 1); - d->displayFormat += d->sectionFormat(i); + d->displayFormat += d->sectionNode(i).format(); } d->displayFormat += d->separators.at(0); d->separators = reverse(d->separators); @@ -2220,9 +2220,9 @@ void QDateTimeEditPrivate::_q_editorCursorPositionChanged(int oldpos, int newpos } } - QDTEDEBUG << "currentSectionIndex is set to" << sectionName(sectionType(s)) + QDTEDEBUG << "currentSectionIndex is set to" << sectionNode(s).name() << oldpos << newpos - << "was" << sectionName(sectionType(currentSectionIndex)); + << "was" << sectionNode(currentSectionIndex).name(); currentSectionIndex = s; Q_ASSERT_X(currentSectionIndex < sectionNodes.size(), diff --git a/src/widgets/widgets/qdockarealayout.cpp b/src/widgets/widgets/qdockarealayout.cpp index 69be43a51e..29089311c6 100644 --- a/src/widgets/widgets/qdockarealayout.cpp +++ b/src/widgets/widgets/qdockarealayout.cpp @@ -3356,8 +3356,9 @@ QSet<QTabBar*> QDockAreaLayout::usedTabBars() const QSet<QWidget*> QDockAreaLayout::usedSeparatorWidgets() const { QSet<QWidget*> result; - - for (int i = 0; i < separatorWidgets.count(); ++i) + const int numSeparators = separatorWidgets.count(); + result.reserve(numSeparators); + for (int i = 0; i < numSeparators; ++i) result << separatorWidgets.at(i); for (int i = 0; i < QInternal::DockCount; ++i) { const QDockAreaLayoutInfo &dock = docks[i]; diff --git a/src/widgets/widgets/qdockwidget.cpp b/src/widgets/widgets/qdockwidget.cpp index 7eaab2f7ba..03faca157f 100644 --- a/src/widgets/widgets/qdockwidget.cpp +++ b/src/widgets/widgets/qdockwidget.cpp @@ -1451,6 +1451,8 @@ bool QDockWidget::event(QEvent *event) switch (event->type()) { #ifndef QT_NO_ACTION case QEvent::Hide: + if (d->state && d->state->dragging) + d->endDrag(true); if (layout != 0) layout->keepSize(this); d->toggleViewAction->setChecked(false); |