From c3baa7c1dc8c29bfe60e8e5c676c606d4f699005 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 5 Jun 2014 08:22:25 +0200 Subject: Fix selection by dragging after double click in QWidgetTextControl. Remove return in mouseMove depending on variable mousePressed which is not present in Qt 4. The variable was true in Qt versions before 5.3 due to an additional mouse press event received before a double click. Task-number: QTBUG-39023 Task-number: QTBUG-25831 Change-Id: I57ed9284961195c71df9e9b9d697b1cfbad7c228 Reviewed-by: Laszlo Agocs --- src/widgets/widgets/qwidgettextcontrol.cpp | 3 --- 1 file changed, 3 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp index 54b20e36f5..b34c297f2e 100644 --- a/src/widgets/widgets/qwidgettextcontrol.cpp +++ b/src/widgets/widgets/qwidgettextcontrol.cpp @@ -1692,9 +1692,6 @@ void QWidgetTextControlPrivate::mouseMoveEvent(QEvent *e, Qt::MouseButton button return; } - if (!mousePressed) - return; - const qreal mouseX = qreal(mousePos.x()); int newCursorPos = q->hitTest(mousePos, Qt::FuzzyHit); -- cgit v1.2.3 From c3e416296a1026d7ba99cf209f5e0720ff5050b1 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 26 May 2014 14:24:20 +0200 Subject: Revert "Fixed duplicate QMoveEvent generated for each QWidget::move call" A better fix is to check whether the widget already has the requested geometry when receiving the spontaneous event from the platform in QWidgetWindow and to suppress that. This reverts commit 72259baa76a0f1faa1983c720621676e9c15e15f. Task-number: QTBUG-32590 Change-Id: I4d7a9b4c340c2d6a427727ecb8de50c3d199f7a9 Reviewed-by: Andy Shaw --- src/widgets/kernel/qwidget_qpa.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/kernel/qwidget_qpa.cpp b/src/widgets/kernel/qwidget_qpa.cpp index 17ed4ca477..e5f552679c 100644 --- a/src/widgets/kernel/qwidget_qpa.cpp +++ b/src/widgets/kernel/qwidget_qpa.cpp @@ -779,10 +779,7 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove) } } - // generate a move event for QWidgets without window handles. QWidgets with native - // window handles already receive a move event from - // QGuiApplicationPrivate::processGeometryChangeEvent. - if (isMove && (!q->windowHandle() || q->testAttribute(Qt::WA_DontShowOnScreen))) { + if (isMove) { QMoveEvent e(q->pos(), oldPos); QApplication::sendEvent(q, &e); } -- cgit v1.2.3 From a1c5198387fdb7db44a02bb94c56187874e67304 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 26 May 2014 14:28:19 +0200 Subject: Suppress move/resize events if they are the result of call to move()/resize(). QWidget::resize() or QWidget::move() set the new size/position values and send events. The spontaneous events generated by the platform should be ignored in that case. Task-number: QTBUG-30744 Task-number: QTBUG-38768 Task-number: QTBUG-32590 Change-Id: I9c0ae38842ed76a8a88ca64fdc9bbe106b2766b7 Reviewed-by: Andy Shaw --- src/widgets/kernel/qwidgetwindow.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp index fc328e7af0..35a526e77d 100644 --- a/src/widgets/kernel/qwidgetwindow.cpp +++ b/src/widgets/kernel/qwidgetwindow.cpp @@ -591,16 +591,24 @@ void QWidgetWindow::updateNormalGeometry() void QWidgetWindow::handleMoveEvent(QMoveEvent *event) { + // If the widget's position already matches that of the event, this is a + // result of call to QWidget::move(), which already sends an event. + const bool spontaneous = m_widget->geometry().topLeft() != event->pos(); updateGeometry(); - QGuiApplication::sendSpontaneousEvent(m_widget, event); + if (spontaneous) + QGuiApplication::sendSpontaneousEvent(m_widget, event); } void QWidgetWindow::handleResizeEvent(QResizeEvent *event) { QSize oldSize = m_widget->data->crect.size(); + // If the widget's size already matches that of the event, this is a + // result of call to QWidget::resize(), which already sends an event. + const bool spontaneous = oldSize != event->size(); updateGeometry(); - QGuiApplication::sendSpontaneousEvent(m_widget, event); + if (spontaneous) + QGuiApplication::sendSpontaneousEvent(m_widget, event); if (m_widget->d_func()->paintOnScreen()) { QRegion updateRegion(geometry()); -- cgit v1.2.3 From 8480ddbe60492bb284fc614fd7bf304d3d9bd130 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Mon, 9 Jun 2014 22:59:16 +0200 Subject: Remove unnecessary comma in QStackedWidget doc. Change-Id: Iaa6102ea90c695eb2d81cc5d4fbd00dafc7783f5 Reviewed-by: Jerome Pasion --- src/widgets/widgets/qstackedwidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/widgets') diff --git a/src/widgets/widgets/qstackedwidget.cpp b/src/widgets/widgets/qstackedwidget.cpp index 4b7170a596..6dbc7c8fad 100644 --- a/src/widgets/widgets/qstackedwidget.cpp +++ b/src/widgets/widgets/qstackedwidget.cpp @@ -91,7 +91,7 @@ public: the list using the addWidget() function, or inserted at a given index using the insertWidget() function. The removeWidget() function removes a widget from the stacked widget. The number of - widgets contained in the stacked widget, can + widgets contained in the stacked widget can be obtained using the count() function. The widget() function returns the widget at a given index -- cgit v1.2.3 From 7da3228abbb77af653b716a3729fac9b20279bfb Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Mon, 9 Jun 2014 14:06:08 +0200 Subject: Fix typo in QGraphicsTextItem::defaultTextColor() documentation. Change-Id: I6e255483d63a3024d9cbfe09a12f33d7fddf36c0 Reviewed-by: Jerome Pasion --- src/widgets/graphicsview/qgraphicsitem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/widgets') diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp index d4edc63403..e327a8737a 100644 --- a/src/widgets/graphicsview/qgraphicsitem.cpp +++ b/src/widgets/graphicsview/qgraphicsitem.cpp @@ -9911,7 +9911,7 @@ void QGraphicsTextItem::setDefaultTextColor(const QColor &col) } /*! - Returns the default text color that is used to for unformatted text. + Returns the default text color that is used for unformatted text. */ QColor QGraphicsTextItem::defaultTextColor() const { -- cgit v1.2.3 From e3d32bce79ee81e0434e91b225adaa6c42b5ec3a Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Tue, 10 Jun 2014 11:42:23 +0200 Subject: Fix failing qtdeclarativetextedit auto-test After commit c3baa7c1dc8c29bfe60e8e5c676c606d4f699005 the qtdeclarativetextedit tests in the qtquick1 module started failing. This was due to commit 852abfca6f4c349dce9b895956922f96d82df579 from 4.8 not being forward-ported from Qt 4 to Qt 5, hence the comment in c3baa7c1dc8c29bfe60e8e5c676c606d4f699005 about the missing mousePressEvent line. It was intentionally removed and instead used further down, which is what this patch adds and therefore acts as forward-port of 852abfca6f4c349dce9b895956922f96d82df579. Change-Id: I55978c961002382c1f228bf796c469c10686ba9f Reviewed-by: Friedemann Kleint --- src/widgets/widgets/qwidgettextcontrol.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp index b34c297f2e..96438a0bdf 100644 --- a/src/widgets/widgets/qwidgettextcontrol.cpp +++ b/src/widgets/widgets/qwidgettextcontrol.cpp @@ -1712,7 +1712,7 @@ void QWidgetTextControlPrivate::mouseMoveEvent(QEvent *e, Qt::MouseButton button if (newCursorPos == -1) return; - if (wordSelectionEnabled && !selectedWordOnDoubleClick.hasSelection()) { + if (mousePressed && wordSelectionEnabled && !selectedWordOnDoubleClick.hasSelection()) { selectedWordOnDoubleClick = cursor; selectedWordOnDoubleClick.select(QTextCursor::WordUnderCursor); } @@ -1721,7 +1721,7 @@ void QWidgetTextControlPrivate::mouseMoveEvent(QEvent *e, Qt::MouseButton button extendBlockwiseSelection(newCursorPos); else if (selectedWordOnDoubleClick.hasSelection()) extendWordwiseSelection(newCursorPos, mouseX); - else if (!isPreediting()) + else if (mousePressed && !isPreediting()) setCursorPosition(newCursorPos, QTextCursor::KeepAnchor); if (interactionFlags & Qt::TextEditable) { -- cgit v1.2.3 From 857c82f8a4a29399733218f783241b839b939f58 Mon Sep 17 00:00:00 2001 From: Jerome Pasion Date: Wed, 4 Jun 2014 18:11:00 +0200 Subject: Doc: Updated Layout examples. -added links to and from the overviews. -added information on how to run the example. -updated copyright. Task-number: QTBUG-33597 Change-Id: Ib049cb94f136caa6916878959ae830248bd236b5 Reviewed-by: Martin Smith Reviewed-by: Nico Vertriest --- src/widgets/doc/src/qtwidgets-index.qdoc | 1 + src/widgets/doc/src/widgets-and-layouts/layout.qdoc | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'src/widgets') diff --git a/src/widgets/doc/src/qtwidgets-index.qdoc b/src/widgets/doc/src/qtwidgets-index.qdoc index 859a0ef933..bc74f43b35 100644 --- a/src/widgets/doc/src/qtwidgets-index.qdoc +++ b/src/widgets/doc/src/qtwidgets-index.qdoc @@ -139,6 +139,7 @@ interfaces \section2 Examples \list \li \l{Qt Widgets Examples} + \li \l{Layout Examples} \endlist \section1 API Reference diff --git a/src/widgets/doc/src/widgets-and-layouts/layout.qdoc b/src/widgets/doc/src/widgets-and-layouts/layout.qdoc index 99d512b507..f581df4cb3 100644 --- a/src/widgets/doc/src/widgets-and-layouts/layout.qdoc +++ b/src/widgets/doc/src/widgets-and-layouts/layout.qdoc @@ -386,5 +386,13 @@ then set it. (This does not only apply to layouts, you should do the same if you implement your own resizeEvent(), for example.) \endlist -*/ + \section1 Layout Examples + + Many Qt Widgets \l{Qt Widgets Examples}{examples} already use layouts, + however, several examples exist to showcase various layouts. + + \list + \li \l{Layout Examples} + \endlist +*/ -- cgit v1.2.3 From a6d7e09e89a73b3706aabbf2d08586f238348c7c Mon Sep 17 00:00:00 2001 From: David Faure Date: Fri, 6 Jun 2014 13:53:58 +0200 Subject: QWidget: fix documentation for isEnabledTo(0) It is NOT always the same as isEnabled(). Added a unittest to prove it. Change-Id: I7717126835923e8c091249bfcdf81767c44fb5f7 Reviewed-by: Giuseppe D'Angelo --- src/widgets/kernel/qwidget.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/widgets') diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 65e435fbdc..7396808442 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -2912,7 +2912,13 @@ void QWidget::showNormal() This is the case if neither the widget itself nor every parent up to but excluding \a ancestor has been explicitly disabled. - isEnabledTo(0) is equivalent to isEnabled(). + isEnabledTo(0) returns false if this widget or any if its ancestors + was explicitly disabled. + + The word ancestor here means a parent widget within the same window. + + Therefore isEnabledTo(0) stops at this widget's window, unlike + isEnabled() which also takes parent windows into considerations. \sa setEnabled(), enabled */ -- cgit v1.2.3 From 02b7b21f9bafcba3231610fef31b590474567472 Mon Sep 17 00:00:00 2001 From: Zhang Xingtao Date: Thu, 12 Jun 2014 19:11:35 +0800 Subject: Doc: correct the format of Q_PLUGIN_METADATA macro in sample codes Change-Id: I464a0c0a590b0b90cf0fe7ccd448ee9bf704bd4f Reviewed-by: Olivier Goffart --- src/widgets/doc/snippets/qstyleplugin/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/widgets') diff --git a/src/widgets/doc/snippets/qstyleplugin/main.cpp b/src/widgets/doc/snippets/qstyleplugin/main.cpp index 4cf20ab960..e1a0d1b626 100644 --- a/src/widgets/doc/snippets/qstyleplugin/main.cpp +++ b/src/widgets/doc/snippets/qstyleplugin/main.cpp @@ -45,7 +45,7 @@ class MyStylePlugin : public QStylePlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QStyleFactoryInterface" FILE mystyleplugin.json) + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QStyleFactoryInterface" FILE "mystyleplugin.json") public: MyStylePlugin(QObject *parent = 0); -- cgit v1.2.3 From 5da108a4a76b163116f1b816090075a9b86cf077 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 13 Jun 2014 08:56:17 +0200 Subject: Revert "Revert "Fixed duplicate QMoveEvent generated for each QWidget::move call"" This reverts commit c3e416296a1026d7ba99cf209f5e0720ff5050b1. The idea of detecting non-spontaneous events by comparing against the widget's crect has problems when sequences of programmatic resizes occur. In addition, QWindowSystemInterface's queueing of events is problematic for this. Task-number: QTBUG-39611 Task-number: QTBUG-32590 Change-Id: I9ff8049add147be23e064a513e8645ae04577c6c Reviewed-by: Andy Shaw --- src/widgets/kernel/qwidget_qpa.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/widgets') diff --git a/src/widgets/kernel/qwidget_qpa.cpp b/src/widgets/kernel/qwidget_qpa.cpp index e5f552679c..17ed4ca477 100644 --- a/src/widgets/kernel/qwidget_qpa.cpp +++ b/src/widgets/kernel/qwidget_qpa.cpp @@ -779,7 +779,10 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove) } } - if (isMove) { + // generate a move event for QWidgets without window handles. QWidgets with native + // window handles already receive a move event from + // QGuiApplicationPrivate::processGeometryChangeEvent. + if (isMove && (!q->windowHandle() || q->testAttribute(Qt::WA_DontShowOnScreen))) { QMoveEvent e(q->pos(), oldPos); QApplication::sendEvent(q, &e); } -- cgit v1.2.3 From 9c80a3be4b3beb28a3a6bda717c15b0ded523557 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 13 Jun 2014 08:59:45 +0200 Subject: Revert "Suppress move/resize events if they are the result of call to move()/resize()." This reverts commit a1c5198387fdb7db44a02bb94c56187874e67304. The idea of detecting non-spontaneous events by comparing against the widget's crect has problems when sequences of programmatic resizes occur. In addition, QWindowSystemInterface's queueing of events is problematic for this. Task-number: QTBUG-39611 Task-number: QTBUG-32590 Change-Id: I4674d8d5d5d432d938f7226b5790543335665c1f Reviewed-by: Andy Shaw --- src/widgets/kernel/qwidgetwindow.cpp | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp index 35a526e77d..fc328e7af0 100644 --- a/src/widgets/kernel/qwidgetwindow.cpp +++ b/src/widgets/kernel/qwidgetwindow.cpp @@ -591,24 +591,16 @@ void QWidgetWindow::updateNormalGeometry() void QWidgetWindow::handleMoveEvent(QMoveEvent *event) { - // If the widget's position already matches that of the event, this is a - // result of call to QWidget::move(), which already sends an event. - const bool spontaneous = m_widget->geometry().topLeft() != event->pos(); updateGeometry(); - if (spontaneous) - QGuiApplication::sendSpontaneousEvent(m_widget, event); + QGuiApplication::sendSpontaneousEvent(m_widget, event); } void QWidgetWindow::handleResizeEvent(QResizeEvent *event) { QSize oldSize = m_widget->data->crect.size(); - // If the widget's size already matches that of the event, this is a - // result of call to QWidget::resize(), which already sends an event. - const bool spontaneous = oldSize != event->size(); updateGeometry(); - if (spontaneous) - QGuiApplication::sendSpontaneousEvent(m_widget, event); + QGuiApplication::sendSpontaneousEvent(m_widget, event); if (m_widget->d_func()->paintOnScreen()) { QRegion updateRegion(geometry()); -- cgit v1.2.3 From 16b90bb68343dc45a34d59083a2b62200fcc9551 Mon Sep 17 00:00:00 2001 From: Jan Arve Saether Date: Thu, 12 Jun 2014 20:55:21 +0200 Subject: QFontComboBox sometimes became too wide because of wrong fixed size The fixed width should not be set on QFontComboBox itself, but on the popup. This regressed with commit bfb25c03523757d66974189e54dda97962206ef9, and caused assistants preferences dialog to become wider than the desktop. Change-Id: I2059794fc12d34837cdb7dfded80df57d102a6f0 Reviewed-by: Fabian Bumberger --- src/widgets/widgets/qfontcombobox.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/widgets') diff --git a/src/widgets/widgets/qfontcombobox.cpp b/src/widgets/widgets/qfontcombobox.cpp index 40ca73904c..db01543629 100644 --- a/src/widgets/widgets/qfontcombobox.cpp +++ b/src/widgets/widgets/qfontcombobox.cpp @@ -548,7 +548,7 @@ bool QFontComboBox::event(QEvent *e) if (e->type() == QEvent::Resize) { QListView *lview = qobject_cast(view()); if (lview) { - setFixedWidth(qMin(width() * 5 / 3, + lview->window()->setFixedWidth(qMin(width() * 5 / 3, QApplication::desktop()->availableGeometry(lview).width())); } } -- cgit v1.2.3 From d88b976858437f081ef9f8150b3697586a5bf73a Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 18 Jun 2014 15:30:35 -0700 Subject: Fix compilation in under -no-c++11 mode IndexSetter can't be passed to QObject::connect() since C++98 templates require global types (they can't be function-local). Change-Id: I099322f835661d4679140b7810b50dbeb0e4b9e0 Reviewed-by: Gabriel de Dietrich Reviewed-by: Olivier Goffart --- src/widgets/widgets/qcombobox.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index f857f4eac0..3718f09337 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -2377,6 +2377,16 @@ QSize QComboBox::sizeHint() const } #ifdef Q_OS_OSX + +namespace { +struct IndexSetter { + int index; + QComboBox *cb; + + void operator()(void) { cb->setCurrentIndex(index); } +}; +} + /*! * \internal * @@ -2391,13 +2401,6 @@ bool QComboBoxPrivate::showNativePopup() if (QPlatformMenu *menu = theme->createPlatformMenu()) { int itemsCount = q->count(); - struct IndexSetter { - int index; - QComboBox *cb; - - void operator()(void) { cb->setCurrentIndex(index); } - }; - QList items; items.reserve(itemsCount); QPlatformMenuItem *currentItem = 0; -- cgit v1.2.3 From 3fd184b663efcf3691efcd6411fb0b18f941f7b2 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 17 Jun 2014 17:13:11 +0200 Subject: Use QModelIndex to get the data from underlying model Change-Id: Ibeb70079afd566c78289168540296b926f36d1af Initial-patch-by: Irfan Omair Task-number: QTBUG-27597 Reviewed-by: Andy Shaw --- 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 3718f09337..3491c5ba85 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtWidgets module of the Qt Toolkit. @@ -2055,7 +2055,7 @@ void QComboBoxPrivate::setCurrentIndex(const QModelIndex &mi) if (indexChanged) currentIndex = QPersistentModelIndex(normalized); if (lineEdit) { - QString newText = q->itemText(normalized.row()); + const QString newText = itemText(normalized); if (lineEdit->text() != newText) lineEdit->setText(newText); updateLineEditGeometry(); -- cgit v1.2.3 From 47b3ecf3f49933f2a7e3a9dd98f0641d513822bb Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Tue, 17 Jun 2014 15:54:59 +0200 Subject: Remove the widget from the stylesheet cache before polishing If the widget exists in the style rules cache before it polishes for the first time then it should be removed from styleSheetCache too so that the latest set stylesheet is used for the polishing. Task-number: QTBUG-39427 Change-Id: Ic1e7988afe530f16ea9996bae56543ed554d6be9 Reviewed-by: Friedemann Kleint --- src/widgets/styles/qstylesheetstyle.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/widgets') diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index 94f8e36235..60bfc8e075 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -2697,6 +2697,7 @@ void QStyleSheetStyle::polish(QWidget *w) styleSheetCaches->styleRulesCache.remove(w); styleSheetCaches->hasStyleRuleCache.remove(w); styleSheetCaches->renderRulesCache.remove(w); + styleSheetCaches->styleSheetCache.remove(w); } setGeometry(w); setProperties(w); -- cgit v1.2.3 From 6b15a5a869e6180a000751958def1cf485c23f68 Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Mon, 16 Jun 2014 13:23:31 +0200 Subject: QComboBox: update focus policy when setting a new line edit On OS X, the focus policy of QComboBox is different when editable or not. Task-number: QTBUG-39650 Change-Id: I394564f8a1a6d462e86d2497fe8874e6107a8a58 Reviewed-by: Gabriel de Dietrich Reviewed-by: Jake Petroules --- src/widgets/widgets/qcombobox.cpp | 24 ++++++++++++++++-------- src/widgets/widgets/qcombobox_p.h | 1 + 2 files changed, 17 insertions(+), 8 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index 3491c5ba85..eae0cbbd06 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -1085,6 +1085,19 @@ void QComboBoxPrivate::updateViewContainerPaletteAndOpacity() lineEdit->setPalette(q->palette()); } +void QComboBoxPrivate::updateFocusPolicy() +{ +#ifdef Q_OS_OSX + Q_Q(QComboBox); + + // See comment in QComboBoxPrivate::init() + if (q->isEditable()) + q->setFocusPolicy(Qt::WheelFocus); + else + q->setFocusPolicy(Qt::TabFocus); +#endif +} + /*! Initialize \a option with the values from this QComboBox. This method is useful for subclasses when they need a QStyleOptionComboBox, but don't want @@ -1691,10 +1704,6 @@ void QComboBox::setEditable(bool editable) } QLineEdit *le = new QLineEdit(this); setLineEdit(le); -#ifdef Q_OS_MAC - // See comment in QComboBoxPrivate::init() - setFocusPolicy(Qt::WheelFocus); -#endif } else { if (style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, this)) { d->viewContainer()->updateScrollers(); @@ -1704,12 +1713,10 @@ void QComboBox::setEditable(bool editable) d->lineEdit->hide(); d->lineEdit->deleteLater(); d->lineEdit = 0; -#ifdef Q_OS_MAC - // See comment in QComboBoxPrivate::init() - setFocusPolicy(Qt::TabFocus); -#endif } + d->updateFocusPolicy(); + d->viewContainer()->updateTopBottomMargin(); if (!testAttribute(Qt::WA_Resized)) adjustSize(); @@ -1743,6 +1750,7 @@ void QComboBox::setLineEdit(QLineEdit *edit) connect(d->lineEdit, SIGNAL(textChanged(QString)), this, SIGNAL(currentTextChanged(QString))); d->lineEdit->setFrame(false); d->lineEdit->setContextMenuPolicy(Qt::NoContextMenu); + d->updateFocusPolicy(); d->lineEdit->setFocusProxy(this); d->lineEdit->setAttribute(Qt::WA_MacShowFocusRect, false); #ifndef QT_NO_COMPLETER diff --git a/src/widgets/widgets/qcombobox_p.h b/src/widgets/widgets/qcombobox_p.h index dceffe8d35..fb1ed71ee6 100644 --- a/src/widgets/widgets/qcombobox_p.h +++ b/src/widgets/widgets/qcombobox_p.h @@ -376,6 +376,7 @@ public: void keyboardSearchString(const QString &text); void modelChanged(); void updateViewContainerPaletteAndOpacity(); + void updateFocusPolicy(); #ifdef Q_OS_OSX bool showNativePopup(); -- cgit v1.2.3 From b5f284379155dee390c13a8d69b74d92f6ba9d19 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Fri, 13 Jun 2014 23:30:46 +0200 Subject: Add that the corner settings are saved/restored with the state Change-Id: Iee4c04291001470518176d8b3a49c08b52a6336e Reviewed-by: Jerome Pasion --- src/widgets/widgets/qmainwindow.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/widgets/qmainwindow.cpp b/src/widgets/widgets/qmainwindow.cpp index 358569a5e4..36ca90ba00 100644 --- a/src/widgets/widgets/qmainwindow.cpp +++ b/src/widgets/widgets/qmainwindow.cpp @@ -1226,7 +1226,9 @@ Qt::DockWidgetArea QMainWindow::dockWidgetArea(QDockWidget *dockwidget) const /*! Saves the current state of this mainwindow's toolbars and - dockwidgets. The \a version number is stored as part of the data. + dockwidgets. This includes the corner settings which can + be set with setCorner(). The \a version number is stored + as part of the data. The \l{QObject::objectName}{objectName} property is used to identify each QToolBar and QDockWidget. You should make sure @@ -1255,8 +1257,9 @@ QByteArray QMainWindow::saveState(int version) const /*! Restores the \a state of this mainwindow's toolbars and - dockwidgets. The \a version number is compared with that stored - in \a state. If they do not match, the mainwindow's state is left + dockwidgets. Also restores the corner settings too. The + \a version number is compared with that stored in \a state. + If they do not match, the mainwindow's state is left unchanged, and this function returns \c false; otherwise, the state is restored, and this function returns \c true. -- cgit v1.2.3 From 7c833601402d536bccb1541a17755d20a1a102de Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 25 Jun 2014 10:04:40 +0200 Subject: QColorDialog: Do not update custom/standard color cells while picking. Delay the updating of the custom/standard color cells to the mouse release of the color pick. This makes it possible to pre-select a custom color cell for assignment before the pick and prevents that from changing when its color is crossed by accident. Rename the existing method QColorDialogPrivate::setCurrentColor(QRgb) to setCurrentRgbColor() and move QColor::setCurrentColor() to QColorDialogPrivate, introducing an enumeration for specifying what to set. Task-number: QTBUG-39792 Change-Id: Ibfe96e345589346e8c72976a0335e901798f2766 Reviewed-by: Paul Olav Tvete --- src/widgets/dialogs/qcolordialog.cpp | 39 ++++++++++++++++++++++-------------- src/widgets/dialogs/qcolordialog_p.h | 11 ++++++++-- 2 files changed, 33 insertions(+), 17 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/dialogs/qcolordialog.cpp b/src/widgets/dialogs/qcolordialog.cpp index 8866a3e97e..3889a589c7 100644 --- a/src/widgets/dialogs/qcolordialog.cpp +++ b/src/widgets/dialogs/qcolordialog.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtWidgets module of the Qt Toolkit. @@ -1442,7 +1442,7 @@ void QColorDialogPrivate::_q_newHsv(int h, int s, int v) } //sets all widgets to display rgb -void QColorDialogPrivate::setCurrentColor(QRgb rgb) +void QColorDialogPrivate::setCurrentRgbColor(QRgb rgb) { if (!nativeDialogInUse) { cs->setRgb(rgb); @@ -1525,14 +1525,14 @@ void QColorDialogPrivate::_q_nextCustom(int r, int c) void QColorDialogPrivate::_q_newCustom(int r, int c) { const int i = r + 2 * c; - setCurrentColor(QColorDialogOptions::customColor(i)); + setCurrentRgbColor(QColorDialogOptions::customColor(i)); if (standard) standard->setSelected(-1,-1); } void QColorDialogPrivate::_q_newStandard(int r, int c) { - setCurrentColor(QColorDialogOptions::standardColor(r + c * 6)); + setCurrentRgbColor(QColorDialogOptions::standardColor(r + c * 6)); if (custom) custom->setSelected(-1,-1); } @@ -1873,6 +1873,21 @@ QColorDialog::QColorDialog(const QColor &initial, QWidget *parent) d->init(initial); } +void QColorDialogPrivate::setCurrentColor(const QColor &color, SetColorMode setColorMode) +{ + if (nativeDialogInUse) { + platformColorDialogHelper()->setCurrentColor(color); + return; + } + + if (setColorMode & ShowColor) { + setCurrentRgbColor(color.rgb()); + setCurrentAlpha(color.alpha()); + } + if (setColorMode & SelectColor) + selectColor(color); +} + /*! \property QColorDialog::currentColor \brief the currently selected color in the dialog @@ -1881,13 +1896,7 @@ QColorDialog::QColorDialog(const QColor &initial, QWidget *parent) void QColorDialog::setCurrentColor(const QColor &color) { Q_D(QColorDialog); - if (d->nativeDialogInUse) - d->platformColorDialogHelper()->setCurrentColor(color); - else { - d->setCurrentColor(color.rgb()); - d->selectColor(color); - d->setCurrentAlpha(color.alpha()); - } + d->setCurrentColor(color); } QColor QColorDialog::currentColor() const @@ -2162,10 +2171,11 @@ void QColorDialog::changeEvent(QEvent *e) bool QColorDialogPrivate::handleColorPickingMouseMove(QMouseEvent *e) { - Q_Q(QColorDialog); const QPoint globalPos = e->globalPos(); const QColor color = grabScreenColor(globalPos); - q->setCurrentColor(color); + // QTBUG-39792, do not change standard, custom color selectors while moving as + // otherwise it is not possible to pre-select a custom cell for assignment. + setCurrentColor(color, ShowColor); lblScreenColorInfo->setText(QColorDialog::tr("Cursor at %1, %2, color: %3\nPress ESC to cancel") .arg(globalPos.x()).arg(globalPos.y()).arg(color.name())); return true; @@ -2173,8 +2183,7 @@ bool QColorDialogPrivate::handleColorPickingMouseMove(QMouseEvent *e) bool QColorDialogPrivate::handleColorPickingMouseButtonRelease(QMouseEvent *e) { - Q_Q(QColorDialog); - q->setCurrentColor(grabScreenColor(e->globalPos())); + setCurrentColor(grabScreenColor(e->globalPos()), SetColorAll); releaseColorPicking(); return true; } diff --git a/src/widgets/dialogs/qcolordialog_p.h b/src/widgets/dialogs/qcolordialog_p.h index 72c3b0e3cd..feabce4bbf 100644 --- a/src/widgets/dialogs/qcolordialog_p.h +++ b/src/widgets/dialogs/qcolordialog_p.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtWidgets module of the Qt Toolkit. @@ -77,6 +77,12 @@ class QColorDialogPrivate : public QDialogPrivate Q_DECLARE_PUBLIC(QColorDialog) public: + enum SetColorMode { + ShowColor = 0x1, + SelectColor = 0x2, + SetColorAll = ShowColor | SelectColor + }; + QColorDialogPrivate() : options(new QColorDialogOptions) {} QPlatformColorDialogHelper *platformColorDialogHelper() const @@ -86,7 +92,8 @@ public: void initWidgets(); QRgb currentColor() const; QColor currentQColor() const; - void setCurrentColor(QRgb rgb); + void setCurrentColor(const QColor &color, SetColorMode setColorMode = SetColorAll); + void setCurrentRgbColor(QRgb rgb); void setCurrentQColor(const QColor &color); bool selectColor(const QColor &color); QColor grabScreenColor(const QPoint &p); -- cgit v1.2.3 From 5d6b763ee521b830c2b19949016f9436627496d6 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Wed, 25 Jun 2014 13:12:53 +0100 Subject: qtoolbar: add missing header on OSX. Without this you get: ``` widgets/qtoolbar.cpp:1047:5: error: incomplete type 'QPlatformNativeInterface' named in nested name specifier QPlatformNativeInterface::NativeResourceForIntegrationFunction function = ^~~~~~~~~~~~~~~~~~~~~~~~~~ qtbase/src/widgets/../../include/QtGui/../../src/gui/kernel/qguiapplication.h:57:7: note: forward declaration of 'QPlatformNativeInterface' class QPlatformNativeInterface; ``` Change-Id: I1301a8aa8b25eb12821e91125743be779e52db0f Reviewed-by: Jake Petroules Reviewed-by: Mike McQuaid Reviewed-by: Giuseppe D'Angelo --- src/widgets/widgets/qtoolbar.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/widgets') diff --git a/src/widgets/widgets/qtoolbar.cpp b/src/widgets/widgets/qtoolbar.cpp index 3fd615c3c7..1c05529cd6 100644 --- a/src/widgets/widgets/qtoolbar.cpp +++ b/src/widgets/widgets/qtoolbar.cpp @@ -59,6 +59,10 @@ #include #include +#ifdef Q_OS_OSX +#include +#endif + #include "qtoolbar_p.h" #include "qtoolbarseparator_p.h" #include "qtoolbarlayout_p.h" -- cgit v1.2.3 From 5de4ed9db38c7a1a480e5979c2bb3b0340c8a230 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Sat, 28 Jun 2014 15:47:58 +0200 Subject: QMac/FusionStyle: fix the background color for transient scrollbars Task-number: QTBUG-39922 Change-Id: I4b313296ae845bc9e116494aa66c577b432b4a67 Reviewed-by: Gabriel de Dietrich --- src/widgets/styles/qfusionstyle.cpp | 2 +- src/widgets/styles/qmacstyle_mac.mm | 2 +- src/widgets/styles/qstylehelper.cpp | 10 ++++++++++ src/widgets/styles/qstylehelper_p.h | 1 + 4 files changed, 13 insertions(+), 2 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp index 2172c9082f..82c53def7d 100644 --- a/src/widgets/styles/qfusionstyle.cpp +++ b/src/widgets/styles/qfusionstyle.cpp @@ -2493,7 +2493,7 @@ void QFusionStyle::drawComplexControl(ComplexControl control, const QStyleOption QColor arrowColor = option->palette.foreground().color(); arrowColor.setAlpha(220); - const QColor bgColor = option->palette.color(QPalette::Base); + const QColor bgColor = QStyleHelper::backgroundColor(option->palette, widget); const bool isDarkBg = bgColor.red() < 128 && bgColor.green() < 128 && bgColor.blue() < 128; if (transient) { diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index 8bc454a795..8cb7ce1c87 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -5133,7 +5133,7 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex [scroller initWithFrame:NSMakeRect(0, 0, slider->rect.width(), slider->rect.height())]; // mac os behaviour: as soon as one color channel is >= 128, // the bg is considered bright, scroller is dark - const QColor bgColor = opt->palette.color(QPalette::Base); + const QColor bgColor = QStyleHelper::backgroundColor(opt->palette, widget); const bool isDarkBg = bgColor.red() < 128 && bgColor.green() < 128 && bgColor.blue() < 128; if (isDarkBg) diff --git a/src/widgets/styles/qstylehelper.cpp b/src/widgets/styles/qstylehelper.cpp index fc73488154..6be07a3f45 100644 --- a/src/widgets/styles/qstylehelper.cpp +++ b/src/widgets/styles/qstylehelper.cpp @@ -45,6 +45,8 @@ #include #include #include +#include +#include #include "qstylehelper_p.h" #include @@ -387,5 +389,13 @@ void drawBorderPixmap(const QPixmap &pixmap, QPainter *painter, const QRect &rec } } + +QColor backgroundColor(const QPalette &pal, const QWidget* widget) +{ + if (qobject_cast(widget) && widget->parent() && + qobject_cast(widget->parent()->parent())) + return widget->parentWidget()->parentWidget()->palette().color(QPalette::Base); + return pal.color(QPalette::Base); +} } QT_END_NAMESPACE diff --git a/src/widgets/styles/qstylehelper_p.h b/src/widgets/styles/qstylehelper_p.h index 6355cbc985..73e5c94dcd 100644 --- a/src/widgets/styles/qstylehelper_p.h +++ b/src/widgets/styles/qstylehelper_p.h @@ -86,6 +86,7 @@ namespace QStyleHelper bool isInstanceOf(QObject *obj, QAccessible::Role role); bool hasAncestor(QObject *obj, QAccessible::Role role); #endif + QColor backgroundColor(const QPalette &pal, const QWidget* widget = 0); } -- cgit v1.2.3 From 2021c6c8f74df35f7bf71f9d4a6208c055a3cf15 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 30 Jun 2014 13:52:46 +0200 Subject: Fix pixel noise in X11 systray icons that are not 22x22 If a system tray icon is set to a non default size by an X11 system tray, the area beyond 22x22 will not be painted, since the first paint is performed before the first resize, and the first resize does not trigger expose either. The bug can be seen in KDE if the system tray is not 22 pixel height. This patch triggers updates on resize to ensure we always repaint fully on resize. Change-Id: Ia81d2329a2c9faff220f07163ac38cafbd520ffc Reviewed-by: Shawn Rutledge --- src/widgets/util/qsystemtrayicon_x11.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/widgets') diff --git a/src/widgets/util/qsystemtrayicon_x11.cpp b/src/widgets/util/qsystemtrayicon_x11.cpp index 347e5701c0..21ce23437f 100644 --- a/src/widgets/util/qsystemtrayicon_x11.cpp +++ b/src/widgets/util/qsystemtrayicon_x11.cpp @@ -83,6 +83,7 @@ protected: virtual void mouseDoubleClickEvent(QMouseEvent *ev); virtual bool event(QEvent *); virtual void paintEvent(QPaintEvent *); + virtual void resizeEvent(QResizeEvent *); private slots: void systemTrayWindowChanged(QScreen *screen); @@ -205,6 +206,11 @@ void QSystemTrayIconSys::paintEvent(QPaintEvent *) q->icon().paint(&painter, rect); } +void QSystemTrayIconSys::resizeEvent(QResizeEvent *) +{ + update(); +} + //////////////////////////////////////////////////////////////////////////// QSystemTrayIconPrivate::QSystemTrayIconPrivate() -- cgit v1.2.3 From 83f06da1c6bffff61af78cbe75a0691d53742b53 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Thu, 26 Jun 2014 20:18:35 +0200 Subject: Mac Style: Fix QLineEdit frame in 10.10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also removes some dead code. Change-Id: Id590bd56641918a163f8bad251e3e0e750adfc6f Reviewed-by: Jake Petroules Reviewed-by: Morten Johan Sørvig --- src/widgets/styles/qmacstyle_mac.mm | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index 8cb7ce1c87..0084bf68dc 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -3186,17 +3186,15 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai fdi.version = qt_mac_hitheme_version; fdi.state = tds; SInt32 frame_size; - if (pe == PE_FrameLineEdit) { - fdi.kind = frame->features & QStyleOptionFrame::Rounded ? kHIThemeFrameTextFieldRound : - kHIThemeFrameTextFieldSquare; - GetThemeMetric(kThemeMetricEditTextFrameOutset, &frame_size); - if ((frame->state & State_ReadOnly) || !(frame->state & State_Enabled)) - fdi.state = kThemeStateInactive; - } else { - baseColor = QColor(150, 150, 150); //hardcoded since no query function --Sam - fdi.kind = kHIThemeFrameListBox; - GetThemeMetric(kThemeMetricListBoxFrameOutset, &frame_size); - } + fdi.kind = frame->features & QStyleOptionFrame::Rounded ? kHIThemeFrameTextFieldRound : + kHIThemeFrameTextFieldSquare; + GetThemeMetric(kThemeMetricEditTextFrameOutset, &frame_size); + if ((frame->state & State_ReadOnly) || !(frame->state & State_Enabled)) + fdi.state = kThemeStateInactive; + else if (fdi.state == kThemeStatePressed) + // This pressed state doesn't make sense for a line edit frame. + // And Yosemite agrees with us. Otherwise it starts showing yellow pixels. + fdi.state = kThemeStateActive; fdi.isFocused = (frame->state & State_HasFocus); int lw = frame->lineWidth; if (lw <= 0) -- cgit v1.2.3