summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorMorten Johan Sørvig <morten.sorvig@digia.com>2015-04-13 14:28:58 +0200
committerMorten Johan Sørvig <morten.sorvig@digia.com>2015-04-13 14:28:58 +0200
commit02ff2973ceeef00ced4468b6e15cfadd9f021b0d (patch)
treee5b51329fceb3d0134e533e41c0f3800549f1786 /src/widgets
parentc5b743472fc36986cf34636dbcb73a0d0fa6b9e6 (diff)
parent16c32710bc8a5ecefc833352159361be564f3fe4 (diff)
Merge remote-tracking branch 'gerrit/dev' into dev-highdpi
Conflicts: src/plugins/platforms/xcb/qxcbbackingstore.cpp Change-Id: Ib7f277957636186d0abd58d8c710392ef7b02e13
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/dialogs/qerrormessage.cpp81
-rw-r--r--src/widgets/dialogs/qfiledialog.cpp10
-rw-r--r--src/widgets/doc/src/modelview.qdoc2
-rw-r--r--src/widgets/graphicsview/qgraphicsitem.cpp53
-rw-r--r--src/widgets/kernel/qapplication.cpp5
-rw-r--r--src/widgets/kernel/qlayout.cpp3
-rw-r--r--src/widgets/kernel/qlayoutitem.cpp3
-rw-r--r--src/widgets/kernel/qopenglwidget.cpp27
-rw-r--r--src/widgets/kernel/qwidget.cpp26
-rw-r--r--src/widgets/kernel/qwidgetwindow.cpp7
-rw-r--r--src/widgets/styles/qandroidstyle.cpp4
-rw-r--r--src/widgets/styles/qfusionstyle.cpp10
-rw-r--r--src/widgets/styles/qproxystyle.cpp4
-rw-r--r--src/widgets/styles/qstylesheetstyle.cpp7
-rw-r--r--src/widgets/widgets/qcombobox.cpp183
-rw-r--r--src/widgets/widgets/qcombobox_p.h11
-rw-r--r--src/widgets/widgets/qdockarealayout.cpp21
-rw-r--r--src/widgets/widgets/qdockarealayout_p.h3
-rw-r--r--src/widgets/widgets/qmainwindowlayout.cpp12
-rw-r--r--src/widgets/widgets/qmainwindowlayout_p.h1
-rw-r--r--src/widgets/widgets/qmdisubwindow.cpp3
-rw-r--r--src/widgets/widgets/qtabbar.cpp4
-rw-r--r--src/widgets/widgets/qwidgetlinecontrol.cpp4
23 files changed, 330 insertions, 154 deletions
diff --git a/src/widgets/dialogs/qerrormessage.cpp b/src/widgets/dialogs/qerrormessage.cpp
index 4c3a5497d4..855bae3c9f 100644
--- a/src/widgets/dialogs/qerrormessage.cpp
+++ b/src/widgets/dialogs/qerrormessage.cpp
@@ -47,9 +47,10 @@
#include "qpixmap.h"
#include "qmetaobject.h"
#include "qthread.h"
-#include "qqueue.h"
#include "qset.h"
+#include <queue>
+
#include <stdio.h>
#include <stdlib.h>
@@ -68,16 +69,18 @@ public:
QCheckBox * again;
QTextEdit * errors;
QLabel * icon;
- QQueue<QPair<QString, QString> > pending;
+ std::queue<QPair<QString, QString> > pending;
QSet<QString> doNotShow;
QSet<QString> doNotShowType;
QString currentMessage;
QString currentType;
+ bool isMessageToBeShown(const QString &message, const QString &type) const;
bool nextPending();
void retranslateStrings();
};
+namespace {
class QErrorMessageTextView : public QTextEdit
{
public:
@@ -87,6 +90,7 @@ public:
virtual QSize minimumSizeHint() const Q_DECL_OVERRIDE;
virtual QSize sizeHint() const Q_DECL_OVERRIDE;
};
+} // unnamed namespace
QSize QErrorMessageTextView::minimumSizeHint() const
{
@@ -217,29 +221,32 @@ QErrorMessage::QErrorMessage(QWidget * parent)
: QDialog(*new QErrorMessagePrivate, parent)
{
Q_D(QErrorMessage);
- QGridLayout * grid = new QGridLayout(this);
+
d->icon = new QLabel(this);
-#ifndef QT_NO_MESSAGEBOX
- d->icon->setPixmap(QMessageBox::standardIcon(QMessageBox::Information));
- d->icon->setAlignment(Qt::AlignHCenter | Qt::AlignTop);
-#endif
- grid->addWidget(d->icon, 0, 0, Qt::AlignTop);
d->errors = new QErrorMessageTextView(this);
- grid->addWidget(d->errors, 0, 1);
d->again = new QCheckBox(this);
- d->again->setChecked(true);
- grid->addWidget(d->again, 1, 1, Qt::AlignTop);
d->ok = new QPushButton(this);
+ QGridLayout * grid = new QGridLayout(this);
+
+ connect(d->ok, SIGNAL(clicked()), this, SLOT(accept()));
+ grid->addWidget(d->icon, 0, 0, Qt::AlignTop);
+ grid->addWidget(d->errors, 0, 1);
+ grid->addWidget(d->again, 1, 1, Qt::AlignTop);
+ grid->addWidget(d->ok, 2, 0, 1, 2, Qt::AlignCenter);
+ grid->setColumnStretch(1, 42);
+ grid->setRowStretch(0, 42);
+#ifndef QT_NO_MESSAGEBOX
+ d->icon->setPixmap(QMessageBox::standardIcon(QMessageBox::Information));
+ d->icon->setAlignment(Qt::AlignHCenter | Qt::AlignTop);
+#endif
+ d->again->setChecked(true);
#if defined(Q_OS_WINCE)
d->ok->setFixedSize(0,0);
#endif
- connect(d->ok, SIGNAL(clicked()), this, SLOT(accept()));
d->ok->setFocus();
- grid->addWidget(d->ok, 2, 0, 1, 2, Qt::AlignCenter);
- grid->setColumnStretch(1, 42);
- grid->setRowStretch(0, 42);
+
d->retranslateStrings();
}
@@ -265,11 +272,13 @@ QErrorMessage::~QErrorMessage()
void QErrorMessage::done(int a)
{
Q_D(QErrorMessage);
- if (!d->again->isChecked() && !d->currentMessage.isEmpty() && d->currentType.isEmpty()) {
- d->doNotShow.insert(d->currentMessage);
- }
- if (!d->again->isChecked() && !d->currentType.isEmpty()) {
- d->doNotShowType.insert(d->currentType);
+ if (!d->again->isChecked()) {
+ if (d->currentType.isEmpty()) {
+ if (!d->currentMessage.isEmpty())
+ d->doNotShow.insert(d->currentMessage);
+ } else {
+ d->doNotShowType.insert(d->currentType);
+ }
}
d->currentMessage.clear();
d->currentType.clear();
@@ -301,20 +310,27 @@ QErrorMessage * QErrorMessage::qtHandler()
/*! \internal */
+bool QErrorMessagePrivate::isMessageToBeShown(const QString &message, const QString &type) const
+{
+ return !message.isEmpty()
+ && (type.isEmpty() ? !doNotShow.contains(message) : !doNotShowType.contains(type));
+}
+
bool QErrorMessagePrivate::nextPending()
{
- while (!pending.isEmpty()) {
- QPair<QString,QString> pendingMessage = pending.dequeue();
- QString message = pendingMessage.first;
- QString type = pendingMessage.second;
- if (!message.isEmpty() && ((type.isEmpty() && !doNotShow.contains(message)) || (!type.isEmpty() && !doNotShowType.contains(type)))) {
+ while (!pending.empty()) {
+ QPair<QString,QString> &pendingMessage = pending.front();
+ QString message = qMove(pendingMessage.first);
+ QString type = qMove(pendingMessage.second);
+ pending.pop();
+ if (isMessageToBeShown(message, type)) {
#ifndef QT_NO_TEXTHTMLPARSER
errors->setHtml(message);
#else
errors->setPlainText(message);
#endif
- currentMessage = message;
- currentType = type;
+ currentMessage = qMove(message);
+ currentType = qMove(type);
return true;
}
}
@@ -333,12 +349,7 @@ bool QErrorMessagePrivate::nextPending()
void QErrorMessage::showMessage(const QString &message)
{
- Q_D(QErrorMessage);
- if (d->doNotShow.contains(message))
- return;
- d->pending.enqueue(qMakePair(message,QString()));
- if (!isVisible() && d->nextPending())
- show();
+ showMessage(message, QString());
}
/*!
@@ -358,9 +369,9 @@ void QErrorMessage::showMessage(const QString &message)
void QErrorMessage::showMessage(const QString &message, const QString &type)
{
Q_D(QErrorMessage);
- if (d->doNotShow.contains(message) && d->doNotShowType.contains(type))
+ if (!d->isMessageToBeShown(message, type))
return;
- d->pending.push_back(qMakePair(message,type));
+ d->pending.push(qMakePair(message, type));
if (!isVisible() && d->nextPending())
show();
}
diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp
index 455111225e..6a1374e3ee 100644
--- a/src/widgets/dialogs/qfiledialog.cpp
+++ b/src/widgets/dialogs/qfiledialog.cpp
@@ -976,6 +976,16 @@ QDir QFileDialog::directory() const
\note The non-native QFileDialog supports only local files.
+ \note On Windows, it is possible to pass URLs representing
+ one of the \e {virtual folders}, such as "Computer" or "Network".
+ This is done by passing a QUrl using the scheme \c clsid followed
+ by the CLSID value with the curly braces removed. For example the URL
+ \c clsid:374DE290-123F-4565-9164-39C4925E467B denotes the download
+ location. For a complete list of possible values, see the MSDN documentation on
+ \l{https://msdn.microsoft.com/en-us/library/windows/desktop/dd378457.aspx}{KNOWNFOLDERID}.
+ This feature was added in Qt 5.5.
+
+ \sa QUuid
\since 5.2
*/
void QFileDialog::setDirectoryUrl(const QUrl &directory)
diff --git a/src/widgets/doc/src/modelview.qdoc b/src/widgets/doc/src/modelview.qdoc
index e3a569e8ac..2cdf724ae8 100644
--- a/src/widgets/doc/src/modelview.qdoc
+++ b/src/widgets/doc/src/modelview.qdoc
@@ -576,7 +576,7 @@
problem.
Qt Labs provides software called
- \l{http://wiki.qt.io/?title=Model_Test}{ModelTest},
+ \l{http://wiki.qt.io/Model_Test}{ModelTest},
which checks models while your programming is running. Every time the model
is changed, ModelTest scans the model and reports errors with an assert.
This is especially important for tree models, since their hierarchical
diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp
index 533564c1dc..eaa5cb99e4 100644
--- a/src/widgets/graphicsview/qgraphicsitem.cpp
+++ b/src/widgets/graphicsview/qgraphicsitem.cpp
@@ -736,7 +736,6 @@
#include "qgraphicsproxywidget.h"
#include "qgraphicsscenebsptreeindex_p.h"
#include <QtCore/qbitarray.h>
-#include <QtCore/qdebug.h>
#include <QtCore/qpoint.h>
#include <QtCore/qstack.h>
#include <QtCore/qtimer.h>
@@ -761,6 +760,7 @@
#include <private/qwidget_p.h>
#include <private/qapplication_p.h>
#include <private/qgesturemanager_p.h>
+#include <private/qdebug_p.h>
QT_BEGIN_NAMESPACE
@@ -11283,8 +11283,24 @@ QPixmap QGraphicsItemEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QP
#endif //QT_NO_GRAPHICSEFFECT
#ifndef QT_NO_DEBUG_STREAM
+static void formatGraphicsItemHelper(QDebug debug, const QGraphicsItem *item)
+{
+ if (const QGraphicsItem *parent = item->parentItem())
+ debug << ", parent=" << static_cast<const void *>(parent);
+ debug << ", pos=";
+ QtDebugUtils::formatQPoint(debug, item->pos());
+ if (const qreal z = item->zValue())
+ debug << ", z=" << item->zValue();
+ if (item->flags())
+ debug << ", flags=" << item->flags();
+}
+
+// FIXME: Qt 6: Make this QDebug operator<<(QDebug debug, const QGraphicsItem *item)
QDebug operator<<(QDebug debug, QGraphicsItem *item)
{
+ QDebugStateSaver saver(debug);
+ debug.nospace();
+
if (!item) {
debug << "QGraphicsItem(0)";
return debug;
@@ -11294,29 +11310,40 @@ QDebug operator<<(QDebug debug, QGraphicsItem *item)
debug << o->metaObject()->className();
else
debug << "QGraphicsItem";
- debug << "(this =" << (void*)item
- << ", parent =" << (void*)item->parentItem()
- << ", pos =" << item->pos()
- << ", z =" << item->zValue() << ", flags = "
- << item->flags() << ")";
+ debug << '(' << static_cast<const void *>(item);
+ if (const QGraphicsProxyWidget *pw = qgraphicsitem_cast<const QGraphicsProxyWidget *>(item)) {
+ debug << ", widget=";
+ if (const QWidget *w = pw->widget()) {
+ debug << w->metaObject()->className() << '(' << static_cast<const void *>(w);
+ if (!w->objectName().isEmpty())
+ debug << ", name=" << w->objectName();
+ debug << ')';
+ } else {
+ debug << "QWidget(0)";
+ }
+ }
+ formatGraphicsItemHelper(debug, item);
+ debug << ')';
return debug;
}
+// FIXME: Qt 6: Make this QDebug operator<<(QDebug debug, const QGraphicsObject *item)
QDebug operator<<(QDebug debug, QGraphicsObject *item)
{
+ QDebugStateSaver saver(debug);
+ debug.nospace();
+
if (!item) {
debug << "QGraphicsObject(0)";
return debug;
}
- debug.nospace() << item->metaObject()->className() << '(' << (void*)item;
+ debug << item->metaObject()->className() << '(' << static_cast<const void *>(item);
if (!item->objectName().isEmpty())
- debug << ", name = " << item->objectName();
- debug.nospace() << ", parent = " << ((void*)item->parentItem())
- << ", pos = " << item->pos()
- << ", z = " << item->zValue() << ", flags = "
- << item->flags() << ')';
- return debug.space();
+ debug << ", name=" << item->objectName();
+ formatGraphicsItemHelper(debug, item);
+ debug << ')';
+ return debug;
}
QDebug operator<<(QDebug debug, QGraphicsItem::GraphicsItemChange change)
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index 78c842f7e1..00f590ebc2 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -978,8 +978,7 @@ bool QApplication::compressEvent(QEvent *event, QObject *receiver, QPostEventLis
|| event->type() == QEvent::LayoutRequest
|| event->type() == QEvent::Resize
|| event->type() == QEvent::Move
- || event->type() == QEvent::LanguageChange
- || event->type() == QEvent::InputMethod)) {
+ || event->type() == QEvent::LanguageChange)) {
for (QPostEventList::const_iterator it = postedEvents->constBegin(); it != postedEvents->constEnd(); ++it) {
const QPostEvent &cur = *it;
if (cur.receiver != receiver || cur.event == 0 || cur.event->type() != event->type())
@@ -993,8 +992,6 @@ bool QApplication::compressEvent(QEvent *event, QObject *receiver, QPostEventLis
((QMoveEvent *)(cur.event))->p = ((QMoveEvent *)event)->p;
} else if (cur.event->type() == QEvent::LanguageChange) {
;
- } else if ( cur.event->type() == QEvent::InputMethod ) {
- *(QInputMethodEvent *)(cur.event) = *(QInputMethodEvent *)event;
} else {
continue;
}
diff --git a/src/widgets/kernel/qlayout.cpp b/src/widgets/kernel/qlayout.cpp
index 822690942e..dcacea4777 100644
--- a/src/widgets/kernel/qlayout.cpp
+++ b/src/widgets/kernel/qlayout.cpp
@@ -1175,13 +1175,12 @@ QLayoutItem *QLayout::replaceWidget(QWidget *from, QWidget *to, Qt::FindChildOpt
if (index == -1)
return 0;
+ addChildWidget(to);
QLayoutItem *newitem = new QWidgetItem(to);
newitem->setAlignment(item->alignment());
QLayoutItem *r = d->replaceAt(index, newitem);
if (!r)
delete newitem;
- else
- addChildWidget(to);
return r;
}
diff --git a/src/widgets/kernel/qlayoutitem.cpp b/src/widgets/kernel/qlayoutitem.cpp
index 0e69bbc8ae..b21925e1d4 100644
--- a/src/widgets/kernel/qlayoutitem.cpp
+++ b/src/widgets/kernel/qlayoutitem.cpp
@@ -850,9 +850,10 @@ int QWidgetItemV2::heightForWidth(int width) const
#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.space();
+ return dbg;
}
#endif
diff --git a/src/widgets/kernel/qopenglwidget.cpp b/src/widgets/kernel/qopenglwidget.cpp
index 8c60818819..9a0584bea9 100644
--- a/src/widgets/kernel/qopenglwidget.cpp
+++ b/src/widgets/kernel/qopenglwidget.cpp
@@ -46,6 +46,7 @@
#include <QtGui/private/qopenglextensions_p.h>
#include <QtGui/private/qfont_p.h>
#include <QtGui/private/qopenglpaintdevice_p.h>
+#include <QtGui/private/qopenglcontext_p.h>
#include <QtWidgets/private/qwidget_p.h>
QT_BEGIN_NAMESPACE
@@ -435,6 +436,23 @@ QT_BEGIN_NAMESPACE
each frame. To restore the preserved behavior, call setUpdateBehavior() with
\c PartialUpdate.
+ \section1 Alternatives
+
+ Adding a QOpenGLWidget into a window turns on OpenGL-based
+ compositing for the entire window. In some special cases this may
+ not be ideal, and the old QGLWidget-style behavior with a separate,
+ native child window is desired. Desktop applications that understand
+ the limitations of this approach (for example when it comes to
+ overlaps, transparency, scroll views and MDI areas), can use
+ QOpenGLWindow with QWidget::createWindowContainer(). This is a
+ modern alternative to QGLWidget and is faster than QOpenGLWidget due
+ to the lack of the additional composition step. It is strongly
+ recommended to limit the usage of this approach to cases where there
+ is no other choice. Note that this option is not suitable for most
+ embedded and mobile platforms, and it is known to have issues on
+ certain desktop platforms (e.g. OS X) too. The stable,
+ cross-platform solution is always QOpenGLWidget.
+
\e{OpenGL is a trademark of Silicon Graphics, Inc. in the United States and other
countries.}
@@ -775,11 +793,18 @@ void QOpenGLWidgetPrivate::resolveSamples()
void QOpenGLWidgetPrivate::invokeUserPaint()
{
Q_Q(QOpenGLWidget);
- QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions();
+
+ QOpenGLContext *ctx = QOpenGLContext::currentContext();
+ Q_ASSERT(ctx && fbo);
+
+ QOpenGLFunctions *f = ctx->functions();
+ QOpenGLContextPrivate::get(ctx)->defaultFboRedirect = fbo->handle();
f->glViewport(0, 0, q->width() * q->devicePixelRatio(), q->height() * q->devicePixelRatio());
q->paintGL();
flushPending = true;
+
+ QOpenGLContextPrivate::get(ctx)->defaultFboRedirect = 0;
}
void QOpenGLWidgetPrivate::render()
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index 2d76cee008..321cf0641c 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -6116,8 +6116,15 @@ QIcon QWidget::windowIcon() const
void QWidgetPrivate::setWindowIcon_helper()
{
+ Q_Q(QWidget);
QEvent e(QEvent::WindowIconChange);
- QApplication::sendEvent(q_func(), &e);
+
+ // Do not send the event if the widget is a top level.
+ // In that case, setWindowIcon_sys does it, and event propagation from
+ // QWidgetWindow to the top level QWidget ensures that the event reaches
+ // the top level anyhow
+ if (!q->windowHandle())
+ QApplication::sendEvent(q, &e);
for (int i = 0; i < children.size(); ++i) {
QWidget *w = qobject_cast<QWidget *>(children.at(i));
if (w && !w->isWindow())
@@ -8049,28 +8056,13 @@ void QWidget::setVisible(bool visible)
&& !parentWidget()->testAttribute(Qt::WA_WState_Created))
parentWidget()->window()->d_func()->createRecursively();
- //we have to at least create toplevels before applyX11SpecificCommandLineArguments
- //but not children of non-visible parents
+ //create toplevels but not children of non-visible parents
QWidget *pw = parentWidget();
if (!testAttribute(Qt::WA_WState_Created)
&& (isWindow() || pw->testAttribute(Qt::WA_WState_Created))) {
create();
}
- // Handling of the -qwindowgeometry, -geometry command line arguments
- if (windowType() == Qt::Window && windowHandle()) {
- static bool done = false;
- if (!done) {
- done = true;
- const QRect oldGeometry = frameGeometry();
- const QRect geometry = QGuiApplicationPrivate::applyWindowGeometrySpecification(oldGeometry, windowHandle());
- if (oldGeometry.size() != geometry.size())
- resize(geometry.size());
- if (geometry.topLeft() != oldGeometry.topLeft())
- move(geometry.topLeft());
- } // done
- }
-
bool wasResized = testAttribute(Qt::WA_Resized);
Qt::WindowStates initialWindowState = windowState();
diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp
index 12f5d4b8b0..efe7d9415b 100644
--- a/src/widgets/kernel/qwidgetwindow.cpp
+++ b/src/widgets/kernel/qwidgetwindow.cpp
@@ -161,7 +161,7 @@ bool QWidgetWindow::event(QEvent *event)
if (m_widget->testAttribute(Qt::WA_DontShowOnScreen)) {
// \a event is uninteresting for QWidgetWindow, the event was probably
// generated before WA_DontShowOnScreen was set
- return m_widget->event(event);
+ return QCoreApplication::sendEvent(m_widget, event);
}
switch (event->type()) {
@@ -303,7 +303,7 @@ bool QWidgetWindow::event(QEvent *event)
break;
}
- if (m_widget->event(event) && event->type() != QEvent::Timer)
+ if (QCoreApplication::sendEvent(m_widget, event) && event->type() != QEvent::Timer)
return true;
return QWindow::event(event);
@@ -465,7 +465,8 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
}
if (qApp->activePopupWidget() != activePopupWidget
- && qt_replay_popup_mouse_event) {
+ && qt_replay_popup_mouse_event
+ && QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::ReplayMousePressOutsidePopup).toBool()) {
if (m_widget->windowType() != Qt::Popup)
qt_button_down = 0;
if (event->type() == QEvent::MouseButtonPress) {
diff --git a/src/widgets/styles/qandroidstyle.cpp b/src/widgets/styles/qandroidstyle.cpp
index f1d5eca90b..c73908d0a5 100644
--- a/src/widgets/styles/qandroidstyle.cpp
+++ b/src/widgets/styles/qandroidstyle.cpp
@@ -1811,6 +1811,10 @@ QRect QAndroidStyle::AndroidSpinnerControl::subControlRect(const QStyleOptionCom
{
if (sc == QStyle::SC_ComboBoxListBoxPopup)
return option->rect;
+ if (sc == QStyle::SC_ComboBoxArrow) {
+ const QRect editField = subControlRect(option, QStyle::SC_ComboBoxEditField, widget);
+ return QRect(editField.topRight(), QSize(option->rect.width() - editField.width(), option->rect.height()));
+ }
return AndroidControl::subControlRect(option, sc, widget);
}
diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp
index 1f7a87e23d..6d722c680b 100644
--- a/src/widgets/styles/qfusionstyle.cpp
+++ b/src/widgets/styles/qfusionstyle.cpp
@@ -209,7 +209,10 @@ static QPixmap colorizedImage(const QString &fileName, const QColor &color, int
unsigned char green = gray + qt_div_255(sourceGreen * colorDiff);
unsigned char blue = gray + qt_div_255(sourceBlue * colorDiff);
unsigned char alpha = qt_div_255(qAlpha(col) * qAlpha(source));
- data[x] = qRgba(red, green, blue, alpha);
+ data[x] = qRgba(std::min(alpha, red),
+ std::min(alpha, green),
+ std::min(alpha, blue),
+ alpha);
}
}
if (rotation != 0) {
@@ -3608,6 +3611,11 @@ int QFusionStyle::styleHint(StyleHint hint, const QStyleOption *option, const QW
case SH_Menu_SupportsSections:
return 1;
+#if defined(Q_OS_IOS)
+ case SH_ComboBox_UseNativePopup:
+ return 1;
+#endif
+
case SH_ToolBox_SelectedPageTitleBold:
case SH_ScrollView_FrameOnlyAroundContents:
case SH_Menu_AllowActiveAndDisabled:
diff --git a/src/widgets/styles/qproxystyle.cpp b/src/widgets/styles/qproxystyle.cpp
index 4b1c58dc50..61f836b23c 100644
--- a/src/widgets/styles/qproxystyle.cpp
+++ b/src/widgets/styles/qproxystyle.cpp
@@ -101,8 +101,8 @@ void QProxyStylePrivate::ensureBaseStyle() const
/*!
Constructs a QProxyStyle object for overriding behavior in the
- specified base \a style, or in the current \l{QApplication::style()}
- {application style} if base \a style is not specified.
+ specified \a style, or in the default native \l{QApplication::style()}
+ {style} if \a style is not specified.
Ownership of \a style is transferred to QProxyStyle.
*/
diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp
index 4993457b32..86b5632d2e 100644
--- a/src/widgets/styles/qstylesheetstyle.cpp
+++ b/src/widgets/styles/qstylesheetstyle.cpp
@@ -2393,6 +2393,13 @@ static bool unstylable(const QWidget *w)
return true;
}
#endif
+
+#ifndef QT_NO_TABBAR
+ if (w->metaObject() == &QWidget::staticMetaObject
+ && qobject_cast<const QTabBar*>(w->parentWidget()))
+ return true; // The moving tab of a QTabBar
+#endif
+
return false;
}
diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp
index ab4c7bfff6..76f923904d 100644
--- a/src/widgets/widgets/qcombobox.cpp
+++ b/src/widgets/widgets/qcombobox.cpp
@@ -53,6 +53,7 @@
#include <qmath.h>
#include <qmetaobject.h>
#include <qabstractproxymodel.h>
+#include <qstylehints.h>
#include <private/qguiapplication_p.h>
#include <private/qapplication_p.h>
#include <private/qcombobox_p.h>
@@ -93,12 +94,22 @@ QComboBoxPrivate::QComboBoxPrivate()
hoverControl(QStyle::SC_None),
autoCompletionCaseSensitivity(Qt::CaseInsensitive),
indexBeforeChange(-1)
+#ifdef Q_OS_MAC
+ , m_platformMenu(0)
+#endif
#ifndef QT_NO_COMPLETER
, completer(0)
#endif
{
}
+QComboBoxPrivate::~QComboBoxPrivate()
+{
+#ifdef Q_OS_MAC
+ cleanupNativePopup();
+#endif
+}
+
QStyleOptionMenuItem QComboMenuDelegate::getStyleOption(const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
@@ -215,6 +226,7 @@ void QComboBoxPrivate::_q_modelReset()
}
if (currentIndex.row() != indexBeforeChange)
_q_emitCurrentIndexChanged(currentIndex);
+ modelChanged();
q->update();
}
@@ -2078,8 +2090,11 @@ void QComboBoxPrivate::setCurrentIndex(const QModelIndex &mi)
currentIndex = QPersistentModelIndex(normalized);
if (lineEdit) {
const QString newText = itemText(normalized);
- if (lineEdit->text() != newText)
+ if (lineEdit->text() != newText) {
lineEdit->setText(newText);
+ if (lineEdit->completer())
+ lineEdit->completer()->setCompletionPrefix(newText);
+ }
updateLineEditGeometry();
}
if (indexChanged) {
@@ -2398,7 +2413,7 @@ QSize QComboBox::sizeHint() const
return d->recomputeSizeHint(d->sizeHint);
}
-#ifdef Q_OS_OSX
+#ifdef Q_OS_MAC
namespace {
struct IndexSetter {
@@ -2409,6 +2424,19 @@ struct IndexSetter {
};
}
+void QComboBoxPrivate::cleanupNativePopup()
+{
+ if (!m_platformMenu)
+ return;
+
+ int count = int(m_platformMenu->tag());
+ for (int i = 0; i < count; ++i)
+ m_platformMenu->menuItemAt(i)->deleteLater();
+
+ delete m_platformMenu;
+ m_platformMenu = 0;
+}
+
/*!
* \internal
*
@@ -2419,60 +2447,62 @@ bool QComboBoxPrivate::showNativePopup()
{
Q_Q(QComboBox);
- QPlatformTheme *theme = QGuiApplicationPrivate::instance()->platformTheme();
- if (QPlatformMenu *menu = theme->createPlatformMenu()) {
- int itemsCount = q->count();
-
- QList<QPlatformMenuItem *> items;
- items.reserve(itemsCount);
- QPlatformMenuItem *currentItem = 0;
- int currentIndex = q->currentIndex();
-
- for (int i = 0; i < itemsCount; ++i) {
- QPlatformMenuItem *item = theme->createPlatformMenuItem();
- QModelIndex rowIndex = model->index(i, modelColumn, root);
- QVariant textVariant = model->data(rowIndex, Qt::EditRole);
- item->setText(textVariant.toString());
- QVariant iconVariant = model->data(rowIndex, Qt::DecorationRole);
- if (iconVariant.canConvert<QIcon>())
- item->setIcon(iconVariant.value<QIcon>());
- item->setCheckable(true);
- item->setChecked(i == currentIndex);
- if (!currentItem || i == currentIndex)
- currentItem = item;
-
- IndexSetter setter = { i, q };
- QObject::connect(item, &QPlatformMenuItem::activated, setter);
-
- menu->insertMenuItem(item, 0);
- menu->syncMenuItem(item);
- }
+ cleanupNativePopup();
- QWindow *tlw = q->window()->windowHandle();
- menu->setFont(q->font());
- menu->setMinimumWidth(q->rect().width());
- QPoint offset = QPoint(0, 7);
- if (q->testAttribute(Qt::WA_MacSmallSize))
- offset = QPoint(-1, 7);
- else if (q->testAttribute(Qt::WA_MacMiniSize))
- offset = QPoint(-2, 6);
- menu->showPopup(tlw, QRect(tlw->mapFromGlobal(q->mapToGlobal(offset)), QSize()), currentItem);
- menu->deleteLater();
- Q_FOREACH (QPlatformMenuItem *item, items)
- item->deleteLater();
-
- // The Cocoa popup will swallow any mouse release event.
- // We need to fake one here to un-press the button.
- QMouseEvent mouseReleased(QEvent::MouseButtonRelease, q->pos(), Qt::LeftButton,
- Qt::MouseButtons(Qt::LeftButton), Qt::KeyboardModifiers());
- qApp->sendEvent(q, &mouseReleased);
+ QPlatformTheme *theme = QGuiApplicationPrivate::instance()->platformTheme();
+ m_platformMenu = theme->createPlatformMenu();
+ if (!m_platformMenu)
+ return false;
+
+ int itemsCount = q->count();
+ m_platformMenu->setTag(quintptr(itemsCount));
+
+ QPlatformMenuItem *currentItem = 0;
+ int currentIndex = q->currentIndex();
+
+ for (int i = 0; i < itemsCount; ++i) {
+ QPlatformMenuItem *item = theme->createPlatformMenuItem();
+ QModelIndex rowIndex = model->index(i, modelColumn, root);
+ QVariant textVariant = model->data(rowIndex, Qt::EditRole);
+ item->setText(textVariant.toString());
+ QVariant iconVariant = model->data(rowIndex, Qt::DecorationRole);
+ if (iconVariant.canConvert<QIcon>())
+ item->setIcon(iconVariant.value<QIcon>());
+ item->setCheckable(true);
+ item->setChecked(i == currentIndex);
+ if (!currentItem || i == currentIndex)
+ currentItem = item;
+
+ IndexSetter setter = { i, q };
+ QObject::connect(item, &QPlatformMenuItem::activated, setter);
+
+ m_platformMenu->insertMenuItem(item, 0);
+ m_platformMenu->syncMenuItem(item);
+ }
+
+ QWindow *tlw = q->window()->windowHandle();
+ m_platformMenu->setFont(q->font());
+ m_platformMenu->setMinimumWidth(q->rect().width());
+ QPoint offset = QPoint(0, 7);
+ if (q->testAttribute(Qt::WA_MacSmallSize))
+ offset = QPoint(-1, 7);
+ else if (q->testAttribute(Qt::WA_MacMiniSize))
+ offset = QPoint(-2, 6);
+
+ m_platformMenu->showPopup(tlw, QRect(tlw->mapFromGlobal(q->mapToGlobal(offset)), QSize()), currentItem);
- return true;
- }
+#ifdef Q_OS_OSX
+ // The Cocoa popup will swallow any mouse release event.
+ // We need to fake one here to un-press the button.
+ QMouseEvent mouseReleased(QEvent::MouseButtonRelease, q->pos(), Qt::LeftButton,
+ Qt::MouseButtons(Qt::LeftButton), Qt::KeyboardModifiers());
+ qApp->sendEvent(q, &mouseReleased);
+#endif
- return false;
+ return true;
}
-#endif // Q_OS_OSX
+
+#endif // Q_OS_MAC
/*!
Displays the list of items in the combobox. If the list is empty
@@ -2494,7 +2524,7 @@ void QComboBox::showPopup()
initStyleOption(&opt);
const bool usePopup = style->styleHint(QStyle::SH_ComboBox_Popup, &opt, this);
-#ifdef Q_OS_OSX
+#ifdef Q_OS_MAC
if (usePopup
&& (!d->container
|| (view()->metaObject()->className() == QByteArray("QComboBoxListView")
@@ -2502,7 +2532,7 @@ void QComboBox::showPopup()
&& style->styleHint(QStyle::SH_ComboBox_UseNativePopup, &opt, this)
&& d->showNativePopup())
return;
-#endif // Q_OS_OSX
+#endif // Q_OS_MAC
#ifdef QT_KEYPAD_NAVIGATION
#ifndef QT_NO_COMPLETER
@@ -2989,39 +3019,51 @@ bool QComboBox::event(QEvent *event)
void QComboBox::mousePressEvent(QMouseEvent *e)
{
Q_D(QComboBox);
+ if (!QGuiApplication::styleHints()->setFocusOnTouchRelease())
+ d->showPopupFromMouseEvent(e);
+}
+
+/*!
+ \reimp
+*/
+void QComboBoxPrivate::showPopupFromMouseEvent(QMouseEvent *e)
+{
+ Q_Q(QComboBox);
QStyleOptionComboBox opt;
- initStyleOption(&opt);
- QStyle::SubControl sc = style()->hitTestComplexControl(QStyle::CC_ComboBox, &opt, e->pos(),
- this);
- if (e->button() == Qt::LeftButton && (sc == QStyle::SC_ComboBoxArrow || !isEditable())
- && !d->viewContainer()->isVisible()) {
+ q->initStyleOption(&opt);
+ 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_ComboBoxArrow || !q->isEditable())
+ && !viewContainer()->isVisible()) {
if (sc == QStyle::SC_ComboBoxArrow)
- d->updateArrow(QStyle::State_Sunken);
+ updateArrow(QStyle::State_Sunken);
#ifdef QT_KEYPAD_NAVIGATION
//if the container already exists, then d->viewContainer() is safe to call
- if (d->container) {
+ if (container) {
#endif
// We've restricted the next couple of lines, because by not calling
// viewContainer(), we avoid creating the QComboBoxPrivateContainer.
- d->viewContainer()->blockMouseReleaseTimer.start(QApplication::doubleClickInterval());
- d->viewContainer()->initialClickPosition = mapToGlobal(e->pos());
+ viewContainer()->blockMouseReleaseTimer.start(QApplication::doubleClickInterval());
+ viewContainer()->initialClickPosition = q->mapToGlobal(e->pos());
#ifdef QT_KEYPAD_NAVIGATION
}
#endif
- showPopup();
+ q->showPopup();
// The code below ensures that regular mousepress and pick item still works
// If it was not called the viewContainer would ignore event since it didn't have
// a mousePressEvent first.
- if (d->viewContainer())
- d->viewContainer()->maybeIgnoreMouseButtonRelease = false;
+ if (viewContainer())
+ viewContainer()->maybeIgnoreMouseButtonRelease = false;
} else {
#ifdef QT_KEYPAD_NAVIGATION
- if (QApplication::keypadNavigationEnabled() && sc == QStyle::SC_ComboBoxEditField && d->lineEdit) {
- d->lineEdit->event(e); //so lineedit can move cursor, etc
+ if (QApplication::keypadNavigationEnabled() && sc == QStyle::SC_ComboBoxEditField && lineEdit) {
+ lineEdit->event(e); //so lineedit can move cursor, etc
return;
}
#endif
- QWidget::mousePressEvent(e);
+ e->ignore();
}
}
@@ -3031,8 +3073,9 @@ void QComboBox::mousePressEvent(QMouseEvent *e)
void QComboBox::mouseReleaseEvent(QMouseEvent *e)
{
Q_D(QComboBox);
- Q_UNUSED(e);
d->updateArrow(QStyle::State_None);
+ if (QGuiApplication::styleHints()->setFocusOnTouchRelease() && hasFocus())
+ d->showPopupFromMouseEvent(e);
}
/*!
diff --git a/src/widgets/widgets/qcombobox_p.h b/src/widgets/widgets/qcombobox_p.h
index 5ee7d72e8e..3fdfdcc22f 100644
--- a/src/widgets/widgets/qcombobox_p.h
+++ b/src/widgets/widgets/qcombobox_p.h
@@ -71,6 +71,7 @@
QT_BEGIN_NAMESPACE
class QAction;
+class QPlatformMenu;
class QComboBoxListView : public QListView
{
@@ -252,6 +253,7 @@ private:
QElapsedTimer popupTimer;
friend class QComboBox;
+ friend class QComboBoxPrivate;
};
class Q_AUTOTEST_EXPORT QComboMenuDelegate : public QAbstractItemDelegate
@@ -331,7 +333,7 @@ class Q_AUTOTEST_EXPORT QComboBoxPrivate : public QWidgetPrivate
Q_DECLARE_PUBLIC(QComboBox)
public:
QComboBoxPrivate();
- ~QComboBoxPrivate() {}
+ ~QComboBoxPrivate();
void init();
QComboBoxPrivateContainer* viewContainer();
void updateLineEditGeometry();
@@ -371,8 +373,10 @@ public:
void modelChanged();
void updateViewContainerPaletteAndOpacity();
void updateFocusPolicy();
+ void showPopupFromMouseEvent(QMouseEvent *e);
-#ifdef Q_OS_OSX
+#ifdef Q_OS_MAC
+ void cleanupNativePopup();
bool showNativePopup();
#endif
@@ -401,6 +405,9 @@ public:
QPersistentModelIndex root;
Qt::CaseSensitivity autoCompletionCaseSensitivity;
int indexBeforeChange;
+#ifdef Q_OS_MAC
+ QPlatformMenu *m_platformMenu;
+#endif
#ifndef QT_NO_COMPLETER
QPointer<QCompleter> completer;
#endif
diff --git a/src/widgets/widgets/qdockarealayout.cpp b/src/widgets/widgets/qdockarealayout.cpp
index 20dd4c976c..af0f2515fe 100644
--- a/src/widgets/widgets/qdockarealayout.cpp
+++ b/src/widgets/widgets/qdockarealayout.cpp
@@ -2244,6 +2244,22 @@ QRect QDockAreaLayoutInfo::tabContentRect() const
return result;
}
+
+int QDockAreaLayoutInfo::tabIndexToListIndex(int tabIndex) const
+{
+ Q_ASSERT(tabbed && tabBar);
+ quintptr data = qvariant_cast<quintptr>(tabBar->tabData(tabIndex));
+ for (int i = 0; i < item_list.count(); ++i) {
+ if (tabId(item_list.at(i)) == data)
+ return i;
+ }
+ return -1;
+}
+
+void QDockAreaLayoutInfo::moveTab(int from, int to)
+{
+ item_list.move(tabIndexToListIndex(from), tabIndexToListIndex(to));
+}
#endif // QT_NO_TABBAR
/******************************************************************************
@@ -2681,6 +2697,8 @@ void QDockAreaLayout::getGrid(QVector<QLayoutStruct> *_ver_struct_list,
ver_struct_list[i].sizeHint
= qMax(ver_struct_list[i].sizeHint, ver_struct_list[i].minimumSize);
}
+ if (have_central && ver_struct_list[0].empty && ver_struct_list[2].empty)
+ ver_struct_list[1].maximumSize = QWIDGETSIZE_MAX;
}
if (_hor_struct_list != 0) {
@@ -2740,6 +2758,9 @@ void QDockAreaLayout::getGrid(QVector<QLayoutStruct> *_ver_struct_list,
hor_struct_list[i].sizeHint
= qMax(hor_struct_list[i].sizeHint, hor_struct_list[i].minimumSize);
}
+ if (have_central && hor_struct_list[0].empty && hor_struct_list[2].empty)
+ hor_struct_list[1].maximumSize = QWIDGETSIZE_MAX;
+
}
}
diff --git a/src/widgets/widgets/qdockarealayout_p.h b/src/widgets/widgets/qdockarealayout_p.h
index 7c67466c7b..64fae7ebf6 100644
--- a/src/widgets/widgets/qdockarealayout_p.h
+++ b/src/widgets/widgets/qdockarealayout_p.h
@@ -208,6 +208,9 @@ public:
QSize tabBarSizeHint() const;
QSet<QTabBar*> usedTabBars() const;
+
+ int tabIndexToListIndex(int) const;
+ void moveTab(int from, int to);
#endif // QT_NO_TABBAR
};
diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp
index 046666f571..3620aa04fc 100644
--- a/src/widgets/widgets/qmainwindowlayout.cpp
+++ b/src/widgets/widgets/qmainwindowlayout.cpp
@@ -1280,7 +1280,9 @@ QTabBar *QMainWindowLayout::getTabBar()
result->setDrawBase(true);
result->setElideMode(Qt::ElideRight);
result->setDocumentMode(_documentMode);
+ result->setMovable(true);
connect(result, SIGNAL(currentChanged(int)), this, SLOT(tabChanged()));
+ connect(result, &QTabBar::tabMoved, this, &QMainWindowLayout::tabMoved);
}
usedTabBars.insert(result);
@@ -1316,6 +1318,16 @@ void QMainWindowLayout::tabChanged()
if (QWidget *w = centralWidget())
w->raise();
}
+
+void QMainWindowLayout::tabMoved(int from, int to)
+{
+ QTabBar *tb = qobject_cast<QTabBar*>(sender());
+ Q_ASSERT(tb);
+ QDockAreaLayoutInfo *info = layoutState.dockAreaLayout.info(tb);
+ Q_ASSERT(info);
+
+ info->moveTab(from, to);
+}
#endif // QT_NO_TABBAR
bool QMainWindowLayout::startSeparatorMove(const QPoint &pos)
diff --git a/src/widgets/widgets/qmainwindowlayout_p.h b/src/widgets/widgets/qmainwindowlayout_p.h
index 9f84ee95db..8ccb4d303f 100644
--- a/src/widgets/widgets/qmainwindowlayout_p.h
+++ b/src/widgets/widgets/qmainwindowlayout_p.h
@@ -286,6 +286,7 @@ private Q_SLOTS:
#ifndef QT_NO_DOCKWIDGET
#ifndef QT_NO_TABBAR
void tabChanged();
+ void tabMoved(int from, int to);
#endif
#endif
private:
diff --git a/src/widgets/widgets/qmdisubwindow.cpp b/src/widgets/widgets/qmdisubwindow.cpp
index cab60f75ec..1808030639 100644
--- a/src/widgets/widgets/qmdisubwindow.cpp
+++ b/src/widgets/widgets/qmdisubwindow.cpp
@@ -3058,6 +3058,9 @@ void QMdiSubWindow::leaveEvent(QEvent * /*leaveEvent*/)
/*!
\reimp
+
+ \warning When maximizing or restoring a subwindow, the resulting call to this function
+ may have an invalid QResizeEvent::oldSize().
*/
void QMdiSubWindow::resizeEvent(QResizeEvent *resizeEvent)
{
diff --git a/src/widgets/widgets/qtabbar.cpp b/src/widgets/widgets/qtabbar.cpp
index 02c34d9ef6..b2973bd8b3 100644
--- a/src/widgets/widgets/qtabbar.cpp
+++ b/src/widgets/widgets/qtabbar.cpp
@@ -2031,10 +2031,14 @@ void QTabBar::keyPressEvent(QKeyEvent *event)
#ifndef QT_NO_WHEELEVENT
void QTabBar::wheelEvent(QWheelEvent *event)
{
+#ifndef Q_OS_MAC
Q_D(QTabBar);
int offset = event->delta() > 0 ? -1 : 1;
d->setCurrentNextEnabledIndex(offset);
QWidget::wheelEvent(event);
+#else
+ Q_UNUSED(event)
+#endif
}
#endif //QT_NO_WHEELEVENT
diff --git a/src/widgets/widgets/qwidgetlinecontrol.cpp b/src/widgets/widgets/qwidgetlinecontrol.cpp
index f259f7e3a4..759e41a5fa 100644
--- a/src/widgets/widgets/qwidgetlinecontrol.cpp
+++ b/src/widgets/widgets/qwidgetlinecontrol.cpp
@@ -936,7 +936,7 @@ void QWidgetLineControl::parseInputMask(const QString &maskFields)
delete [] m_maskData;
m_maskData = 0;
m_maxLength = 32767;
- internalSetText(QString());
+ internalSetText(QString(), -1, false);
}
return;
}
@@ -1022,7 +1022,7 @@ void QWidgetLineControl::parseInputMask(const QString &maskFields)
}
}
}
- internalSetText(m_text);
+ internalSetText(m_text, -1, false);
}