summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@theqtcompany.com>2014-10-27 13:00:36 +0100
committerFrederik Gladhorn <frederik.gladhorn@theqtcompany.com>2014-10-27 13:00:36 +0100
commit2eb26c170920d28213b71e549d5dac4663febb14 (patch)
tree8df5223ac114d758c2112a8fc787992175556418 /src/widgets
parent49ddae28e0dcd1c59dd5d742cffedd5290d1224a (diff)
parent81998b4e8e440076bd22a9164f0a93481c0e597a (diff)
Merge remote-tracking branch 'origin/5.4' into dev
Conflicts: src/gui/text/qfontdatabase.cpp Change-Id: I6ac1f55faa22b8e7b591386fb67f0333d0ea443d
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/dialogs/qfontdialog.cpp1
-rw-r--r--src/widgets/dialogs/qwizard_win.cpp5
-rw-r--r--src/widgets/doc/snippets/customstyle/customstyle.cpp2
-rw-r--r--src/widgets/doc/snippets/customstyle/customstyle.h2
-rw-r--r--src/widgets/doc/snippets/customstyle/customstyle.pro1
-rw-r--r--src/widgets/doc/snippets/customstyle/main.cpp2
-rw-r--r--src/widgets/doc/snippets/customviewstyle.cpp2
-rw-r--r--src/widgets/graphicsview/qgraphicsgridlayoutengine.cpp20
-rw-r--r--src/widgets/graphicsview/qgraphicsgridlayoutengine_p.h4
-rw-r--r--src/widgets/graphicsview/qgraphicsitem.cpp2
-rw-r--r--src/widgets/graphicsview/qgraphicsscene.cpp2
-rw-r--r--src/widgets/graphicsview/qgraphicsview.cpp2
-rw-r--r--src/widgets/graphicsview/qgraphicswidget.cpp4
-rw-r--r--src/widgets/itemviews/qabstractitemview.cpp1
-rw-r--r--src/widgets/kernel/qlayout.cpp9
-rw-r--r--src/widgets/kernel/qstandardgestures.cpp4
-rw-r--r--src/widgets/kernel/qwidget.cpp38
-rw-r--r--src/widgets/styles/qmacstyle_mac.mm2
-rw-r--r--src/widgets/styles/qstyle.cpp12
-rw-r--r--src/widgets/styles/qstylesheetstyle.cpp14
-rw-r--r--src/widgets/styles/qwindowsvistastyle.cpp22
-rw-r--r--src/widgets/styles/qwindowsxpstyle.cpp33
-rw-r--r--src/widgets/styles/qwindowsxpstyle_p_p.h1
-rw-r--r--src/widgets/widgets/qcalendarwidget.cpp3
-rw-r--r--src/widgets/widgets/qcombobox.cpp29
-rw-r--r--src/widgets/widgets/qcombobox_p.h6
-rw-r--r--src/widgets/widgets/qdockarealayout.cpp6
-rw-r--r--src/widgets/widgets/qwidgetlinecontrol.cpp7
28 files changed, 148 insertions, 88 deletions
diff --git a/src/widgets/dialogs/qfontdialog.cpp b/src/widgets/dialogs/qfontdialog.cpp
index 109b726880..d12b109d9f 100644
--- a/src/widgets/dialogs/qfontdialog.cpp
+++ b/src/widgets/dialogs/qfontdialog.cpp
@@ -322,6 +322,7 @@ void QFontDialogPrivate::init()
familyList->setFocus();
retranslateStrings();
+ sampleEdit->setObjectName(QLatin1String("qt_fontDialog_sampleEdit"));
}
/*!
diff --git a/src/widgets/dialogs/qwizard_win.cpp b/src/widgets/dialogs/qwizard_win.cpp
index 6a09f9c273..69761473fc 100644
--- a/src/widgets/dialogs/qwizard_win.cpp
+++ b/src/widgets/dialogs/qwizard_win.cpp
@@ -653,10 +653,7 @@ HFONT QVistaHelper::getCaptionFont(HANDLE hTheme)
{
LOGFONT lf = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0 } };
- if (!hTheme)
- pGetThemeSysFont(hTheme, WIZ_TMT_CAPTIONFONT, &lf);
- else
- {
+ if (!hTheme || FAILED(pGetThemeSysFont(hTheme, WIZ_TMT_CAPTIONFONT, &lf))) {
NONCLIENTMETRICS ncm;
ncm.cbSize = sizeof(NONCLIENTMETRICS);
SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, false);
diff --git a/src/widgets/doc/snippets/customstyle/customstyle.cpp b/src/widgets/doc/snippets/customstyle/customstyle.cpp
index b5d44ebecd..16715929a8 100644
--- a/src/widgets/doc/snippets/customstyle/customstyle.cpp
+++ b/src/widgets/doc/snippets/customstyle/customstyle.cpp
@@ -45,7 +45,7 @@
CustomStyle::CustomStyle()
{
//! [0]
- QSpinBox *spinBox = qobject_cast<QSpinBox *>(widget);
+ const QSpinBox *spinBox = qobject_cast<const QSpinBox *>(widget);
if (spinBox) {
//! [0] //! [1]
}
diff --git a/src/widgets/doc/snippets/customstyle/customstyle.h b/src/widgets/doc/snippets/customstyle/customstyle.h
index 0f23efc922..0782bdc09c 100644
--- a/src/widgets/doc/snippets/customstyle/customstyle.h
+++ b/src/widgets/doc/snippets/customstyle/customstyle.h
@@ -49,7 +49,7 @@ class CustomStyle : public QProxyStyle
Q_OBJECT
public:
- CustomStyle()
+ CustomStyle();
~CustomStyle() {}
void drawPrimitive(PrimitiveElement element, const QStyleOption *option,
diff --git a/src/widgets/doc/snippets/customstyle/customstyle.pro b/src/widgets/doc/snippets/customstyle/customstyle.pro
index af0ee4e141..02b9b2791d 100644
--- a/src/widgets/doc/snippets/customstyle/customstyle.pro
+++ b/src/widgets/doc/snippets/customstyle/customstyle.pro
@@ -1,2 +1,3 @@
+QT += widgets
HEADERS += customstyle.h
SOURCES += customstyle.cpp main.cpp
diff --git a/src/widgets/doc/snippets/customstyle/main.cpp b/src/widgets/doc/snippets/customstyle/main.cpp
index 19fb6b2be9..8164a1e877 100644
--- a/src/widgets/doc/snippets/customstyle/main.cpp
+++ b/src/widgets/doc/snippets/customstyle/main.cpp
@@ -39,7 +39,7 @@
****************************************************************************/
//! [using a custom style]
-#include <QtGui>
+#include <QtWidgets>
#include "customstyle.h"
diff --git a/src/widgets/doc/snippets/customviewstyle.cpp b/src/widgets/doc/snippets/customviewstyle.cpp
index cdb4ed1d77..0e641653aa 100644
--- a/src/widgets/doc/snippets/customviewstyle.cpp
+++ b/src/widgets/doc/snippets/customviewstyle.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "customviewstyle.h"
diff --git a/src/widgets/graphicsview/qgraphicsgridlayoutengine.cpp b/src/widgets/graphicsview/qgraphicsgridlayoutengine.cpp
index 3d9c5d6de5..c9b2ecd62c 100644
--- a/src/widgets/graphicsview/qgraphicsgridlayoutengine.cpp
+++ b/src/widgets/graphicsview/qgraphicsgridlayoutengine.cpp
@@ -38,9 +38,29 @@
#include "qgraphicslayoutitem_p.h"
#include "qgraphicslayout_p.h"
#include "qgraphicswidget.h"
+#include <private/qgraphicswidget_p.h>
QT_BEGIN_NAMESPACE
+bool QGraphicsGridLayoutEngineItem::isHidden() const
+{
+ if (QGraphicsItem *item = q_layoutItem->graphicsItem())
+ return QGraphicsItemPrivate::get(item)->explicitlyHidden;
+ return false;
+}
+
+/*!
+ \internal
+
+ If this returns true, the layout will arrange just as if the item was never added to the layout.
+ (Note that this shouldn't lead to a "double spacing" where the item was hidden)
+ ### Qt6: Move to QGraphicsLayoutItem and make virtual
+*/
+bool QGraphicsGridLayoutEngineItem::isIgnored() const
+{
+ return isHidden() && !q_layoutItem->sizePolicy().retainSizeWhenHidden();
+}
+
/*
returns \c true if the size policy returns \c true for either hasHeightForWidth()
or hasWidthForHeight()
diff --git a/src/widgets/graphicsview/qgraphicsgridlayoutengine_p.h b/src/widgets/graphicsview/qgraphicsgridlayoutengine_p.h
index 4d6bdfce0a..07486514f8 100644
--- a/src/widgets/graphicsview/qgraphicsgridlayoutengine_p.h
+++ b/src/widgets/graphicsview/qgraphicsgridlayoutengine_p.h
@@ -82,6 +82,10 @@ public:
return q_layoutItem->effectiveSizeHint(which, constraint);
}
+ bool isHidden() const;
+
+ virtual bool isIgnored() const Q_DECL_OVERRIDE;
+
virtual void setGeometry(const QRectF &rect) Q_DECL_OVERRIDE
{
q_layoutItem->setGeometry(rect);
diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp
index 114c45dc0f..67d135271c 100644
--- a/src/widgets/graphicsview/qgraphicsitem.cpp
+++ b/src/widgets/graphicsview/qgraphicsitem.cpp
@@ -797,7 +797,7 @@ static QPainterPath qt_graphicsItem_shapeFromPath(const QPainterPath &path, cons
// if we pass a value of 0.0 to QPainterPathStroker::setWidth()
const qreal penWidthZero = qreal(0.00000001);
- if (path == QPainterPath())
+ if (path == QPainterPath() || pen == Qt::NoPen)
return path;
QPainterPathStroker ps;
ps.setCapStyle(pen.capStyle());
diff --git a/src/widgets/graphicsview/qgraphicsscene.cpp b/src/widgets/graphicsview/qgraphicsscene.cpp
index fdcb66f69b..8765b8114d 100644
--- a/src/widgets/graphicsview/qgraphicsscene.cpp
+++ b/src/widgets/graphicsview/qgraphicsscene.cpp
@@ -392,7 +392,7 @@ void QGraphicsScenePrivate::_q_emitUpdated()
*/
void QGraphicsScenePrivate::registerTopLevelItem(QGraphicsItem *item)
{
- item->d_ptr->ensureSequentialSiblingIndex();
+ ensureSequentialTopLevelSiblingIndexes();
needSortTopLevelItems = true; // ### maybe false
item->d_ptr->siblingIndex = topLevelItems.size();
topLevelItems.append(item);
diff --git a/src/widgets/graphicsview/qgraphicsview.cpp b/src/widgets/graphicsview/qgraphicsview.cpp
index 88d5e52204..5484ecb96e 100644
--- a/src/widgets/graphicsview/qgraphicsview.cpp
+++ b/src/widgets/graphicsview/qgraphicsview.cpp
@@ -765,7 +765,7 @@ void QGraphicsViewPrivate::updateRubberBand(const QMouseEvent *event)
}
// Set the new selection area
QPainterPath selectionArea;
- selectionArea.addPolygon(mapToScene(rubberBandRect));
+ selectionArea.addPolygon(q->mapToScene(rubberBandRect));
selectionArea.closeSubpath();
if (scene)
scene->setSelectionArea(selectionArea, rubberBandSelectionMode, q->viewportTransform());
diff --git a/src/widgets/graphicsview/qgraphicswidget.cpp b/src/widgets/graphicsview/qgraphicswidget.cpp
index 4a9c3b098e..5bd563e535 100644
--- a/src/widgets/graphicsview/qgraphicswidget.cpp
+++ b/src/widgets/graphicsview/qgraphicswidget.cpp
@@ -1137,6 +1137,10 @@ QVariant QGraphicsWidget::itemChange(GraphicsItemChange change, const QVariant &
setAttribute(Qt::WA_Resized, false);
}
}
+
+ // layout size hint only changes if an item changes from/to explicitly hidden state
+ if (value.toBool() || d->explicitlyHidden)
+ updateGeometry();
break;
case ItemVisibleHasChanged:
if (!value.toBool()) {
diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp
index 3fbb17ff3f..a6361bd750 100644
--- a/src/widgets/itemviews/qabstractitemview.cpp
+++ b/src/widgets/itemviews/qabstractitemview.cpp
@@ -837,6 +837,7 @@ void QAbstractItemView::setItemDelegate(QAbstractItemDelegate *delegate)
}
d->itemDelegate = delegate;
viewport()->update();
+ d->doDelayedItemsLayout();
}
/*!
diff --git a/src/widgets/kernel/qlayout.cpp b/src/widgets/kernel/qlayout.cpp
index 3900444df4..46cab90ab4 100644
--- a/src/widgets/kernel/qlayout.cpp
+++ b/src/widgets/kernel/qlayout.cpp
@@ -1106,15 +1106,6 @@ bool QLayout::activate()
ms.setWidth(mw->minimumSize().width());
if (heightSet)
ms.setHeight(mw->minimumSize().height());
- if ((!heightSet || !widthSet) && hasHeightForWidth()) {
- int h = minimumHeightForWidth(ms.width());
- if (h > ms.height()) {
- if (!heightSet)
- ms.setHeight(0);
- if (!widthSet)
- ms.setWidth(0);
- }
- }
mw->setMinimumSize(ms);
} else if (!widthSet || !heightSet) {
QSize ms = mw->minimumSize();
diff --git a/src/widgets/kernel/qstandardgestures.cpp b/src/widgets/kernel/qstandardgestures.cpp
index 78a2c65060..0822c04033 100644
--- a/src/widgets/kernel/qstandardgestures.cpp
+++ b/src/widgets/kernel/qstandardgestures.cpp
@@ -341,10 +341,10 @@ QGestureRecognizer::Result QSwipeGestureRecognizer::recognize(QGesture *state,
if (d->horizontalDirection == QSwipeGesture::NoDirection)
d->horizontalDirection = horizontal;
if (d->verticalDirection != vertical || d->horizontalDirection != horizontal) {
- // the user has changed the direction!
result = QGestureRecognizer::CancelGesture;
+ } else {
+ result = QGestureRecognizer::TriggerGesture;
}
- result = QGestureRecognizer::TriggerGesture;
} else {
if (q->state() != Qt::NoGesture)
result = QGestureRecognizer::TriggerGesture;
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index af1745d845..63497ce745 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -1360,11 +1360,11 @@ void q_createNativeChildrenAndSetParent(const QWidget *parentWidget)
if (!childWidget->internalWinId())
childWidget->winId();
if (childWidget->windowHandle()) {
- QWindow *parentWindow = childWidget->nativeParentWidget()->windowHandle();
- if (childWidget->isWindow())
- childWidget->windowHandle()->setTransientParent(parentWindow);
- else
- childWidget->windowHandle()->setParent(parentWindow);
+ if (childWidget->isWindow()) {
+ childWidget->windowHandle()->setTransientParent(parentWidget->window()->windowHandle());
+ } else {
+ childWidget->windowHandle()->setParent(childWidget->nativeParentWidget()->windowHandle());
+ }
}
} else {
q_createNativeChildrenAndSetParent(childWidget);
@@ -1401,10 +1401,8 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
win->setProperty(propertyName, q->property(propertyName));
}
-#ifdef Q_OS_OSX
if (q->testAttribute(Qt::WA_ShowWithoutActivating))
win->setProperty("_q_showWithoutActivating", QVariant(true));
-#endif
win->setFlags(data.window_flags);
fixPosIncludesFrame();
if (q->testAttribute(Qt::WA_Moved)
@@ -9663,6 +9661,10 @@ QVariant QWidget::inputMethodQuery(Qt::InputMethodQuery query) const
is set, the input method may change its visual components to reflect
that only numbers can be entered.
+ \warning Some widgets require certain flags in order to work as
+ intended. To set a flag, do \c{w->setInputMethodHints(w->inputMethodHints()|f)}
+ instead of \c{w->setInputMethodHints(f)}.
+
\note The flags are only hints, so the particular input method
implementation is free to ignore them. If you want to be
sure that a certain type of characters are entered,
@@ -12250,6 +12252,17 @@ QPaintEngine *QWidget::paintEngine() const
*/
QPoint QWidget::mapToGlobal(const QPoint &pos) const
{
+#ifndef QT_NO_GRAPHICSVIEW
+ Q_D(const QWidget);
+ if (d->extra && d->extra->proxyWidget) {
+ const QList <QGraphicsView *> views = d->extra->proxyWidget->scene()->views();
+ if (!views.isEmpty()) {
+ const QPointF scenePos = d->extra->proxyWidget->mapToScene(pos);
+ const QPoint viewPortPos = views.first()->mapFromScene(scenePos);
+ return views.first()->viewport()->mapToGlobal(viewPortPos);
+ }
+ }
+#endif // !QT_NO_GRAPHICSVIEW
int x = pos.x(), y = pos.y();
const QWidget *w = this;
while (w) {
@@ -12274,6 +12287,17 @@ QPoint QWidget::mapToGlobal(const QPoint &pos) const
*/
QPoint QWidget::mapFromGlobal(const QPoint &pos) const
{
+#ifndef QT_NO_GRAPHICSVIEW
+ Q_D(const QWidget);
+ if (d->extra && d->extra->proxyWidget) {
+ const QList <QGraphicsView *> views = d->extra->proxyWidget->scene()->views();
+ if (!views.isEmpty()) {
+ const QPoint viewPortPos = views.first()->viewport()->mapFromGlobal(pos);
+ const QPointF scenePos = views.first()->mapToScene(viewPortPos);
+ return d->extra->proxyWidget->mapFromScene(scenePos).toPoint();
+ }
+ }
+#endif // !QT_NO_GRAPHICSVIEW
int x = pos.x(), y = pos.y();
const QWidget *w = this;
while (w) {
diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm
index ff0f51ee13..fb0bafa66d 100644
--- a/src/widgets/styles/qmacstyle_mac.mm
+++ b/src/widgets/styles/qmacstyle_mac.mm
@@ -6025,8 +6025,10 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
p->fillPath(path, brush);
} else if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5) {
static QPixmap pm(QLatin1String(":/qt-project.org/mac/style/images/leopard-unified-toolbar-on.png"));
+ p->save();
p->setRenderHint(QPainter::SmoothPixmapTransform);
QStyleHelper::drawBorderPixmap(pm, p, tb->rect, 2, 2, 2, 2);
+ p->restore();
} else {
QPen oldPen = p->pen();
p->setPen(QColor(0, 0, 0, 0x3a));
diff --git a/src/widgets/styles/qstyle.cpp b/src/widgets/styles/qstyle.cpp
index 3affd84124..7c4d239894 100644
--- a/src/widgets/styles/qstyle.cpp
+++ b/src/widgets/styles/qstyle.cpp
@@ -1463,6 +1463,12 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment,
\value PM_TabCloseIndicatorWidth The default width of a close button on a tab in a tab bar.
\value PM_TabCloseIndicatorHeight The default height of a close button on a tab in a tab bar.
+ \value PM_ScrollView_ScrollBarSpacing Distance between frame and scrollbar
+ with SH_ScrollView_FrameOnlyAroundContents set.
+ \value PM_ScrollView_ScrollBarOverlap Overlap between scroll bars and scroll content
+
+ \value PM_SubMenuOverlap The horizontal overlap between a submenu and its parent.
+
\value PM_TreeViewIndentation The indentation of items in a tree view.
This enum value has been introduced in Qt 5.4.
@@ -1483,12 +1489,6 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment,
and PM_LayoutVerticalSpacing
instead.
- \value PM_ScrollView_ScrollBarSpacing Distance between frame and scrollbar
- with SH_ScrollView_FrameOnlyAroundContents set.
- \value PM_ScrollView_ScrollBarOverlap Overlap between scroll bars and scroll content
-
- \value PM_SubMenuOverlap The horizontal overlap between a submenu and its parent.
-
\sa pixelMetric()
*/
diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp
index a6c7f5dde2..e9f20de842 100644
--- a/src/widgets/styles/qstylesheetstyle.cpp
+++ b/src/widgets/styles/qstylesheetstyle.cpp
@@ -4047,26 +4047,28 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
}
if (!dwOpt->title.isEmpty()) {
- QRect r = opt->rect;
+ QRect r = subElementRect(SE_DockWidgetTitleBarText, opt, w);
if (dwOpt->verticalTitleBar) {
QSize s = r.size();
s.transpose();
r.setSize(s);
-
p->save();
p->translate(r.left(), r.top() + r.width());
p->rotate(-90);
p->translate(-r.left(), -r.top());
}
+ r = subRule.contentsRect(r);
Qt::Alignment alignment = 0;
if (subRule.hasPosition())
alignment = subRule.position()->textAlignment;
if (alignment == 0)
alignment = Qt::AlignLeft;
- drawItemText(p, subRule.contentsRect(opt->rect),
+
+ QString titleText = p->fontMetrics().elidedText(dwOpt->title, Qt::ElideRight, r.width());
+ drawItemText(p, r,
alignment | Qt::TextShowMnemonic, dwOpt->palette,
- dwOpt->state & State_Enabled, dwOpt->title,
+ dwOpt->state & State_Enabled, titleText,
QPalette::WindowText);
if (dwOpt->verticalTitleBar)
@@ -5826,6 +5828,10 @@ bool QStyleSheetStyle::event(QEvent *e)
void QStyleSheetStyle::updateStyleSheetFont(QWidget* w) const
{
+ // Qt's fontDialog relies on the font of the sample edit for its selection,
+ // we should never override it.
+ if (w->objectName() == QLatin1String("qt_fontDialog_sampleEdit"))
+ return;
QWidget *container = containerWidget(w);
QRenderRule rule = renderRule(container, PseudoElement_None,
PseudoClass_Active | PseudoClass_Enabled | extendedPseudoClass(container));
diff --git a/src/widgets/styles/qwindowsvistastyle.cpp b/src/widgets/styles/qwindowsvistastyle.cpp
index a6eb2c0bc6..007952192a 100644
--- a/src/widgets/styles/qwindowsvistastyle.cpp
+++ b/src/widgets/styles/qwindowsvistastyle.cpp
@@ -1756,26 +1756,8 @@ void QWindowsVistaStyle::drawComplexControl(ComplexControl control, const QStyle
theme.stateId = stateId;
d->drawBackground(theme);
- // Calculate rect of gripper
- const int swidth = theme.rect.width();
- const int sheight = theme.rect.height();
-
- const QMargins contentsMargin = theme.margins(theme.rect, TMT_SIZINGMARGINS)
- / QWindowsXPStylePrivate::devicePixelRatio(widget);
-
- theme.partId = flags & State_Horizontal ? SBP_GRIPPERHORZ : SBP_GRIPPERVERT;
- const QSize size = theme.size() / QWindowsXPStylePrivate::devicePixelRatio(widget);
-
if (QSysInfo::WindowsVersion < QSysInfo::WV_WINDOWS8) {
- QPoint gripperBoundsPos(0, 0);
- if ((flags & State_Horizontal
- && swidth - contentsMargin.left() - contentsMargin.right() > size.width())
- || sheight - contentsMargin.top() - contentsMargin.bottom() > size.height()) {
- gripperBoundsPos = QPoint(theme.rect.left() + (swidth - size.width()) / 2,
- theme.rect.top() + (sheight - size.height()) / 2);
- }
- const QRect gripperBounds(gripperBoundsPos, size);
-
+ const QRect gripperBounds = QWindowsXPStylePrivate::scrollBarGripperBounds(flags, widget, &theme);
// Draw gripper if there is enough space
if (!gripperBounds.isEmpty() && flags & State_Enabled) {
painter->save();
@@ -2285,7 +2267,7 @@ int QWindowsVistaStyle::pixelMetric(PixelMetric metric, const QStyleOption *opti
if (!QWindowsVistaStylePrivate::useVista())
return QWindowsStyle::pixelMetric(metric, option, widget);
- int ret = QWindowsStylePrivate::fixedPixelMetric(metric);
+ int ret = QWindowsVistaStylePrivate::fixedPixelMetric(metric);
if (ret != QWindowsStylePrivate::InvalidMetric)
return int(QStyleHelper::dpiScaled(ret));
diff --git a/src/widgets/styles/qwindowsxpstyle.cpp b/src/widgets/styles/qwindowsxpstyle.cpp
index 624023f627..c18bbb3431 100644
--- a/src/widgets/styles/qwindowsxpstyle.cpp
+++ b/src/widgets/styles/qwindowsxpstyle.cpp
@@ -2529,6 +2529,20 @@ void QWindowsXPStyle::drawControl(ControlElement element, const QStyleOption *op
d->drawBackground(theme);
}
+QRect QWindowsXPStylePrivate::scrollBarGripperBounds(QStyle::State flags, const QWidget *widget, XPThemeData *theme)
+{
+ const bool horizontal = flags & QStyle::State_Horizontal;
+ const QMargins contentsMargin = theme->margins(theme->rect, TMT_SIZINGMARGINS)
+ / QWindowsStylePrivate::devicePixelRatio(widget);
+ theme->partId = horizontal ? SBP_GRIPPERHORZ : SBP_GRIPPERVERT;
+ const QSize size = theme->size() / QWindowsStylePrivate::devicePixelRatio(widget);
+
+ const int hSpace = theme->rect.width() - size.width();
+ const int vSpace = theme->rect.height() - size.height();
+ const bool sufficientSpace = horizontal && hSpace > (contentsMargin.left() + contentsMargin.right())
+ || vSpace > contentsMargin.top() + contentsMargin.bottom();
+ return sufficientSpace ? QRect(theme->rect.topLeft() + QPoint(hSpace, vSpace) / 2, size) : QRect();
+}
/*!
\reimp
@@ -2754,24 +2768,7 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo
theme.stateId = stateId;
d->drawBackground(theme);
- // Calculate rect of gripper
- const int swidth = theme.rect.width();
- const int sheight = theme.rect.height();
-
- const QMargins contentsMargin = theme.margins(theme.rect, TMT_SIZINGMARGINS)
- / QWindowsStylePrivate::devicePixelRatio(widget);
-
- theme.partId = flags & State_Horizontal ? SBP_GRIPPERHORZ : SBP_GRIPPERVERT;
- const QSize size = theme.size() / QWindowsStylePrivate::devicePixelRatio(widget);
- QPoint gripperBoundsPos(0, 0);
- if ((flags & State_Horizontal
- && swidth - contentsMargin.left() - contentsMargin.right() > size.width())
- || sheight - contentsMargin.top() - contentsMargin.bottom() > size.height()) {
- gripperBoundsPos = QPoint(theme.rect.left() + (swidth - size.width()) / 2,
- theme.rect.top() + (sheight - size.height()) /2);
- }
- const QRect gripperBounds(gripperBoundsPos, size);
-
+ const QRect gripperBounds = QWindowsXPStylePrivate::scrollBarGripperBounds(flags, widget, &theme);
// Draw gripper if there is enough space
if (!gripperBounds.isEmpty()) {
p->save();
diff --git a/src/widgets/styles/qwindowsxpstyle_p_p.h b/src/widgets/styles/qwindowsxpstyle_p_p.h
index 4f42b60681..5027588c93 100644
--- a/src/widgets/styles/qwindowsxpstyle_p_p.h
+++ b/src/widgets/styles/qwindowsxpstyle_p_p.h
@@ -392,6 +392,7 @@ public:
static bool resolveSymbols();
static bool useXP(bool update = false);
+ static QRect scrollBarGripperBounds(QStyle::State flags, const QWidget *widget, XPThemeData *theme);
bool isTransparent(XPThemeData &themeData);
QRegion region(XPThemeData &themeData);
diff --git a/src/widgets/widgets/qcalendarwidget.cpp b/src/widgets/widgets/qcalendarwidget.cpp
index d6704c20d2..fa3dbc1f32 100644
--- a/src/widgets/widgets/qcalendarwidget.cpp
+++ b/src/widgets/widgets/qcalendarwidget.cpp
@@ -2247,6 +2247,9 @@ QSize QCalendarWidget::minimumSizeHint() const
w *= cols;
w = qMax(headerSize.width(), w);
h = (h * rows) + headerSize.height();
+ QMargins cm = contentsMargins();
+ w += cm.left() + cm.right();
+ h += cm.top() + cm.bottom();
d->cachedSizeHint = QSize(w, h);
return d->cachedSizeHint;
}
diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp
index 44e22555db..fda37c49de 100644
--- a/src/widgets/widgets/qcombobox.cpp
+++ b/src/widgets/widgets/qcombobox.cpp
@@ -479,9 +479,9 @@ void QComboBoxPrivateContainer::updateScrollers()
view->verticalScrollBar()->minimum() < view->verticalScrollBar()->maximum()) {
bool needTop = view->verticalScrollBar()->value()
- > (view->verticalScrollBar()->minimum() + spacing());
+ > (view->verticalScrollBar()->minimum() + topMargin());
bool needBottom = view->verticalScrollBar()->value()
- < (view->verticalScrollBar()->maximum() - spacing()*2);
+ < (view->verticalScrollBar()->maximum() - bottomMargin() - topMargin());
if (needTop)
top->show();
else
@@ -572,13 +572,27 @@ void QComboBoxPrivateContainer::setItemView(QAbstractItemView *itemView)
}
/*!
+ Returns the top/bottom vertical margin of the view.
+*/
+int QComboBoxPrivateContainer::topMargin() const
+{
+ if (const QListView *lview = qobject_cast<const QListView*>(view))
+ return lview->spacing();
+#ifndef QT_NO_TABLEVIEW
+ if (const QTableView *tview = qobject_cast<const QTableView*>(view))
+ return tview->showGrid() ? 1 : 0;
+#endif
+ return 0;
+}
+
+/*!
Returns the spacing between the items in the view.
*/
int QComboBoxPrivateContainer::spacing() const
{
QListView *lview = qobject_cast<QListView*>(view);
if (lview)
- return lview->spacing();
+ return 2 * lview->spacing(); // QListView::spacing is the padding around the item.
#ifndef QT_NO_TABLEVIEW
QTableView *tview = qobject_cast<QTableView*>(view);
if (tview)
@@ -1690,8 +1704,6 @@ void QComboBox::setEditable(bool editable)
if (isEditable() == editable)
return;
- d->updateDelegate();
-
QStyleOptionComboBox opt;
initStyleOption(&opt);
if (editable) {
@@ -1712,6 +1724,7 @@ void QComboBox::setEditable(bool editable)
d->lineEdit = 0;
}
+ d->updateDelegate();
d->updateFocusPolicy();
d->viewContainer()->updateTopBottomMargin();
@@ -2528,7 +2541,7 @@ void QComboBox::showPopup()
QModelIndex idx = d->model->index(i, d->modelColumn, parent);
if (!idx.isValid())
continue;
- listHeight += view()->visualRect(idx).height() + container->spacing();
+ listHeight += view()->visualRect(idx).height();
#ifndef QT_NO_TREEVIEW
if (d->model->hasChildren(idx) && treeView && treeView->isExpanded(idx))
toCheck.push(idx);
@@ -2540,12 +2553,14 @@ void QComboBox::showPopup()
}
}
}
+ if (count > 1)
+ listHeight += (count - 1) * container->spacing();
listRect.setHeight(listHeight);
}
{
// add the spacing for the grid on the top and the bottom;
- int heightMargin = 2*container->spacing();
+ int heightMargin = container->topMargin() + container->bottomMargin();
// add the frame of the container
int marginTop, marginBottom;
diff --git a/src/widgets/widgets/qcombobox_p.h b/src/widgets/widgets/qcombobox_p.h
index becdde55ae..4e1b4125ab 100644
--- a/src/widgets/widgets/qcombobox_p.h
+++ b/src/widgets/widgets/qcombobox_p.h
@@ -214,6 +214,8 @@ public:
QAbstractItemView *itemView() const;
void setItemView(QAbstractItemView *itemView);
int spacing() const;
+ int topMargin() const;
+ int bottomMargin() const { return topMargin(); }
void updateTopBottomMargin();
QTimer blockMouseReleaseTimer;
@@ -252,7 +254,7 @@ private:
friend class QComboBox;
};
-class QComboMenuDelegate : public QAbstractItemDelegate
+class Q_AUTOTEST_EXPORT QComboMenuDelegate : public QAbstractItemDelegate
{ Q_OBJECT
public:
QComboMenuDelegate(QObject *parent, QComboBox *cmb) : QAbstractItemDelegate(parent), mCombo(cmb) {}
@@ -281,7 +283,7 @@ private:
// Note that this class is intentionally not using QStyledItemDelegate
// Vista does not use the new theme for combo boxes and there might
// be other side effects from using the new class
-class QComboBoxDelegate : public QItemDelegate
+class Q_AUTOTEST_EXPORT QComboBoxDelegate : public QItemDelegate
{ Q_OBJECT
public:
QComboBoxDelegate(QObject *parent, QComboBox *cmb) : QItemDelegate(parent), mCombo(cmb) {}
diff --git a/src/widgets/widgets/qdockarealayout.cpp b/src/widgets/widgets/qdockarealayout.cpp
index 7ac2791112..702cd8bac9 100644
--- a/src/widgets/widgets/qdockarealayout.cpp
+++ b/src/widgets/widgets/qdockarealayout.cpp
@@ -2575,12 +2575,14 @@ void QDockAreaLayout::getGrid(QVector<QLayoutStruct> *_ver_struct_list,
{
QSize center_hint(0, 0);
QSize center_min(0, 0);
+ QSize center_max(0, 0);
const bool have_central = centralWidgetItem != 0 && !centralWidgetItem->isEmpty();
if (have_central) {
center_hint = centralWidgetRect.size();
if (!center_hint.isValid())
center_hint = centralWidgetItem->sizeHint();
center_min = centralWidgetItem->minimumSize();
+ center_max = centralWidgetItem->maximumSize();
}
QRect center_rect = rect;
@@ -2656,7 +2658,7 @@ void QDockAreaLayout::getGrid(QVector<QLayoutStruct> *_ver_struct_list,
left = (tl_significant && bl_significant) ? left_min.height() : 0;
right = (tr_significant && br_significant) ? right_min.height() : 0;
ver_struct_list[1].minimumSize = qMax(left, center_min.height(), right);
- ver_struct_list[1].maximumSize = have_central ? QWIDGETSIZE_MAX : 0;
+ ver_struct_list[1].maximumSize = center_max.height();
ver_struct_list[1].expansive = have_central;
ver_struct_list[1].empty = docks[QInternal::LeftDock].isEmpty()
&& !have_central
@@ -2717,7 +2719,7 @@ void QDockAreaLayout::getGrid(QVector<QLayoutStruct> *_ver_struct_list,
bottom = (bl_significant && br_significant) ? bottom_min.width() : 0;
hor_struct_list[1].minimumSize = qMax(top, center_min.width(), bottom);
- hor_struct_list[1].maximumSize = have_central ? QWIDGETSIZE_MAX : 0;
+ hor_struct_list[1].maximumSize = center_max.width();
hor_struct_list[1].expansive = have_central;
hor_struct_list[1].empty = !have_central;
hor_struct_list[1].pos = center_rect.left();
diff --git a/src/widgets/widgets/qwidgetlinecontrol.cpp b/src/widgets/widgets/qwidgetlinecontrol.cpp
index 90fbfc1639..a82dd99591 100644
--- a/src/widgets/widgets/qwidgetlinecontrol.cpp
+++ b/src/widgets/widgets/qwidgetlinecontrol.cpp
@@ -1607,6 +1607,13 @@ void QWidgetLineControl::processKeyEvent(QKeyEvent* event)
if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return) {
if (hasAcceptableInput() || fixup()) {
+
+ QInputMethod *inputMethod = QApplication::inputMethod();
+ inputMethod->commit();
+ QWidget *lineEdit = qobject_cast<QWidget *>(parent());
+ if (!(lineEdit && lineEdit->inputMethodHints() & Qt::ImhMultiLine))
+ inputMethod->hide();
+
emit accepted();
emit editingFinished();
}