summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/widgets')
-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
4 files changed, 45 insertions, 17 deletions
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)
{