summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/dialogs/qsidebar.cpp1
-rw-r--r--src/widgets/dialogs/qwizard.h2
-rw-r--r--src/widgets/graphicsview/qgraphicswidget.cpp1
-rw-r--r--src/widgets/kernel/qapplication.cpp3
-rw-r--r--src/widgets/kernel/qwidget.cpp23
-rw-r--r--src/widgets/kernel/qwidgetbackingstore.cpp6
-rw-r--r--src/widgets/styles/qwindowsvistastyle.cpp48
-rw-r--r--src/widgets/styles/qwindowsxpstyle.cpp38
-rw-r--r--src/widgets/styles/qwindowsxpstyle_p_p.h1
-rw-r--r--src/widgets/widgets/qdatetimeedit.cpp6
-rw-r--r--src/widgets/widgets/qdockarealayout.cpp5
-rw-r--r--src/widgets/widgets/qdockwidget.cpp2
12 files changed, 73 insertions, 63 deletions
diff --git a/src/widgets/dialogs/qsidebar.cpp b/src/widgets/dialogs/qsidebar.cpp
index f883705cc3..645f418c4e 100644
--- a/src/widgets/dialogs/qsidebar.cpp
+++ b/src/widgets/dialogs/qsidebar.cpp
@@ -460,6 +460,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 9193f0b659..e0bb1459d5 100644
--- a/src/widgets/dialogs/qwizard.h
+++ b/src/widgets/dialogs/qwizard.h
@@ -182,7 +182,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 8ffb60411c..cd651e2897 100644
--- a/src/widgets/graphicsview/qgraphicswidget.cpp
+++ b/src/widgets/graphicsview/qgraphicswidget.cpp
@@ -306,6 +306,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 91302d9e62..3ab477ccfb 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -3161,9 +3161,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 5bff30524a..7bd4920ff1 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -6415,13 +6415,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);
}
@@ -7918,8 +7918,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;
@@ -8053,8 +8056,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
@@ -12842,9 +12848,8 @@ void QWidget::setMask(const QRegion &newMask)
void QWidgetPrivate::setMask_sys(const QRegion &region)
{
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 334b6cd463..bfa1d69fa8 100644
--- a/src/widgets/kernel/qwidgetbackingstore.cpp
+++ b/src/widgets/kernel/qwidgetbackingstore.cpp
@@ -1249,13 +1249,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 3fa0fc899d..d900e4d181 100644
--- a/src/widgets/styles/qwindowsvistastyle.cpp
+++ b/src/widgets/styles/qwindowsvistastyle.cpp
@@ -213,6 +213,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
@@ -243,6 +263,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
{
@@ -259,11 +280,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;
@@ -498,26 +515,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 c350e82c69..5b01312dfb 100644
--- a/src/widgets/styles/qwindowsxpstyle.cpp
+++ b/src/widgets/styles/qwindowsxpstyle.cpp
@@ -371,6 +371,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.
@@ -1600,30 +1616,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 5ee418f278..5a0abc1d78 100644
--- a/src/widgets/styles/qwindowsxpstyle_p_p.h
+++ b/src/widgets/styles/qwindowsxpstyle_p_p.h
@@ -415,6 +415,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 abee788a46..7ed4564654 100644
--- a/src/widgets/widgets/qdatetimeedit.cpp
+++ b/src/widgets/widgets/qdatetimeedit.cpp
@@ -873,7 +873,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);
@@ -2214,9 +2214,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 df26db57ae..2823bd6f2f 100644
--- a/src/widgets/widgets/qdockarealayout.cpp
+++ b/src/widgets/widgets/qdockarealayout.cpp
@@ -3350,8 +3350,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 67eb466ba8..da6c3431ff 100644
--- a/src/widgets/widgets/qdockwidget.cpp
+++ b/src/widgets/widgets/qdockwidget.cpp
@@ -1445,6 +1445,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);