From 0c28e1ab7a430d56702cb8545320356de3bda711 Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Wed, 14 Jan 2015 19:27:22 +0300 Subject: Fix finding the closest active touch point for the pressed touch point Currently pressed touch point is added to the list of active touch points in Gui module. It must be excluded from consideration when we traverse the list. Task-number: QTBUG-43255 Change-Id: Idddab093b1f6a79122cf18fad7f43bfc93ce7eea Reviewed-by: Shawn Rutledge Reviewed-by: Marc Mutz --- src/widgets/kernel/qapplication.cpp | 7 ++++--- src/widgets/kernel/qapplication_p.h | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index abd0231b00..ba14a06af4 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -4275,15 +4275,16 @@ void QApplicationPrivate::cleanupMultitouch_sys() { } -QWidget *QApplicationPrivate::findClosestTouchPointTarget(QTouchDevice *device, const QPointF &screenPos) +QWidget *QApplicationPrivate::findClosestTouchPointTarget(QTouchDevice *device, const QTouchEvent::TouchPoint &touchPoint) { + const QPointF screenPos = touchPoint.screenPos(); int closestTouchPointId = -1; QObject *closestTarget = 0; qreal closestDistance = qreal(0.); QHash::const_iterator it = activeTouchPoints.constBegin(), ite = activeTouchPoints.constEnd(); while (it != ite) { - if (it.key().device == device) { + if (it.key().device == device && it.key().touchPointId != touchPoint.id()) { const QTouchEvent::TouchPoint &touchPoint = it->touchPoint; qreal dx = screenPos.x() - touchPoint.screenPos().x(); qreal dy = screenPos.y() - touchPoint.screenPos().y(); @@ -4339,7 +4340,7 @@ bool QApplicationPrivate::translateRawTouchEvent(QWidget *window, } if (device->type() == QTouchDevice::TouchScreen) { - QWidget *closestWidget = d->findClosestTouchPointTarget(device, touchPoint.screenPos()); + QWidget *closestWidget = d->findClosestTouchPointTarget(device, touchPoint); QWidget *widget = static_cast(target.data()); if (closestWidget && (widget->isAncestorOf(closestWidget) || closestWidget->isAncestorOf(widget))) { diff --git a/src/widgets/kernel/qapplication_p.h b/src/widgets/kernel/qapplication_p.h index 7d97235c66..7f76d1ba97 100644 --- a/src/widgets/kernel/qapplication_p.h +++ b/src/widgets/kernel/qapplication_p.h @@ -280,7 +280,7 @@ public: void initializeMultitouch_sys(); void cleanupMultitouch(); void cleanupMultitouch_sys(); - QWidget *findClosestTouchPointTarget(QTouchDevice *device, const QPointF &screenPos); + QWidget *findClosestTouchPointTarget(QTouchDevice *device, const QTouchEvent::TouchPoint &touchPoint); void appendTouchPoint(const QTouchEvent::TouchPoint &touchPoint); void removeTouchPoint(int touchPointId); static bool translateRawTouchEvent(QWidget *widget, -- cgit v1.2.3 From 1f281bfd63402b50f3db378a027da26ca52ffb27 Mon Sep 17 00:00:00 2001 From: Christoph Schleifenbaum Date: Sat, 18 Apr 2015 14:39:18 +0200 Subject: ItemViews: Fix acceptance of drag enter events Always accept drag enter events if the mime type and the drop actions matches. Whether the drop can actually happen on the currently hovered index will be decided in the following drag move event. Change-Id: I27e865cb65513dfe3f57ad3f1bc8cebf4c29a692 Task-number: QTBUG-45037 Reviewed-by: David Faure --- src/widgets/itemviews/qabstractitemview_p.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/widgets') diff --git a/src/widgets/itemviews/qabstractitemview_p.h b/src/widgets/itemviews/qabstractitemview_p.h index c3bd1fb504..be5d4b7b71 100644 --- a/src/widgets/itemviews/qabstractitemview_p.h +++ b/src/widgets/itemviews/qabstractitemview_p.h @@ -168,8 +168,20 @@ public: QModelIndex index; int col = -1; int row = -1; + const QMimeData *mime = event->mimeData(); + + // Drag enter event shall always be accepted, if mime type and action match. + // Whether the data can actually be dropped will be checked in drag move. + if (event->type() == QEvent::DragEnter) { + const QStringList modelTypes = model->mimeTypes(); + for (int i = 0; i < modelTypes.count(); ++i) + if (mime->hasFormat(modelTypes.at(i)) + && (event->dropAction() & model->supportedDropActions())) + return true; + } + if (dropOn(event, &row, &col, &index)) { - return model->canDropMimeData(event->mimeData(), + return model->canDropMimeData(mime, dragDropMode == QAbstractItemView::InternalMove ? Qt::MoveAction : event->dropAction(), row, col, index); } -- cgit v1.2.3 From 4db5d3ccd17d448b59db491e2f261892f31fec74 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Mon, 10 Nov 2014 12:04:56 +0100 Subject: Fix shortcuts when using setDefaultAction Don't remove ampersands when setting the text: they will be removed when the text is displayed. This fixes double removal of ampersands. [ChangeLog][QtWidgets][QToolButton] Fix double removal of ampersands Task-number: QTBUG-23396 Change-Id: I56bf50eb24aae32a81d614824aca0b63363587c8 Reviewed-by: Timur Pocheptsov --- src/widgets/widgets/qtoolbutton.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/widgets') diff --git a/src/widgets/widgets/qtoolbutton.cpp b/src/widgets/widgets/qtoolbutton.cpp index bb3f2d74a8..e897b578c3 100644 --- a/src/widgets/widgets/qtoolbutton.cpp +++ b/src/widgets/widgets/qtoolbutton.cpp @@ -897,7 +897,7 @@ void QToolButton::setDefaultAction(QAction *action) return; if (!actions().contains(action)) addAction(action); - setText(action->iconText()); + setText(action->text()); setIcon(action->icon()); #ifndef QT_NO_TOOLTIP setToolTip(action->toolTip()); -- cgit v1.2.3 From 3287e7a68a3feff5c34f109b6af0f894a0362801 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Fri, 1 May 2015 18:31:54 +0200 Subject: QGraphicsWidget: call normal "setParent" when setting a parent QGraphicsWidgetPrivate::init had a special code path for setting the item's parent. For some reason that code path caused the ItemChildAddedChange notification not to be sent to the parent element, which is wrong. Instead use the "normal" path, which is what the QGraphicsItem constructor does anyhow. Change-Id: Iad84cae05d797022a45977d35ca00c80c17c306a Task-number: QTBUG-45867 Reviewed-by: Andreas Aardal Hanssen --- src/widgets/graphicsview/qgraphicswidget_p.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/graphicsview/qgraphicswidget_p.cpp b/src/widgets/graphicsview/qgraphicswidget_p.cpp index 402d54d2d8..e9ab6dffec 100644 --- a/src/widgets/graphicsview/qgraphicswidget_p.cpp +++ b/src/widgets/graphicsview/qgraphicswidget_p.cpp @@ -64,9 +64,7 @@ void QGraphicsWidgetPrivate::init(QGraphicsItem *parentItem, Qt::WindowFlags wFl adjustWindowFlags(&wFlags); windowFlags = wFlags; - if (parentItem) - setParentItemHelper(parentItem, 0, 0); - + q->setParentItem(parentItem); q->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred, QSizePolicy::DefaultType)); q->setGraphicsItem(q); -- cgit v1.2.3 From 337c279215fa6daf12a1cd1370bcbf10db809bb0 Mon Sep 17 00:00:00 2001 From: Volker Krause Date: Fri, 1 May 2015 13:15:22 +0200 Subject: Make data tables const. Moves some of them to the .rodata section, the rest at least to .data.rel.ro[.local]. Change-Id: I85676ddf22b0c0097f3f0dce4c3dc018dc29d045 Reviewed-by: Marc Mutz Reviewed-by: Thiago Macieira Reviewed-by: Giuseppe D'Angelo --- src/widgets/styles/qcommonstylepixmaps_p.h | 2 +- src/widgets/styles/qstylesheetstyle.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/styles/qcommonstylepixmaps_p.h b/src/widgets/styles/qcommonstylepixmaps_p.h index 471903e927..8075256158 100644 --- a/src/widgets/styles/qcommonstylepixmaps_p.h +++ b/src/widgets/styles/qcommonstylepixmaps_p.h @@ -348,7 +348,7 @@ static const char * const qt_unshade_xpm[] = { "..........", ".........."}; -static const char * dock_widget_close_xpm[] = { +static const char * const dock_widget_close_xpm[] = { "8 8 2 1", "# c #000000", ". c None", diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index 4993457b32..ae7accf7d0 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -586,7 +586,7 @@ public: }; /////////////////////////////////////////////////////////////////////////////////////////// -static const char *knownStyleHints[] = { +static const char *const knownStyleHints[] = { "activate-on-singleclick", "alignment", "arrow-keys-navigate-into-children", -- cgit v1.2.3 From 91efad8ef773ce93093e2a795fd389c50e7033f0 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Wed, 6 May 2015 11:31:04 +0200 Subject: doc: document how QFileDialog can be used to pick photos on iOS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Iab4a0842f811cd26484123e6949c9b6a0ef0d524 Reviewed-by: Topi Reiniö --- src/widgets/dialogs/qfiledialog.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/widgets') diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp index 8590467abc..a9d5574428 100644 --- a/src/widgets/dialogs/qfiledialog.cpp +++ b/src/widgets/dialogs/qfiledialog.cpp @@ -893,6 +893,12 @@ void QFileDialogPrivate::_q_goToUrl(const QUrl &url) /*! Sets the file dialog's current \a directory. + + \note On iOS, if you set \a directory to \l{QStandardPaths::standardLocations()} + {QStandardPaths::standardLocations(QStandardPaths::PicturesLocation).last()}, + a native image picker dialog will be used for accessing the user's photo album. + The filename returned can be loaded using QFile and related APIs. + This feature was added in Qt 5.5. */ void QFileDialog::setDirectory(const QString &directory) { -- cgit v1.2.3 From ae050611b4004220071cc49e456bc444d9679ddc Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Wed, 6 May 2015 15:21:27 +0200 Subject: Mark QGraphicsScene::focusNextPrevChild as virtual in Qt 6 It's supposed to mirror QWidget's one, but this one isn't virtual, making it useless. Change-Id: I0dc531bd12b5e18fa11816c03ef5b3941851198f Task-number: QTBUG-45633 Reviewed-by: Andreas Aardal Hanssen --- src/widgets/graphicsview/qgraphicsscene.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/widgets') diff --git a/src/widgets/graphicsview/qgraphicsscene.h b/src/widgets/graphicsview/qgraphicsscene.h index b025730bb1..68382bf498 100644 --- a/src/widgets/graphicsview/qgraphicsscene.h +++ b/src/widgets/graphicsview/qgraphicsscene.h @@ -282,6 +282,10 @@ protected: QWidget *widget = 0); protected Q_SLOTS: + // ### Qt 6: make unconditional +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + virtual +#endif bool focusNextPrevChild(bool next); Q_SIGNALS: -- cgit v1.2.3 From 07af5bfcea7f92b1cf309be5e22f3f0e53e83ca1 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 6 May 2015 13:59:37 +0200 Subject: Give QSizePolicy its own .cpp Previously, implementation was spread between qlayout.cpp and qlayoutitem.cpp and the docs between those two files and qsizepolicy.qdoc. Move everything into a new qsizepolicy.cpp. Change-Id: Id15c2c13572b7b8863be596603100f388eafea07 Reviewed-by: Friedemann Kleint Reviewed-by: Giuseppe D'Angelo --- src/widgets/kernel/kernel.pri | 1 + src/widgets/kernel/qlayout.cpp | 81 ------ src/widgets/kernel/qlayoutitem.cpp | 19 -- src/widgets/kernel/qsizepolicy.cpp | 498 ++++++++++++++++++++++++++++++++++++ src/widgets/kernel/qsizepolicy.h | 3 +- src/widgets/kernel/qsizepolicy.qdoc | 387 ---------------------------- 6 files changed, 500 insertions(+), 489 deletions(-) create mode 100644 src/widgets/kernel/qsizepolicy.cpp delete mode 100644 src/widgets/kernel/qsizepolicy.qdoc (limited to 'src/widgets') diff --git a/src/widgets/kernel/kernel.pri b/src/widgets/kernel/kernel.pri index 88c1e2595b..21a982f349 100644 --- a/src/widgets/kernel/kernel.pri +++ b/src/widgets/kernel/kernel.pri @@ -49,6 +49,7 @@ SOURCES += \ kernel/qlayoutengine.cpp \ kernel/qlayoutitem.cpp \ kernel/qshortcut.cpp \ + kernel/qsizepolicy.cpp \ kernel/qstackedlayout.cpp \ kernel/qtooltip.cpp \ kernel/qwhatsthis.cpp \ diff --git a/src/widgets/kernel/qlayout.cpp b/src/widgets/kernel/qlayout.cpp index 822690942e..d3e5986103 100644 --- a/src/widgets/kernel/qlayout.cpp +++ b/src/widgets/kernel/qlayout.cpp @@ -1471,85 +1471,4 @@ QSize QLayout::closestAcceptableSize(const QWidget *widget, const QSize &size) return result; } -void QSizePolicy::setControlType(ControlType type) -{ - /* - The control type is a flag type, with values 0x1, 0x2, 0x4, 0x8, 0x10, - etc. In memory, we pack it onto the available bits (CTSize) in - setControlType(), and unpack it here. - - Example: - - 0x00000001 maps to 0 - 0x00000002 maps to 1 - 0x00000004 maps to 2 - 0x00000008 maps to 3 - etc. - */ - - int i = 0; - while (true) { - if (type & (0x1 << i)) { - bits.ctype = i; - return; - } - ++i; - } -} - -QSizePolicy::ControlType QSizePolicy::controlType() const -{ - return QSizePolicy::ControlType(1 << bits.ctype); -} - -#ifndef QT_NO_DATASTREAM - -/*! - \relates QSizePolicy - \since 4.2 - - Writes the size \a policy to the data stream \a stream. - - \sa{Serializing Qt Data Types}{Format of the QDataStream operators} -*/ -QDataStream &operator<<(QDataStream &stream, const QSizePolicy &policy) -{ - // The order here is for historical reasons. (compatibility with Qt4) - quint32 data = (policy.bits.horPolicy | // [0, 3] - policy.bits.verPolicy << 4 | // [4, 7] - policy.bits.hfw << 8 | // [8] - policy.bits.ctype << 9 | // [9, 13] - policy.bits.wfh << 14 | // [14] - policy.bits.retainSizeWhenHidden << 15 | // [15] - policy.bits.verStretch << 16 | // [16, 23] - policy.bits.horStretch << 24); // [24, 31] - return stream << data; -} - -#define VALUE_OF_BITS(data, bitstart, bitcount) ((data >> bitstart) & ((1 << bitcount) -1)) - -/*! - \relates QSizePolicy - \since 4.2 - - Reads the size \a policy from the data stream \a stream. - - \sa{Serializing Qt Data Types}{Format of the QDataStream operators} -*/ -QDataStream &operator>>(QDataStream &stream, QSizePolicy &policy) -{ - quint32 data; - stream >> data; - policy.bits.horPolicy = VALUE_OF_BITS(data, 0, 4); - policy.bits.verPolicy = VALUE_OF_BITS(data, 4, 4); - policy.bits.hfw = VALUE_OF_BITS(data, 8, 1); - policy.bits.ctype = VALUE_OF_BITS(data, 9, 5); - policy.bits.wfh = VALUE_OF_BITS(data, 14, 1); - policy.bits.retainSizeWhenHidden = VALUE_OF_BITS(data, 15, 1); - policy.bits.verStretch = VALUE_OF_BITS(data, 16, 8); - policy.bits.horStretch = VALUE_OF_BITS(data, 24, 8); - return stream; -} -#endif // QT_NO_DATASTREAM - QT_END_NAMESPACE diff --git a/src/widgets/kernel/qlayoutitem.cpp b/src/widgets/kernel/qlayoutitem.cpp index b21925e1d4..21f4c9a221 100644 --- a/src/widgets/kernel/qlayoutitem.cpp +++ b/src/widgets/kernel/qlayoutitem.cpp @@ -34,7 +34,6 @@ #include "qlayout.h" #include "qapplication.h" -#include "qdebug.h" #include "qlayoutengine_p.h" #include "qmenubar.h" #include "qtoolbar.h" @@ -67,14 +66,6 @@ inline static QSize toLayoutItemSize(QWidgetPrivate *priv, const QSize &size) return toLayoutItemRect(priv, QRect(QPoint(0, 0), size)).size(); } -/*! - Returns a QVariant storing this QSizePolicy. -*/ -QSizePolicy::operator QVariant() const -{ - return QVariant(QVariant::SizePolicy, this); -} - /*! \class QLayoutItem \brief The QLayoutItem class provides an abstract item that a @@ -847,14 +838,4 @@ int QWidgetItemV2::heightForWidth(int width) const return height; } -#ifndef QT_NO_DEBUG_STREAM -QDebug operator<<(QDebug dbg, const QSizePolicy &p) -{ - QDebugStateSaver saver(dbg); - dbg.nospace() << "QSizePolicy(horizontalPolicy = " << p.horizontalPolicy() - << ", verticalPolicy = " << p.verticalPolicy() << ')'; - return dbg; -} -#endif - QT_END_NAMESPACE diff --git a/src/widgets/kernel/qsizepolicy.cpp b/src/widgets/kernel/qsizepolicy.cpp new file mode 100644 index 0000000000..ba57a4f867 --- /dev/null +++ b/src/widgets/kernel/qsizepolicy.cpp @@ -0,0 +1,498 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the QtWidgets module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qsizepolicy.h" + +#include +#include +#include + +QT_BEGIN_NAMESPACE + +/*! + \class QSizePolicy + \brief The QSizePolicy class is a layout attribute describing horizontal + and vertical resizing policy. + + \ingroup geomanagement + \inmodule QtWidgets + + The size policy of a widget is an expression of its willingness to + be resized in various ways, and affects how the widget is treated + by the \l{Layout Management}{layout engine}. Each widget returns a + QSizePolicy that describes the horizontal and vertical resizing + policy it prefers when being laid out. You can change this for + a specific widget by changing its QWidget::sizePolicy property. + + QSizePolicy contains two independent QSizePolicy::Policy values + and two stretch factors; one describes the widgets's horizontal + size policy, and the other describes its vertical size policy. It + also contains a flag to indicate whether the height and width of + its preferred size are related. + + The horizontal and vertical policies can be set in the + constructor, and altered using the setHorizontalPolicy() and + setVerticalPolicy() functions. The stretch factors can be set + using the setHorizontalStretch() and setVerticalStretch() + functions. The flag indicating whether the widget's + \l{QWidget::sizeHint()}{sizeHint()} is width-dependent (such as a + menu bar or a word-wrapping label) can be set using the + setHeightForWidth() function. + + The current size policies and stretch factors be retrieved using + the horizontalPolicy(), verticalPolicy(), horizontalStretch() and + verticalStretch() functions. Alternatively, use the transpose() + function to swap the horizontal and vertical policies and + stretches. The hasHeightForWidth() function returns the current + status of the flag indicating the size hint dependencies. + + Use the expandingDirections() function to determine whether the + associated widget can make use of more space than its + \l{QWidget::sizeHint()}{sizeHint()} function indicates, as well as + find out in which directions it can expand. + + Finally, the QSizePolicy class provides operators comparing this + size policy to a given policy, as well as a QVariant operator + storing this QSizePolicy as a QVariant object. + + \sa QSize, QWidget::sizeHint(), QWidget::sizePolicy, + QLayoutItem::sizeHint() +*/ + +/*! + \enum QSizePolicy::PolicyFlag + + These flags are combined together to form the various \l{Policy} + values: + + \value GrowFlag The widget can grow beyond its size hint if necessary. + \value ExpandFlag The widget should get as much space as possible. + \value ShrinkFlag The widget can shrink below its size hint if necessary. + \value IgnoreFlag The widget's size hint is ignored. The widget will get + as much space as possible. + + \sa Policy +*/ + +/*! + \enum QSizePolicy::Policy + + This enum describes the various per-dimension sizing types used + when constructing a QSizePolicy. + + \value Fixed The QWidget::sizeHint() is the only acceptable + alternative, so the widget can never grow or shrink (e.g. the + vertical direction of a push button). + + \value Minimum The sizeHint() is minimal, and sufficient. The + widget can be expanded, but there is no advantage to it being + larger (e.g. the horizontal direction of a push button). + It cannot be smaller than the size provided by sizeHint(). + + \value Maximum The sizeHint() is a maximum. The widget can be + shrunk any amount without detriment if other widgets need the + space (e.g. a separator line). + It cannot be larger than the size provided by sizeHint(). + + \value Preferred The sizeHint() is best, but the widget can be + shrunk and still be useful. The widget can be expanded, but there + is no advantage to it being larger than sizeHint() (the default + QWidget policy). + + \value Expanding The sizeHint() is a sensible size, but the + widget can be shrunk and still be useful. The widget can make use + of extra space, so it should get as much space as possible (e.g. + the horizontal direction of a horizontal slider). + + \value MinimumExpanding The sizeHint() is minimal, and sufficient. + The widget can make use of extra space, so it should get as much + space as possible (e.g. the horizontal direction of a horizontal + slider). + + \value Ignored The sizeHint() is ignored. The widget will get as + much space as possible. + + \sa PolicyFlag, setHorizontalPolicy(), setVerticalPolicy() +*/ + +/*! + \fn QSizePolicy::QSizePolicy() + + Constructs a QSizePolicy object with \l Fixed as its horizontal + and vertical policies. + + The policies can be altered using the setHorizontalPolicy() and + setVerticalPolicy() functions. Use the setHeightForWidth() + function if the preferred height of the widget is dependent on the + width of the widget (for example, a QLabel with line wrapping). + + \sa setHorizontalStretch(), setVerticalStretch() +*/ + +/*! + \fn QSizePolicy::QSizePolicy(Policy horizontal, Policy vertical, ControlType type) + \since 4.3 + + Constructs a QSizePolicy object with the given \a horizontal and + \a vertical policies, and the specified control \a type. + + Use setHeightForWidth() if the preferred height of the widget is + dependent on the width of the widget (for example, a QLabel with + line wrapping). + + \sa setHorizontalStretch(), setVerticalStretch(), controlType() +*/ + +/*! + \fn QSizePolicy::Policy QSizePolicy::horizontalPolicy() const + + Returns the horizontal component of the size policy. + + \sa setHorizontalPolicy(), verticalPolicy(), horizontalStretch() +*/ + +/*! + \fn QSizePolicy::Policy QSizePolicy::verticalPolicy() const + + Returns the vertical component of the size policy. + + \sa setVerticalPolicy(), horizontalPolicy(), verticalStretch() +*/ + +/*! + \fn void QSizePolicy::setHorizontalPolicy(Policy policy) + + Sets the horizontal component to the given \a policy. + + \sa horizontalPolicy(), setVerticalPolicy(), setHorizontalStretch() +*/ + +/*! + \fn void QSizePolicy::setVerticalPolicy(Policy policy) + + Sets the vertical component to the given \a policy. + + \sa verticalPolicy(), setHorizontalPolicy(), setVerticalStretch() +*/ + +/*! + \fn Qt::Orientations QSizePolicy::expandingDirections() const + + Returns whether a widget can make use of more space than the + QWidget::sizeHint() function indicates. + + A value of Qt::Horizontal or Qt::Vertical means that the widget + can grow horizontally or vertically (i.e., the horizontal or + vertical policy is \l Expanding or \l MinimumExpanding), whereas + Qt::Horizontal | Qt::Vertical means that it can grow in both + dimensions. + + \sa horizontalPolicy(), verticalPolicy() +*/ + +/*! + \since 4.3 + + Returns the control type associated with the widget for which + this size policy applies. +*/ +QSizePolicy::ControlType QSizePolicy::controlType() const +{ + return QSizePolicy::ControlType(1 << bits.ctype); +} + + +/*! + \since 4.3 + + Sets the control type associated with the widget for which this + size policy applies to \a type. + + The control type specifies the type of the widget for which this + size policy applies. It is used by some styles, notably + QMacStyle, to insert proper spacing between widgets. For example, + the Mac OS X Aqua guidelines specify that push buttons should be + separated by 12 pixels, whereas vertically stacked radio buttons + only require 6 pixels. + + \sa QStyle::layoutSpacing() +*/ +void QSizePolicy::setControlType(ControlType type) +{ + /* + The control type is a flag type, with values 0x1, 0x2, 0x4, 0x8, 0x10, + etc. In memory, we pack it onto the available bits (CTSize) in + setControlType(), and unpack it here. + + Example: + + 0x00000001 maps to 0 + 0x00000002 maps to 1 + 0x00000004 maps to 2 + 0x00000008 maps to 3 + etc. + */ + + int i = 0; + while (true) { + if (type & (0x1 << i)) { + bits.ctype = i; + return; + } + ++i; + } +} + +/*! + \fn void QSizePolicy::setHeightForWidth(bool dependent) + + Sets the flag determining whether the widget's preferred height + depends on its width, to \a dependent. + + \sa hasHeightForWidth(), setWidthForHeight() +*/ + +/*! + \fn bool QSizePolicy::hasHeightForWidth() const + + Returns \c true if the widget's preferred height depends on its + width; otherwise returns \c false. + + \sa setHeightForWidth() +*/ + +/*! + \fn void QSizePolicy::setWidthForHeight(bool dependent) + + Sets the flag determining whether the widget's width + depends on its height, to \a dependent. + + This is only supported for QGraphicsLayout's subclasses. + It is not possible to have a layout with both height-for-width + and width-for-height constraints at the same time. + + \sa hasWidthForHeight(), setHeightForWidth() +*/ + +/*! + \fn bool QSizePolicy::hasWidthForHeight() const + + Returns \c true if the widget's width depends on its + height; otherwise returns \c false. + + \sa setWidthForHeight() +*/ + +/*! + \fn bool QSizePolicy::operator==(const QSizePolicy &other) const + + Returns \c true if this policy is equal to \a other; otherwise + returns \c false. + + \sa operator!=() +*/ + +/*! + \fn bool QSizePolicy::operator!=(const QSizePolicy &other) const + + Returns \c true if this policy is different from \a other; otherwise + returns \c false. + + \sa operator==() +*/ + +/*! + \fn int QSizePolicy::horizontalStretch() const + + Returns the horizontal stretch factor of the size policy. + + \sa setHorizontalStretch(), verticalStretch(), horizontalPolicy() +*/ + +/*! + \fn int QSizePolicy::verticalStretch() const + + Returns the vertical stretch factor of the size policy. + + \sa setVerticalStretch(), horizontalStretch(), verticalPolicy() +*/ + +/*! + \fn void QSizePolicy::setHorizontalStretch(int stretchFactor) + + Sets the horizontal stretch factor of the size policy to the given \a + stretchFactor. \a stretchFactor must be in the range [0,255]. + + When two widgets are adjacent to each other in a horizontal layout, + setting the horizontal stretch factor of the widget on the left to 2 + and the factor of widget on the right to 1 will ensure that the widget + on the left will always be twice the size of the one on the right. + + \sa horizontalStretch(), setVerticalStretch(), setHorizontalPolicy() +*/ + +/*! + \fn void QSizePolicy::setVerticalStretch(int stretchFactor) + + Sets the vertical stretch factor of the size policy to the given + \a stretchFactor. \a stretchFactor must be in the range [0,255]. + + When two widgets are adjacent to each other in a vertical layout, + setting the vertical stretch factor of the widget on the top to 2 + and the factor of widget on the bottom to 1 will ensure that + the widget on the top will always be twice the size of the one + on the bottom. + + \sa verticalStretch(), setHorizontalStretch(), setVerticalPolicy() +*/ + +/*! + \fn void QSizePolicy::transpose() + + Swaps the horizontal and vertical policies and stretches. +*/ + +/*! + \fn void QSizePolicy::retainSizeWhenHidden() const + \since 5.2 + + Returns if the layout should retain the widgets size when it is hidden. This is by default false. + + \sa setRetainSizeWhenHidden() +*/ + +/*! + \fn void QSizePolicy::setRetainSizeWhenHidden(bool retainSize) + \since 5.2 + + Set if a layout should retain the widgets size when it is hidden. + If \a retainSize is true the layout will not be changed by hiding the widget. + + \sa retainSizeWhenHidden() +*/ + +/*! + \enum QSizePolicy::ControlType + \since 4.3 + + This enum specifies the different types of widgets in terms of + layout interaction: + + \value DefaultType The default type, when none is specified. + \value ButtonBox A QDialogButtonBox instance. + \value CheckBox A QCheckBox instance. + \value ComboBox A QComboBox instance. + \value Frame A QFrame instance. + \value GroupBox A QGroupBox instance. + \value Label A QLabel instance. + \value Line A QFrame instance with QFrame::HLine or QFrame::VLine. + \value LineEdit A QLineEdit instance. + \value PushButton A QPushButton instance. + \value RadioButton A QRadioButton instance. + \value Slider A QAbstractSlider instance. + \value SpinBox A QAbstractSpinBox instance. + \value TabWidget A QTabWidget instance. + \value ToolButton A QToolButton instance. + + \sa setControlType(), controlType() +*/ + +/*! + Returns a QVariant storing this QSizePolicy. +*/ +QSizePolicy::operator QVariant() const +{ + return QVariant(QVariant::SizePolicy, this); +} + +#ifndef QT_NO_DATASTREAM + +/*! + \relates QSizePolicy + \since 4.2 + + Writes the size \a policy to the data stream \a stream. + + \sa{Serializing Qt Data Types}{Format of the QDataStream operators} +*/ +QDataStream &operator<<(QDataStream &stream, const QSizePolicy &policy) +{ + // The order here is for historical reasons. (compatibility with Qt4) + quint32 data = (policy.bits.horPolicy | // [0, 3] + policy.bits.verPolicy << 4 | // [4, 7] + policy.bits.hfw << 8 | // [8] + policy.bits.ctype << 9 | // [9, 13] + policy.bits.wfh << 14 | // [14] + policy.bits.retainSizeWhenHidden << 15 | // [15] + policy.bits.verStretch << 16 | // [16, 23] + policy.bits.horStretch << 24); // [24, 31] + return stream << data; +} + +#define VALUE_OF_BITS(data, bitstart, bitcount) ((data >> bitstart) & ((1 << bitcount) -1)) + +/*! + \relates QSizePolicy + \since 4.2 + + Reads the size \a policy from the data stream \a stream. + + \sa{Serializing Qt Data Types}{Format of the QDataStream operators} +*/ +QDataStream &operator>>(QDataStream &stream, QSizePolicy &policy) +{ + quint32 data; + stream >> data; + policy.bits.horPolicy = VALUE_OF_BITS(data, 0, 4); + policy.bits.verPolicy = VALUE_OF_BITS(data, 4, 4); + policy.bits.hfw = VALUE_OF_BITS(data, 8, 1); + policy.bits.ctype = VALUE_OF_BITS(data, 9, 5); + policy.bits.wfh = VALUE_OF_BITS(data, 14, 1); + policy.bits.retainSizeWhenHidden = VALUE_OF_BITS(data, 15, 1); + policy.bits.verStretch = VALUE_OF_BITS(data, 16, 8); + policy.bits.horStretch = VALUE_OF_BITS(data, 24, 8); + return stream; +} +#endif // QT_NO_DATASTREAM + +#ifndef QT_NO_DEBUG_STREAM +QDebug operator<<(QDebug dbg, const QSizePolicy &p) +{ + QDebugStateSaver saver(dbg); + dbg.nospace() << "QSizePolicy(horizontalPolicy = " << p.horizontalPolicy() + << ", verticalPolicy = " << p.verticalPolicy() << ')'; + return dbg; +} +#endif + +QT_END_NAMESPACE diff --git a/src/widgets/kernel/qsizepolicy.h b/src/widgets/kernel/qsizepolicy.h index 2376a2c644..6cd511f513 100644 --- a/src/widgets/kernel/qsizepolicy.h +++ b/src/widgets/kernel/qsizepolicy.h @@ -112,7 +112,7 @@ public: bool operator==(const QSizePolicy& s) const { return data == s.data; } bool operator!=(const QSizePolicy& s) const { return data != s.data; } - operator QVariant() const; // implemented in qlayoutitem.cpp + operator QVariant() const; int horizontalStretch() const { return static_cast(bits.horStretch); } int verticalStretch() const { return static_cast(bits.verStretch); } @@ -155,7 +155,6 @@ Q_DECLARE_TYPEINFO(QSizePolicy, Q_PRIMITIVE_TYPE); Q_DECLARE_OPERATORS_FOR_FLAGS(QSizePolicy::ControlTypes) #ifndef QT_NO_DATASTREAM -// implemented in qlayout.cpp Q_WIDGETS_EXPORT QDataStream &operator<<(QDataStream &, const QSizePolicy &); Q_WIDGETS_EXPORT QDataStream &operator>>(QDataStream &, QSizePolicy &); #endif diff --git a/src/widgets/kernel/qsizepolicy.qdoc b/src/widgets/kernel/qsizepolicy.qdoc deleted file mode 100644 index e84412bc46..0000000000 --- a/src/widgets/kernel/qsizepolicy.qdoc +++ /dev/null @@ -1,387 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: http://www.gnu.org/copyleft/fdl.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \class QSizePolicy - \brief The QSizePolicy class is a layout attribute describing horizontal - and vertical resizing policy. - - \ingroup geomanagement - \inmodule QtWidgets - - The size policy of a widget is an expression of its willingness to - be resized in various ways, and affects how the widget is treated - by the \l{Layout Management}{layout engine}. Each widget returns a - QSizePolicy that describes the horizontal and vertical resizing - policy it prefers when being laid out. You can change this for - a specific widget by changing its QWidget::sizePolicy property. - - QSizePolicy contains two independent QSizePolicy::Policy values - and two stretch factors; one describes the widgets's horizontal - size policy, and the other describes its vertical size policy. It - also contains a flag to indicate whether the height and width of - its preferred size are related. - - The horizontal and vertical policies can be set in the - constructor, and altered using the setHorizontalPolicy() and - setVerticalPolicy() functions. The stretch factors can be set - using the setHorizontalStretch() and setVerticalStretch() - functions. The flag indicating whether the widget's - \l{QWidget::sizeHint()}{sizeHint()} is width-dependent (such as a - menu bar or a word-wrapping label) can be set using the - setHeightForWidth() function. - - The current size policies and stretch factors be retrieved using - the horizontalPolicy(), verticalPolicy(), horizontalStretch() and - verticalStretch() functions. Alternatively, use the transpose() - function to swap the horizontal and vertical policies and - stretches. The hasHeightForWidth() function returns the current - status of the flag indicating the size hint dependencies. - - Use the expandingDirections() function to determine whether the - associated widget can make use of more space than its - \l{QWidget::sizeHint()}{sizeHint()} function indicates, as well as - find out in which directions it can expand. - - Finally, the QSizePolicy class provides operators comparing this - size policy to a given policy, as well as a QVariant operator - storing this QSizePolicy as a QVariant object. - - \sa QSize, QWidget::sizeHint(), QWidget::sizePolicy, - QLayoutItem::sizeHint() -*/ - -/*! - \enum QSizePolicy::PolicyFlag - - These flags are combined together to form the various \l{Policy} - values: - - \value GrowFlag The widget can grow beyond its size hint if necessary. - \value ExpandFlag The widget should get as much space as possible. - \value ShrinkFlag The widget can shrink below its size hint if necessary. - \value IgnoreFlag The widget's size hint is ignored. The widget will get - as much space as possible. - - \sa Policy -*/ - -/*! - \enum QSizePolicy::Policy - - This enum describes the various per-dimension sizing types used - when constructing a QSizePolicy. - - \value Fixed The QWidget::sizeHint() is the only acceptable - alternative, so the widget can never grow or shrink (e.g. the - vertical direction of a push button). - - \value Minimum The sizeHint() is minimal, and sufficient. The - widget can be expanded, but there is no advantage to it being - larger (e.g. the horizontal direction of a push button). - It cannot be smaller than the size provided by sizeHint(). - - \value Maximum The sizeHint() is a maximum. The widget can be - shrunk any amount without detriment if other widgets need the - space (e.g. a separator line). - It cannot be larger than the size provided by sizeHint(). - - \value Preferred The sizeHint() is best, but the widget can be - shrunk and still be useful. The widget can be expanded, but there - is no advantage to it being larger than sizeHint() (the default - QWidget policy). - - \value Expanding The sizeHint() is a sensible size, but the - widget can be shrunk and still be useful. The widget can make use - of extra space, so it should get as much space as possible (e.g. - the horizontal direction of a horizontal slider). - - \value MinimumExpanding The sizeHint() is minimal, and sufficient. - The widget can make use of extra space, so it should get as much - space as possible (e.g. the horizontal direction of a horizontal - slider). - - \value Ignored The sizeHint() is ignored. The widget will get as - much space as possible. - - \sa PolicyFlag, setHorizontalPolicy(), setVerticalPolicy() -*/ - -/*! - \fn QSizePolicy::QSizePolicy() - - Constructs a QSizePolicy object with \l Fixed as its horizontal - and vertical policies. - - The policies can be altered using the setHorizontalPolicy() and - setVerticalPolicy() functions. Use the setHeightForWidth() - function if the preferred height of the widget is dependent on the - width of the widget (for example, a QLabel with line wrapping). - - \sa setHorizontalStretch(), setVerticalStretch() -*/ - -/*! - \fn QSizePolicy::QSizePolicy(Policy horizontal, Policy vertical, ControlType type) - \since 4.3 - - Constructs a QSizePolicy object with the given \a horizontal and - \a vertical policies, and the specified control \a type. - - Use setHeightForWidth() if the preferred height of the widget is - dependent on the width of the widget (for example, a QLabel with - line wrapping). - - \sa setHorizontalStretch(), setVerticalStretch(), controlType() -*/ - -/*! - \fn QSizePolicy::Policy QSizePolicy::horizontalPolicy() const - - Returns the horizontal component of the size policy. - - \sa setHorizontalPolicy(), verticalPolicy(), horizontalStretch() -*/ - -/*! - \fn QSizePolicy::Policy QSizePolicy::verticalPolicy() const - - Returns the vertical component of the size policy. - - \sa setVerticalPolicy(), horizontalPolicy(), verticalStretch() -*/ - -/*! - \fn void QSizePolicy::setHorizontalPolicy(Policy policy) - - Sets the horizontal component to the given \a policy. - - \sa horizontalPolicy(), setVerticalPolicy(), setHorizontalStretch() -*/ - -/*! - \fn void QSizePolicy::setVerticalPolicy(Policy policy) - - Sets the vertical component to the given \a policy. - - \sa verticalPolicy(), setHorizontalPolicy(), setVerticalStretch() -*/ - -/*! - \fn Qt::Orientations QSizePolicy::expandingDirections() const - - Returns whether a widget can make use of more space than the - QWidget::sizeHint() function indicates. - - A value of Qt::Horizontal or Qt::Vertical means that the widget - can grow horizontally or vertically (i.e., the horizontal or - vertical policy is \l Expanding or \l MinimumExpanding), whereas - Qt::Horizontal | Qt::Vertical means that it can grow in both - dimensions. - - \sa horizontalPolicy(), verticalPolicy() -*/ - -/*! - \fn ControlType QSizePolicy::controlType() const - \since 4.3 - - Returns the control type associated with the widget for which - this size policy applies. -*/ - -/*! - \fn void QSizePolicy::setControlType(ControlType type) - \since 4.3 - - Sets the control type associated with the widget for which this - size policy applies to \a type. - - The control type specifies the type of the widget for which this - size policy applies. It is used by some styles, notably - QMacStyle, to insert proper spacing between widgets. For example, - the Mac OS X Aqua guidelines specify that push buttons should be - separated by 12 pixels, whereas vertically stacked radio buttons - only require 6 pixels. - - \sa QStyle::layoutSpacing() -*/ - -/*! - \fn void QSizePolicy::setHeightForWidth(bool dependent) - - Sets the flag determining whether the widget's preferred height - depends on its width, to \a dependent. - - \sa hasHeightForWidth(), setWidthForHeight() -*/ - -/*! - \fn bool QSizePolicy::hasHeightForWidth() const - - Returns \c true if the widget's preferred height depends on its - width; otherwise returns \c false. - - \sa setHeightForWidth() -*/ - -/*! - \fn void QSizePolicy::setWidthForHeight(bool dependent) - - Sets the flag determining whether the widget's width - depends on its height, to \a dependent. - - This is only supported for QGraphicsLayout's subclasses. - It is not possible to have a layout with both height-for-width - and width-for-height constraints at the same time. - - \sa hasWidthForHeight(), setHeightForWidth() -*/ - -/*! - \fn bool QSizePolicy::hasWidthForHeight() const - - Returns \c true if the widget's width depends on its - height; otherwise returns \c false. - - \sa setWidthForHeight() -*/ - -/*! - \fn bool QSizePolicy::operator==(const QSizePolicy &other) const - - Returns \c true if this policy is equal to \a other; otherwise - returns \c false. - - \sa operator!=() -*/ - -/*! - \fn bool QSizePolicy::operator!=(const QSizePolicy &other) const - - Returns \c true if this policy is different from \a other; otherwise - returns \c false. - - \sa operator==() -*/ - -/*! - \fn int QSizePolicy::horizontalStretch() const - - Returns the horizontal stretch factor of the size policy. - - \sa setHorizontalStretch(), verticalStretch(), horizontalPolicy() -*/ - -/*! - \fn int QSizePolicy::verticalStretch() const - - Returns the vertical stretch factor of the size policy. - - \sa setVerticalStretch(), horizontalStretch(), verticalPolicy() -*/ - -/*! - \fn void QSizePolicy::setHorizontalStretch(int stretchFactor) - - Sets the horizontal stretch factor of the size policy to the given \a - stretchFactor. \a stretchFactor must be in the range [0,255]. - - When two widgets are adjacent to each other in a horizontal layout, - setting the horizontal stretch factor of the widget on the left to 2 - and the factor of widget on the right to 1 will ensure that the widget - on the left will always be twice the size of the one on the right. - - \sa horizontalStretch(), setVerticalStretch(), setHorizontalPolicy() -*/ - -/*! - \fn void QSizePolicy::setVerticalStretch(int stretchFactor) - - Sets the vertical stretch factor of the size policy to the given - \a stretchFactor. \a stretchFactor must be in the range [0,255]. - - When two widgets are adjacent to each other in a vertical layout, - setting the vertical stretch factor of the widget on the top to 2 - and the factor of widget on the bottom to 1 will ensure that - the widget on the top will always be twice the size of the one - on the bottom. - - \sa verticalStretch(), setHorizontalStretch(), setVerticalPolicy() -*/ - -/*! - \fn void QSizePolicy::transpose() - - Swaps the horizontal and vertical policies and stretches. -*/ - -/*! - \fn void QSizePolicy::retainSizeWhenHidden() const - \since 5.2 - - Returns if the layout should retain the widgets size when it is hidden. This is by default false. - - \sa setRetainSizeWhenHidden() -*/ - -/*! - \fn void QSizePolicy::setRetainSizeWhenHidden(bool retainSize) - \since 5.2 - - Set if a layout should retain the widgets size when it is hidden. - If \a retainSize is true the layout will not be changed by hiding the widget. - - \sa retainSizeWhenHidden() -*/ - -/*! - \enum QSizePolicy::ControlType - \since 4.3 - - This enum specifies the different types of widgets in terms of - layout interaction: - - \value DefaultType The default type, when none is specified. - \value ButtonBox A QDialogButtonBox instance. - \value CheckBox A QCheckBox instance. - \value ComboBox A QComboBox instance. - \value Frame A QFrame instance. - \value GroupBox A QGroupBox instance. - \value Label A QLabel instance. - \value Line A QFrame instance with QFrame::HLine or QFrame::VLine. - \value LineEdit A QLineEdit instance. - \value PushButton A QPushButton instance. - \value RadioButton A QRadioButton instance. - \value Slider A QAbstractSlider instance. - \value SpinBox A QAbstractSpinBox instance. - \value TabWidget A QTabWidget instance. - \value ToolButton A QToolButton instance. - - \sa setControlType(), controlType() -*/ - -- cgit v1.2.3 From e374ffc29c67493a51527117b55a53dfa5dd4267 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 6 May 2015 15:56:28 +0200 Subject: QSizePolicy: improve docs of retainSizeWhenHidden Fixed markup and grammar. Change-Id: Ie2427965f905135572fd1f81e4a6d7514dea7022 Reviewed-by: Friedemann Kleint Reviewed-by: Giuseppe D'Angelo --- src/widgets/kernel/qsizepolicy.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/kernel/qsizepolicy.cpp b/src/widgets/kernel/qsizepolicy.cpp index ba57a4f867..1476b4c5d7 100644 --- a/src/widgets/kernel/qsizepolicy.cpp +++ b/src/widgets/kernel/qsizepolicy.cpp @@ -386,7 +386,8 @@ void QSizePolicy::setControlType(ControlType type) \fn void QSizePolicy::retainSizeWhenHidden() const \since 5.2 - Returns if the layout should retain the widgets size when it is hidden. This is by default false. + Returns whether the layout should retain the widget's size when it is hidden. + This is \c false by default. \sa setRetainSizeWhenHidden() */ @@ -395,8 +396,8 @@ void QSizePolicy::setControlType(ControlType type) \fn void QSizePolicy::setRetainSizeWhenHidden(bool retainSize) \since 5.2 - Set if a layout should retain the widgets size when it is hidden. - If \a retainSize is true the layout will not be changed by hiding the widget. + Sets whether a layout should retain the widget's size when it is hidden. + If \a retainSize is \c true, the layout will not be changed by hiding the widget. \sa retainSizeWhenHidden() */ -- cgit v1.2.3 From ea17cc07685575fd1c00c0fc7c4aaa5d87ce72e8 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Wed, 6 May 2015 14:02:48 +0200 Subject: QColumnView: re-enable scrolling of the preview widget MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For some reason, each column in a QColumnView is a QAbstractItemView, *including* the preview widget's column. Unfortunately, the preview widget's column class was not overriding scrollContentsBy, so scrolling it had no effect. A more comprehensive solution would be a major refactoring of the code to make that column a plain Q(Abstract)ScrollArea, as it doesn't need QAIV's APIs at all, but I don't want to change code and risk breaking behavior. Change-Id: Ice500a8eaef13c295df4cc274b9f80d9a24c65f4 Task-number: QTBUG-11392 Reviewed-by: Friedemann Kleint Reviewed-by: Alexander Volkov Reviewed-by: Thorbjørn Lund Martsum --- src/widgets/itemviews/qcolumnview_p.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/widgets') diff --git a/src/widgets/itemviews/qcolumnview_p.h b/src/widgets/itemviews/qcolumnview_p.h index ed30b5f085..0c0bdb5d1f 100644 --- a/src/widgets/itemviews/qcolumnview_p.h +++ b/src/widgets/itemviews/qcolumnview_p.h @@ -89,6 +89,16 @@ public: QAbstractScrollArea::resizeEvent(event); } + void scrollContentsBy(int dx, int dy) Q_DECL_OVERRIDE + { + if (!previewWidget) + return; + scrollDirtyRegion(dx, dy); + viewport()->scroll(dx, dy); + + QAbstractItemView::scrollContentsBy(dx, dy); + } + QRect visualRect(const QModelIndex &) const Q_DECL_OVERRIDE { return QRect(); -- cgit v1.2.3 From a34e9ebc1b908d31ba645688a8b0e9e53c2d3c6e Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Wed, 6 May 2015 17:00:21 +0200 Subject: QLineEdit: show the clear button if it gets enabled after setting a text We were fetching "lastText" too late, and setting the opacity of the clear button to 0. Change-Id: I82c2aea7dab4af4424fb57e12f78d07a0374457e Task-number: QTBUG-45518 Reviewed-by: Friedemann Kleint --- src/widgets/widgets/qlineedit_p.cpp | 8 ++++---- src/widgets/widgets/qlineedit_p.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/widgets/qlineedit_p.cpp b/src/widgets/widgets/qlineedit_p.cpp index 6a41c3791f..ad3a92d35a 100644 --- a/src/widgets/widgets/qlineedit_p.cpp +++ b/src/widgets/widgets/qlineedit_p.cpp @@ -440,6 +440,10 @@ QWidget *QLineEditPrivate::addAction(QAction *newAction, QAction *before, QLineE Q_Q(QLineEdit); if (!newAction) return 0; + if (!hasSideWidgets()) { // initial setup. + QObject::connect(q, SIGNAL(textChanged(QString)), q, SLOT(_q_textChanged(QString))); + lastTextSize = q->text().size(); + } QWidget *w = 0; // Store flags about QWidgetAction here since removeAction() may be called from ~QAction, // in which a qobject_cast<> no longer works. @@ -456,10 +460,6 @@ QWidget *QLineEditPrivate::addAction(QAction *newAction, QAction *before, QLineE toolButton->setDefaultAction(newAction); w = toolButton; } - if (!hasSideWidgets()) { // initial setup. - QObject::connect(q, SIGNAL(textChanged(QString)), q, SLOT(_q_textChanged(QString))); - lastTextSize = q->text().size(); - } // If there is a 'before' action, it takes preference PositionIndexPair positionIndex = before ? findSideWidget(before) : PositionIndexPair(position, -1); SideWidgetEntryList &list = positionIndex.first == QLineEdit::TrailingPosition ? trailingSideWidgets : leadingSideWidgets; diff --git a/src/widgets/widgets/qlineedit_p.h b/src/widgets/widgets/qlineedit_p.h index 1ede07e4cb..4654262ea7 100644 --- a/src/widgets/widgets/qlineedit_p.h +++ b/src/widgets/widgets/qlineedit_p.h @@ -65,7 +65,7 @@ QT_BEGIN_NAMESPACE // QLineEditIconButton: This is a simple helper class that represents clickable icons that fade in with text -class QLineEditIconButton : public QToolButton +class Q_AUTOTEST_EXPORT QLineEditIconButton : public QToolButton { Q_OBJECT Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity) -- cgit v1.2.3 From 1ac1ae05f551d45772ff2a840dba128abf04171e Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Fri, 8 May 2015 13:49:54 +0200 Subject: QDialogButtonBox: prevent crashes on deletions in slots As usual, user code connected to signals emitted from Qt may destroy an object's internal status while a signal is being emitted. Guard a bit QDialogButtonBox signal emissions to prevent crashes in case the button or a dialog get deleted from a slot connected to clicked(). Also, be sure to emit the corresponding accepted/rejected/etc. signal. Change-Id: I7b1888070a8f2f56aa60923a17f90fb5efef145c Task-number: QTBUG-45835 Reviewed-by: Friedemann Kleint Reviewed-by: Olivier Goffart (Woboq GmbH) Reviewed-by: Marc Mutz --- src/widgets/widgets/qdialogbuttonbox.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/widgets') diff --git a/src/widgets/widgets/qdialogbuttonbox.cpp b/src/widgets/widgets/qdialogbuttonbox.cpp index 237eb775b9..3e8c08f923 100644 --- a/src/widgets/widgets/qdialogbuttonbox.cpp +++ b/src/widgets/widgets/qdialogbuttonbox.cpp @@ -852,9 +852,19 @@ void QDialogButtonBoxPrivate::_q_handleButtonClicked() { Q_Q(QDialogButtonBox); if (QAbstractButton *button = qobject_cast(q->sender())) { + // Can't fetch this *after* emitting clicked, as clicked may destroy the button + // or change its role. Now changing the role is not possible yet, but arguably + // both clicked and accepted/rejected/etc. should be emitted "atomically" + // depending on whatever role the button had at the time of the click. + const QDialogButtonBox::ButtonRole buttonRole = q->buttonRole(button); + QPointer guard(q); + emit q->clicked(button); - switch (q->buttonRole(button)) { + if (!guard) + return; + + switch (buttonRole) { case QPlatformDialogHelper::AcceptRole: case QPlatformDialogHelper::YesRole: emit q->accepted(); -- cgit v1.2.3 From 52c122e616f389bdeeffd3eedcd17c49e7e437c2 Mon Sep 17 00:00:00 2001 From: Christoph Schleifenbaum Date: Wed, 22 Apr 2015 13:06:32 +0200 Subject: Improve QListView scroll bar calculation. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When both scroll bar's policies are set to ScrollBarAsNeeded, make sure the scroll bars are shown if needed and not show if not. Even the corner case, where one scroll bar's visibility depends on the other, is handled properly. Task-number: QTBUG-45470 Change-Id: I11d6ccf7c0b51644a5ce2d5c3fc59e2e4812755d Reviewed-by: Giuseppe D'Angelo Reviewed-by: Thorbjørn Lund Martsum Reviewed-by: Thorbjørn Lindeijer --- src/widgets/itemviews/qlistview.cpp | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/itemviews/qlistview.cpp b/src/widgets/itemviews/qlistview.cpp index b7a4ec3925..f3fd3e75a1 100644 --- a/src/widgets/itemviews/qlistview.cpp +++ b/src/widgets/itemviews/qlistview.cpp @@ -1846,8 +1846,17 @@ void QCommonListViewBase::updateHorizontalScrollBar(const QSize &step) const bool bothScrollBarsAuto = qq->verticalScrollBarPolicy() == Qt::ScrollBarAsNeeded && qq->horizontalScrollBarPolicy() == Qt::ScrollBarAsNeeded; - if (bothScrollBarsAuto && contentsSize.width() - qq->verticalScrollBar()->width() <= viewport()->width() - && contentsSize.height() - qq->horizontalScrollBar()->height() <= viewport()->height()) { + const QSize viewportSize(viewport()->width() + (qq->verticalScrollBar()->maximum() > 0 ? qq->verticalScrollBar()->width() : 0), + viewport()->height() + (qq->horizontalScrollBar()->maximum() > 0 ? qq->horizontalScrollBar()->height() : 0)); + + bool verticalWantsToShow = contentsSize.height() > viewportSize.height(); + bool horizontalWantsToShow; + if (verticalWantsToShow) + horizontalWantsToShow = contentsSize.width() > viewportSize.width() - qq->verticalScrollBar()->width(); + else + horizontalWantsToShow = contentsSize.width() > viewportSize.width(); + + if (bothScrollBarsAuto && !horizontalWantsToShow) { // break the infinite loop described above by setting the range to 0, 0. // QAbstractScrollArea will then hide the scroll bar for us horizontalScrollBar()->setRange(0, 0); @@ -1868,8 +1877,17 @@ void QCommonListViewBase::updateVerticalScrollBar(const QSize &step) const bool bothScrollBarsAuto = qq->verticalScrollBarPolicy() == Qt::ScrollBarAsNeeded && qq->horizontalScrollBarPolicy() == Qt::ScrollBarAsNeeded; - if (bothScrollBarsAuto && contentsSize.width() - qq->verticalScrollBar()->width() <= viewport()->width() - && contentsSize.height() - qq->horizontalScrollBar()->height() <= viewport()->height()) { + const QSize viewportSize(viewport()->width() + (qq->verticalScrollBar()->maximum() > 0 ? qq->verticalScrollBar()->width() : 0), + viewport()->height() + (qq->horizontalScrollBar()->maximum() > 0 ? qq->horizontalScrollBar()->height() : 0)); + + bool horizontalWantsToShow = contentsSize.width() > viewportSize.width(); + bool verticalWantsToShow; + if (horizontalWantsToShow) + verticalWantsToShow = contentsSize.height() > viewportSize.height() - qq->horizontalScrollBar()->height(); + else + verticalWantsToShow = contentsSize.height() > viewportSize.height(); + + if (bothScrollBarsAuto && !verticalWantsToShow) { // break the infinite loop described above by setting the range to 0, 0. // QAbstractScrollArea will then hide the scroll bar for us verticalScrollBar()->setRange(0, 0); -- cgit v1.2.3 From 6ea636b0bd73f067c08217aa4e0ccc3f0209ede0 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Thu, 7 May 2015 19:00:11 +0200 Subject: Create contexts and pbuffers with the correct screen in QOpenGLWidget It won't be functional otherwise with GLX when the QOpenGLWidget is targeting a separate X screen. Change-Id: Ibe5b89023f833039bb67d94b78b173de2e021ac9 Reviewed-by: Gunnar Sletta --- src/widgets/kernel/qopenglwidget.cpp | 2 ++ src/widgets/kernel/qwidget.cpp | 1 + 2 files changed, 3 insertions(+) (limited to 'src/widgets') diff --git a/src/widgets/kernel/qopenglwidget.cpp b/src/widgets/kernel/qopenglwidget.cpp index d4d23604a3..b8df25b38f 100644 --- a/src/widgets/kernel/qopenglwidget.cpp +++ b/src/widgets/kernel/qopenglwidget.cpp @@ -739,6 +739,7 @@ void QOpenGLWidgetPrivate::initialize() QScopedPointer ctx(new QOpenGLContext); ctx->setShareContext(shareContext); ctx->setFormat(requestedFormat); + ctx->setScreen(shareContext->screen()); if (!ctx->create()) { qWarning("QOpenGLWidget: Failed to create context"); return; @@ -762,6 +763,7 @@ void QOpenGLWidgetPrivate::initialize() // in QQuickWidget, use a dedicated QOffscreenSurface. surface = new QOffscreenSurface; surface->setFormat(ctx->format()); + surface->setScreen(ctx->screen()); surface->create(); if (!ctx->makeCurrent(surface)) { diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index b2ea83c991..c7b141e700 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -12074,6 +12074,7 @@ QOpenGLContext *QWidgetPrivate::shareContext() const QOpenGLContext *ctx = new QOpenGLContext; ctx->setShareContext(qt_gl_global_share_context()); ctx->setFormat(extra->topextra->window->format()); + ctx->setScreen(extra->topextra->window->screen()); ctx->create(); that->extra->topextra->shareContext = ctx; } -- cgit v1.2.3 From 2023b9e76baf8d8a3b1ea59748624e16f3297ac3 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Wed, 22 Apr 2015 14:18:20 +0200 Subject: Doc: clarify ownership after QStackedWidget::removeWidget Change-Id: Ia14b72cdac3205a3896c47ecc81b31adb508181b Task-number: QTBUG-44891 Reviewed-by: Leena Miettinen --- src/widgets/widgets/qstackedwidget.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/widgets') diff --git a/src/widgets/widgets/qstackedwidget.cpp b/src/widgets/widgets/qstackedwidget.cpp index fd1bf57321..411651f480 100644 --- a/src/widgets/widgets/qstackedwidget.cpp +++ b/src/widgets/widgets/qstackedwidget.cpp @@ -182,7 +182,9 @@ int QStackedWidget::insertWidget(int index, QWidget *widget) not deleted but simply removed from the stacked layout, causing it to be hidden. - \b{Note:} Ownership of \a widget reverts to the application. + \note Parent object and parent widget of \a widget will remain the + QStackedWidget. If the application wants to reuse the removed + \a widget, then it is recommended to re-parent it. \sa addWidget(), insertWidget(), currentWidget() */ -- cgit v1.2.3 From cf5e55707365ce0da33a2602191cb0f95bd12eff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Wed, 13 May 2015 10:18:44 +0200 Subject: Remove init() function declaration. Fix doc error. This function is not used in Qt 5 and there is no definition for it. Change-Id: Id7e4fe1ada54005f65a559ae1ab393d011c37480 Reviewed-by: Timur Pocheptsov --- src/widgets/widgets/qmacnativewidget_mac.h | 1 - 1 file changed, 1 deletion(-) (limited to 'src/widgets') diff --git a/src/widgets/widgets/qmacnativewidget_mac.h b/src/widgets/widgets/qmacnativewidget_mac.h index b27d877e8f..761e55656b 100644 --- a/src/widgets/widgets/qmacnativewidget_mac.h +++ b/src/widgets/widgets/qmacnativewidget_mac.h @@ -52,7 +52,6 @@ public: NSView *nativeView() const; protected: - void init(NSView *parentView); bool event(QEvent *ev); private: -- cgit v1.2.3 From 21e6c7ae4745a76b676dfaa9fe17a2dd40fc0c5c Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Fri, 24 Apr 2015 16:48:14 +0200 Subject: Cocoa integration - implement Qt::WindowModal file dialogs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, for Qt::WindowModal dialogs we were creating modal sheet with beginSheetModalForWindow: and later (from exec) calling -runModal, essentially making a window modal dialog into (now) application modal sheet, which is not right- it's centered relative to desktop and the jump from window modal sheet's position (centered relative to a window) to application modal was quite visible. Now, instead of [panel runModal] (== [NSApp runModalForWindow:panel]) we call [NSApp runModalForWindow:theRequiredWindow]. Change-Id: I793dc72c7d1fe96497bb35754f4d0eac9a5e00e5 Reviewed-by: Morten Johan Sørvig --- src/widgets/dialogs/qdialog.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/widgets') diff --git a/src/widgets/dialogs/qdialog.cpp b/src/widgets/dialogs/qdialog.cpp index 65def6d4b8..6676a3ccba 100644 --- a/src/widgets/dialogs/qdialog.cpp +++ b/src/widgets/dialogs/qdialog.cpp @@ -534,7 +534,10 @@ int QDialog::exec() QPointer guard = this; if (d->nativeDialogInUse) { - d->platformHelper()->exec(); + if (windowModality() == Qt::WindowModal) + d->platformHelper()->execModalForWindow(d->parentWindow()); + else + d->platformHelper()->exec(); } else { QEventLoop eventLoop; d->eventLoop = &eventLoop; -- cgit v1.2.3 From 86601fc5758b223bc74687b19e3ec020b1d61d3a Mon Sep 17 00:00:00 2001 From: Kati Kankaanpaa Date: Wed, 13 May 2015 10:28:42 -0700 Subject: Fix division by zero crash when restoring screen settings The restoredScreenNumber was used before it's existence was checked, which caused 'division by zero' if the screen has been removed after storing the screen number. The check if restoredScreenNumber exists was moved to happen before restoredScreenNumber is used for the first time. Change-Id: Iada0e8c5cbb6d8ca88df171dbee045be249f50cd Reviewed-by: Friedemann Kleint --- src/widgets/kernel/qwidget.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index c7b141e700..910468b53a 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -7315,6 +7315,8 @@ bool QWidget::restoreGeometry(const QByteArray &geometry) stream >> restoredScreenWidth; const QDesktopWidget * const desktop = QApplication::desktop(); + if (restoredScreenNumber >= desktop->numScreens()) + restoredScreenNumber = desktop->primaryScreen(); const qreal screenWidthF = qreal(desktop->screenGeometry(restoredScreenNumber).width()); // Sanity check bailing out when large variations of screen sizes occur due to // high DPI scaling or different levels of DPI awareness. @@ -7342,9 +7344,6 @@ bool QWidget::restoreGeometry(const QByteArray &geometry) .expandedTo(d_func()->adjustedSize())); } - if (restoredScreenNumber >= desktop->numScreens()) - restoredScreenNumber = desktop->primaryScreen(); - const QRect availableGeometry = desktop->availableGeometry(restoredScreenNumber); // Modify the restored geometry if we are about to restore to coordinates -- cgit v1.2.3 From 45f60d2da2dc2fa1cf84bce5c09a3e63dd48440a Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Thu, 14 May 2015 12:05:24 +0200 Subject: QFileSystemModel: remove useless check The NULL check is on the line before, no point of repeating it again. Change-Id: Id6fa9ffc4dcc00819882f2d3157e9dbdb0e1db78 Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/widgets/dialogs/qfilesystemmodel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/widgets') diff --git a/src/widgets/dialogs/qfilesystemmodel.cpp b/src/widgets/dialogs/qfilesystemmodel.cpp index 04238f242a..88d327168c 100644 --- a/src/widgets/dialogs/qfilesystemmodel.cpp +++ b/src/widgets/dialogs/qfilesystemmodel.cpp @@ -544,7 +544,7 @@ QModelIndex QFileSystemModel::parent(const QModelIndex &index) const QFileSystemModelPrivate::QFileSystemNode *indexNode = d->node(index); Q_ASSERT(indexNode != 0); - QFileSystemModelPrivate::QFileSystemNode *parentNode = (indexNode ? indexNode->parent : 0); + QFileSystemModelPrivate::QFileSystemNode *parentNode = indexNode->parent; if (parentNode == 0 || parentNode == &d->root) return QModelIndex(); -- cgit v1.2.3 From 6779ec383d9609cd02a4aaf0dc82d6a9f958a07c Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Thu, 14 May 2015 12:06:16 +0200 Subject: QMenuBar: honor the left widget size hint expandedTo() returns the expanded size, so we must assign the return value (otherwise it's a no op). We were accidentally discarding it. Task-number: QTBUG-36010 Change-Id: Ic70c12648382a6b2ef7d70809bf25caa4cbe2f3a Reviewed-by: Friedemann Kleint --- src/widgets/widgets/qmenubar.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/widgets') diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp index 4659d9cf6c..1ad99bed9c 100644 --- a/src/widgets/widgets/qmenubar.cpp +++ b/src/widgets/widgets/qmenubar.cpp @@ -1632,7 +1632,7 @@ QSize QMenuBar::sizeHint() const if(d->leftWidget) { QSize sz = d->leftWidget->sizeHint(); sz.rheight() += margin; - ret.expandedTo(sz); + ret = ret.expandedTo(sz); } if(d->rightWidget) { QSize sz = d->rightWidget->sizeHint(); -- cgit v1.2.3 From a2c4e68141b4b80d317f5295aa687b5cb4f1dd9c Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Thu, 14 May 2015 12:07:20 +0200 Subject: QStyle debug helpers: refactor dead code ... or compilers complain about the second, unreachable return. Change-Id: Ic89361859fcf5cf33a57de0c803526702fa831b8 Reviewed-by: Friedemann Kleint --- src/widgets/styles/qstyle.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/widgets') diff --git a/src/widgets/styles/qstyle.cpp b/src/widgets/styles/qstyle.cpp index 862a4302f3..1849331b79 100644 --- a/src/widgets/styles/qstyle.cpp +++ b/src/widgets/styles/qstyle.cpp @@ -2368,8 +2368,8 @@ QDebug operator<<(QDebug debug, QStyle::State state) return operator<< (debug, state); # else Q_UNUSED(state); -# endif return debug; +# endif } # endif // !QT_NO_DEBUG_STREAM #endif // QT_VERSION < QT_VERSION_CHECK(6,0,0) -- cgit v1.2.3 From 31e055cee97b5d41ff0bed3246b5e85a8d954164 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Mon, 20 Apr 2015 12:52:55 +0200 Subject: Fix typo and formatting in QWidget font documentation. Change-Id: I6dea7f1aa2827dbc4c4068184690c80a36ef2be6 Reviewed-by: Venugopal Shivashankar --- src/widgets/kernel/qwidget.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 910468b53a..e701eb07ba 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -4859,7 +4859,7 @@ void QWidget::unsetLayoutDirection() \fn QFontMetrics QWidget::fontMetrics() const Returns the font metrics for the widget's current font. - Equivalent to QFontMetrics(widget->font()). + Equivalent to \c QFontMetrics(widget->font()). \sa font(), fontInfo(), setFont() */ @@ -4868,7 +4868,7 @@ void QWidget::unsetLayoutDirection() \fn QFontInfo QWidget::fontInfo() const Returns the font info for the widget's current font. - Equivalent to QFontInto(widget->font()). + Equivalent to \c QFontInfo(widget->font()). \sa font(), fontMetrics(), setFont() */ -- cgit v1.2.3 From f65c04b37e63526540f9717a63fd305f4c3ac579 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Tue, 12 May 2015 15:06:53 +0200 Subject: WinRT/Winphone: Fix warnings in qtbase Change-Id: I41725bcfeee0124b259e96f1e3a261e30f14350a Reviewed-by: Kai Koehne Reviewed-by: Maurice Kalinowski --- src/widgets/dialogs/qfileinfogatherer.cpp | 2 ++ src/widgets/dialogs/qfilesystemmodel.cpp | 4 +++- src/widgets/styles/qwindowsstyle.cpp | 9 +++++---- 3 files changed, 10 insertions(+), 5 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/dialogs/qfileinfogatherer.cpp b/src/widgets/dialogs/qfileinfogatherer.cpp index df07de7975..7329019a87 100644 --- a/src/widgets/dialogs/qfileinfogatherer.cpp +++ b/src/widgets/dialogs/qfileinfogatherer.cpp @@ -185,6 +185,8 @@ void QFileInfoGatherer::removePath(const QString &path) #ifndef QT_NO_FILESYSTEMWATCHER QMutexLocker locker(&mutex); watcher->removePath(path); +#else + Q_UNUSED(path); #endif } diff --git a/src/widgets/dialogs/qfilesystemmodel.cpp b/src/widgets/dialogs/qfilesystemmodel.cpp index 88d327168c..4859231d95 100644 --- a/src/widgets/dialogs/qfilesystemmodel.cpp +++ b/src/widgets/dialogs/qfilesystemmodel.cpp @@ -653,10 +653,12 @@ int QFileSystemModel::columnCount(const QModelIndex &parent) const */ QVariant QFileSystemModel::myComputer(int role) const { +#ifndef QT_NO_FILESYSTEMWATCHER Q_D(const QFileSystemModel); +#endif switch (role) { case Qt::DisplayRole: - return d->myComputer(); + return QFileSystemModelPrivate::myComputer(); #ifndef QT_NO_FILESYSTEMWATCHER case Qt::DecorationRole: return d->fileInfoGatherer.iconProvider()->icon(QFileIconProvider::Computer); diff --git a/src/widgets/styles/qwindowsstyle.cpp b/src/widgets/styles/qwindowsstyle.cpp index bed2b5c57a..14af5ede39 100644 --- a/src/widgets/styles/qwindowsstyle.cpp +++ b/src/widgets/styles/qwindowsstyle.cpp @@ -299,8 +299,8 @@ void QWindowsStyle::polish(QPalette &pal) int QWindowsStylePrivate::pixelMetricFromSystemDp(QStyle::PixelMetric pm, const QStyleOption *, const QWidget *widget) { - switch (pm) { #if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) + switch (pm) { case QStyle::PM_DockWidgetFrameWidth: # ifndef Q_OS_WINCE return GetSystemMetrics(SM_CXFRAME); @@ -337,13 +337,14 @@ int QWindowsStylePrivate::pixelMetricFromSystemDp(QStyle::PixelMetric pm, const # else return GetSystemMetrics(SM_CYDLGFRAME); # endif -#else - Q_UNUSED(widget) -#endif // Q_OS_WIN default: break; } +#else // Q_OS_WIN && !Q_OS_WINRT + Q_UNUSED(pm); + Q_UNUSED(widget); +#endif return QWindowsStylePrivate::InvalidMetric; } -- cgit v1.2.3 From b3f7b2329402f548694711acd209455316aa9c6c Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 20 May 2015 15:56:14 +0200 Subject: Unclutter debug operators of gestures. Use the helpers in qdebug_p.h to suppress class and enum names. Change-Id: Ib71f0a1e5b3c22f44d68a7930fef38384f037204 Reviewed-by: Shawn Rutledge --- src/widgets/kernel/qgesture.cpp | 50 +++++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 17 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/kernel/qgesture.cpp b/src/widgets/kernel/qgesture.cpp index 713a019cc3..7b7d465070 100644 --- a/src/widgets/kernel/qgesture.cpp +++ b/src/widgets/kernel/qgesture.cpp @@ -36,7 +36,7 @@ #include "private/qstandardgestures_p.h" #include "qgraphicsview.h" -#include +#include #ifndef QT_NO_GESTURES QT_BEGIN_NAMESPACE @@ -1091,9 +1091,12 @@ QPointF QGestureEvent::mapToGraphicsScene(const QPointF &gesturePoint) const static void formatGestureHeader(QDebug d, const char *className, const QGesture *gesture) { - d << className << "(state=" << gesture->state(); - if (gesture->hasHotSpot()) - d << ",hotSpot=" << gesture->hotSpot(); + d << className << "(state="; + QtDebugUtils::formatQEnum(d, gesture->state()); + if (gesture->hasHotSpot()) { + d << ",hotSpot="; + QtDebugUtils::formatQPoint(d, gesture->hotSpot()); + } } Q_WIDGETS_EXPORT QDebug operator<<(QDebug d, const QGesture *gesture) @@ -1103,31 +1106,42 @@ Q_WIDGETS_EXPORT QDebug operator<<(QDebug d, const QGesture *gesture) switch (gesture->gestureType()) { case Qt::TapGesture: formatGestureHeader(d, "QTapGesture", gesture); - d << ",position=" << static_cast(gesture)->position() << ')'; + d << ",position="; + QtDebugUtils::formatQPoint(d, static_cast(gesture)->position()); + d << ')'; break; case Qt::TapAndHoldGesture: { const QTapAndHoldGesture *tap = static_cast(gesture); formatGestureHeader(d, "QTapAndHoldGesture", tap); - d << ",position=" << tap->position() << ",timeout=" << tap->timeout() << ')'; + d << ",position="; + QtDebugUtils::formatQPoint(d, tap->position()); + d << ",timeout=" << tap->timeout() << ')'; } break; case Qt::PanGesture: { const QPanGesture *pan = static_cast(gesture); formatGestureHeader(d, "QPanGesture", pan); - d << ",lastOffset=" << pan->lastOffset() << ",offset=" << pan->offset() - << ",acceleration=" << pan->acceleration() - << ",delta=" << pan->delta() << ')'; + d << ",lastOffset="; + QtDebugUtils::formatQPoint(d, pan->lastOffset()); + d << pan->lastOffset(); + d << ",offset="; + QtDebugUtils::formatQPoint(d, pan->offset()); + d << ",acceleration=" << pan->acceleration() << ",delta="; + QtDebugUtils::formatQPoint(d, pan->delta()); + d << ')'; } break; case Qt::PinchGesture: { const QPinchGesture *pinch = static_cast(gesture); formatGestureHeader(d, "QPinchGesture", pinch); d << ",totalChangeFlags=" << pinch->totalChangeFlags() - << ",changeFlags=" << pinch->changeFlags() - << ",startCenterPoint=" << pinch->startCenterPoint() - << ",lastCenterPoint=" << pinch->lastCenterPoint() - << ",centerPoint=" << pinch->centerPoint() - << ",totalScaleFactor=" << pinch->totalScaleFactor() + << ",changeFlags=" << pinch->changeFlags() << ",startCenterPoint="; + QtDebugUtils::formatQPoint(d, pinch->startCenterPoint()); + d << ",lastCenterPoint="; + QtDebugUtils::formatQPoint(d, pinch->lastCenterPoint()); + d << ",centerPoint="; + QtDebugUtils::formatQPoint(d, pinch->centerPoint()); + d << ",totalScaleFactor=" << pinch->totalScaleFactor() << ",lastScaleFactor=" << pinch->lastScaleFactor() << ",scaleFactor=" << pinch->scaleFactor() << ",totalRotationAngle=" << pinch->totalRotationAngle() @@ -1138,9 +1152,11 @@ Q_WIDGETS_EXPORT QDebug operator<<(QDebug d, const QGesture *gesture) case Qt::SwipeGesture: { const QSwipeGesture *swipe = static_cast(gesture); formatGestureHeader(d, "QSwipeGesture", swipe); - d << ",horizontalDirection=" << swipe->horizontalDirection() - << ",verticalDirection=" << swipe->verticalDirection() - << ",swipeAngle=" << swipe->swipeAngle() << ')'; + d << ",horizontalDirection="; + QtDebugUtils::formatQEnum(d, swipe->horizontalDirection()); + d << ",verticalDirection="; + QtDebugUtils::formatQEnum(d, swipe->verticalDirection()); + d << ",swipeAngle=" << swipe->swipeAngle() << ')'; } break; default: -- cgit v1.2.3 From 2858a3c91b745357c1fa99b49b24705a155c6609 Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Fri, 15 May 2015 14:19:02 +0300 Subject: Don't propagate single touch events only from touchpads on OS X This way the tests that send fake touchscreen events can work. Change-Id: I997ef015d0096249c4549dbd21b99d0248e0c987 Task-number: QTBUG-46111 Reviewed-by: Friedemann Kleint Reviewed-by: Caroline Chao Reviewed-by: Shawn Rutledge --- src/widgets/kernel/qapplication.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index d61277f990..d61737efc9 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -4358,8 +4358,10 @@ bool QApplicationPrivate::translateRawTouchEvent(QWidget *window, #ifdef Q_OS_OSX // Single-touch events are normally not sent unless WA_TouchPadAcceptSingleTouchEvents is set. - // In Qt 4 this check was in OS X-only coode. That behavior is preserved here by the #ifdef. - if (touchPoints.count() == 1 && !targetWidget->testAttribute(Qt::WA_TouchPadAcceptSingleTouchEvents)) + // In Qt 4 this check was in OS X-only code. That behavior is preserved here by the #ifdef. + if (touchPoints.count() == 1 + && device->type() == QTouchDevice::TouchPad + && !targetWidget->testAttribute(Qt::WA_TouchPadAcceptSingleTouchEvents)) continue; #endif -- cgit v1.2.3 From d8bfd812c3383e24196588f5d3e1de4719fcac02 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Tue, 19 May 2015 12:36:55 +0200 Subject: D-Bus system tray icon: submenus can be created after context menu MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QMenuPrivate::init() calls QPlatformTheme::createPlatformMenu() to create a platform menu, but on Linux, that returns null for now. QSystemTrayIcon::setContextMenu() results in recursive calls to QSystemTrayIconPrivate::addPlatformMenu() which then calls QDBusTrayIcon::createMenu() for the context menu and each submenu. However if a submenu is added afterwards, a corresponding platform menu is not immediately created. Now copyActionToPlatformItem() will detect and create the missing platform submenu, by calling a new method: DBusPlatformMenu::createSubMenu(). This is because there is no way of knowing that it's a tray-specific context menu (which is so far the only case in which we use DBusPlatformMenu). So, QPlatformMenu::createSubMenu() needs to exist as a new QPA interface for this use case. Task-number: QTBUG-45803 Change-Id: Ib319e873082196515ea0580d70d069099cf2c175 Reviewed-by: Jørgen Lind --- src/widgets/widgets/qmenu.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp index 1749f9d8c7..2f0dcc49d1 100644 --- a/src/widgets/widgets/qmenu.cpp +++ b/src/widgets/widgets/qmenu.cpp @@ -183,7 +183,7 @@ void QMenuPrivate::setPlatformMenu(QPlatformMenu *menu) } // forward declare function -static void copyActionToPlatformItem(const QAction *action, QPlatformMenuItem* item); +static void copyActionToPlatformItem(const QAction *action, QPlatformMenuItem *item, QPlatformMenu *itemsMenu); void QMenuPrivate::syncPlatformMenu() { @@ -200,7 +200,7 @@ void QMenuPrivate::syncPlatformMenu() menuItem->setTag(reinterpret_cast(action)); QObject::connect(menuItem, SIGNAL(activated()), action, SLOT(trigger()), Qt::QueuedConnection); QObject::connect(menuItem, SIGNAL(hovered()), action, SIGNAL(hovered()), Qt::QueuedConnection); - copyActionToPlatformItem(action, menuItem); + copyActionToPlatformItem(action, menuItem, platformMenu.data()); platformMenu->insertMenuItem(menuItem, beforeItem); beforeItem = menuItem; } @@ -3105,7 +3105,7 @@ QMenu::timerEvent(QTimerEvent *e) } } -static void copyActionToPlatformItem(const QAction *action, QPlatformMenuItem* item) +static void copyActionToPlatformItem(const QAction *action, QPlatformMenuItem *item, QPlatformMenu *itemsMenu) { item->setText(action->text()); item->setIsSeparator(action->isSeparator()); @@ -3131,6 +3131,8 @@ static void copyActionToPlatformItem(const QAction *action, QPlatformMenuItem* i item->setEnabled(action->isEnabled()); if (action->menu()) { + if (!action->menu()->platformMenu()) + action->menu()->setPlatformMenu(itemsMenu->createSubMenu()); item->setMenu(action->menu()->platformMenu()); } else { item->setMenu(0); @@ -3185,7 +3187,7 @@ void QMenu::actionEvent(QActionEvent *e) menuItem->setTag(reinterpret_cast(e->action())); QObject::connect(menuItem, SIGNAL(activated()), e->action(), SLOT(trigger())); QObject::connect(menuItem, SIGNAL(hovered()), e->action(), SIGNAL(hovered())); - copyActionToPlatformItem(e->action(), menuItem); + copyActionToPlatformItem(e->action(), menuItem, d->platformMenu); QPlatformMenuItem* beforeItem = d->platformMenu->menuItemForTag(reinterpret_cast(e->before())); d->platformMenu->insertMenuItem(menuItem, beforeItem); } else if (e->type() == QEvent::ActionRemoved) { @@ -3195,7 +3197,7 @@ void QMenu::actionEvent(QActionEvent *e) } else if (e->type() == QEvent::ActionChanged) { QPlatformMenuItem *menuItem = d->platformMenu->menuItemForTag(reinterpret_cast(e->action())); if (menuItem) { - copyActionToPlatformItem(e->action(), menuItem); + copyActionToPlatformItem(e->action(), menuItem, d->platformMenu); d->platformMenu->syncMenuItem(menuItem); } } -- cgit v1.2.3 From 6794319bbdba69beb7baaff46520f3be15a1d490 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 21 May 2015 15:45:41 +0200 Subject: Fix a crash in tst_QTouchEvent::deleteInRawEventTranslation(). The test deletes a widget in QEvent::TouchBegin. This is part of a series of patches to revive the test; it is currently not run since tests/auto/gui/kernel/qtouchevent/qtouchevent.pro is missing CONFIG += testcase. Task-number: QTBUG-46266 Change-Id: I65c0a431ff1807133438764dd8b3c16bb9cb6743 Reviewed-by: Caroline Chao --- src/widgets/kernel/qapplication.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index d61737efc9..aa7940b623 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -4377,7 +4377,7 @@ bool QApplicationPrivate::translateRawTouchEvent(QWidget *window, QHash::ConstIterator it = widgetsNeedingEvents.constBegin(); const QHash::ConstIterator end = widgetsNeedingEvents.constEnd(); for (; it != end; ++it) { - QWidget *widget = it.key(); + const QPointer widget = it.key(); if (!QApplicationPrivate::tryModalHelper(widget, 0)) continue; @@ -4417,7 +4417,8 @@ bool QApplicationPrivate::translateRawTouchEvent(QWidget *window, // has been implicitly accepted and continue to send touch events if (QApplication::sendSpontaneousEvent(widget, &touchEvent) && touchEvent.isAccepted()) { accepted = true; - widget->setAttribute(Qt::WA_WState_AcceptedTouchBeginEvent); + if (!widget.isNull()) + widget->setAttribute(Qt::WA_WState_AcceptedTouchBeginEvent); } break; } -- cgit v1.2.3 From fe6eeab5618d9f42929872faff94dacdc0890fd2 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 26 May 2015 12:08:17 +0200 Subject: QWindowsVistaStyle: Do not stop animations when falling back to XP. Otherwise, progress bar animations are stopped. Task-number: QTBUG-46308 Change-Id: I7b6a2b26afb885db6bc9aea719a002f0ebe7274d Reviewed-by: J-P Nurmi --- src/widgets/styles/qwindowsvistastyle.cpp | 6 ------ 1 file changed, 6 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/styles/qwindowsvistastyle.cpp b/src/widgets/styles/qwindowsvistastyle.cpp index f715d93298..daa8ab12a9 100644 --- a/src/widgets/styles/qwindowsvistastyle.cpp +++ b/src/widgets/styles/qwindowsvistastyle.cpp @@ -250,8 +250,6 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt int state = option->state; if (!QWindowsVistaStylePrivate::useVista()) { - foreach (const QObject *target, d->animationTargets()) - d->stopAnimation(target); QWindowsStyle::drawPrimitive(element, option, painter, widget); return; } @@ -810,8 +808,6 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption QWindowsVistaStylePrivate *d = const_cast(d_func()); if (!QWindowsVistaStylePrivate::useVista()) { - foreach (const QObject *target, d->animationTargets()) - d->stopAnimation(target); QWindowsStyle::drawControl(element, option, painter, widget); return; } @@ -1494,8 +1490,6 @@ void QWindowsVistaStyle::drawComplexControl(ComplexControl control, const QStyle { QWindowsVistaStylePrivate *d = const_cast(d_func()); if (!QWindowsVistaStylePrivate::useVista()) { - foreach (const QObject *target, d->animationTargets()) - d->stopAnimation(target); QWindowsStyle::drawComplexControl(control, option, painter, widget); return; } -- cgit v1.2.3 From 42b7a7c6097825e9fa4a11abac3ad61db051162d Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Wed, 27 May 2015 12:27:19 +0200 Subject: Fix crash due to QTreeView accessing deleted model indexes. QTreeViewPrivate::updateScrollBars depends on a correctly set up viewItems vector. If a delayed layout is pending, we must call QTreeViewPrivate::executePostedLayout before accessing any stored model indices. Task-number: QTBUG-45697 Change-Id: I55fcbaf81f225b26181c2cf739283740b85dd16a Reviewed-by: Friedemann Kleint Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/widgets/itemviews/qtreeview.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/widgets') diff --git a/src/widgets/itemviews/qtreeview.cpp b/src/widgets/itemviews/qtreeview.cpp index 43db43fcd4..9b3e270fdd 100644 --- a/src/widgets/itemviews/qtreeview.cpp +++ b/src/widgets/itemviews/qtreeview.cpp @@ -3658,6 +3658,7 @@ void QTreeViewPrivate::updateScrollBars() if (!viewportSize.isValid()) viewportSize = QSize(0, 0); + executePostedLayout(); if (viewItems.isEmpty()) { q->doItemsLayout(); } -- cgit v1.2.3 From e22d75d0b139fe9e4b11f32ebc5fb1024f493fbe Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Fri, 2 Jan 2015 10:09:21 +0100 Subject: Translate AM/PM under the QDateTimeParser context so it is consistent In order to ensure that the same text will be used in both QDateTimeParser and QDateTimeEdit, use the QDateTimeParser context for the AM and PM strings. Task-number: QTBUG-251 Change-Id: I89b0809825251181440bf19cbe5828024a43acfb Reviewed-by: Oswald Buddenhagen --- src/widgets/widgets/qdatetimeedit.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/widgets/qdatetimeedit.cpp b/src/widgets/widgets/qdatetimeedit.cpp index b1749fa5d3..a8da78a025 100644 --- a/src/widgets/widgets/qdatetimeedit.cpp +++ b/src/widgets/widgets/qdatetimeedit.cpp @@ -2316,9 +2316,9 @@ void QDateTimeEdit::paintEvent(QPaintEvent *event) QString QDateTimeEditPrivate::getAmPmText(AmPm ap, Case cs) const { if (ap == AmText) { - return (cs == UpperCase ? QDateTimeEdit::tr("AM") : QDateTimeEdit::tr("am")); + return (cs == UpperCase ? QDateTimeParser::tr("AM") : QDateTimeParser::tr("am")); } else { - return (cs == UpperCase ? QDateTimeEdit::tr("PM") : QDateTimeEdit::tr("pm")); + return (cs == UpperCase ? QDateTimeParser::tr("PM") : QDateTimeParser::tr("pm")); } } -- cgit v1.2.3 From bccdb62340659cfdf4e0f8b53180fb73fda6ea39 Mon Sep 17 00:00:00 2001 From: Ivan Komissarov Date: Wed, 27 May 2015 15:12:54 +0300 Subject: Improve QHeaderView::sectionsInserted performance Old implementation had complexity O(oldSectionCount); replace it with O(hiddenSectionCount) algorithm. This boosts performance in case of the vertical headers for models with big row count. Change-Id: I7bb02f5579ce83fbdecf5f8c3aa7dcc0ac60dd40 Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/widgets/itemviews/qheaderview.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp index 66ff472724..bca315f80b 100644 --- a/src/widgets/itemviews/qheaderview.cpp +++ b/src/widgets/itemviews/qheaderview.cpp @@ -1879,13 +1879,13 @@ void QHeaderView::sectionsInserted(const QModelIndex &parent, // insert sections into hiddenSectionSize QHash newHiddenSectionSize; // from logical index to section size - for (int i = 0; i < logicalFirst; ++i) - if (isSectionHidden(i)) - newHiddenSectionSize[i] = d->hiddenSectionSize[i]; - for (int j = logicalLast + 1; j < d->sectionCount(); ++j) - if (isSectionHidden(j)) - newHiddenSectionSize[j] = d->hiddenSectionSize[j - insertCount]; - d->hiddenSectionSize = newHiddenSectionSize; + for (QHash::const_iterator it = d->hiddenSectionSize.cbegin(), + end = d->hiddenSectionSize.cend(); it != end; ++it) { + const int oldIndex = it.key(); + const int newIndex = (oldIndex < logicalFirst) ? oldIndex : oldIndex + insertCount; + newHiddenSectionSize[newIndex] = it.value(); + } + d->hiddenSectionSize.swap(newHiddenSectionSize); d->doDelayedResizeSections(); emit sectionCountChanged(oldCount, count()); -- cgit v1.2.3 From 0a7fcfd61263bc156b780c5e48656c00c64721ed Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 28 May 2015 10:00:45 +0200 Subject: Windows: Fix font metrics of Vista style wizards. QVistaHelper::drawTitleBar() used the font returned by QApplication::font("QMdiSubWindowTitleBar") (typically "MS Shell Dlg 2",16) to calculate the bounding rectangle of the title text. However, if the window is a toplevel QVistaHelper::drawTitleText() uses the theme font obtained for WIZ_TMT_CAPTIONFONT (typically "Segoe UI",11.25) to draw the title (since it is a window title). This causes the font to be cropped when changing the application font or spurious black rectangles to occur. Fix this by exposing QWindowsFontDatabase::LOGFONT_to_QFont() via QWindowsNativeInterface, and creating a QFont from the LOGFONT obtained for WIZ_TMT_CAPTIONFONT and using that for the bounding rectangle in the case of toplevel windows. Split up the HFONT QVistaHelper::getCaptionFont(HANDLE hTheme) into static LOGFONT getCaptionLogFont(HANDLE hTheme) and use that to obtain the HFONT in drawTitleText() or QFont in static QFont getCaptionQFont(), respectively. Task-number: QTBUG-46360 Change-Id: I9069b403f7f948b6738eec452cb7584be45b8a29 Reviewed-by: Oliver Wolff --- src/widgets/dialogs/qwizard_win.cpp | 50 ++++++++++++++++++++++++++----------- src/widgets/dialogs/qwizard_win_p.h | 1 - 2 files changed, 35 insertions(+), 16 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/dialogs/qwizard_win.cpp b/src/widgets/dialogs/qwizard_win.cpp index 701fea1c03..a4b37f360b 100644 --- a/src/widgets/dialogs/qwizard_win.cpp +++ b/src/widgets/dialogs/qwizard_win.cpp @@ -361,6 +361,36 @@ bool QVistaHelper::setDWMTitleBar(TitleBarChangeType type) Q_GUI_EXPORT HICON qt_pixmapToWinHICON(const QPixmap &); +static LOGFONT getCaptionLogFont(HANDLE hTheme) +{ + LOGFONT result = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0 } }; + + if (!hTheme || FAILED(pGetThemeSysFont(hTheme, WIZ_TMT_CAPTIONFONT, &result))) { + NONCLIENTMETRICS ncm; + ncm.cbSize = sizeof(NONCLIENTMETRICS); + SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, false); + result = ncm.lfMessageFont; + } + return result; +} + +static bool getCaptionQFont(int dpi, QFont *result) +{ + if (!pOpenThemeData) + return false; + const HANDLE hTheme = + pOpenThemeData(QApplicationPrivate::getHWNDForWidget(QApplication::desktop()), L"WINDOW"); + if (!hTheme) + return false; + // Call into QWindowsNativeInterface to convert the LOGFONT into a QFont. + const LOGFONT logFont = getCaptionLogFont(hTheme); + QPlatformNativeInterface *ni = QGuiApplication::platformNativeInterface(); + return ni && QMetaObject::invokeMethod(ni, "logFontToQFont", Qt::DirectConnection, + Q_RETURN_ARG(QFont, *result), + Q_ARG(const void *, &logFont), + Q_ARG(int, dpi)); +} + void QVistaHelper::drawTitleBar(QPainter *painter) { Q_ASSERT(backButton_); @@ -378,7 +408,9 @@ void QVistaHelper::drawTitleBar(QPainter *painter) const int verticalCenter = (btnTop + btnHeight / 2) - 1; const QString text = wizard->window()->windowTitle(); - const QFont font = QApplication::font("QMdiSubWindowTitleBar"); + QFont font; + if (!isWindow || !getCaptionQFont(wizard->logicalDpiY() * wizard->devicePixelRatio(), &font)) + font = QApplication::font("QMdiSubWindowTitleBar"); const QFontMetrics fontMetrics(font); const QRect brect = fontMetrics.boundingRect(text); int textHeight = brect.height(); @@ -649,19 +681,6 @@ bool QVistaHelper::eventFilter(QObject *obj, QEvent *event) return false; } -HFONT QVistaHelper::getCaptionFont(HANDLE hTheme) -{ - LOGFONT lf = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0 } }; - - if (!hTheme || FAILED(pGetThemeSysFont(hTheme, WIZ_TMT_CAPTIONFONT, &lf))) { - NONCLIENTMETRICS ncm; - ncm.cbSize = sizeof(NONCLIENTMETRICS); - SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, false); - lf = ncm.lfMessageFont; - } - return CreateFontIndirect(&lf); -} - // Return a HDC for the wizard along with the transformation if the // wizard is a child window. HDC QVistaHelper::backingStoreDC(const QWidget *wizard, QPoint *offset) @@ -713,7 +732,8 @@ bool QVistaHelper::drawTitleText(QPainter *painter, const QString &text, const Q bmp = CreateDIBSection(hdc, &dib, DIB_RGB_COLORS, NULL, NULL, 0); // Set up the DC - HFONT hCaptionFont = getCaptionFont(hTheme); + const LOGFONT captionLogFont = getCaptionLogFont(hTheme); + const HFONT hCaptionFont = CreateFontIndirect(&captionLogFont); HBITMAP hOldBmp = (HBITMAP)SelectObject(dcMem, (HGDIOBJ) bmp); HFONT hOldFont = (HFONT)SelectObject(dcMem, (HGDIOBJ) hCaptionFont); diff --git a/src/widgets/dialogs/qwizard_win_p.h b/src/widgets/dialogs/qwizard_win_p.h index 8c36472bee..84b795d506 100644 --- a/src/widgets/dialogs/qwizard_win_p.h +++ b/src/widgets/dialogs/qwizard_win_p.h @@ -105,7 +105,6 @@ public: static HDC backingStoreDC(const QWidget *wizard, QPoint *offset); private: - static HFONT getCaptionFont(HANDLE hTheme); HWND wizardHWND() const; bool drawTitleText(QPainter *painter, const QString &text, const QRect &rect, HDC hdc); static bool drawBlackRect(const QRect &rect, HDC hdc); -- cgit v1.2.3 From f5d1c329ce9c2c81e3bf59017fb2cdd4261b5336 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Wed, 27 May 2015 15:00:00 +0200 Subject: Emphasize the need for calling setDefaultFormat early on OS X MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTBUG-46067 Change-Id: I0fe6e7ba309306a8fc471424b30eed4491bd39e7 Reviewed-by: Topi Reiniö --- src/widgets/kernel/qopenglwidget.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/widgets') diff --git a/src/widgets/kernel/qopenglwidget.cpp b/src/widgets/kernel/qopenglwidget.cpp index b8df25b38f..9bfdc62e60 100644 --- a/src/widgets/kernel/qopenglwidget.cpp +++ b/src/widgets/kernel/qopenglwidget.cpp @@ -104,6 +104,12 @@ QT_BEGIN_NAMESPACE non-sharable. To overcome this issue, prefer using QSurfaceFormat::setDefaultFormat() instead of setFormat(). + \note Calling QSurfaceFormat::setDefaultFormat() before constructing + the QApplication instance is mandatory on some platforms (for example, + OS X) when an OpenGL core profile context is requested. This is to + ensure that resource sharing between contexts stays functional as all + internal contexts are created using the correct version and profile. + \section1 Painting Techniques As described above, subclass QOpenGLWidget to render pure 3D content in the -- cgit v1.2.3 From 45751d0ea3c4325f8f8c33969015763b5b897e77 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 18 May 2015 10:52:06 +0200 Subject: Fix combobox regression 5.4 -> 5.5 To avoid a touch release outside the combobox triggering the popup, a check was added that the combobox was hit. This fails if the combox itself is only used for the popup and associated behavior, but does not exist as widget. This patch changes the check so that only touch release checks for a hit, but a generic click still behaves as in 5.4 to avoid regressions. This fixes comboboxes no longer working in QtWebKit, since QtWebKit renders its own comboxes in webpages, and only uses the popup of the QComboBox. Task-number: QTBUG-46152 Change-Id: I74fd57b2e42e77aa4a269d812ca4a6689f254889 Reviewed-by: Florian Bruhin Reviewed-by: Friedemann Kleint --- src/widgets/widgets/qcombobox.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/widgets') diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index 76f923904d..ef80e359df 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -3034,7 +3034,7 @@ void QComboBoxPrivate::showPopupFromMouseEvent(QMouseEvent *e) QStyle::SubControl sc = q->style()->hitTestComplexControl(QStyle::CC_ComboBox, &opt, e->pos(), q); if (e->button() == Qt::LeftButton - && sc != QStyle::SC_None + && !(sc == QStyle::SC_None && e->type() == QEvent::MouseButtonRelease) && (sc == QStyle::SC_ComboBoxArrow || !q->isEditable()) && !viewContainer()->isVisible()) { if (sc == QStyle::SC_ComboBoxArrow) -- cgit v1.2.3 From 78e335408303380310dd59fab421e495cf517ead Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 1 Jun 2015 11:44:37 +0200 Subject: Clip QOpenGLWidget and QQuickWidget correctly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Introduce support for the widgets' clipRect(). Right now render-to-texture widgets in scroll areas placed close to each other result in broken (non-existent) clipping. Similarly, stack-on-top widgets fail to clip when placed inside a scroll area. This is now corrected and the qopenglwidget example is enhanced to utilize a scroll area. Task-number: QTBUG-45860 Change-Id: I859a63d61a50d64ba9e87244f83c5969dce12337 Reviewed-by: Jørgen Lind --- src/widgets/kernel/qwidgetbackingstore.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/widgets') diff --git a/src/widgets/kernel/qwidgetbackingstore.cpp b/src/widgets/kernel/qwidgetbackingstore.cpp index 485cf82078..5752317924 100644 --- a/src/widgets/kernel/qwidgetbackingstore.cpp +++ b/src/widgets/kernel/qwidgetbackingstore.cpp @@ -962,7 +962,8 @@ static void findTextureWidgetsRecursively(QWidget *tlw, QWidget *widget, QPlatfo QPlatformTextureList::Flags flags = 0; if (widget->testAttribute(Qt::WA_AlwaysStackOnTop)) flags |= QPlatformTextureList::StacksOnTop; - widgetTextures->appendTexture(widget, wd->textureId(), QRect(widget->mapTo(tlw, QPoint()), widget->size()), flags); + const QRect rect(widget->mapTo(tlw, QPoint()), widget->size()); + widgetTextures->appendTexture(widget, wd->textureId(), rect, wd->clipRect(), flags); } for (int i = 0; i < wd->children.size(); ++i) { -- cgit v1.2.3 From 0e1b4e896fba50ce6603bc323b2940e6859e7421 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 1 Jun 2015 15:23:19 +0200 Subject: Avoid QWidget dependency in QtGui MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It's not a real dependency as all we need is to store a pointer, but better not to use the name QWidget at all. Change-Id: I30ef1dd44ac7e42c1b9c84675f94088b8c516076 Reviewed-by: Jørgen Lind --- src/widgets/kernel/qwidgetbackingstore.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/widgets') diff --git a/src/widgets/kernel/qwidgetbackingstore.cpp b/src/widgets/kernel/qwidgetbackingstore.cpp index 5752317924..d1070839fa 100644 --- a/src/widgets/kernel/qwidgetbackingstore.cpp +++ b/src/widgets/kernel/qwidgetbackingstore.cpp @@ -1157,7 +1157,7 @@ void QWidgetBackingStore::doSync() #ifndef QT_NO_OPENGL if (widgetTextures && widgetTextures->count()) { for (int i = 0; i < widgetTextures->count(); ++i) { - QWidget *w = widgetTextures->widget(i); + QWidget *w = static_cast(widgetTextures->source(i)); if (dirtyRenderToTextureWidgets.contains(w)) { const QRect rect = widgetTextures->geometry(i); // mapped to the tlw already dirty += rect; -- cgit v1.2.3