summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@theqtcompany.com>2015-04-06 19:10:10 +0200
committerLiang Qi <liang.qi@theqtcompany.com>2015-04-06 19:10:25 +0200
commit20cac3d9c9c22153e9e316daff32b6050ff6be6b (patch)
treeb563a89475df9afb4f40841ec371be9488d5b1ed /src/widgets
parent8ce85d74b692392a4ea0785360156f37418cff13 (diff)
parent9eb0b09abce28b11e4915fc9c3b3e996eb19cef2 (diff)
Merge remote-tracking branch 'origin/5.5' into dev
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/doc/src/modelview.qdoc2
-rw-r--r--src/widgets/graphicsview/qgraphicsitem.cpp53
-rw-r--r--src/widgets/kernel/qlayoutitem.cpp3
-rw-r--r--src/widgets/kernel/qwidget.cpp17
-rw-r--r--src/widgets/styles/qandroidstyle.cpp4
-rw-r--r--src/widgets/styles/qfusionstyle.cpp5
-rw-r--r--src/widgets/widgets/qcombobox.cpp52
-rw-r--r--src/widgets/widgets/qcombobox_p.h2
-rw-r--r--src/widgets/widgets/qdockarealayout.cpp5
-rw-r--r--src/widgets/widgets/qmdisubwindow.cpp3
10 files changed, 97 insertions, 49 deletions
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/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/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index a48bfdf3c6..64370eeef5 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -8056,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/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 a5fc4eb3a2..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) {
diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp
index 7a8fcc2c76..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>
@@ -225,6 +226,7 @@ void QComboBoxPrivate::_q_modelReset()
}
if (currentIndex.row() != indexBeforeChange)
_q_emitCurrentIndexChanged(currentIndex);
+ modelChanged();
q->update();
}
@@ -2088,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) {
@@ -3014,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();
}
}
@@ -3056,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 580054780f..3fdfdcc22f 100644
--- a/src/widgets/widgets/qcombobox_p.h
+++ b/src/widgets/widgets/qcombobox_p.h
@@ -253,6 +253,7 @@ private:
QElapsedTimer popupTimer;
friend class QComboBox;
+ friend class QComboBoxPrivate;
};
class Q_AUTOTEST_EXPORT QComboMenuDelegate : public QAbstractItemDelegate
@@ -372,6 +373,7 @@ public:
void modelChanged();
void updateViewContainerPaletteAndOpacity();
void updateFocusPolicy();
+ void showPopupFromMouseEvent(QMouseEvent *e);
#ifdef Q_OS_MAC
void cleanupNativePopup();
diff --git a/src/widgets/widgets/qdockarealayout.cpp b/src/widgets/widgets/qdockarealayout.cpp
index 20dd4c976c..e71b9616fc 100644
--- a/src/widgets/widgets/qdockarealayout.cpp
+++ b/src/widgets/widgets/qdockarealayout.cpp
@@ -2681,6 +2681,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 +2742,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/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)
{