From 89867f86fc5766c30253748560b8c16f721e808e Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Mon, 24 Nov 2014 16:44:31 +0100 Subject: iOS, QComboBox: don't apply special case for OS X on iOS The special-case that was added for OS X before the iOS port came to be stops the virtual keyboard from working correctly. Task-number: QTBUG-41613 Change-Id: I0b8c83e98584389ea4a8aada16a1ee1a64300400 Reviewed-by: Jake Petroules --- src/widgets/widgets/qcombobox.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index fda37c49de..40cf2f0f95 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -942,8 +942,8 @@ QComboBox::QComboBox(QComboBoxPrivate &dd, QWidget *parent) void QComboBoxPrivate::init() { Q_Q(QComboBox); -#ifdef Q_OS_MAC - // On Mac, only line edits and list views always get tab focus. It's only +#ifdef Q_OS_OSX + // On OS X, only line edits and list views always get tab focus. It's only // when we enable full keyboard access that other controls can get tab focus. // When it's not editable, a combobox looks like a button, and it behaves as // such in this respect. -- cgit v1.2.3 From 4958cadeda4baf20f74f6b46689ca05d3f2b7875 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 18 Nov 2014 17:02:49 +0100 Subject: QMainWindow: Observe left contents margin when positioning status bar. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTBUG-38152 Change-Id: I4c762a113dbfe47472d1087aa34c0e327083ee16 Reviewed-by: Jan Arve Sæther --- src/widgets/widgets/qmainwindowlayout.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/widgets') diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp index 8f8642a72a..827e2ed2ba 100644 --- a/src/widgets/widgets/qmainwindowlayout.cpp +++ b/src/widgets/widgets/qmainwindowlayout.cpp @@ -1440,7 +1440,7 @@ void QMainWindowLayout::setGeometry(const QRect &_r) QLayout::setGeometry(r); if (statusbar) { - QRect sbr(QPoint(0, 0), + QRect sbr(QPoint(r.left(), 0), QSize(r.width(), statusbar->heightForWidth(r.width())) .expandedTo(statusbar->minimumSize())); sbr.moveBottom(r.bottom()); -- cgit v1.2.3 From 03c4b52e1314f0f54d65e163b5f85dce212c6cf6 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 19 Nov 2014 10:24:58 +0100 Subject: QLayout: Observe contents margin when positioning the menu bar. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTBUG-38152 Change-Id: I53ea6bce33057251265a7eca1651aeabca314ba9 Reviewed-by: Jan Arve Sæther --- src/widgets/kernel/qlayout.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/widgets') diff --git a/src/widgets/kernel/qlayout.cpp b/src/widgets/kernel/qlayout.cpp index 46cab90ab4..f124f1ed8e 100644 --- a/src/widgets/kernel/qlayout.cpp +++ b/src/widgets/kernel/qlayout.cpp @@ -576,11 +576,12 @@ void QLayoutPrivate::doResize(const QSize &r) int mbh = menuBarHeightForWidth(menubar, r.width()); QWidget *mw = q->parentWidget(); QRect rect = mw->testAttribute(Qt::WA_LayoutOnEntireRect) ? mw->rect() : mw->contentsRect(); + const int mbTop = rect.top(); rect.setTop(rect.top() + mbh); q->setGeometry(rect); #ifndef QT_NO_MENUBAR if (menubar) - menubar->setGeometry(0,0,r.width(), mbh); + menubar->setGeometry(rect.left(), mbTop, r.width(), mbh); #endif } -- cgit v1.2.3 From 2ca57e39e32d056e17a1db68b6c6ef1345ecdf7c Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Tue, 11 Nov 2014 12:34:13 +0100 Subject: Respect the size hint signal for the column and row delegates MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The sizeHintChanged() signal from the column and row delegates need to be connected to the doItemsLayout() slot so that the view is updated when the size hint changes. Additionally doDelayedItemsLayout() is called to ensure that this is up-to-date as the size hints may have changed when the new delegate was set on the row or column. Change-Id: I458293f05ce9ef40a03bdbcab1a6e7a10f648c89 Reviewed-by: Thorbjørn Lund Martsum Reviewed-by: Kevin Puetz --- src/widgets/itemviews/qabstractitemview.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/widgets') diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp index 16de80476f..71404c9792 100644 --- a/src/widgets/itemviews/qabstractitemview.cpp +++ b/src/widgets/itemviews/qabstractitemview.cpp @@ -891,6 +891,7 @@ void QAbstractItemView::setItemDelegateForRow(int row, QAbstractItemDelegate *de disconnect(rowDelegate, SIGNAL(closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint)), this, SLOT(closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint))); disconnect(rowDelegate, SIGNAL(commitData(QWidget*)), this, SLOT(commitData(QWidget*))); + disconnect(rowDelegate, SIGNAL(sizeHintChanged(QModelIndex)), this, SLOT(doItemsLayout())); } d->rowDelegates.remove(row); } @@ -899,10 +900,12 @@ void QAbstractItemView::setItemDelegateForRow(int row, QAbstractItemDelegate *de connect(delegate, SIGNAL(closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint)), this, SLOT(closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint))); connect(delegate, SIGNAL(commitData(QWidget*)), this, SLOT(commitData(QWidget*))); + connect(delegate, SIGNAL(sizeHintChanged(QModelIndex)), this, SLOT(doItemsLayout()), Qt::QueuedConnection); } d->rowDelegates.insert(row, delegate); } viewport()->update(); + d->doDelayedItemsLayout(); } /*! @@ -948,6 +951,7 @@ void QAbstractItemView::setItemDelegateForColumn(int column, QAbstractItemDelega disconnect(columnDelegate, SIGNAL(closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint)), this, SLOT(closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint))); disconnect(columnDelegate, SIGNAL(commitData(QWidget*)), this, SLOT(commitData(QWidget*))); + disconnect(columnDelegate, SIGNAL(sizeHintChanged(QModelIndex)), this, SLOT(doItemsLayout())); } d->columnDelegates.remove(column); } @@ -956,10 +960,12 @@ void QAbstractItemView::setItemDelegateForColumn(int column, QAbstractItemDelega connect(delegate, SIGNAL(closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint)), this, SLOT(closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint))); connect(delegate, SIGNAL(commitData(QWidget*)), this, SLOT(commitData(QWidget*))); + connect(delegate, SIGNAL(sizeHintChanged(QModelIndex)), this, SLOT(doItemsLayout()), Qt::QueuedConnection); } d->columnDelegates.insert(column, delegate); } viewport()->update(); + d->doDelayedItemsLayout(); } /*! -- cgit v1.2.3 From 8e9d78e43ef6dd7a6fc3be8874fc518db8537c91 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 19 Nov 2014 16:23:51 +0100 Subject: QMenuBar: fix extra indent on the right with a TopLeftCorner widget. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When setting a left corner widget on a QMenuBar, the first action rectangle is offset by its width and thus the width should not be added to the size hint. Use QSize::expandedTo() instead. Task-number: QTBUG-36010 Change-Id: I660e3facbd0aeb5fb84fac8923db3e0c7998309d Reviewed-by: Jan Arve Sæther --- src/widgets/widgets/qmenubar.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp index 871af35159..619cb64636 100644 --- a/src/widgets/widgets/qmenubar.cpp +++ b/src/widgets/widgets/qmenubar.cpp @@ -1631,9 +1631,8 @@ QSize QMenuBar::sizeHint() const int margin = 2*vmargin + 2*fw + spaceBelowMenuBar; if(d->leftWidget) { QSize sz = d->leftWidget->sizeHint(); - ret.setWidth(ret.width() + sz.width()); - if(sz.height() + margin > ret.height()) - ret.setHeight(sz.height() + margin); + sz.rheight() += margin; + ret.expandedTo(sz); } if(d->rightWidget) { QSize sz = d->rightWidget->sizeHint(); -- cgit v1.2.3 From 20d10d90f2715e6cee46be63c1314eb62f06bc5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 4 Dec 2014 11:31:01 +0100 Subject: Revert "QWidgetTextControl: Suppress drag selection for OS-synthesized mouse events." MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit cf0d96f4c8584a7eb9eeca304932f6ea88894b27. It broke text selection on iOS and was never tested on that platform. Task-number: QTBUG-43101 Change-Id: I9f224a3838a1f741bc9a9c24f16923ef2018ddf3 Reviewed-by: Friedemann Kleint Reviewed-by: Tor Arne Vestbø --- src/widgets/kernel/qapplication.cpp | 26 -------------------------- src/widgets/kernel/qapplication_p.h | 1 - src/widgets/widgets/qwidgettextcontrol.cpp | 9 +-------- 3 files changed, 1 insertion(+), 35 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 82b9fec37f..269fe452c1 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -53,7 +53,6 @@ #include "qtranslator.h" #include "qvariant.h" #include "qwidget.h" -#include "qgraphicssceneevent.h" #include "private/qdnd_p.h" #include "private/qguiapplication_p.h" #include "qcolormap.h" @@ -2287,31 +2286,6 @@ QWidget *QApplicationPrivate::focusNextPrevChild_helper(QWidget *toplevel, bool return w; } -Qt::MouseEventSource QApplicationPrivate::mouseEventSource(const QEvent *e) -{ - switch (e->type()) { - case QEvent::NonClientAreaMouseButtonDblClick: - case QEvent::NonClientAreaMouseButtonPress: - case QEvent::NonClientAreaMouseButtonRelease: - case QEvent::NonClientAreaMouseMove: - case QEvent::MouseButtonDblClick: - case QEvent::MouseButtonPress: - case QEvent::MouseButtonRelease: - case QEvent::MouseMove: - return static_cast(e)->source(); -#ifndef QT_NO_GRAPHICSVIEW - case QEvent::GraphicsSceneMouseDoubleClick: - case QEvent::GraphicsSceneMousePress: - case QEvent::GraphicsSceneMouseRelease: - case QEvent::GraphicsSceneMouseMove: - return static_cast(e)->source(); -#endif // !QT_NO_GRAPHICSVIEW - default: - break; - } - return Qt::MouseEventNotSynthesized; -} - /*! \fn void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave, const QPointF &globalPosF) \internal diff --git a/src/widgets/kernel/qapplication_p.h b/src/widgets/kernel/qapplication_p.h index b24b592fbe..7d97235c66 100644 --- a/src/widgets/kernel/qapplication_p.h +++ b/src/widgets/kernel/qapplication_p.h @@ -168,7 +168,6 @@ public: static void setFocusWidget(QWidget *focus, Qt::FocusReason reason); static QWidget *focusNextPrevChild_helper(QWidget *toplevel, bool next, bool *wrappingOccurred = 0); - static Qt::MouseEventSource mouseEventSource(const QEvent *e); #ifndef QT_NO_GRAPHICSVIEW // Maintain a list of all scenes to ensure font and palette propagation to diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp index 8f017b7b87..dfec6a14d4 100644 --- a/src/widgets/widgets/qwidgettextcontrol.cpp +++ b/src/widgets/widgets/qwidgettextcontrol.cpp @@ -1580,10 +1580,8 @@ void QWidgetTextControlPrivate::mousePressEvent(QEvent *e, Qt::MouseButton butto cursor.clearSelection(); } } - // Do not start selection on a mouse event synthesized from a touch event. if (!(button & Qt::LeftButton) || - !((interactionFlags & Qt::TextSelectableByMouse) || (interactionFlags & Qt::TextEditable)) - || QApplicationPrivate::mouseEventSource(e) != Qt::MouseEventNotSynthesized) { + !((interactionFlags & Qt::TextSelectableByMouse) || (interactionFlags & Qt::TextEditable))) { e->ignore(); return; } @@ -1754,11 +1752,6 @@ void QWidgetTextControlPrivate::mouseReleaseEvent(QEvent *e, Qt::MouseButton but { Q_Q(QWidgetTextControl); - if (QApplicationPrivate::mouseEventSource(e) != Qt::MouseEventNotSynthesized) { - setCursorPosition(pos); // Emulate Tap to set cursor for events synthesized from touch. - return; - } - const QTextCursor oldSelection = cursor; if (sendMouseEventToInputContext( e, QEvent::MouseButtonRelease, button, pos, modifiers, buttons, globalPos)) { -- cgit v1.2.3 From fd29be6a6beafe4bfaf5a73d19a0d6a924217d16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 3 Dec 2014 15:33:10 +0100 Subject: Revert "Use single finger pan to scroll text edits on touch screens." MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 2ffa46054d13c639cf9f7846a74ad3ebd07b9f5c. It completely broke text selection in text edits on iOS, and wasn't even tested on that platform before landing. It's also changing behavior in a patch release for multiple platforms, from being able to both scroll and select text, to only being able to scroll, which would be considered a feature-regression and an automatic -2 on the original patch. This means QTBUG-40461, a P2 regression from Qt 4 on Windows, will have to be re-opened, so that we can fix it properly. Task-number: QTBUG-43101 Change-Id: I26a2bafb4500b1ff4dc3fb942f197d11038b630b Reviewed-by: Tor Arne Vestbø Reviewed-by: Shawn Rutledge Reviewed-by: Friedemann Kleint --- src/widgets/kernel/qstandardgestures.cpp | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/kernel/qstandardgestures.cpp b/src/widgets/kernel/qstandardgestures.cpp index 53e5d091fa..6656903e70 100644 --- a/src/widgets/kernel/qstandardgestures.cpp +++ b/src/widgets/kernel/qstandardgestures.cpp @@ -38,7 +38,6 @@ #include "qwidget.h" #include "qabstractscrollarea.h" #include -#include #include "qdebug.h" #ifndef QT_NO_GESTURES @@ -68,26 +67,8 @@ static QPointF panOffset(const QList &touchPoints, int return result / qreal(count); } -// ### fixme: Remove this -// Use single finger pan to scroll QPlainTextEdit/QTextEdit -// by changing the number of pan points to 1 for these classes. -// This used to be Qt 4's behavior on Windows which was achieved using native -// Windows gesture recognizers for these classes. -// The other classes inheriting QScrollArea still use standard 2 finger pan. -// In the long run, they should also use single finger pan to -// scroll on touch screens, however, this requires a distinct Tap&Hold-followed-by-pan -// type gesture to avoid clashes with item view selection and DnD. - -static inline int panTouchPoints(const QTouchEvent *event, const QObject *object, - int defaultTouchPoints) -{ - return event->device()->type() == QTouchDevice::TouchScreen && object && object->parent() - && (object->parent()->inherits("QPlainTextEdit") || object->parent()->inherits("QTextEdit")) - ? 1 : defaultTouchPoints; -} - QGestureRecognizer::Result QPanGestureRecognizer::recognize(QGesture *state, - QObject *object, + QObject *, QEvent *event) { QPanGesture *q = static_cast(state); @@ -100,7 +81,7 @@ QGestureRecognizer::Result QPanGestureRecognizer::recognize(QGesture *state, result = QGestureRecognizer::MayBeGesture; QTouchEvent::TouchPoint p = ev->touchPoints().at(0); d->lastOffset = d->offset = QPointF(); - d->pointCount = panTouchPoints(ev, object, m_pointCount); + d->pointCount = m_pointCount; break; } case QEvent::TouchEnd: { -- cgit v1.2.3 From 8860522d7e8d76c6b59a593a329a6bfa754cb432 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 1 Dec 2014 10:05:42 +0100 Subject: QDockWidget: Prevent repetitive unplugging of floating dock widgets. When calling QDockWidget::setTitleBarWidget() from within signal QDockWidget::topLevelChanged(), a nested call of QDockWidgetPrivate::setWindowState(unplug=true) is triggered, leaving it with Qt::X11BypassWindowManagerHint set and thus invisible/off screen. Force the unplug parameter to false if the widget is already in floating state. Task-number: QTBUG-42818 Task-number: QTBUG-38964 Change-Id: I6aff61e4ee1501f5db281566b66db66c19351410 Reviewed-by: Gatis Paeglis --- src/widgets/widgets/qdockwidget.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/widgets') diff --git a/src/widgets/widgets/qdockwidget.cpp b/src/widgets/widgets/qdockwidget.cpp index 4be133e277..93e6131ab9 100644 --- a/src/widgets/widgets/qdockwidget.cpp +++ b/src/widgets/widgets/qdockwidget.cpp @@ -1009,6 +1009,8 @@ void QDockWidgetPrivate::setWindowState(bool floating, bool unplug, const QRect } bool wasFloating = q->isFloating(); + if (wasFloating) // Prevent repetitive unplugging from nested invocations (QTBUG-42818) + unplug = false; bool hidden = q->isHidden(); if (q->isVisible()) -- cgit v1.2.3 From 8920200c97f0a514397e039ba74588127163c2b9 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Wed, 3 Dec 2014 15:02:34 +0100 Subject: QColumnView: don't set an invalid index as the current one When any item in a QColumnView gets selected, the next column gets normally set to show the children of that index. When we are on a leaf of a tree model, the next column will have an invalid root index, yet we set that root index as the "current index" for the current column. Due to the special handling for invalid indexes in QAbstractItemView::setCurrentIndex, this ends up breaking the current item AND the current selection in that column. Further clicks inside the column for instance trigger the entire column (up to the clicked index) to get selected, because of that broken first setCurrentIndex. The simple fix is to stop doing that when the next column has an invalid root index. Task-number: QTBUG-2329 Change-Id: Icd10c0b958e25cd868536e1315561787977b68bd Reviewed-by: David Faure Reviewed-by: Joerg Bornemann --- src/widgets/itemviews/qcolumnview.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/itemviews/qcolumnview.cpp b/src/widgets/itemviews/qcolumnview.cpp index 1c60d50922..3234e1e832 100644 --- a/src/widgets/itemviews/qcolumnview.cpp +++ b/src/widgets/itemviews/qcolumnview.cpp @@ -976,8 +976,11 @@ void QColumnViewPrivate::_q_changeCurrentColumn() QAbstractItemView *view = columns.at(i); view->setSelectionModel(replacementSelectionModel); view->setFocusPolicy(Qt::NoFocus); - if (columns.size() > i + 1) - view->setCurrentIndex(columns.at(i+1)->rootIndex()); + if (columns.size() > i + 1) { + const QModelIndex newRootIndex = columns.at(i + 1)->rootIndex(); + if (newRootIndex.isValid()) + view->setCurrentIndex(newRootIndex); + } break; } } -- cgit v1.2.3 From a43684c0da78e7187fd2f4fc05791064174da9de Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Thu, 4 Dec 2014 15:24:25 +0100 Subject: QMacStyle: Fix 32-bit build Again one of those CGRect vs. NSRect issues. Change-Id: Ia933cd6f002585e21247d2f9f85d2451db6dbaa0 Reviewed-by: Jake Petroules Reviewed-by: Timur Pocheptsov --- src/widgets/styles/qmacstyle_mac.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/widgets') diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index 00112a5c6d..5c17cdf489 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -5572,7 +5572,7 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex CGContextTranslateCTM(ctx, 0, rect.size.height); CGContextScaleCTM(ctx, 1, -1); } - [sl.cell drawBarInside:tdi.bounds flipped:NO]; + [sl.cell drawBarInside:NSRectFromCGRect(tdi.bounds) flipped:NO]; // No need to restore the CTM later, the context has been saved // and will be restored at the end of drawNSViewInRect() }); -- cgit v1.2.3 From aca0fb17862875209a234f0384b981efe831f4b6 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 5 Dec 2014 09:06:33 +0100 Subject: Update window flags from QToolBarPrivate::endDrag(). Activate previously #ifdef'ed code which cleared the Qt::X11BypassWindowManager hint. With the hint set, the tool bar stays on top and does not get deactivated along with the application by the WM. Task-number: QTBUG-41189 Change-Id: I6f3f334860e46dd4867f5942f15e5a090340f2d7 Reviewed-by: Andy Shaw --- src/widgets/widgets/qtoolbar.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/widgets/qtoolbar.cpp b/src/widgets/widgets/qtoolbar.cpp index 17e64be4f4..77119a0d7d 100644 --- a/src/widgets/widgets/qtoolbar.cpp +++ b/src/widgets/widgets/qtoolbar.cpp @@ -220,10 +220,8 @@ void QToolBarPrivate::endDrag() if (!layout->plug(state->widgetItem)) { if (q->isFloatable()) { layout->restore(); -#if defined(Q_WS_X11) || defined(Q_WS_MAC) setWindowState(true); // gets rid of the X11BypassWindowManager window flag // and activates the resizer -#endif q->activateWindow(); } else { layout->revert(state->widgetItem); -- cgit v1.2.3 From 370d421495a200860c9fb583b526dcf8bf8145fb Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Tue, 4 Nov 2014 11:47:50 +0100 Subject: Widgets: be more careful when setting focus on touch release MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit An application might choose to change focus when receiving mouse/touch press/move events. This is in conflict with Qt assigning focus on touch release (QPlatformIntegration::SetFocusOnTouchRelease), since Qt might then reassign focus to something else. An example of this is seen with the "frozencolumn" example. Here, when the user double clicks on a cell, the application creates an 'edit' widget inside the cell that gets focus. But at soon as the last release is sent, Qt will change focus to the focus proxy of QScrollArea instead. This patch will introduce an exception to setting focus on release, so that we only set focus if we detect that focus didn't change (by the app) while processing press/move events. Task-number: QTBUG-39390 Change-Id: I7b398b59e3175265afd2fcd938e11f88155abc89 Reviewed-by: Laszlo Agocs Reviewed-by: Friedemann Kleint Reviewed-by: Tor Arne Vestbø --- src/widgets/kernel/qapplication.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/widgets') diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 269fe452c1..b7d0869289 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -4172,11 +4172,13 @@ void QApplicationPrivate::giveFocusAccordingToFocusPolicy(QWidget *widget, QEven { const bool setFocusOnRelease = QGuiApplication::styleHints()->setFocusOnTouchRelease(); Qt::FocusPolicy focusPolicy = Qt::ClickFocus; + static QPointer focusedWidgetOnTouchBegin = 0; switch (event->type()) { case QEvent::MouseButtonPress: case QEvent::MouseButtonDblClick: case QEvent::TouchBegin: + focusedWidgetOnTouchBegin = QApplication::focusWidget(); if (setFocusOnRelease) return; break; @@ -4184,6 +4186,11 @@ void QApplicationPrivate::giveFocusAccordingToFocusPolicy(QWidget *widget, QEven case QEvent::TouchEnd: if (!setFocusOnRelease) return; + if (focusedWidgetOnTouchBegin != QApplication::focusWidget()) { + // Focus widget was changed while delivering press/move events. + // To not interfere with application logic, we leave focus as-is + return; + } break; case QEvent::Wheel: focusPolicy = Qt::WheelFocus; -- cgit v1.2.3 From b5f8502c129c20b3aa3234a3e1c251102d36cdba Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Fri, 14 Nov 2014 17:37:34 +0100 Subject: Styles: improve SH_Header_ArrowAlignment handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The docs were wrong, and the returned values from some styles did not match reality, so fix that. Again, this style hint was not used at all within QWidgets... Task-number: QTBUG-629 Change-Id: Ie6ff80fd09bc3292ba3d787ccca4d6f4c0056e89 Reviewed-by: Friedemann Kleint Reviewed-by: Thorbjørn Lund Martsum --- src/widgets/styles/qcommonstyle.cpp | 5 ++++- src/widgets/styles/qstyle.cpp | 3 ++- src/widgets/styles/qwindowsvistastyle.cpp | 3 +++ 3 files changed, 9 insertions(+), 2 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index 1c5dcf5f0a..aeffa6195d 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -4907,10 +4907,13 @@ int QCommonStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget case SH_TabBar_Alignment: - case SH_Header_ArrowAlignment: ret = Qt::AlignLeft; break; + case SH_Header_ArrowAlignment: + ret = Qt::AlignRight | Qt::AlignVCenter; + break; + case SH_TitleBar_AutoRaise: ret = false; break; diff --git a/src/widgets/styles/qstyle.cpp b/src/widgets/styles/qstyle.cpp index 856ec271fb..ba5bd717b6 100644 --- a/src/widgets/styles/qstyle.cpp +++ b/src/widgets/styles/qstyle.cpp @@ -1663,7 +1663,8 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, \value SH_Header_ArrowAlignment The placement of the sorting indicator may appear in list or table headers. Possible values - are Qt::Left or Qt::Right. + are Qt::Alignment values (that is, an OR combination of + Qt::AlignmentFlag flags). \value SH_Slider_SnapToValue Sliders snap to values while moving, as they do on Windows. diff --git a/src/widgets/styles/qwindowsvistastyle.cpp b/src/widgets/styles/qwindowsvistastyle.cpp index 463b120e04..42a85e8f64 100644 --- a/src/widgets/styles/qwindowsvistastyle.cpp +++ b/src/widgets/styles/qwindowsvistastyle.cpp @@ -2112,6 +2112,9 @@ int QWindowsVistaStyle::styleHint(StyleHint hint, const QStyleOption *option, co else ret = -1; break; + case SH_Header_ArrowAlignment: + ret = Qt::AlignTop | Qt::AlignHCenter; + break; default: ret = QWindowsXPStyle::styleHint(hint, option, widget, returnData); break; -- cgit v1.2.3 From b39bbc95f685e59744fd282b006d3fa7b247ed36 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Wed, 12 Nov 2014 14:13:13 +0100 Subject: QHeaderView: take the sort indicator into account when eliding text MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit By adding PM_HeaderMarkSize to the margins if the section is showing a sort indicator. Turns out that that particular enum was actually unused in QtWidgets (!), so tune the value to match reality. Task-number: QTBUG-629 Change-Id: I8bc70451656d634a064c8b5014e449977c55aa9d Reviewed-by: Cristian Oneț Reviewed-by: Thorbjørn Lund Martsum Reviewed-by: Friedemann Kleint --- src/widgets/itemviews/qheaderview.cpp | 11 +++++++++-- src/widgets/styles/qcommonstyle.cpp | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp index b609134322..beade16339 100644 --- a/src/widgets/itemviews/qheaderview.cpp +++ b/src/widgets/itemviews/qheaderview.cpp @@ -1550,7 +1550,7 @@ int QHeaderView::minimumSectionSize() const Q_D(const QHeaderView); if (d->minimumSectionSize == -1) { QSize strut = QApplication::globalStrut(); - int margin = style()->pixelMetric(QStyle::PM_HeaderMargin, 0, this); + int margin = 2 * style()->pixelMetric(QStyle::PM_HeaderMargin, 0, this); if (d->orientation == Qt::Horizontal) return qMax(strut.width(), (fontMetrics().maxWidth() + margin)); return qMax(strut.height(), (fontMetrics().height() + margin)); @@ -2663,7 +2663,14 @@ void QHeaderView::paintSection(QPainter *painter, const QRect &rect, int logical opt.iconAlignment = Qt::AlignVCenter; opt.text = d->model->headerData(logicalIndex, d->orientation, Qt::DisplayRole).toString(); - const int margin = 2 * style()->pixelMetric(QStyle::PM_HeaderMargin, 0, this); + + int margin = 2 * style()->pixelMetric(QStyle::PM_HeaderMargin, 0, this); + + const Qt::Alignment headerArrowAlignment = static_cast(style()->styleHint(QStyle::SH_Header_ArrowAlignment, 0, this)); + const bool isHeaderArrowOnTheSide = headerArrowAlignment & Qt::AlignVCenter; + if (isSortIndicatorShown() && sortIndicatorSection() == logicalIndex && isHeaderArrowOnTheSide) + margin += style()->pixelMetric(QStyle::PM_HeaderMarkSize, 0, this); + if (d->textElideMode != Qt::ElideNone) opt.text = opt.fontMetrics.elidedText(opt.text, d->textElideMode , rect.width() - margin); diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index aeffa6195d..c688462794 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -4587,7 +4587,7 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid ret = int(QStyleHelper::dpiScaled(4.)); break; case PM_HeaderMarkSize: - ret = int(QStyleHelper::dpiScaled(32.)); + ret = int(QStyleHelper::dpiScaled(16.)); break; case PM_HeaderGripMargin: ret = int(QStyleHelper::dpiScaled(4.)); -- cgit v1.2.3 From 66e48d2c2fad494504cad0b699300c750fa28383 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Mon, 8 Dec 2014 16:14:15 +0100 Subject: Support vertical sliders on Android There is no such thing as a vertical slider in the native Android style. Therefore, we need to rotate the painter in order to draw one. Task-number: QTBUG-41992 Change-Id: Ibe2bf1d7fa27756aad0b8469c8752d6d3e848527 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/widgets/styles/qandroidstyle.cpp | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/styles/qandroidstyle.cpp b/src/widgets/styles/qandroidstyle.cpp index 5b4b346da9..a5a75dae02 100644 --- a/src/widgets/styles/qandroidstyle.cpp +++ b/src/widgets/styles/qandroidstyle.cpp @@ -1719,28 +1719,43 @@ void QAndroidStyle::AndroidSeekBarControl::drawControl(const QStyleOption *optio qstyleoption_cast(option)) { double factor = double(styleOption->sliderPosition - styleOption->minimum) / double(styleOption->maximum - styleOption->minimum); + + // Android does not have a vertical slider. To support the vertical orientation, we rotate + // the painter and pretend that we are horizontal. + if (styleOption->orientation == Qt::Vertical) + factor = 1 - factor; + if (m_progressDrawable->type() == QAndroidStyle::Layer) { QAndroidStyle::AndroidDrawable *clipDrawable = static_cast(m_progressDrawable)->layer(m_progressId); if (clipDrawable->type() == QAndroidStyle::Clip) - static_cast(clipDrawable)->setFactor(factor, styleOption->orientation); + static_cast(clipDrawable)->setFactor(factor, Qt::Horizontal); else - static_cast(m_progressDrawable)->setFactor(m_progressId, factor, styleOption->orientation); + static_cast(m_progressDrawable)->setFactor(m_progressId, factor, Qt::Horizontal); } const AndroidDrawable *drawable = m_seekBarThumb; if (drawable->type() == State) drawable = static_cast(m_seekBarThumb)->bestAndroidStateMatch(option); QStyleOption copy(*option); + + p->save(); + + if (styleOption->orientation == Qt::Vertical) { + // rotate the painter, and transform the rectangle to match + p->rotate(90); + copy.rect = QRect(copy.rect.y(), copy.rect.x() - copy.rect.width(), copy.rect.height(), copy.rect.width()); + } + copy.rect.setHeight(m_progressDrawable->size().height()); copy.rect.setWidth(copy.rect.width() - drawable->size().width()); const int yTranslate = abs(drawable->size().height() - copy.rect.height()) / 2; copy.rect.translate(drawable->size().width() / 2, yTranslate); m_progressDrawable->draw(p, ©); - if (styleOption->orientation == Qt::Vertical) - qCritical() << "Vertical slider are not supported"; int pos = copy.rect.width() * factor - drawable->size().width() / 2; copy.rect.translate(pos, -yTranslate); copy.rect.setSize(drawable->size()); m_seekBarThumb->draw(p, ©); + + p->restore(); } } @@ -1772,8 +1787,13 @@ QRect QAndroidStyle::AndroidSeekBarControl::subControlRect(const QStyleOptionCom QRect r(option->rect); double factor = double(styleOption->sliderPosition - styleOption->minimum) / (styleOption->maximum - styleOption->minimum); - int pos = option->rect.width() * factor - double(drawable->size().width() / 2); - r.setX(r.x() + pos); + if (styleOption->orientation == Qt::Vertical) { + int pos = option->rect.height() * (1 - factor) - double(drawable->size().height() / 2); + r.setY(r.y() + pos); + } else { + int pos = option->rect.width() * factor - double(drawable->size().width() / 2); + r.setX(r.x() + pos); + } r.setSize(drawable->size()); return r; } -- cgit v1.2.3 From b9547af45ea2bbbc634722c1ef41afdb54216ce2 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Tue, 9 Dec 2014 17:32:59 +0100 Subject: Android: Make cursor keys work again On Android, we disable mouse selection, since that does not work well with touch screens. In change a03a69efb9ed89cd4a90878eda20, we accidentally disabled keyboard selection as well. Unfortunately, disabling keyboard selection will disable all keyboard movement. This change re-enables TextSelectableByKeyboard. Task-number: QTBUG-42991 Change-Id: Ie63ed3d88a0abcb72f04e0ec60a5b91c0b14a47e Reviewed-by: Christian Stromme --- src/widgets/widgets/qwidgettextcontrol.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/widgets') diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp index dfec6a14d4..8c48533a03 100644 --- a/src/widgets/widgets/qwidgettextcontrol.cpp +++ b/src/widgets/widgets/qwidgettextcontrol.cpp @@ -110,7 +110,7 @@ QWidgetTextControlPrivate::QWidgetTextControlPrivate() #ifndef Q_OS_ANDROID interactionFlags(Qt::TextEditorInteraction), #else - interactionFlags(Qt::TextEditable), + interactionFlags(Qt::TextEditable | Qt::TextSelectableByKeyboard), #endif dragEnabled(true), #ifndef QT_NO_DRAGANDDROP -- cgit v1.2.3