From d2ca87066004c48764cb56e70f5fcdb6681513b1 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Fri, 17 Mar 2017 15:32:11 +0100 Subject: Make overloaded function appear in assistant index When there are overloaded function for one class, at least one of them mustn't possess \overload command, otherwise it won't appear at all in doc index. Task-number: QTBUG-59506 Change-Id: I650a3969cb45c1a5efdfc3a654e01d113c398f16 Reviewed-by: Martin Smith --- src/widgets/dialogs/qcolordialog.cpp | 1 - src/widgets/dialogs/qfiledialog.cpp | 2 -- src/widgets/dialogs/qfontdialog.cpp | 1 - src/widgets/dialogs/qinputdialog.cpp | 1 - src/widgets/dialogs/qmessagebox.cpp | 2 -- src/widgets/dialogs/qprogressdialog.cpp | 1 - src/widgets/kernel/qapplication.cpp | 1 - src/widgets/widgets/qlineedit.cpp | 2 -- src/widgets/widgets/qmenu.cpp | 2 -- src/widgets/widgets/qmenubar.cpp | 2 -- src/widgets/widgets/qplaintextedit.cpp | 6 ------ src/widgets/widgets/qtabwidget.cpp | 2 -- src/widgets/widgets/qtextedit.cpp | 6 ------ src/widgets/widgets/qtoolbar.cpp | 2 -- 14 files changed, 31 deletions(-) diff --git a/src/widgets/dialogs/qcolordialog.cpp b/src/widgets/dialogs/qcolordialog.cpp index 434cedfdb9..4aa680af61 100644 --- a/src/widgets/dialogs/qcolordialog.cpp +++ b/src/widgets/dialogs/qcolordialog.cpp @@ -2123,7 +2123,6 @@ void QColorDialog::setVisible(bool visible) } /*! - \overload \since 4.5 Opens the dialog and connects its colorSelected() signal to the slot specified diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp index 6b037726a0..870a833b34 100644 --- a/src/widgets/dialogs/qfiledialog.cpp +++ b/src/widgets/dialogs/qfiledialog.cpp @@ -802,8 +802,6 @@ QFileDialog::Options QFileDialog::options() const } /*! - \overload - \since 4.5 This function connects one of its signals to the slot specified by \a receiver diff --git a/src/widgets/dialogs/qfontdialog.cpp b/src/widgets/dialogs/qfontdialog.cpp index 5f912c582f..477c6bd540 100644 --- a/src/widgets/dialogs/qfontdialog.cpp +++ b/src/widgets/dialogs/qfontdialog.cpp @@ -931,7 +931,6 @@ QFontDialog::FontDialogOptions QFontDialog::options() const /*! \since 4.5 - \overload Opens the dialog and connects its fontSelected() signal to the slot specified by \a receiver and \a member. diff --git a/src/widgets/dialogs/qinputdialog.cpp b/src/widgets/dialogs/qinputdialog.cpp index 9a9bd173bd..5a7d6edddf 100644 --- a/src/widgets/dialogs/qinputdialog.cpp +++ b/src/widgets/dialogs/qinputdialog.cpp @@ -1070,7 +1070,6 @@ QString QInputDialog::cancelButtonText() const /*! \since 4.5 - \overload This function connects one of its signals to the slot specified by \a receiver and \a member. The specific signal depends on the arguments that are specified diff --git a/src/widgets/dialogs/qmessagebox.cpp b/src/widgets/dialogs/qmessagebox.cpp index 41a21e6086..99157747dd 100644 --- a/src/widgets/dialogs/qmessagebox.cpp +++ b/src/widgets/dialogs/qmessagebox.cpp @@ -1500,8 +1500,6 @@ void QMessageBox::keyPressEvent(QKeyEvent *e) } /*! - \overload - Opens the dialog and connects its finished() or buttonClicked() signal to the slot specified by \a receiver and \a member. If the slot in \a member has a pointer for its first parameter the connection is to buttonClicked(), diff --git a/src/widgets/dialogs/qprogressdialog.cpp b/src/widgets/dialogs/qprogressdialog.cpp index a276e28a0c..4bf78e2115 100644 --- a/src/widgets/dialogs/qprogressdialog.cpp +++ b/src/widgets/dialogs/qprogressdialog.cpp @@ -865,7 +865,6 @@ void QProgressDialog::forceShow() /*! \since 4.5 - \overload Opens the dialog and connects its canceled() signal to the slot specified by \a receiver and \a member. diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 038226c521..10ded6e34f 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -1345,7 +1345,6 @@ void QApplication::setGlobalStrut(const QSize& strut) /*! \fn QPalette QApplication::palette(const QWidget* widget) - \overload If a \a widget is passed, the default palette for the widget's class is returned. This may or may not be the application palette. In most cases diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp index 190ff8d2c5..96c5982e0c 100644 --- a/src/widgets/widgets/qlineedit.cpp +++ b/src/widgets/widgets/qlineedit.cpp @@ -437,8 +437,6 @@ bool QLineEdit::hasFrame() const #if QT_CONFIG(action) /*! - \overload - Adds the \a action to the list of actions at the \a position. \since 5.2 diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp index 96635ae505..c79e88f094 100644 --- a/src/widgets/widgets/qmenu.cpp +++ b/src/widgets/widgets/qmenu.cpp @@ -1741,8 +1741,6 @@ QMenu::~QMenu() } /*! - \overload - This convenience function creates a new action with \a text. The function adds the newly created action to the menu's list of actions, and returns it. diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp index 6df53dc4e4..ce74a4c2ff 100644 --- a/src/widgets/widgets/qmenubar.cpp +++ b/src/widgets/widgets/qmenubar.cpp @@ -749,8 +749,6 @@ QMenuBar::~QMenuBar() } /*! - \overload - This convenience function creates a new action with \a text. The function adds the newly created action to the menu's list of actions, and returns it. diff --git a/src/widgets/widgets/qplaintextedit.cpp b/src/widgets/widgets/qplaintextedit.cpp index 40b1077656..91fcaa48cf 100644 --- a/src/widgets/widgets/qplaintextedit.cpp +++ b/src/widgets/widgets/qplaintextedit.cpp @@ -2338,8 +2338,6 @@ void QPlainTextEdit::wheelEvent(QWheelEvent *e) #endif /*! - \fn QPlainTextEdit::zoomIn(int range) - Zooms in on the text by making the base font size \a range points larger and recalculating all font sizes to be the new size. This does not change the size of any images. @@ -2352,10 +2350,6 @@ void QPlainTextEdit::zoomIn(int range) } /*! - \fn QPlainTextEdit::zoomOut(int range) - - \overload - Zooms out on the text by making the base font size \a range points smaller and recalculating all font sizes to be the new size. This does not change the size of any images. diff --git a/src/widgets/widgets/qtabwidget.cpp b/src/widgets/widgets/qtabwidget.cpp index df847e4894..8a848554e3 100644 --- a/src/widgets/widgets/qtabwidget.cpp +++ b/src/widgets/widgets/qtabwidget.cpp @@ -511,8 +511,6 @@ QString QTabWidget::tabText(int index) const } /*! - \overload - Sets the \a icon for the tab at position \a index. */ void QTabWidget::setTabIcon(int index, const QIcon &icon) diff --git a/src/widgets/widgets/qtextedit.cpp b/src/widgets/widgets/qtextedit.cpp index 3a368651de..e3a45680ef 100644 --- a/src/widgets/widgets/qtextedit.cpp +++ b/src/widgets/widgets/qtextedit.cpp @@ -2310,8 +2310,6 @@ void QTextEdit::scrollToAnchor(const QString &name) } /*! - \fn QTextEdit::zoomIn(int range) - Zooms in on the text by making the base font size \a range points larger and recalculating all font sizes to be the new size. This does not change the size of any images. @@ -2324,10 +2322,6 @@ void QTextEdit::zoomIn(int range) } /*! - \fn QTextEdit::zoomOut(int range) - - \overload - Zooms out on the text by making the base font size \a range points smaller and recalculating all font sizes to be the new size. This does not change the size of any images. diff --git a/src/widgets/widgets/qtoolbar.cpp b/src/widgets/widgets/qtoolbar.cpp index 4e90bce69d..4af71c126e 100644 --- a/src/widgets/widgets/qtoolbar.cpp +++ b/src/widgets/widgets/qtoolbar.cpp @@ -743,8 +743,6 @@ void QToolBar::clear() } /*! - \overload - Creates a new action with the given \a text. This action is added to the end of the toolbar. */ -- cgit v1.2.3 From 989e86074aeb339075c617ac788ec84d441db62f Mon Sep 17 00:00:00 2001 From: Lorn Potter Date: Fri, 29 Jun 2018 11:08:27 +1000 Subject: wasm: use config for natural scroll on safari MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Idc2ee096144194e3f0d9ca165a578ff9745ef13d Reviewed-by: Morten Johan Sørvig --- .../platforms/wasm/qwasmeventtranslator.cpp | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/plugins/platforms/wasm/qwasmeventtranslator.cpp b/src/plugins/platforms/wasm/qwasmeventtranslator.cpp index 95bedf701c..cc48c15b64 100644 --- a/src/plugins/platforms/wasm/qwasmeventtranslator.cpp +++ b/src/plugins/platforms/wasm/qwasmeventtranslator.cpp @@ -39,15 +39,27 @@ #include #include +#include #include QT_BEGIN_NAMESPACE +using namespace emscripten; // macOS CTRL <-> META switching. We most likely want to enable // the existing switching code in QtGui, but for now do it here. static bool g_usePlatformMacCtrlMetaSwitching = false; +bool g_useNaturalScrolling = false; + +void setNaturalScrolling(bool use) { + g_useNaturalScrolling = use; +} + +EMSCRIPTEN_BINDINGS(mouse_module) { + function("setNaturalScrolling", &setNaturalScrolling); +} + QWasmEventTranslator::QWasmEventTranslator(QObject *parent) : QObject(parent) , draggedWindow(nullptr) @@ -84,6 +96,20 @@ QWasmEventTranslator::QWasmEventTranslator(QObject *parent) Platform(EM_ASM_INT("if (navigator.platform.includes(\"Mac\")) return 1; return 0;")); g_usePlatformMacCtrlMetaSwitching = (platform == MacOSPlatform); + + if (platform == MacOSPlatform) { + g_useNaturalScrolling = true; //make this default on macOS + EM_ASM( + if (window.safari !== undefined) {//this only works on safari + Module["canvas"].addEventListener('wheel', mouseWheelEvent); + function mouseWheelEvent(e) { + if (event.webkitDirectionInvertedFromDevice) { + Module.setNaturalScrolling(event.webkitDirectionInvertedFromDevice); + } + } + } + ); + } } template @@ -449,6 +475,9 @@ int QWasmEventTranslator::wheel_cb(int eventType, const EmscriptenWheelEvent *wh break; }; + if (g_useNaturalScrolling) //macOS platform has document oriented scrolling + scrollFactor = -scrollFactor; + Qt::KeyboardModifiers modifiers = translateMouseEventModifier(&mouseEvent); auto timestamp = mouseEvent.timestamp; QPoint globalPoint(mouseEvent.canvasX, mouseEvent.canvasY); -- cgit v1.2.3 From b6022eccc4c330e01f0cfe8bba211b332dacbb61 Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Sat, 25 Aug 2018 16:00:23 +0200 Subject: Doc: fix QRegularExpression::wildcardToRegularExpression snippet The sample output from wildcardToRegularExpression was from an earlier version of the implementation. This patch fixes this. Change-Id: I48108add01aafed69490ef2527c1ea6a209b220b Reviewed-by: Sze Howe Koh --- .../doc/snippets/code/src_corelib_tools_qregularexpression.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qregularexpression.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qregularexpression.cpp index 28c66628b7..b5d8320bce 100644 --- a/src/corelib/doc/snippets/code/src_corelib_tools_qregularexpression.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_tools_qregularexpression.cpp @@ -353,7 +353,10 @@ while (i.hasNext()) { { //! [31] QString wildcard = QRegularExpression::wildcardToRegularExpression("*.jpeg"); -// wilcard == ".*\.jpeg" +// Will match files with names like: +// foo.jpeg +// f_o_o.jpeg +// föö.jpeg //! [31] } -- cgit v1.2.3 From 933df86bbcb96779b26d888a1e08fddbebbfcfe8 Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Wed, 12 Sep 2018 08:52:49 +0200 Subject: QSFPM: setFilterRegExp and setFilterRegularExpression overloads to slots The setters of both filterRegExp and filterRegularExpression are currently normal functions. This patch moves them to slots to make them usable using the old syntax. This can be done since there are already overloads for both of them so people using the new connect syntax would have needed to use qOverload already therefore there is no SIC. [ChangeLog][QtCore][QSortFilterProxyModel] Setters of both the filterRegExp and filterRegularExpression properties are now slots and can be used with the old as well as the new syntax. Change-Id: Id5cd9a50fa4a62e2bbd6bd665b44bd25a0402852 Fixes: QTBUG-18113 Reviewed-by: David Faure --- src/corelib/itemmodels/qsortfilterproxymodel.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/itemmodels/qsortfilterproxymodel.h b/src/corelib/itemmodels/qsortfilterproxymodel.h index 1304a95d13..0be8b88672 100644 --- a/src/corelib/itemmodels/qsortfilterproxymodel.h +++ b/src/corelib/itemmodels/qsortfilterproxymodel.h @@ -88,11 +88,9 @@ public: QItemSelection mapSelectionFromSource(const QItemSelection &sourceSelection) const override; QRegExp filterRegExp() const; - void setFilterRegExp(const QRegExp ®Exp); #if QT_CONFIG(regularexpression) QRegularExpression filterRegularExpression() const; - void setFilterRegularExpression(const QRegularExpression ®ularExpression); #endif int filterKeyColumn() const; @@ -124,8 +122,10 @@ public: public Q_SLOTS: void setFilterRegExp(const QString &pattern); + void setFilterRegExp(const QRegExp ®Exp); #if QT_CONFIG(regularexpression) void setFilterRegularExpression(const QString &pattern); + void setFilterRegularExpression(const QRegularExpression ®ularExpression); #endif void setFilterWildcard(const QString &pattern); void setFilterFixedString(const QString &pattern); -- cgit v1.2.3 From 18be2337ea85655e39f4ffe3b77d2b3ab243c140 Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Mon, 1 Oct 2018 15:51:13 +0300 Subject: Android: bump android gradle plugin version Needed to fix "No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android" Change-Id: I62d9bae0bf424bb9ba32adce98426245922a841b Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/android/templates/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/android/templates/build.gradle b/src/android/templates/build.gradle index 8affd3c0b4..bf5ce1388a 100644 --- a/src/android/templates/build.gradle +++ b/src/android/templates/build.gradle @@ -5,7 +5,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:3.0.1' + classpath 'com.android.tools.build:gradle:3.2.0' } } -- cgit v1.2.3 From 4840668994739054f0976d90eebe9ccfdff0ed81 Mon Sep 17 00:00:00 2001 From: Andre de la Rocha Date: Tue, 2 Oct 2018 09:19:19 +0200 Subject: Windows QPA: Fix multiple mouse button presses detection The detection of multiple mouse button presses was broken in the new WM_POINTER-based implementation. The bug was due to the incorrect assumption that the press/release of a second mouse button (while another one is held) would also send WM_POINTERDOWN/WM_POINTERUP, while in fact it sends a WM_POINTERUPDATE with the actual event type given by pointerInfo->ButtonChangeType. Task-number: QTBUG-70787 Change-Id: Ib6776ab7f3d0b8eb5e832a0c863a15bde456e0dd Reviewed-by: Friedemann Kleint --- .../platforms/windows/qwindowspointerhandler.cpp | 58 ++++++++++++++++------ 1 file changed, 42 insertions(+), 16 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowspointerhandler.cpp b/src/plugins/platforms/windows/qwindowspointerhandler.cpp index 7ead14822a..c5acc38e7c 100644 --- a/src/plugins/platforms/windows/qwindowspointerhandler.cpp +++ b/src/plugins/platforms/windows/qwindowspointerhandler.cpp @@ -61,6 +61,8 @@ #include #include +#include + #include QT_BEGIN_NAMESPACE @@ -184,41 +186,65 @@ static void getMouseEventInfo(UINT message, POINTER_BUTTON_CHANGE_TYPE changeTyp {POINTER_CHANGE_FIFTHBUTTON_UP, Qt::XButton2}, }; - static const QHash eventMapping { - {WM_POINTERUPDATE, QEvent::MouseMove}, - {WM_POINTERDOWN, QEvent::MouseButtonPress}, - {WM_POINTERUP, QEvent::MouseButtonRelease}, - {WM_NCPOINTERUPDATE, QEvent::NonClientAreaMouseMove}, - {WM_NCPOINTERDOWN, QEvent::NonClientAreaMouseButtonPress}, - {WM_NCPOINTERUP, QEvent::NonClientAreaMouseButtonRelease}, - {WM_POINTERWHEEL, QEvent::Wheel}, - {WM_POINTERHWHEEL, QEvent::Wheel}, + static const POINTER_BUTTON_CHANGE_TYPE downChanges[] = { + POINTER_CHANGE_FIRSTBUTTON_DOWN, + POINTER_CHANGE_SECONDBUTTON_DOWN, + POINTER_CHANGE_THIRDBUTTON_DOWN, + POINTER_CHANGE_FOURTHBUTTON_DOWN, + POINTER_CHANGE_FIFTHBUTTON_DOWN, + }; + + static const POINTER_BUTTON_CHANGE_TYPE upChanges[] = { + POINTER_CHANGE_FIRSTBUTTON_UP, + POINTER_CHANGE_SECONDBUTTON_UP, + POINTER_CHANGE_THIRDBUTTON_UP, + POINTER_CHANGE_FOURTHBUTTON_UP, + POINTER_CHANGE_FIFTHBUTTON_UP, }; if (!eventType || !mouseButton) return; - if (message == WM_POINTERDOWN || message == WM_POINTERUP || message == WM_NCPOINTERDOWN || message == WM_NCPOINTERUP) - *mouseButton = buttonMapping.value(changeType, Qt::NoButton); - else - *mouseButton = Qt::NoButton; + const bool nonClient = message == WM_NCPOINTERUPDATE || + message == WM_NCPOINTERDOWN || + message == WM_NCPOINTERUP; + + if (std::find(std::begin(downChanges), + std::end(downChanges), changeType) < std::end(downChanges)) { + *eventType = nonClient ? QEvent::NonClientAreaMouseButtonPress : + QEvent::MouseButtonPress; + } else if (std::find(std::begin(upChanges), + std::end(upChanges), changeType) < std::end(upChanges)) { + *eventType = nonClient ? QEvent::NonClientAreaMouseButtonRelease : + QEvent::MouseButtonRelease; + } else if (message == WM_POINTERWHEEL || message == WM_POINTERHWHEEL) { + *eventType = QEvent::Wheel; + } else { + *eventType = nonClient ? QEvent::NonClientAreaMouseMove : + QEvent::MouseMove; + } - *eventType = eventMapping.value(message, QEvent::None); + *mouseButton = buttonMapping.value(changeType, Qt::NoButton); // Pointer messages lack a double click indicator. Check if this is the case here. - if (message == WM_POINTERDOWN) { + if (*eventType == QEvent::MouseButtonPress || + *eventType == QEvent::NonClientAreaMouseButtonPress) { static LONG lastTime = 0; static Qt::MouseButton lastButton = Qt::NoButton; + static QEvent::Type lastEvent = QEvent::None; static QPoint lastPos; LONG messageTime = GetMessageTime(); if (*mouseButton == lastButton + && *eventType == lastEvent && messageTime - lastTime < (LONG)GetDoubleClickTime() && qAbs(globalPos.x() - lastPos.x()) < GetSystemMetrics(SM_CXDOUBLECLK) && qAbs(globalPos.y() - lastPos.y()) < GetSystemMetrics(SM_CYDOUBLECLK)) { - *eventType = QEvent::MouseButtonDblClick; + *eventType = nonClient ? QEvent::NonClientAreaMouseButtonDblClick : + QEvent::MouseButtonDblClick; } lastTime = messageTime; lastButton = *mouseButton; + lastEvent = *eventType; lastPos = globalPos; } } -- cgit v1.2.3 From 91d43a48f7307938624d4ab11e488494456646f5 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 24 Sep 2018 15:25:32 +0200 Subject: Prevent instantiation of QGestureManager in ~QWidget, ~QGraphicsItem() Debugging PYSIDE-815 revealed that QGestureManager is instantiated in the application destruction sequence. To prevent that, add a "force" parameter defaulting to true to QGestureManager::instance() and pass false in the destructors and QGestureManager::gesturePending(). Change-Id: I1b76173c926c2a156252b88832b032508d8e8a73 Reviewed-by: Giuseppe D'Angelo Reviewed-by: Richard Moe Gustavsen --- src/widgets/graphicsview/qgraphicsitem.cpp | 2 +- src/widgets/kernel/qapplication.cpp | 4 ++-- src/widgets/kernel/qgesturemanager.cpp | 2 +- src/widgets/kernel/qgesturemanager_p.h | 4 +++- src/widgets/kernel/qwidget.cpp | 2 +- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp index 203b879020..a32f1388bf 100644 --- a/src/widgets/graphicsview/qgraphicsitem.cpp +++ b/src/widgets/graphicsview/qgraphicsitem.cpp @@ -1598,7 +1598,7 @@ QGraphicsItem::~QGraphicsItem() #ifndef QT_NO_GESTURES if (d_ptr->isObject && !d_ptr->gestureContext.isEmpty()) { QGraphicsObject *o = static_cast(this); - if (QGestureManager *manager = QGestureManager::instance()) { + if (QGestureManager *manager = QGestureManager::instance(QGestureManager::DontForceCreation)) { const auto types = d_ptr->gestureContext.keys(); // FIXME: iterate over the map directly? for (Qt::GestureType type : types) manager->cleanupCachedGestures(o, type); diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 10ded6e34f..45b98e9475 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -4521,12 +4521,12 @@ void QApplicationPrivate::notifyDragStarted(const QDrag *drag) #endif // QT_CONFIG(draganddrop) #ifndef QT_NO_GESTURES -QGestureManager* QGestureManager::instance() +QGestureManager* QGestureManager::instance(InstanceCreation ic) { QApplicationPrivate *qAppPriv = QApplicationPrivate::instance(); if (!qAppPriv) return 0; - if (!qAppPriv->gestureManager) + if (!qAppPriv->gestureManager && ic == ForceCreation) qAppPriv->gestureManager = new QGestureManager(qApp); return qAppPriv->gestureManager; } diff --git a/src/widgets/kernel/qgesturemanager.cpp b/src/widgets/kernel/qgesturemanager.cpp index 5bf66d68e3..c4188044cf 100644 --- a/src/widgets/kernel/qgesturemanager.cpp +++ b/src/widgets/kernel/qgesturemanager.cpp @@ -773,7 +773,7 @@ void QGestureManager::recycle(QGesture *gesture) bool QGestureManager::gesturePending(QObject *o) { - const QGestureManager *gm = QGestureManager::instance(); + const QGestureManager *gm = QGestureManager::instance(DontForceCreation); return gm && gm->m_gestureOwners.key(o); } diff --git a/src/widgets/kernel/qgesturemanager_p.h b/src/widgets/kernel/qgesturemanager_p.h index 3df80bab55..3a5c9822eb 100644 --- a/src/widgets/kernel/qgesturemanager_p.h +++ b/src/widgets/kernel/qgesturemanager_p.h @@ -81,7 +81,9 @@ public: bool filterEvent(QGraphicsObject *receiver, QEvent *event); #endif // QT_CONFIG(graphicsview) - static QGestureManager* instance(); // declared in qapplication.cpp + enum InstanceCreation { ForceCreation, DontForceCreation }; + + static QGestureManager *instance(InstanceCreation ic = ForceCreation); // declared in qapplication.cpp static bool gesturePending(QObject *o); void cleanupCachedGestures(QObject *target, Qt::GestureType type); diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index a1a861e216..09a08fac14 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -1572,7 +1572,7 @@ QWidget::~QWidget() #endif #ifndef QT_NO_GESTURES - if (QGestureManager *manager = QGestureManager::instance()) { + if (QGestureManager *manager = QGestureManager::instance(QGestureManager::DontForceCreation)) { // \forall Qt::GestureType type : ungrabGesture(type) (inlined) for (auto it = d->gestureContext.keyBegin(), end = d->gestureContext.keyEnd(); it != end; ++it) manager->cleanupCachedGestures(this, *it); -- cgit v1.2.3 From 5f9a0d64b324abb8bf9baffabd7accb61a83a7e7 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Sun, 23 Sep 2018 14:25:44 +0200 Subject: QtSql: fix code snippets MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The code snippets retrieving the native database driver handles was using qstrcmp() wrong since that is returning 0 when the strings are equal. In some snippets there was even a plain char * comparison which would not work at all. Fix all the places by correctly using qstrcmp() and replace the checks for the valid pointer by not checking for 0. Fixes: QTBUG-70598 Change-Id: I5c53dcfc51c958203fc60fa6a23dd6b27faa1d96 Reviewed-by: André Hartmann Reviewed-by: Paul Wicking Reviewed-by: Venugopal Shivashankar --- src/sql/doc/snippets/code/doc_src_sql-driver.cpp | 2 +- src/sql/doc/snippets/code/src_sql_kernel_qsqldriver.cpp | 12 ++++++------ src/sql/doc/snippets/code/src_sql_kernel_qsqlresult.cpp | 12 ++++++------ 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/sql/doc/snippets/code/doc_src_sql-driver.cpp b/src/sql/doc/snippets/code/doc_src_sql-driver.cpp index 2c0e824db3..54576733bf 100644 --- a/src/sql/doc/snippets/code/doc_src_sql-driver.cpp +++ b/src/sql/doc/snippets/code/doc_src_sql-driver.cpp @@ -106,7 +106,7 @@ while (query.next()) { QVariant v = query.result()->handle(); if (qstrcmp(v.typeName(), "PGresult*") == 0) { PGresult *handle = *static_cast(v.data()); - if (handle != 0) { + if (handle) { // Do something... } } diff --git a/src/sql/doc/snippets/code/src_sql_kernel_qsqldriver.cpp b/src/sql/doc/snippets/code/src_sql_kernel_qsqldriver.cpp index ffae690769..a13cf86d3f 100644 --- a/src/sql/doc/snippets/code/src_sql_kernel_qsqldriver.cpp +++ b/src/sql/doc/snippets/code/src_sql_kernel_qsqldriver.cpp @@ -51,10 +51,10 @@ //! [0] QSqlDatabase db = ...; QVariant v = db.driver()->handle(); -if (v.isValid() && qstrcmp(v.typeName(), "sqlite3*")==0) { +if (v.isValid() && qstrcmp(v.typeName(), "sqlite3*") == 0) { // v.data() returns a pointer to the handle sqlite3 *handle = *static_cast(v.data()); - if (handle != 0) { // check that it is not NULL + if (handle) { ... } } @@ -62,13 +62,13 @@ if (v.isValid() && qstrcmp(v.typeName(), "sqlite3*")==0) { //! [1] -if (qstrcmp(v.typeName(), "PGconn*")) { +if (qstrcmp(v.typeName(), "PGconn*") == 0) { PGconn *handle = *static_cast(v.data()); - if (handle != 0) ... + if (handle) ... } -if (qstrcmp(v.typeName(), "MYSQL*")) { +if (qstrcmp(v.typeName(), "MYSQL*") == 0) { MYSQL *handle = *static_cast(v.data()); - if (handle != 0) ... + if (handle) ... } //! [1] diff --git a/src/sql/doc/snippets/code/src_sql_kernel_qsqlresult.cpp b/src/sql/doc/snippets/code/src_sql_kernel_qsqlresult.cpp index 3424a9140e..8ab2baf2a1 100644 --- a/src/sql/doc/snippets/code/src_sql_kernel_qsqlresult.cpp +++ b/src/sql/doc/snippets/code/src_sql_kernel_qsqlresult.cpp @@ -72,10 +72,10 @@ if (!q.execBatch()) //! [1] QSqlQuery query = ... QVariant v = query.result()->handle(); -if (v.isValid() && qstrcmp(v.typeName(), "sqlite3_stmt*")) { +if (v.isValid() && qstrcmp(v.typeName(), "sqlite3_stmt*") == 0) { // v.data() returns a pointer to the handle sqlite3_stmt *handle = *static_cast(v.data()); - if (handle != 0) { // check that it is not NULL + if (handle) { ... } } @@ -83,13 +83,13 @@ if (v.isValid() && qstrcmp(v.typeName(), "sqlite3_stmt*")) { //! [2] -if (v.typeName() == "PGresult*") { +if (qstrcmp(v.typeName(), "PGresult*") == 0) { PGresult *handle = *static_cast(v.data()); - if (handle != 0) ... + if (handle) ... } -if (v.typeName() == "MYSQL_STMT*") { +if (qstrcmp(v.typeName(), "MYSQL_STMT*") == 0) { MYSQL_STMT *handle = *static_cast(v.data()); - if (handle != 0) ... + if (handle) ... } //! [2] -- cgit v1.2.3 From ddeec1b07edc0f1f225f8dc52efefc2ff63049be Mon Sep 17 00:00:00 2001 From: David Faure Date: Tue, 2 Oct 2018 02:39:21 +0200 Subject: QSFPM: don't let setFilterRegExp(QString) overwrite CaseSensitivity This is a regression from commit 346c15102b, which creates a new QRegExp in setFilterRegExp, losing previously set case sensitivity property (i.e. when the code does proxy->setFilterCaseSensitivity(Qt::CaseInsensitive) before setFilterRegExp). Interestingly that commit ensured that setFilterFixedString would still preserve CaseSensitivity, but not setFilterRegExp(QString). Change-Id: I3d37d001ce6e86dd90e7e07431440a42607172f9 Reviewed-by: Samuel Gaist Reviewed-by: Christian Ehrlicher Reviewed-by: Luca Beldi --- src/corelib/itemmodels/qsortfilterproxymodel.cpp | 1 + .../tst_qsortfilterproxymodel_regexp.cpp | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/src/corelib/itemmodels/qsortfilterproxymodel.cpp index 31b9bbc990..21fbf83382 100644 --- a/src/corelib/itemmodels/qsortfilterproxymodel.cpp +++ b/src/corelib/itemmodels/qsortfilterproxymodel.cpp @@ -2731,6 +2731,7 @@ void QSortFilterProxyModel::setFilterRegExp(const QString &pattern) Q_D(QSortFilterProxyModel); d->filter_about_to_be_changed(); QRegExp rx(pattern); + rx.setCaseSensitivity(d->filter_data.caseSensitivity()); d->filter_data.setRegExp(rx); d->filter_changed(); } diff --git a/tests/auto/corelib/itemmodels/qsortfilterproxymodel_regexp/tst_qsortfilterproxymodel_regexp.cpp b/tests/auto/corelib/itemmodels/qsortfilterproxymodel_regexp/tst_qsortfilterproxymodel_regexp.cpp index e83738661e..38607f1378 100644 --- a/tests/auto/corelib/itemmodels/qsortfilterproxymodel_regexp/tst_qsortfilterproxymodel_regexp.cpp +++ b/tests/auto/corelib/itemmodels/qsortfilterproxymodel_regexp/tst_qsortfilterproxymodel_regexp.cpp @@ -37,6 +37,7 @@ public: tst_QSortFilterProxyModelRegExp(); private slots: void tst_invalid(); + void tst_caseSensitivity(); }; tst_QSortFilterProxyModelRegExp::tst_QSortFilterProxyModelRegExp() : @@ -55,5 +56,14 @@ void tst_QSortFilterProxyModelRegExp::tst_invalid() QCOMPARE(model.filterRegExp(), QRegExp()); } +void tst_QSortFilterProxyModelRegExp::tst_caseSensitivity() +{ + const QLatin1String pattern("test"); + QSortFilterProxyModel model; + model.setFilterCaseSensitivity(Qt::CaseInsensitive); + model.setFilterRegExp(pattern); + QCOMPARE(model.filterCaseSensitivity(), Qt::CaseInsensitive); +} + QTEST_MAIN(tst_QSortFilterProxyModelRegExp) #include "tst_qsortfilterproxymodel_regexp.moc" -- cgit v1.2.3 From 114c4593b6950122ad10326903c986647adb2dc0 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 26 Sep 2018 13:26:03 +0200 Subject: Restore styling of QDockWidget title font Do not override a custom font with the style default. Task-number: QTBUG-70276 Change-Id: I58bf43f791aee5409e29459d579725365703e4f3 Reviewed-by: Friedemann Kleint Reviewed-by: Richard Moe Gustavsen --- src/widgets/widgets/qdockwidget.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/widgets/widgets/qdockwidget.cpp b/src/widgets/widgets/qdockwidget.cpp index 0b2eee7180..6c871aae2c 100644 --- a/src/widgets/widgets/qdockwidget.cpp +++ b/src/widgets/widgets/qdockwidget.cpp @@ -696,7 +696,6 @@ void QDockWidget::initStyleOption(QStyleOptionDockWidget *option) const // If we are in a floating tab, init from the parent because the attributes and the geometry // of the title bar should be taken from the floating window. option->initFrom(floatingTab && !isFloating() ? parentWidget() : this); - option->fontMetrics = QFontMetrics(d->font); option->rect = dwlayout->titleArea(); option->title = d->fixedWindowTitle; option->closable = hasFeature(this, QDockWidget::DockWidgetClosable); @@ -1473,6 +1472,7 @@ void QDockWidget::closeEvent(QCloseEvent *event) void QDockWidget::paintEvent(QPaintEvent *event) { Q_UNUSED(event) + Q_D(QDockWidget); QDockWidgetLayout *layout = qobject_cast(this->layout()); @@ -1493,7 +1493,11 @@ void QDockWidget::paintEvent(QPaintEvent *event) // the title may wish to extend out to all sides (eg. Vista style) QStyleOptionDockWidget titleOpt; initStyleOption(&titleOpt); - p.setFont(d_func()->font); + if (font() == QApplication::font("QDockWidget")) { + titleOpt.fontMetrics = QFontMetrics(d->font); + p.setFont(d->font); + } + p.drawControl(QStyle::CE_DockWidgetTitle, titleOpt); } } -- cgit v1.2.3 From 9c839f95a20904ae66d962f24225dabf13f85266 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Fri, 21 Sep 2018 12:29:19 +0200 Subject: macOS: Ensure QFontDialog picks up changes in NSFontPanel When the font changes in NSFontPanel, it notifies NSFontManager via -[NSFontManager modifyFontViaPanel:], which in turn sends the font manager's action (by default changeFont:) to its target (nil, unless set). Sending the action in -[NSApplication(NSResponder) sendAction:to:from:] will sanitize the 'to' argument via _NSTargetForSendAction. If the argument is non-nill (if we've set the NSFontManager target explicitly), and we're running in an app-modal session (which we are), the target is checked for worksWhenModal -- a property which is defined on NSWindow, and only supposed to be set for subclasses of NSPanel. Since our QNSFontPanelDelegate class doesn't implement this method, the _NSTargetForSendAction function will return nil, and the action is never sent. If we don't set the NSFontManager target (leaving it as nil), the function will skip the worksWhenModal check, and fall back to resolving the target via the responder chain, which includes taking the NSPanel's delegate into account: #0 -[NSWindow delegate] () #1 -[NSWindow(NSEventRouting) supplementalTargetForAction:sender:] () #2 _objectFromResponderChainWhichRespondsToAction () #3 _NSTargetForSendAction () #4 -[NSApplication(NSResponder) sendAction:to:from:] () #5 -[NSFontManager sendAction] () ... Since we want to end up in the QNSFontPanelDelegate, we can rely on the default logic to resolve the target based on the responder chain. But in case _NSTargetForSendAction will at some point also check the resolved target for worksWhenModal, we also implement the worksWhenModal method, to be on the safe side. Fixes: QTBUG-69878 Change-Id: Ie739d016fe0efd17b3d8a99cc1fb1ace81807aff Reviewed-by: Timur Pocheptsov --- src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm index 33b102f3eb..8c0af97a68 100644 --- a/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm +++ b/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm @@ -108,8 +108,6 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSFontPanelDelegate); [mFontPanel setRestorable:NO]; [mFontPanel setDelegate:self]; - [NSFontManager sharedFontManager].target = self; // Action is changeFont: - [mFontPanel retain]; } return self; @@ -119,7 +117,6 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSFontPanelDelegate); { [mStolenContentView release]; [mFontPanel setDelegate:nil]; - [NSFontManager sharedFontManager].target = nil; [[NSNotificationCenter defaultCenter] removeObserver:self]; [super dealloc]; @@ -224,6 +221,13 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSFontPanelDelegate); return (mResultCode == NSModalResponseOK); } +// Future proofing in case _NSTargetForSendAction checks this +// property before sending us the changeFont: message. +- (BOOL)worksWhenModal +{ + return YES; +} + - (QPlatformDialogHelper::DialogCode)dialogResultCode { return (mResultCode == NSModalResponseOK) ? QPlatformDialogHelper::Accepted : QPlatformDialogHelper::Rejected; -- cgit v1.2.3 From 55e63ddbd2b72a5e145d15a2092b7714d50c23c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 20 Sep 2018 16:17:36 +0200 Subject: macOS: Bump the SDK version we've tested with to 10.14 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ibfdb8be91be46b22e0f0b97105121176a02a8576 Reviewed-by: Morten Johan Sørvig --- mkspecs/common/macx.conf | 2 +- mkspecs/features/mac/default_post.prf | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/mkspecs/common/macx.conf b/mkspecs/common/macx.conf index 6e95112f9b..d61ad33351 100644 --- a/mkspecs/common/macx.conf +++ b/mkspecs/common/macx.conf @@ -7,7 +7,7 @@ QMAKE_MAC_SDK = macosx QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.12 QMAKE_APPLE_DEVICE_ARCHS = x86_64 -QT_MAC_SDK_VERSION_TESTED_WITH = 10.13 +QT_MAC_SDK_VERSION_TESTED_WITH = 10.14 device.sdk = macosx device.target = device diff --git a/mkspecs/features/mac/default_post.prf b/mkspecs/features/mac/default_post.prf index 353fda41e6..3e84051057 100644 --- a/mkspecs/features/mac/default_post.prf +++ b/mkspecs/features/mac/default_post.prf @@ -26,10 +26,6 @@ contains(TEMPLATE, .*app) { warning("the $$QMAKE_MAC_SDK_VERSION SDK you are opting in to new features" \ "that Qt has not been prepared for.") - isEqual(QMAKE_MAC_SDK_VERSION, 10.14): \ - warning("E.g., 10.14 enables dark mode and layer-backed views," \ - "which Qt $${QT_MAJOR_VERSION}.$${QT_MINOR_VERSION} does not support.") - warning("Please downgrade the SDK you use to build your app to version" \ "$$QT_MAC_SDK_VERSION_TESTED_WITH, or configure") warning("with CONFIG+=sdk_no_version_check when running qmake" \ -- cgit v1.2.3 From a77e2f4cd4a195d7756ed2d47e9bde2e1d56d95f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 20 Sep 2018 16:15:58 +0200 Subject: macOS: Only verify the major and minor version of the platform SDK MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I8de6c06e8be09483591efdf37c1631134d4ef826 Reviewed-by: Morten Johan Sørvig Reviewed-by: Andy Shaw --- mkspecs/features/mac/default_post.prf | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mkspecs/features/mac/default_post.prf b/mkspecs/features/mac/default_post.prf index 3e84051057..ae17f076a3 100644 --- a/mkspecs/features/mac/default_post.prf +++ b/mkspecs/features/mac/default_post.prf @@ -18,9 +18,11 @@ contains(TEMPLATE, .*app) { !isEmpty($$list($$(QT_MAC_SDK_NO_VERSION_CHECK))): \ CONFIG += sdk_no_version_check - !sdk_no_version_check:!versionAtMost(QMAKE_MAC_SDK_VERSION, $$QT_MAC_SDK_VERSION_TESTED_WITH) { + QMAKE_MAC_SDK_MAJOR_MINOR_VERSION = $$replace(QMAKE_MAC_SDK_VERSION, "(\d+)(\.\d+)(\.\d+)?", \1\2) + + !sdk_no_version_check:!versionAtMost(QMAKE_MAC_SDK_MAJOR_MINOR_VERSION, $$QT_MAC_SDK_VERSION_TESTED_WITH) { warning("Qt has only been tested with version $$QT_MAC_SDK_VERSION_TESTED_WITH"\ - "of the platform SDK, you're using $${QMAKE_MAC_SDK_VERSION}.") + "of the platform SDK, you're using $${QMAKE_MAC_SDK_MAJOR_MINOR_VERSION}.") warning("This is an unsupported configuration. You may experience build issues," \ "and by using") warning("the $$QMAKE_MAC_SDK_VERSION SDK you are opting in to new features" \ -- cgit v1.2.3 From a154ea89e8ae4113f2dd63eb96864c9182f2c459 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Fri, 14 Sep 2018 15:52:48 +0200 Subject: Extend tst_QGL::graphicsViewClipping blacklisting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ife72db5a0d7cb8abe55c60c519087e2b60f26990 Reviewed-by: Andy Shaw Reviewed-by: Tor Arne Vestbø Reviewed-by: Timur Pocheptsov --- tests/auto/opengl/qgl/BLACKLIST | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/opengl/qgl/BLACKLIST b/tests/auto/opengl/qgl/BLACKLIST index 1eb0197484..d3165a51e5 100644 --- a/tests/auto/opengl/qgl/BLACKLIST +++ b/tests/auto/opengl/qgl/BLACKLIST @@ -19,7 +19,7 @@ winrt [graphicsViewClipping] windows winrt -rhel-7.4 ci +linux ci [glFBOUseInGLWidget] windows winrt -- cgit v1.2.3 From 01ade488ddf6dc667f38173ba3b2330224761f45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 31 Jul 2018 14:59:37 +0200 Subject: macOS: Don't call [NSOpenGLContext update] for every frame MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Calling update has a cost, and should only be done when the drawable object changes size or location. Instead of calling update each time makeCurrent is called, we listen for the appropriate notifications, limiting the number of update calls significantly. We still call update on the thread owning the QOpenGLContext, which is not ideal, as [NSOpenGLContext update] should only be called on the main thread, but in practice this works. Getting out of this situation is tricky, and setView has in theory the same problems. Until those problems have been solved we keep the behavior as is. Task-number: QTBUG-63572 Change-Id: Ibac9f8be7843f2aa006af6f7ee670bf027122440 Reviewed-by: Morten Johan Sørvig Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/cocoa/qcocoaglcontext.h | 3 +++ src/plugins/platforms/cocoa/qcocoaglcontext.mm | 37 +++++++++++++++++++++++--- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.h b/src/plugins/platforms/cocoa/qcocoaglcontext.h index cef5892989..eefb1cd0fb 100644 --- a/src/plugins/platforms/cocoa/qcocoaglcontext.h +++ b/src/plugins/platforms/cocoa/qcocoaglcontext.h @@ -41,6 +41,7 @@ #define QCOCOAGLCONTEXT_H #include +#include #include #include #include @@ -79,6 +80,8 @@ private: NSOpenGLContext *m_shareContext = nil; QSurfaceFormat m_format; bool m_didCheckForSoftwareContext = false; + QVarLengthArray m_updateObservers; + QAtomicInt m_needsUpdate = false; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.mm b/src/plugins/platforms/cocoa/qcocoaglcontext.mm index 069429796e..1e1b3907ed 100644 --- a/src/plugins/platforms/cocoa/qcocoaglcontext.mm +++ b/src/plugins/platforms/cocoa/qcocoaglcontext.mm @@ -41,7 +41,6 @@ #include "qcocoawindow.h" #include "qcocoahelpers.h" #include -#include #include #include @@ -351,7 +350,8 @@ bool QCocoaGLContext::makeCurrent(QPlatformSurface *surface) } } - update(); + if (m_needsUpdate.fetchAndStoreRelaxed(false)) + update(); } return true; @@ -383,13 +383,44 @@ bool QCocoaGLContext::setDrawable(QPlatformSurface *surface) if (view == m_context.view) return true; + // Setting the drawable may happen on a separate thread as a result of + // a call to makeCurrent, so we need to set up the observers before we + // associate the view with the context. That way we will guarantee that + // as long as the view is the drawable of the context we will know about + // any updates to the view that require surface invalidation. + + auto updateCallback = [this, view]() { + Q_ASSERT(QThread::currentThread() == qApp->thread()); + if (m_context.view != view) + return; + m_needsUpdate = true; + }; + + m_updateObservers.clear(); + + if (view.layer) { + m_updateObservers.append(QMacScopedObserver(view, NSViewFrameDidChangeNotification, updateCallback)); + m_updateObservers.append(QMacScopedObserver(view.window, NSWindowDidChangeScreenNotification, updateCallback)); + } else { + m_updateObservers.append(QMacScopedObserver(view, NSViewGlobalFrameDidChangeNotification, updateCallback)); + } + + m_updateObservers.append(QMacScopedObserver([NSApplication sharedApplication], + NSApplicationDidChangeScreenParametersNotification, updateCallback)); + + // If any of the observers fire at this point it's fine. We check the + // view association (atomically) in the update callback, and skip the + // update if we haven't associated yet. Setting the drawable below will + // have the same effect as an update. + + // Now we are ready to associate the view with the context if ((m_context.view = view) != view) { qCInfo(lcQpaOpenGLContext) << "Failed to set" << view << "as drawable for" << m_context; + m_updateObservers.clear(); return false; } qCInfo(lcQpaOpenGLContext) << "Set drawable for" << m_context << "to" << m_context.view; - return true; } -- cgit v1.2.3 From d37d8e962a1b9e83800d17207c78bc87f7d64c31 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Fri, 14 Sep 2018 22:58:58 +0200 Subject: QAccessibleTable(Header)Cell: fix isValid() QAccessibleTable(Header)Cell::isValid() did not check if the view is still valid as it is done in QAccessibleTable::isValid() which can lead to a crash during destruction when e.g. operator<<(QAccessibleInterface) is called. Change-Id: I930bf4c22aa0aa6868f58a8e5d0dd1557f6b17af Reviewed-by: Friedemann Kleint Reviewed-by: Richard Moe Gustavsen Reviewed-by: Frederik Gladhorn --- src/widgets/accessible/itemviews.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/widgets/accessible/itemviews.cpp b/src/widgets/accessible/itemviews.cpp index 04a5dcc878..159d61d683 100644 --- a/src/widgets/accessible/itemviews.cpp +++ b/src/widgets/accessible/itemviews.cpp @@ -110,7 +110,7 @@ QAccessibleTable::QAccessibleTable(QWidget *w) bool QAccessibleTable::isValid() const { - return (view() && !qobject_cast(view())->d_func()->data.in_destructor); + return view() && !qt_widget_private(view())->data.in_destructor; } QAccessibleTable::~QAccessibleTable() @@ -1091,7 +1091,8 @@ void QAccessibleTableCell::setText(QAccessible::Text /*t*/, const QString &text) bool QAccessibleTableCell::isValid() const { - return view && view->model() && m_index.isValid(); + return view && !qt_widget_private(view)->data.in_destructor + && view->model() && m_index.isValid(); } QAccessibleInterface *QAccessibleTableCell::parent() const @@ -1180,7 +1181,8 @@ void QAccessibleTableHeaderCell::setText(QAccessible::Text, const QString &) bool QAccessibleTableHeaderCell::isValid() const { - return view && view->model() && (index >= 0) + return view && !qt_widget_private(view)->data.in_destructor + && view->model() && (index >= 0) && ((orientation == Qt::Horizontal) ? (index < view->model()->columnCount()) : (index < view->model()->rowCount())); } -- cgit v1.2.3 From 21355b3630882932be940a48a88d8c40cf7ebf63 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 26 Sep 2018 17:36:04 +0200 Subject: QGraphicsScene: Make focusing on touchBegin optional Usually we focus in when we receive a click or equivalent. QGraphicsScene by default also transfers the focus when you start a touch on a trackpad or similar. Most of the time this also generates a synthetic mouse click, so people don't necessary notice. However, at least on macOS you can configure this behavior. With focusOnTouch switched off, QGraphicsScene behaves as one would expect on macOS. Fixes: QTBUG-59442 Change-Id: Ib87112640eef6b77892ad2490d80eedd055e6dce Reviewed-by: Paul Wicking Reviewed-by: Venugopal Shivashankar Reviewed-by: Shawn Rutledge --- src/widgets/graphicsview/qgraphicsscene.cpp | 91 +++++++++++++++------- src/widgets/graphicsview/qgraphicsscene.h | 4 + src/widgets/graphicsview/qgraphicsscene_p.h | 3 +- .../qgraphicsscene/tst_qgraphicsscene.cpp | 36 +++++++++ 4 files changed, 107 insertions(+), 27 deletions(-) diff --git a/src/widgets/graphicsview/qgraphicsscene.cpp b/src/widgets/graphicsview/qgraphicsscene.cpp index 37af4ecda0..bba992144d 100644 --- a/src/widgets/graphicsview/qgraphicsscene.cpp +++ b/src/widgets/graphicsview/qgraphicsscene.cpp @@ -297,6 +297,7 @@ QGraphicsScenePrivate::QGraphicsScenePrivate() painterStateProtection(true), sortCacheEnabled(false), allItemsIgnoreTouchEvents(true), + focusOnTouch(true), minimumRenderSize(0.0), selectionChanging(0), rectAdjust(2), @@ -2393,6 +2394,7 @@ void QGraphicsScene::clear() d->allItemsIgnoreHoverEvents = true; d->allItemsUseDefaultCursor = true; d->allItemsIgnoreTouchEvents = true; + d->focusOnTouch = true; } /*! @@ -5854,6 +5856,41 @@ void QGraphicsScene::setMinimumRenderSize(qreal minSize) update(); } +/*! + \property QGraphicsScene::focusOnTouch + \since 5.12 + \brief whether items gain focus when receiving a \e {touch begin} event. + + The usual behavior is to transfer focus only when an item is clicked. Often + a tap on a touchpad is interpreted as equivalent to a mouse click by the + operating system, generating a synthesized click event in response. However, + at least on macOS you can configure this behavior. + + By default, QGraphicsScene also transfers focus when you touch on a trackpad + or similar. If the operating system is configured to not generate a + synthetic mouse click on tapping the trackpad, this is surprising. If the + operating system does generate synthetic mouse clicks on tapping the + trackpad, the focus transfer on starting a touch gesture is unnecessary. + + With focusOnTouch switched off, QGraphicsScene behaves as one would expect + on macOS. + + The default value is \c true, ensuring that the default behavior is just as + in Qt versions prior to 5.12. Set to \c false to prevent touch events from + triggering focus changes. +*/ +bool QGraphicsScene::focusOnTouch() const +{ + Q_D(const QGraphicsScene); + return d->focusOnTouch; +} + +void QGraphicsScene::setFocusOnTouch(bool enabled) +{ + Q_D(QGraphicsScene); + d->focusOnTouch = enabled; +} + void QGraphicsScenePrivate::addView(QGraphicsView *view) { views << view; @@ -6033,39 +6070,41 @@ bool QGraphicsScenePrivate::sendTouchBeginEvent(QGraphicsItem *origin, QTouchEve { Q_Q(QGraphicsScene); - if (cachedItemsUnderMouse.isEmpty() || cachedItemsUnderMouse.constFirst() != origin) { - const QTouchEvent::TouchPoint &firstTouchPoint = touchEvent->touchPoints().first(); - cachedItemsUnderMouse = itemsAtPosition(firstTouchPoint.screenPos().toPoint(), - firstTouchPoint.scenePos(), - static_cast(touchEvent->target())); - } + if (focusOnTouch) { + if (cachedItemsUnderMouse.isEmpty() || cachedItemsUnderMouse.constFirst() != origin) { + const QTouchEvent::TouchPoint &firstTouchPoint = touchEvent->touchPoints().first(); + cachedItemsUnderMouse = itemsAtPosition(firstTouchPoint.screenPos().toPoint(), + firstTouchPoint.scenePos(), + static_cast(touchEvent->target())); + } - // Set focus on the topmost enabled item that can take focus. - bool setFocus = false; + // Set focus on the topmost enabled item that can take focus. + bool setFocus = false; - foreach (QGraphicsItem *item, cachedItemsUnderMouse) { - if (item->isEnabled() && ((item->flags() & QGraphicsItem::ItemIsFocusable) && item->d_ptr->mouseSetsFocus)) { - if (!item->isWidget() || ((QGraphicsWidget *)item)->focusPolicy() & Qt::ClickFocus) { + foreach (QGraphicsItem *item, cachedItemsUnderMouse) { + if (item->isEnabled() && ((item->flags() & QGraphicsItem::ItemIsFocusable) && item->d_ptr->mouseSetsFocus)) { + if (!item->isWidget() || ((QGraphicsWidget *)item)->focusPolicy() & Qt::ClickFocus) { + setFocus = true; + if (item != q->focusItem()) + q->setFocusItem(item, Qt::MouseFocusReason); + break; + } + } + if (item->isPanel()) + break; + if (item->d_ptr->flags & QGraphicsItem::ItemStopsClickFocusPropagation) + break; + if (item->d_ptr->flags & QGraphicsItem::ItemStopsFocusHandling) { + // Make sure we don't clear focus. setFocus = true; - if (item != q->focusItem()) - q->setFocusItem(item, Qt::MouseFocusReason); break; } } - if (item->isPanel()) - break; - if (item->d_ptr->flags & QGraphicsItem::ItemStopsClickFocusPropagation) - break; - if (item->d_ptr->flags & QGraphicsItem::ItemStopsFocusHandling) { - // Make sure we don't clear focus. - setFocus = true; - break; - } - } - // If nobody could take focus, clear it. - if (!stickyFocus && !setFocus) - q->setFocusItem(0, Qt::MouseFocusReason); + // If nobody could take focus, clear it. + if (!stickyFocus && !setFocus) + q->setFocusItem(0, Qt::MouseFocusReason); + } bool res = false; bool eventAccepted = touchEvent->isAccepted(); diff --git a/src/widgets/graphicsview/qgraphicsscene.h b/src/widgets/graphicsview/qgraphicsscene.h index 8efbcd273e..287e551db7 100644 --- a/src/widgets/graphicsview/qgraphicsscene.h +++ b/src/widgets/graphicsview/qgraphicsscene.h @@ -106,6 +106,7 @@ class Q_WIDGETS_EXPORT QGraphicsScene : public QObject Q_PROPERTY(bool sortCacheEnabled READ isSortCacheEnabled WRITE setSortCacheEnabled) Q_PROPERTY(bool stickyFocus READ stickyFocus WRITE setStickyFocus) Q_PROPERTY(qreal minimumRenderSize READ minimumRenderSize WRITE setMinimumRenderSize) + Q_PROPERTY(bool focusOnTouch READ focusOnTouch WRITE setFocusOnTouch) public: enum ItemIndexMethod { @@ -253,6 +254,9 @@ public: qreal minimumRenderSize() const; void setMinimumRenderSize(qreal minSize); + bool focusOnTouch() const; + void setFocusOnTouch(bool enabled); + public Q_SLOTS: void update(const QRectF &rect = QRectF()); void invalidate(const QRectF &rect = QRectF(), SceneLayers layers = AllLayers); diff --git a/src/widgets/graphicsview/qgraphicsscene_p.h b/src/widgets/graphicsview/qgraphicsscene_p.h index 2f5d7c54bb..a2d13436fc 100644 --- a/src/widgets/graphicsview/qgraphicsscene_p.h +++ b/src/widgets/graphicsview/qgraphicsscene_p.h @@ -114,7 +114,8 @@ public: quint32 painterStateProtection : 1; quint32 sortCacheEnabled : 1; // for compatibility quint32 allItemsIgnoreTouchEvents : 1; - quint32 padding : 15; + quint32 focusOnTouch : 1; + quint32 padding : 14; qreal minimumRenderSize; diff --git a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp index c8ee2d65a3..838b1f4be6 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp @@ -254,6 +254,7 @@ private slots: void zeroScale(); void focusItemChangedSignal(); void minimumRenderSize(); + void focusOnTouch(); // task specific tests below me void task139710_bspTreeCrash(); @@ -4758,6 +4759,41 @@ void tst_QGraphicsScene::minimumRenderSize() QVERIFY(smallChild->repaints > smallerGrandChild->repaints); } +void tst_QGraphicsScene::focusOnTouch() +{ + QGraphicsScene scene; + QGraphicsView view(&scene); + scene.setSceneRect(0, 0, 100, 100); + QGraphicsRectItem *rect = scene.addRect(0, 0, 100, 100); + rect->setFlag(QGraphicsItem::ItemIsFocusable, true); + + view.show(); + QApplication::setActiveWindow(&view); + QVERIFY(QTest::qWaitForWindowActive(&view)); + + QVERIFY(!rect->hasFocus()); + + scene.setFocusOnTouch(false); + + QTouchDevice device; + device.setType(QTouchDevice::TouchPad); + QList touchPoints; + QTouchEvent::TouchPoint point; + point.setScenePos(QPointF(10, 10)); + point.setState(Qt::TouchPointPressed); + touchPoints.append(point); + QTouchEvent event(QEvent::TouchBegin, &device, Qt::NoModifier, Qt::TouchPointStates(), + touchPoints); + + QApplication::sendEvent(&scene, &event); + + QVERIFY(!rect->hasFocus()); + scene.setFocusOnTouch(true); + + QApplication::sendEvent(&scene, &event); + QVERIFY(rect->hasFocus()); +} + void tst_QGraphicsScene::taskQTBUG_15977_renderWithDeviceCoordinateCache() { QGraphicsScene scene; -- cgit v1.2.3 From 28c831fa13db29bd06666abefcb76f5bdf886320 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 27 Sep 2018 16:00:55 +0200 Subject: QCocoaKeyMapper: Properly initialize all members and reset on update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously some of the members would have random initial values. Also, on updateKeyboard() if we don't find usable uchrData, we should just reset keyboard_layout_format and keyboard_mode, rather than keep the previous values. Task-number: QTBUG-50865 Change-Id: I1297fa55bb1593dd549d0bc122713d5d98f7b1fc Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoakeymapper.h | 13 +++++-------- src/plugins/platforms/cocoa/qcocoakeymapper.mm | 9 +++++---- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoakeymapper.h b/src/plugins/platforms/cocoa/qcocoakeymapper.h index a75e275077..2624f19978 100644 --- a/src/plugins/platforms/cocoa/qcocoakeymapper.h +++ b/src/plugins/platforms/cocoa/qcocoakeymapper.h @@ -89,15 +89,12 @@ public: void clearMappings(); private: - QCFType currentInputSource; + QCFType currentInputSource = nullptr; - enum { NullMode, UnicodeMode, OtherMode } keyboard_mode; - union { - const UCKeyboardLayout *unicode; - void *other; - } keyboard_layout_format; - KeyboardLayoutKind keyboard_kind; - UInt32 keyboard_dead; + enum { NullMode, UnicodeMode, OtherMode } keyboard_mode = NullMode; + const UCKeyboardLayout *keyboard_layout_format = nullptr; + KeyboardLayoutKind keyboard_kind = kKLKCHRuchrKind; + UInt32 keyboard_dead = 0; KeyboardLayoutItem *keyLayout[256]; }; diff --git a/src/plugins/platforms/cocoa/qcocoakeymapper.mm b/src/plugins/platforms/cocoa/qcocoakeymapper.mm index 5e279a400b..c18b7d6bc0 100644 --- a/src/plugins/platforms/cocoa/qcocoakeymapper.mm +++ b/src/plugins/platforms/cocoa/qcocoakeymapper.mm @@ -341,8 +341,6 @@ static int qt_mac_get_key(int modif, const QChar &key, int virtualKey) QCocoaKeyMapper::QCocoaKeyMapper() { memset(keyLayout, 0, sizeof(keyLayout)); - keyboard_layout_format.unicode = 0; - currentInputSource = 0; } QCocoaKeyMapper::~QCocoaKeyMapper() @@ -371,8 +369,11 @@ bool QCocoaKeyMapper::updateKeyboard() keyboard_kind = LMGetKbdType(); if (uchrData) { - keyboard_layout_format.unicode = uchrData; + keyboard_layout_format = uchrData; keyboard_mode = UnicodeMode; + } else { + keyboard_layout_format = nullptr; + keyboard_mode = NullMode; } currentInputSource = source; keyboard_dead = 0; @@ -414,7 +415,7 @@ void QCocoaKeyMapper::updateKeyMap(unsigned short macVirtualKey, QChar unicodeKe keyLayout[macVirtualKey]->qtKey[i] = 0; const UInt32 keyModifier = ((qt_mac_get_mac_modifiers(ModsTbl[i]) >> 8) & 0xFF); - OSStatus err = UCKeyTranslate(keyboard_layout_format.unicode, macVirtualKey, kUCKeyActionDown, keyModifier, + OSStatus err = UCKeyTranslate(keyboard_layout_format, macVirtualKey, kUCKeyActionDown, keyModifier, keyboard_kind, 0, &keyboard_dead, buffer_size, &out_buffer_size, buffer); if (err == noErr && out_buffer_size) { const QChar unicode(buffer[0]); -- cgit v1.2.3 From 0cae5a4c4b3c508463580ba740df95e92d2fc9c0 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Wed, 2 Nov 2016 14:19:26 +0100 Subject: Cocoa integration: fix incorrect keyboard mapping MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When switching between different input sources, we have to update layouts. Task-number: QTBUG-50865 Change-Id: I0c23c19b79a2102dcc533822b0f861c387582c6c Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoakeymapper.mm | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoakeymapper.mm b/src/plugins/platforms/cocoa/qcocoakeymapper.mm index c18b7d6bc0..350ae4b9be 100644 --- a/src/plugins/platforms/cocoa/qcocoakeymapper.mm +++ b/src/plugins/platforms/cocoa/qcocoakeymapper.mm @@ -378,6 +378,10 @@ bool QCocoaKeyMapper::updateKeyboard() currentInputSource = source; keyboard_dead = 0; + const auto newMode = keyboard_mode; + deleteLayouts(); + keyboard_mode = newMode; + return true; } @@ -400,10 +404,8 @@ void QCocoaKeyMapper::clearMappings() void QCocoaKeyMapper::updateKeyMap(unsigned short macVirtualKey, QChar unicodeKey) { - if (updateKeyboard()) { - // ### Qt 4 did this: - // QKeyMapper::changeKeyboard(); - } + updateKeyboard(); + if (keyLayout[macVirtualKey]) return; -- cgit v1.2.3 From d7e274a44621a4c1bb1ede66c00ee1d1e3f7bd13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Thu, 13 Mar 2014 09:10:47 +0100 Subject: StyleSheetStyle: Load @Nx images Perform a @Nx image file lookup when loading pixmaps. Make drawBackgroundImage() handle high-dpi pixmaps, here the layout calculations needs to be in device- independent pixels Fixes: QTBUG-36825 Change-Id: I61e6f53c59f61f3bd88c34a036349e51e8c8ad92 Reviewed-by: Ulf Hermann Reviewed-by: Alex Blasche --- src/widgets/styles/qstylesheetstyle.cpp | 47 +++++++++++++++++---- src/widgets/styles/qstylesheetstyle_p.h | 1 + .../styles/qstylesheetstyle/images/testimage.png | Bin 299 -> 300 bytes .../qstylesheetstyle/images/testimage@2x.png | Bin 0 -> 318 bytes .../widgets/styles/qstylesheetstyle/resources.qrc | 1 + .../qstylesheetstyle/tst_qstylesheetstyle.cpp | 33 +++++++++++++++ 6 files changed, 73 insertions(+), 9 deletions(-) create mode 100644 tests/auto/widgets/styles/qstylesheetstyle/images/testimage@2x.png diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index c2ffcc82b1..58478c7595 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -115,6 +115,8 @@ #include #endif +#include + QT_BEGIN_NAMESPACE using namespace QCss; @@ -952,8 +954,10 @@ QRenderRule::QRenderRule(const QVector &declarations, const QObject Attachment attachment = Attachment_Scroll; origin = Origin_Padding; Origin clip = Origin_Border; - if (v.extractBackground(&brush, &uri, &repeat, &alignment, &origin, &attachment, &clip)) - bg = new QStyleSheetBackgroundData(brush, QPixmap(uri), repeat, alignment, origin, attachment, clip); + if (v.extractBackground(&brush, &uri, &repeat, &alignment, &origin, &attachment, &clip)) { + bg = new QStyleSheetBackgroundData(brush, QStyleSheetStyle::loadPixmap(uri, object), + repeat, alignment, origin, attachment, clip); + } QBrush sfg, fg; QBrush sbg, abg; @@ -992,7 +996,7 @@ QRenderRule::QRenderRule(const QVector &declarations, const QObject bd->bi = new QStyleSheetBorderImageData; QStyleSheetBorderImageData *bi = bd->bi; - bi->pixmap = QPixmap(uri); + bi->pixmap = QStyleSheetStyle::loadPixmap(uri, object); for (int i = 0; i < 4; i++) bi->cuts[i] = cuts[i]; bi->horizStretch = horizStretch; @@ -1215,30 +1219,33 @@ void QRenderRule::drawBackgroundImage(QPainter *p, const QRect &rect, QPoint off if (background()->attachment == Attachment_Fixed) off = QPoint(0, 0); + QSize bgpSize = bgp.size() / bgp.devicePixelRatio(); + int bgpHeight = bgpSize.height(); + int bgpWidth = bgpSize.width(); QRect r = originRect(rect, background()->origin); - QRect aligned = QStyle::alignedRect(Qt::LeftToRight, background()->position, bgp.size(), r); + QRect aligned = QStyle::alignedRect(Qt::LeftToRight, background()->position, bgpSize, r); QRect inter = aligned.translated(-off).intersected(r); switch (background()->repeat) { case Repeat_Y: p->drawTiledPixmap(inter.x(), r.y(), inter.width(), r.height(), bgp, inter.x() - aligned.x() + off.x(), - bgp.height() - int(aligned.y() - r.y()) % bgp.height() + off.y()); + bgpHeight - int(aligned.y() - r.y()) % bgpHeight + off.y()); break; case Repeat_X: p->drawTiledPixmap(r.x(), inter.y(), r.width(), inter.height(), bgp, - bgp.width() - int(aligned.x() - r.x())%bgp.width() + off.x(), + bgpWidth - int(aligned.x() - r.x())%bgpWidth + off.x(), inter.y() - aligned.y() + off.y()); break; case Repeat_XY: p->drawTiledPixmap(r, bgp, - QPoint(bgp.width() - int(aligned.x() - r.x())% bgp.width() + off.x(), - bgp.height() - int(aligned.y() - r.y())%bgp.height() + off.y())); + QPoint(bgpWidth - int(aligned.x() - r.x())% bgpWidth + off.x(), + bgpHeight - int(aligned.y() - r.y())%bgpHeight + off.y())); break; case Repeat_None: default: p->drawPixmap(inter.x(), inter.y(), bgp, inter.x() - aligned.x() + off.x(), - inter.y() - aligned.y() + off.y(), inter.width(), inter.height()); + inter.y() - aligned.y() + off.y(), bgp.width() , bgp.height()); break; } @@ -6107,6 +6114,28 @@ bool QStyleSheetStyle::isNaturalChild(const QObject *obj) return false; } +QPixmap QStyleSheetStyle::loadPixmap(const QString &fileName, const QObject *context) +{ + qreal ratio = -1.0; + if (const QWidget *widget = qobject_cast(context)) { + if (QScreen *screen = QApplication::screenAt(widget->mapToGlobal(QPoint(0, 0)))) + ratio = screen->devicePixelRatio(); + } + + if (ratio < 0) { + if (const QApplication *app = qApp) + ratio = app->devicePixelRatio(); + else + ratio = 1.0; + } + + qreal sourceDevicePixelRatio = 1.0; + QString resolvedFileName = qt_findAtNxFile(fileName, ratio, &sourceDevicePixelRatio); + QPixmap pixmap(resolvedFileName); + pixmap.setDevicePixelRatio(sourceDevicePixelRatio); + return pixmap; +} + QT_END_NAMESPACE #include "moc_qstylesheetstyle_p.cpp" diff --git a/src/widgets/styles/qstylesheetstyle_p.h b/src/widgets/styles/qstylesheetstyle_p.h index d1647fb107..d4edb83525 100644 --- a/src/widgets/styles/qstylesheetstyle_p.h +++ b/src/widgets/styles/qstylesheetstyle_p.h @@ -167,6 +167,7 @@ private: static Qt::Alignment resolveAlignment(Qt::LayoutDirection, Qt::Alignment); static bool isNaturalChild(const QObject *obj); + static QPixmap loadPixmap(const QString &fileName, const QObject *context); bool initObject(const QObject *obj) const; public: static int numinstances; diff --git a/tests/auto/widgets/styles/qstylesheetstyle/images/testimage.png b/tests/auto/widgets/styles/qstylesheetstyle/images/testimage.png index 06fb34f0d6..a4adc7a47f 100644 Binary files a/tests/auto/widgets/styles/qstylesheetstyle/images/testimage.png and b/tests/auto/widgets/styles/qstylesheetstyle/images/testimage.png differ diff --git a/tests/auto/widgets/styles/qstylesheetstyle/images/testimage@2x.png b/tests/auto/widgets/styles/qstylesheetstyle/images/testimage@2x.png new file mode 100644 index 0000000000..d55f0c507b Binary files /dev/null and b/tests/auto/widgets/styles/qstylesheetstyle/images/testimage@2x.png differ diff --git a/tests/auto/widgets/styles/qstylesheetstyle/resources.qrc b/tests/auto/widgets/styles/qstylesheetstyle/resources.qrc index 248bf80f50..f523070073 100644 --- a/tests/auto/widgets/styles/qstylesheetstyle/resources.qrc +++ b/tests/auto/widgets/styles/qstylesheetstyle/resources.qrc @@ -2,5 +2,6 @@ images/testimage.png + images/testimage@2x.png \ No newline at end of file diff --git a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp index 43aec651fe..f5d9433f70 100644 --- a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp +++ b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp @@ -33,6 +33,7 @@ #include #include +#include #include using namespace QTestPrivate; @@ -101,6 +102,9 @@ private slots: void styleSheetTargetAttribute(); void unpolish(); + void highdpiImages_data(); + void highdpiImages(); + private: QColor COLOR(const QWidget& w) { w.ensurePolished(); @@ -2066,6 +2070,35 @@ void tst_QStyleSheetStyle::unpolish() QCOMPARE(w.minimumWidth(), 0); } +void tst_QStyleSheetStyle::highdpiImages_data() +{ + QTest::addColumn("screenFactor"); + QTest::addColumn("color"); + + QTest::newRow("highdpi") << 2.0 << QColor(0x00, 0xFF, 0x00); + QTest::newRow("lowdpi") << 1.0 << QColor(0xFF, 0x00, 0x00); +} + +void tst_QStyleSheetStyle::highdpiImages() +{ + QFETCH(qreal, screenFactor); + QFETCH(QColor, color); + + QWidget w; + QScreen *screen = QGuiApplication::screenAt(w.pos()); + QHighDpiScaling::setScreenFactor(screen, screenFactor); + w.setStyleSheet("QWidget { background-image: url(\":/images/testimage.png\"); }"); + w.show(); + + QVERIFY(QTest::qWaitForWindowExposed(&w)); + QImage image(w.size(), QImage::Format_ARGB32); + w.render(&image); + QVERIFY(testForColors(image, color)); + + QHighDpiScaling::setScreenFactor(screen, 1.0); + QHighDpiScaling::updateHighDpiScaling(); // reset to normal +} + QTEST_MAIN(tst_QStyleSheetStyle) #include "tst_qstylesheetstyle.moc" -- cgit v1.2.3 From 2bd6f5e8d13e60f0d1102c8e4e53ee341146308c Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Wed, 3 Oct 2018 14:36:23 +0200 Subject: QTreeView: adjust documentation of key bindings The documentation for key bindings was a little bit unclear for key asterisk. Also sync the names of the left and right key was not consistent (Left/RightArrow - Left/Right) Change-Id: Icee0821880fcc3ebc2ade939cf80127ebf0976ad Reviewed-by: Paul Wicking Reviewed-by: Luca Beldi Reviewed-by: Leena Miettinen --- src/widgets/itemviews/qtreeview.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/widgets/itemviews/qtreeview.cpp b/src/widgets/itemviews/qtreeview.cpp index b534de5c6a..779bdf36cf 100644 --- a/src/widgets/itemviews/qtreeview.cpp +++ b/src/widgets/itemviews/qtreeview.cpp @@ -131,11 +131,12 @@ QT_BEGIN_NAMESPACE of the sibling that follows the parent. \row \li Left \li Hides the children of the current item (if present) by collapsing a branch. - \row \li Minus \li Same as LeftArrow. + \row \li Minus \li Same as Left. \row \li Right \li Reveals the children of the current item (if present) by expanding a branch. - \row \li Plus \li Same as RightArrow. - \row \li Asterisk \li Expands all children of the current item (if present). + \row \li Plus \li Same as Right. + \row \li Asterisk \li Expands the current item and all its children + (if present). \row \li PageUp \li Moves the cursor up one page. \row \li PageDown \li Moves the cursor down one page. \row \li Home \li Moves the cursor to an item in the same column of the first -- cgit v1.2.3 From bde6a049494f40cd71004d6926899f115af0c3e6 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 4 Oct 2018 10:34:21 +0200 Subject: QtWidgets: Fix Qt application coming to the foreground when launching app by popup menu Check on the application state before requesting activation. Fixes: QTBUG-70810 Change-Id: I550137dc00209b17f4b3c033287ceef1b871ff50 Reviewed-by: Shawn Rutledge --- src/widgets/kernel/qwidget.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 09a08fac14..6753c35cfc 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -6600,9 +6600,12 @@ QWidget *QWidgetPrivate::deepestFocusProxy() const void QWidgetPrivate::setFocus_sys() { Q_Q(QWidget); - // Embedded native widget may have taken the focus; get it back to toplevel if that is the case + // Embedded native widget may have taken the focus; get it back to toplevel + // if that is the case (QTBUG-25852) const QWidget *topLevel = q->window(); - if (topLevel->windowType() != Qt::Popup) { + // Do not activate in case the popup menu opens another application (QTBUG-70810). + if (QGuiApplication::applicationState() == Qt::ApplicationActive + && topLevel->windowType() != Qt::Popup) { if (QWindow *nativeWindow = q->window()->windowHandle()) { if (nativeWindow != QGuiApplication::focusWindow() && q->testAttribute(Qt::WA_WState_Created)) { -- cgit v1.2.3 From 9d27aec869502c7e1689b44a528d9cbd8b1f0545 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Fri, 14 Sep 2018 15:29:59 +0200 Subject: Optimize gamma-table lookup on SSE2 and NEON Speeds up gamma-corrected text rendering. Change-Id: I38c12ff52f4601853c3f3524de2761a932111160 Reviewed-by: Erik Verbruggen --- src/gui/painting/qcolorprofile_p.h | 156 +++++++++++++++++++++++++++++-------- 1 file changed, 122 insertions(+), 34 deletions(-) diff --git a/src/gui/painting/qcolorprofile_p.h b/src/gui/painting/qcolorprofile_p.h index ca1786ee6d..425e9abace 100644 --- a/src/gui/painting/qcolorprofile_p.h +++ b/src/gui/painting/qcolorprofile_p.h @@ -55,6 +55,11 @@ #include #include +#if defined(__SSE2__) +#include +#elif defined(__ARM_NEON__) || defined(__ARM_NEON) +#include +#endif QT_BEGIN_NAMESPACE class Q_GUI_EXPORT QColorProfile @@ -67,82 +72,165 @@ public: QRgba64 toLinear64(QRgb rgb32) const { - ushort r = m_toLinear[qRed(rgb32) << 4]; - ushort g = m_toLinear[qGreen(rgb32) << 4]; - ushort b = m_toLinear[qBlue(rgb32) << 4]; +#if defined(__SSE2__) + __m128i v = _mm_cvtsi32_si128(rgb32); + v = _mm_unpacklo_epi8(v, _mm_setzero_si128()); + const __m128i vidx = _mm_slli_epi16(v, 4); + const int ridx = _mm_extract_epi16(vidx, 2); + const int gidx = _mm_extract_epi16(vidx, 1); + const int bidx = _mm_extract_epi16(vidx, 0); + v = _mm_slli_epi16(v, 8); // a * 256 + v = _mm_insert_epi16(v, m_toLinear[ridx], 0); + v = _mm_insert_epi16(v, m_toLinear[gidx], 1); + v = _mm_insert_epi16(v, m_toLinear[bidx], 2); + v = _mm_add_epi16(v, _mm_srli_epi16(v, 8)); + QRgba64 rgba64; + _mm_storel_epi64(reinterpret_cast<__m128i *>(&rgba64), v); + return rgba64; +#elif (defined(__ARM_NEON__) || defined(__ARM_NEON)) && Q_BYTE_ORDER == Q_LITTLE_ENDIAN + uint8x8_t v8 = vreinterpret_u8_u32(vmov_n_u32(rgb32)); + uint16x4_t v16 = vget_low_u16(vmovl_u8(v8)); + const uint16x4_t vidx = vshl_n_u16(v16, 4); + const int ridx = vget_lane_u16(vidx, 2); + const int gidx = vget_lane_u16(vidx, 1); + const int bidx = vget_lane_u16(vidx, 0); + v16 = vshl_n_u16(v16, 8); // a * 256 + v16 = vset_lane_u16(m_toLinear[ridx], v16, 0); + v16 = vset_lane_u16(m_toLinear[gidx], v16, 1); + v16 = vset_lane_u16(m_toLinear[bidx], v16, 2); + v16 = vadd_u16(v16, vshr_n_u16(v16, 8)); + return QRgba64::fromRgba64(vget_lane_u64(vreinterpret_u64_u16(v16), 0)); +#else + uint r = m_toLinear[qRed(rgb32) << 4]; + uint g = m_toLinear[qGreen(rgb32) << 4]; + uint b = m_toLinear[qBlue(rgb32) << 4]; r = r + (r >> 8); g = g + (g >> 8); b = b + (b >> 8); return QRgba64::fromRgba64(r, g, b, qAlpha(rgb32) * 257); +#endif } QRgb toLinear(QRgb rgb32) const { - uchar r = (m_toLinear[qRed(rgb32) << 4] + 0x80) >> 8; - uchar g = (m_toLinear[qGreen(rgb32) << 4] + 0x80) >> 8; - uchar b = (m_toLinear[qBlue(rgb32) << 4] + 0x80) >> 8; - return qRgba(r, g, b, qAlpha(rgb32)); + return convertWithTable(rgb32, m_toLinear); } QRgba64 toLinear(QRgba64 rgb64) const { - ushort r = rgb64.red(); - ushort g = rgb64.green(); - ushort b = rgb64.blue(); - r = r - (r >> 8); - g = g - (g >> 8); - b = b - (b >> 8); - r = m_toLinear[r >> 4]; - g = m_toLinear[g >> 4]; - b = m_toLinear[b >> 4]; - r = r + (r >> 8); - g = g + (g >> 8); - b = b + (b >> 8); - return QRgba64::fromRgba64(r, g, b, rgb64.alpha()); + return convertWithTable(rgb64, m_toLinear); } QRgb fromLinear64(QRgba64 rgb64) const { - ushort r = rgb64.red(); - ushort g = rgb64.green(); - ushort b = rgb64.blue(); +#if defined(__SSE2__) + __m128i v = _mm_loadl_epi64(reinterpret_cast(&rgb64)); + v = _mm_sub_epi16(v, _mm_srli_epi16(v, 8)); + const __m128i vidx = _mm_srli_epi16(v, 4); + const int ridx = _mm_extract_epi16(vidx, 0); + const int gidx = _mm_extract_epi16(vidx, 1); + const int bidx = _mm_extract_epi16(vidx, 2); + v = _mm_insert_epi16(v, m_fromLinear[ridx], 2); + v = _mm_insert_epi16(v, m_fromLinear[gidx], 1); + v = _mm_insert_epi16(v, m_fromLinear[bidx], 0); + v = _mm_add_epi16(v, _mm_set1_epi16(0x80)); + v = _mm_srli_epi16(v, 8); + v = _mm_packus_epi16(v, v); + return _mm_cvtsi128_si32(v); +#elif (defined(__ARM_NEON__) || defined(__ARM_NEON)) && Q_BYTE_ORDER == Q_LITTLE_ENDIAN + uint16x4_t v = vreinterpret_u16_u64(vmov_n_u64(rgb64)); + v = vsub_u16(v, vshr_n_u16(v, 8)); + const uint16x4_t vidx = vshr_n_u16(v, 4); + const int ridx = vget_lane_u16(vidx, 0); + const int gidx = vget_lane_u16(vidx, 1); + const int bidx = vget_lane_u16(vidx, 2); + v = vset_lane_u16(m_fromLinear[ridx], v, 2); + v = vset_lane_u16(m_fromLinear[gidx], v, 1); + v = vset_lane_u16(m_fromLinear[bidx], v, 0); + uint8x8_t v8 = vrshrn_n_u16(vcombine_u16(v, v), 8); + return vget_lane_u32(vreinterpret_u32_u8(v8), 0); +#else + uint a = rgb64.alpha(); + uint r = rgb64.red(); + uint g = rgb64.green(); + uint b = rgb64.blue(); + a = a - (a >> 8); r = r - (r >> 8); g = g - (g >> 8); b = b - (b >> 8); + a = (a + 0x80) >> 8; r = (m_fromLinear[r >> 4] + 0x80) >> 8; g = (m_fromLinear[g >> 4] + 0x80) >> 8; b = (m_fromLinear[b >> 4] + 0x80) >> 8; - return qRgba(r, g, b, rgb64.alpha8()); + return (a << 24) | (r << 16) | (g << 8) | b; +#endif } QRgb fromLinear(QRgb rgb32) const { - uchar r = (m_fromLinear[qRed(rgb32) << 4] + 0x80) >> 8; - uchar g = (m_fromLinear[qGreen(rgb32) << 4] + 0x80) >> 8; - uchar b = (m_fromLinear[qBlue(rgb32) << 4] + 0x80) >> 8; - return qRgba(r, g, b, qAlpha(rgb32)); + return convertWithTable(rgb32, m_fromLinear); } QRgba64 fromLinear(QRgba64 rgb64) const { + return convertWithTable(rgb64, m_fromLinear); + } + +private: + QColorProfile() { } + + Q_ALWAYS_INLINE static QRgb convertWithTable(QRgb rgb32, const ushort *table) + { + const int r = (table[qRed(rgb32) << 4] + 0x80) >> 8; + const int g = (table[qGreen(rgb32) << 4] + 0x80) >> 8; + const int b = (table[qBlue(rgb32) << 4] + 0x80) >> 8; + return (rgb32 & 0xff000000) | (r << 16) | (g << 8) | b; + } + Q_ALWAYS_INLINE static QRgba64 convertWithTable(QRgba64 rgb64, const ushort *table) + { +#if defined(__SSE2__) + __m128i v = _mm_loadl_epi64(reinterpret_cast(&rgb64)); + v = _mm_sub_epi16(v, _mm_srli_epi16(v, 8)); + const __m128i vidx = _mm_srli_epi16(v, 4); + const int ridx = _mm_extract_epi16(vidx, 2); + const int gidx = _mm_extract_epi16(vidx, 1); + const int bidx = _mm_extract_epi16(vidx, 0); + v = _mm_insert_epi16(v, table[ridx], 2); + v = _mm_insert_epi16(v, table[gidx], 1); + v = _mm_insert_epi16(v, table[bidx], 0); + v = _mm_add_epi16(v, _mm_srli_epi16(v, 8)); + QRgba64 rgba64; + _mm_storel_epi64(reinterpret_cast<__m128i *>(&rgba64), v); + return rgba64; +#elif (defined(__ARM_NEON__) || defined(__ARM_NEON)) && Q_BYTE_ORDER == Q_LITTLE_ENDIAN + uint16x4_t v = vreinterpret_u16_u64(vmov_n_u64(rgb64)); + v = vsub_u16(v, vshr_n_u16(v, 8)); + const uint16x4_t vidx = vshr_n_u16(v, 4); + const int ridx = vget_lane_u16(vidx, 2); + const int gidx = vget_lane_u16(vidx, 1); + const int bidx = vget_lane_u16(vidx, 0); + v = vset_lane_u16(table[ridx], v, 2); + v = vset_lane_u16(table[gidx], v, 1); + v = vset_lane_u16(table[bidx], v, 0); + v = vadd_u16(v, vshr_n_u16(v, 8)); + return QRgba64::fromRgba64(vget_lane_u64(vreinterpret_u64_u16(v), 0)); +#else ushort r = rgb64.red(); ushort g = rgb64.green(); ushort b = rgb64.blue(); r = r - (r >> 8); g = g - (g >> 8); b = b - (b >> 8); - r = m_fromLinear[r >> 4]; - g = m_fromLinear[g >> 4]; - b = m_fromLinear[b >> 4]; + r = table[r >> 4]; + g = table[g >> 4]; + b = table[b >> 4]; r = r + (r >> 8); g = g + (g >> 8); b = b + (b >> 8); return QRgba64::fromRgba64(r, g, b, rgb64.alpha()); +#endif } -private: - QColorProfile() { } - // We translate to 0-65280 (255*256) instead to 0-65535 to make simple // shifting an accurate conversion. // We translate from 0-4080 (255*16) for the same speed up, and to keep -- cgit v1.2.3 From 9f710b15f0b1651a26d5b80c2bcb48104bd12db2 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Thu, 20 Sep 2018 12:34:31 +0200 Subject: uic: Write the float and double properties in 'f' format Make the code consistent with the DomProperty::write() method. Task-number: QTBUG-70613 Change-Id: I622b4a019a4473823584de97304f8324f2cf0c6b Reviewed-by: Friedemann Kleint --- src/tools/uic/cpp/cppwriteinitialization.cpp | 4 +-- tests/auto/tools/uic/baseline/buttongroup.ui.h | 20 +++++++-------- .../auto/tools/uic/baseline/qpagesetupwidget.ui.h | 14 +++++----- .../auto/tools/uic/baseline/qtgradienteditor.ui.h | 30 +++++++++++----------- tests/auto/tools/uic/baseline/validators.ui.h | 14 +++++----- 5 files changed, 41 insertions(+), 41 deletions(-) diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp index 6a0e2f0338..4f6ac1eb97 100644 --- a/src/tools/uic/cpp/cppwriteinitialization.cpp +++ b/src/tools/uic/cpp/cppwriteinitialization.cpp @@ -1405,10 +1405,10 @@ void WriteInitialization::writeProperties(const QString &varName, propertyValue += QLatin1Char(')'); break; case DomProperty::Float: - propertyValue = QString::number(p->elementFloat()); + propertyValue = QString::number(p->elementFloat(), 'f', 8); break; case DomProperty::Double: - propertyValue = QString::number(p->elementDouble()); + propertyValue = QString::number(p->elementDouble(), 'f', 15); break; case DomProperty::Char: { const DomChar *c = p->elementChar(); diff --git a/tests/auto/tools/uic/baseline/buttongroup.ui.h b/tests/auto/tools/uic/baseline/buttongroup.ui.h index ddc3995d4b..87814dcba1 100644 --- a/tests/auto/tools/uic/baseline/buttongroup.ui.h +++ b/tests/auto/tools/uic/baseline/buttongroup.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'buttongroup.ui' ** -** Created by: Qt User Interface Compiler version 5.10.1 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ @@ -129,9 +129,9 @@ public: sizePolicy3.setHeightForWidth(periodSpinBox->sizePolicy().hasHeightForWidth()); periodSpinBox->setSizePolicy(sizePolicy3); periodSpinBox->setMinimumSize(QSize(0, 30)); - periodSpinBox->setMinimum(-1); - periodSpinBox->setSingleStep(0.1); - periodSpinBox->setValue(-1); + periodSpinBox->setMinimum(-1.000000000000000); + periodSpinBox->setSingleStep(0.100000000000000); + periodSpinBox->setValue(-1.000000000000000); formLayout->setWidget(0, QFormLayout::FieldRole, periodSpinBox); @@ -139,9 +139,9 @@ public: amplitudeSpinBox->setObjectName(QString::fromUtf8("amplitudeSpinBox")); amplitudeSpinBox->setEnabled(false); amplitudeSpinBox->setMinimumSize(QSize(0, 30)); - amplitudeSpinBox->setMinimum(-1); - amplitudeSpinBox->setSingleStep(0.1); - amplitudeSpinBox->setValue(-1); + amplitudeSpinBox->setMinimum(-1.000000000000000); + amplitudeSpinBox->setSingleStep(0.100000000000000); + amplitudeSpinBox->setValue(-1.000000000000000); formLayout->setWidget(2, QFormLayout::FieldRole, amplitudeSpinBox); @@ -155,9 +155,9 @@ public: overshootSpinBox->setObjectName(QString::fromUtf8("overshootSpinBox")); overshootSpinBox->setEnabled(false); overshootSpinBox->setMinimumSize(QSize(0, 30)); - overshootSpinBox->setMinimum(-1); - overshootSpinBox->setSingleStep(0.1); - overshootSpinBox->setValue(-1); + overshootSpinBox->setMinimum(-1.000000000000000); + overshootSpinBox->setSingleStep(0.100000000000000); + overshootSpinBox->setValue(-1.000000000000000); formLayout->setWidget(4, QFormLayout::FieldRole, overshootSpinBox); diff --git a/tests/auto/tools/uic/baseline/qpagesetupwidget.ui.h b/tests/auto/tools/uic/baseline/qpagesetupwidget.ui.h index e914c664d3..a5379bc468 100644 --- a/tests/auto/tools/uic/baseline/qpagesetupwidget.ui.h +++ b/tests/auto/tools/uic/baseline/qpagesetupwidget.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'qpagesetupwidget.ui' ** -** Created by: Qt User Interface Compiler version 5.9.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ @@ -104,7 +104,7 @@ public: horizontalLayout_3->setObjectName(QString::fromUtf8("horizontalLayout_3")); pageWidth = new QDoubleSpinBox(groupBox_2); pageWidth->setObjectName(QString::fromUtf8("pageWidth")); - pageWidth->setMaximum(9999.99); + pageWidth->setMaximum(9999.989999999999782); horizontalLayout_3->addWidget(pageWidth); @@ -115,7 +115,7 @@ public: pageHeight = new QDoubleSpinBox(groupBox_2); pageHeight->setObjectName(QString::fromUtf8("pageHeight")); - pageHeight->setMaximum(9999.99); + pageHeight->setMaximum(9999.989999999999782); horizontalLayout_3->addWidget(pageHeight); @@ -199,7 +199,7 @@ public: topMargin = new QDoubleSpinBox(groupBox); topMargin->setObjectName(QString::fromUtf8("topMargin")); topMargin->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); - topMargin->setMaximum(999.99); + topMargin->setMaximum(999.990000000000009); gridLayout->addWidget(topMargin, 0, 1, 1, 1); @@ -212,7 +212,7 @@ public: leftMargin = new QDoubleSpinBox(groupBox); leftMargin->setObjectName(QString::fromUtf8("leftMargin")); leftMargin->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); - leftMargin->setMaximum(999.99); + leftMargin->setMaximum(999.990000000000009); horizontalLayout->addWidget(leftMargin); @@ -223,7 +223,7 @@ public: rightMargin = new QDoubleSpinBox(groupBox); rightMargin->setObjectName(QString::fromUtf8("rightMargin")); rightMargin->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); - rightMargin->setMaximum(999.99); + rightMargin->setMaximum(999.990000000000009); horizontalLayout->addWidget(rightMargin); @@ -241,7 +241,7 @@ public: bottomMargin = new QDoubleSpinBox(groupBox); bottomMargin->setObjectName(QString::fromUtf8("bottomMargin")); bottomMargin->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); - bottomMargin->setMaximum(999.99); + bottomMargin->setMaximum(999.990000000000009); gridLayout->addWidget(bottomMargin, 2, 1, 1, 1); diff --git a/tests/auto/tools/uic/baseline/qtgradienteditor.ui.h b/tests/auto/tools/uic/baseline/qtgradienteditor.ui.h index 21dc9551d0..9db07f35ac 100644 --- a/tests/auto/tools/uic/baseline/qtgradienteditor.ui.h +++ b/tests/auto/tools/uic/baseline/qtgradienteditor.ui.h @@ -31,7 +31,7 @@ /******************************************************************************** ** Form generated from reading UI file 'qtgradienteditor.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ @@ -176,8 +176,8 @@ public: spinBox1->setGeometry(QRect(279, 69, 73, 23)); spinBox1->setKeyboardTracking(false); spinBox1->setDecimals(3); - spinBox1->setMaximum(1); - spinBox1->setSingleStep(0.01); + spinBox1->setMaximum(1.000000000000000); + spinBox1->setSingleStep(0.010000000000000); label2 = new QLabel(QtGradientEditor); label2->setObjectName(QString::fromUtf8("label2")); label2->setGeometry(QRect(209, 99, 64, 23)); @@ -186,8 +186,8 @@ public: spinBox2->setGeometry(QRect(279, 99, 73, 23)); spinBox2->setKeyboardTracking(false); spinBox2->setDecimals(3); - spinBox2->setMaximum(1); - spinBox2->setSingleStep(0.01); + spinBox2->setMaximum(1.000000000000000); + spinBox2->setSingleStep(0.010000000000000); label3 = new QLabel(QtGradientEditor); label3->setObjectName(QString::fromUtf8("label3")); label3->setGeometry(QRect(209, 129, 64, 23)); @@ -196,8 +196,8 @@ public: spinBox3->setGeometry(QRect(279, 129, 73, 23)); spinBox3->setKeyboardTracking(false); spinBox3->setDecimals(3); - spinBox3->setMaximum(1); - spinBox3->setSingleStep(0.01); + spinBox3->setMaximum(1.000000000000000); + spinBox3->setSingleStep(0.010000000000000); label4 = new QLabel(QtGradientEditor); label4->setObjectName(QString::fromUtf8("label4")); label4->setGeometry(QRect(209, 159, 64, 23)); @@ -206,8 +206,8 @@ public: spinBox4->setGeometry(QRect(279, 159, 73, 23)); spinBox4->setKeyboardTracking(false); spinBox4->setDecimals(3); - spinBox4->setMaximum(1); - spinBox4->setSingleStep(0.01); + spinBox4->setMaximum(1.000000000000000); + spinBox4->setSingleStep(0.010000000000000); label5 = new QLabel(QtGradientEditor); label5->setObjectName(QString::fromUtf8("label5")); label5->setGeometry(QRect(209, 189, 64, 23)); @@ -216,8 +216,8 @@ public: spinBox5->setGeometry(QRect(279, 189, 73, 23)); spinBox5->setKeyboardTracking(false); spinBox5->setDecimals(3); - spinBox5->setMaximum(1); - spinBox5->setSingleStep(0.01); + spinBox5->setMaximum(1.000000000000000); + spinBox5->setSingleStep(0.010000000000000); gradientStopsWidget = new QtGradientStopsWidget(QtGradientEditor); gradientStopsWidget->setObjectName(QString::fromUtf8("gradientStopsWidget")); gradientStopsWidget->setGeometry(QRect(10, 225, 193, 67)); @@ -390,10 +390,10 @@ public: positionSpinBox->setObjectName(QString::fromUtf8("positionSpinBox")); positionSpinBox->setKeyboardTracking(false); positionSpinBox->setDecimals(3); - positionSpinBox->setMinimum(0); - positionSpinBox->setMaximum(1); - positionSpinBox->setSingleStep(0.01); - positionSpinBox->setValue(0); + positionSpinBox->setMinimum(0.000000000000000); + positionSpinBox->setMaximum(1.000000000000000); + positionSpinBox->setSingleStep(0.010000000000000); + positionSpinBox->setValue(0.000000000000000); vboxLayout1->addWidget(positionSpinBox); diff --git a/tests/auto/tools/uic/baseline/validators.ui.h b/tests/auto/tools/uic/baseline/validators.ui.h index 0595cf2037..d0ae777f65 100644 --- a/tests/auto/tools/uic/baseline/validators.ui.h +++ b/tests/auto/tools/uic/baseline/validators.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'validators.ui' ** -** Created by: Qt User Interface Compiler version 5.10.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ @@ -252,9 +252,9 @@ public: doubleMinVal->setObjectName(QString::fromUtf8("doubleMinVal")); sizePolicy.setHeightForWidth(doubleMinVal->sizePolicy().hasHeightForWidth()); doubleMinVal->setSizePolicy(sizePolicy); - doubleMinVal->setMinimum(-100000); - doubleMinVal->setMaximum(100000); - doubleMinVal->setValue(0); + doubleMinVal->setMinimum(-100000.000000000000000); + doubleMinVal->setMaximum(100000.000000000000000); + doubleMinVal->setValue(0.000000000000000); gridLayout1->addWidget(doubleMinVal, 0, 1, 1, 1); @@ -281,9 +281,9 @@ public: doubleMaxVal->setObjectName(QString::fromUtf8("doubleMaxVal")); sizePolicy.setHeightForWidth(doubleMaxVal->sizePolicy().hasHeightForWidth()); doubleMaxVal->setSizePolicy(sizePolicy); - doubleMaxVal->setMinimum(-100000); - doubleMaxVal->setMaximum(100000); - doubleMaxVal->setValue(1000); + doubleMaxVal->setMinimum(-100000.000000000000000); + doubleMaxVal->setMaximum(100000.000000000000000); + doubleMaxVal->setValue(1000.000000000000000); gridLayout1->addWidget(doubleMaxVal, 1, 1, 1, 1); -- cgit v1.2.3 From cd3374c4efb48f3088429c8735610e7c6b61d1af Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Tue, 18 Sep 2018 14:06:27 +0200 Subject: Cleanup in eglfs device integration .pro files There is no need to apply QMAKE_LFLAGS_NOUNDEF in a .pro file that loads qt_module.prf or qt_plugin.prf, both of which do the same. Change-Id: I1ec86cddb4d0991becc136f8bd50d6652c885a6b Reviewed-by: Laszlo Agocs Reviewed-by: Oswald Buddenhagen --- src/plugins/platforms/eglfs/deviceintegration/eglfs_brcm/eglfs_brcm.pro | 1 - src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/eglfs_kms.pro | 1 - .../eglfs/deviceintegration/eglfs_kms_egldevice/eglfs_kms_egldevice.pro | 1 - .../eglfs/deviceintegration/eglfs_kms_support/eglfs_kms_support.pro | 1 - .../platforms/eglfs/deviceintegration/eglfs_kms_vsp2/eglfs_kms_vsp2.pro | 1 - src/plugins/platforms/eglfs/deviceintegration/eglfs_mali/eglfs_mali.pro | 1 - src/plugins/platforms/eglfs/deviceintegration/eglfs_rcar/eglfs_rcar.pro | 1 - src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/eglfs_viv.pro | 1 - .../platforms/eglfs/deviceintegration/eglfs_viv_wl/eglfs_viv_wl.pro | 1 - src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/eglfs_x11.pro | 1 - src/plugins/platforms/eglfs/eglfsdeviceintegration.pro | 2 -- 11 files changed, 12 deletions(-) diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_brcm/eglfs_brcm.pro b/src/plugins/platforms/eglfs/deviceintegration/eglfs_brcm/eglfs_brcm.pro index fee67da2de..aa487be8c0 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_brcm/eglfs_brcm.pro +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_brcm/eglfs_brcm.pro @@ -6,7 +6,6 @@ INCLUDEPATH += $$PWD/../../api CONFIG += egl LIBS += -lbcm_host -QMAKE_LFLAGS += $$QMAKE_LFLAGS_NOUNDEF # Avoid X11 header collision, use generic EGL native types DEFINES += QT_EGL_NO_X11 diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/eglfs_kms.pro b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/eglfs_kms.pro index 43170a3875..f5c2c0ed89 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/eglfs_kms.pro +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/eglfs_kms.pro @@ -13,7 +13,6 @@ DEFINES += QT_EGL_NO_X11 QMAKE_USE += gbm drm CONFIG += egl -QMAKE_LFLAGS += $$QMAKE_LFLAGS_NOUNDEF SOURCES += $$PWD/qeglfskmsgbmmain.cpp \ $$PWD/qeglfskmsgbmintegration.cpp \ diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/eglfs_kms_egldevice.pro b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/eglfs_kms_egldevice.pro index 36f037ac6c..a6145c07e6 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/eglfs_kms_egldevice.pro +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/eglfs_kms_egldevice.pro @@ -9,7 +9,6 @@ DEFINES += QT_EGL_NO_X11 QMAKE_USE += drm CONFIG += egl -QMAKE_LFLAGS += $$QMAKE_LFLAGS_NOUNDEF SOURCES += $$PWD/qeglfskmsegldevicemain.cpp \ $$PWD/qeglfskmsegldeviceintegration.cpp \ diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/eglfs_kms_support.pro b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/eglfs_kms_support.pro index 4d1321079c..40806b6a9b 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/eglfs_kms_support.pro +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/eglfs_kms_support.pro @@ -11,7 +11,6 @@ DEFINES += QT_EGL_NO_X11 QMAKE_USE += drm CONFIG += egl -QMAKE_LFLAGS += $$QMAKE_LFLAGS_NOUNDEF SOURCES += $$PWD/qeglfskmsintegration.cpp \ $$PWD/qeglfskmsdevice.cpp \ diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_vsp2/eglfs_kms_vsp2.pro b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_vsp2/eglfs_kms_vsp2.pro index 826c2f989f..f63b768a38 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_vsp2/eglfs_kms_vsp2.pro +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_vsp2/eglfs_kms_vsp2.pro @@ -13,7 +13,6 @@ DEFINES += QT_EGL_NO_X11 QMAKE_USE += gbm drm v4l2 CONFIG += egl -QMAKE_LFLAGS += $$QMAKE_LFLAGS_NOUNDEF SOURCES += $$PWD/qeglfskmsvsp2main.cpp \ $$PWD/qeglfskmsvsp2integration.cpp \ diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_mali/eglfs_mali.pro b/src/plugins/platforms/eglfs/deviceintegration/eglfs_mali/eglfs_mali.pro index 5e6f636e2b..3261a6dbba 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_mali/eglfs_mali.pro +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_mali/eglfs_mali.pro @@ -7,7 +7,6 @@ DEFINES += QT_EGL_NO_X11 INCLUDEPATH += $$PWD/../../api CONFIG += egl -QMAKE_LFLAGS += $$QMAKE_LFLAGS_NOUNDEF SOURCES += $$PWD/qeglfsmalimain.cpp \ $$PWD/qeglfsmaliintegration.cpp diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_rcar/eglfs_rcar.pro b/src/plugins/platforms/eglfs/deviceintegration/eglfs_rcar/eglfs_rcar.pro index 04236449a0..62acd51cea 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_rcar/eglfs_rcar.pro +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_rcar/eglfs_rcar.pro @@ -5,7 +5,6 @@ QT += core-private gui-private eglfsdeviceintegration-private INCLUDEPATH += $$PWD/../../api CONFIG += egl DEFINES += LINUX=1 EGL_API_FB=1 -QMAKE_LFLAGS += $$QMAKE_LFLAGS_NOUNDEF SOURCES += $$PWD/qeglfsrcarmain.cpp \ $$PWD/qeglfsrcarintegration.cpp diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/eglfs_viv.pro b/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/eglfs_viv.pro index f9cce8d48b..8d3be9c2ac 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/eglfs_viv.pro +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/eglfs_viv.pro @@ -5,7 +5,6 @@ QT += core-private gui-private eglfsdeviceintegration-private INCLUDEPATH += $$PWD/../../api CONFIG += egl DEFINES += LINUX=1 EGL_API_FB=1 -QMAKE_LFLAGS += $$QMAKE_LFLAGS_NOUNDEF SOURCES += $$PWD/qeglfsvivmain.cpp \ $$PWD/qeglfsvivintegration.cpp diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/eglfs_viv_wl.pro b/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/eglfs_viv_wl.pro index 065a103376..45d73e1eb8 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/eglfs_viv_wl.pro +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/eglfs_viv_wl.pro @@ -5,7 +5,6 @@ QT += core-private gui-private eglfsdeviceintegration-private INCLUDEPATH += $$PWD/../../api CONFIG += egl DEFINES += LINUX=1 EGL_API_FB=1 -QMAKE_LFLAGS += $$QMAKE_LFLAGS_NOUNDEF SOURCES += $$PWD/qeglfsvivwlmain.cpp \ $$PWD/qeglfsvivwlintegration.cpp diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/eglfs_x11.pro b/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/eglfs_x11.pro index 391f63615b..acbd1cc785 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/eglfs_x11.pro +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/eglfs_x11.pro @@ -9,7 +9,6 @@ INCLUDEPATH += $$PWD/../../api CONFIG += egl QMAKE_USE += xcb_xlib -QMAKE_LFLAGS += $$QMAKE_LFLAGS_NOUNDEF SOURCES += $$PWD/qeglfsx11main.cpp \ $$PWD/qeglfsx11integration.cpp diff --git a/src/plugins/platforms/eglfs/eglfsdeviceintegration.pro b/src/plugins/platforms/eglfs/eglfsdeviceintegration.pro index 187cbc025f..8bb7b614f1 100644 --- a/src/plugins/platforms/eglfs/eglfsdeviceintegration.pro +++ b/src/plugins/platforms/eglfs/eglfsdeviceintegration.pro @@ -27,8 +27,6 @@ DEFINES += QT_BUILD_EGL_DEVICE_LIB include($$PWD/api/api.pri) -QMAKE_LFLAGS += $$QMAKE_LFLAGS_NOUNDEF - !isEmpty(EGLFS_PLATFORM_HOOKS_SOURCES) { HEADERS += $$EGLFS_PLATFORM_HOOKS_HEADERS SOURCES += $$EGLFS_PLATFORM_HOOKS_SOURCES -- cgit v1.2.3 From 05b8ba51550127c85cd2db5cb819b695b56c57ce Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Wed, 3 Oct 2018 14:21:09 +0300 Subject: QLineEdit: take the size of actions' icons from a style The height of a line edit depends on the height of its font, which in turn depends on DPI. So use the DPI-scaled icon size from a style instead of hard-coded values. Task-number: QTBUG-65627 Change-Id: Ic1f5af61b0d6346cfbc828817c4a3a39296a41ba Reviewed-by: Richard Moe Gustavsen --- src/widgets/widgets/qlineedit.cpp | 3 ++- src/widgets/widgets/qlineedit_p.cpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp index 96c5982e0c..242a4405ca 100644 --- a/src/widgets/widgets/qlineedit.cpp +++ b/src/widgets/widgets/qlineedit.cpp @@ -680,7 +680,8 @@ QSize QLineEdit::sizeHint() const Q_D(const QLineEdit); ensurePolished(); QFontMetrics fm(font()); - int h = qMax(fm.height(), 14) + 2*d->verticalMargin + const int iconSize = style()->pixelMetric(QStyle::PM_SmallIconSize, 0, this); + int h = qMax(fm.height(), iconSize - 2) + 2*d->verticalMargin + d->topTextMargin + d->bottomTextMargin + d->topmargin + d->bottommargin; int w = fm.horizontalAdvance(QLatin1Char('x')) * 17 + 2*d->horizontalMargin diff --git a/src/widgets/widgets/qlineedit_p.cpp b/src/widgets/widgets/qlineedit_p.cpp index 33d542abc0..fce3d47b17 100644 --- a/src/widgets/widgets/qlineedit_p.cpp +++ b/src/widgets/widgets/qlineedit_p.cpp @@ -441,7 +441,7 @@ QLineEditPrivate::SideWidgetParameters QLineEditPrivate::sideWidgetParameters() { Q_Q(const QLineEdit); SideWidgetParameters result; - result.iconSize = q->height() < 34 ? 16 : 32; + result.iconSize = q->style()->pixelMetric(QStyle::PM_SmallIconSize, 0, q); result.margin = result.iconSize / 4; result.widgetWidth = result.iconSize + 6; result.widgetHeight = result.iconSize + 2; -- cgit v1.2.3 From 29208fa07c1b9f656ea2535696828385b7832226 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Mon, 10 Sep 2018 12:19:09 +0200 Subject: winrt: Explicitly set main thread in QCoreApplication's constructor For winrt we cannot rely on the fact, that QThread::current will be called from the correct thread for the first time. The application's main entry point creates a suspended thread and starts it right afterwards. At that moment, other functionality (QLoggingRegistry for example) might have called QThread::current, which set the wrong thread as the main thread. In order to avoid this situation, the main thread is explicitly set in QCoreApplication's constructor. Task-number: QTBUG-66418 Change-Id: I8b6347357a80eb395ae758bd3d420adef0826751 Reviewed-by: Friedemann Kleint Reviewed-by: Simon Hausmann --- src/corelib/kernel/qcoreapplication.cpp | 4 ++++ src/corelib/thread/qthread_p.h | 3 +++ src/corelib/thread/qthread_win.cpp | 35 +++++++++++++++++++++++++++++++-- 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 1350a7aa94..463e30e1c3 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -482,6 +482,10 @@ QCoreApplicationPrivate::QCoreApplicationPrivate(int &aargc, char **aargv, uint qFatal("FATAL: The application binary appears to be running setuid, this is a security hole."); # endif // Q_OS_UNIX +#ifdef Q_OS_WINRT + QThreadData::setMainThread(); +#endif + QThread *cur = QThread::currentThread(); // note: this may end up setting theMainThread! if (cur != theMainThread) qWarning("WARNING: QApplication was not created in the main() thread."); diff --git a/src/corelib/thread/qthread_p.h b/src/corelib/thread/qthread_p.h index 64e3f33191..7d9442ab79 100644 --- a/src/corelib/thread/qthread_p.h +++ b/src/corelib/thread/qthread_p.h @@ -243,6 +243,9 @@ public: ~QThreadData(); static Q_AUTOTEST_EXPORT QThreadData *current(bool createIfNecessary = true); +#ifdef Q_OS_WINRT + static void setMainThread(); +#endif static void clearCurrentThreadData(); static QThreadData *get2(QThread *thread) { Q_ASSERT_X(thread != 0, "QThread", "internal error"); return thread->d_func()->data; } diff --git a/src/corelib/thread/qthread_win.cpp b/src/corelib/thread/qthread_win.cpp index eebaf90d9b..e04d27d7b6 100644 --- a/src/corelib/thread/qthread_win.cpp +++ b/src/corelib/thread/qthread_win.cpp @@ -140,11 +140,15 @@ QThreadData *QThreadData::current(bool createIfNecessary) threadData->isAdopted = true; threadData->threadId.store(reinterpret_cast(quintptr(GetCurrentThreadId()))); +#ifndef Q_OS_WINRT if (!QCoreApplicationPrivate::theMainThread) { QCoreApplicationPrivate::theMainThread = threadData->thread.load(); - // TODO: is there a way to reflect the branch's behavior using - // WinRT API? } else { +#else + // for winrt the main thread is set explicitly in QCoreApplication's constructor as the + // native main thread (Xaml thread) is not Qt's main thread. + { +#endif HANDLE realHandle = INVALID_HANDLE_VALUE; DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), @@ -159,6 +163,33 @@ QThreadData *QThreadData::current(bool createIfNecessary) return threadData; } +#ifdef Q_OS_WINRT +void QThreadData::setMainThread() +{ + Q_ASSERT(!QCoreApplicationPrivate::theMainThread); + qt_create_tls(); + QThreadData *threadData = reinterpret_cast(TlsGetValue(qt_current_thread_data_tls_index)); + if (!threadData) { + threadData = new QThreadData; + // This needs to be called prior to new AdoptedThread() to + // avoid recursion. + TlsSetValue(qt_current_thread_data_tls_index, threadData); + QT_TRY { + threadData->thread = new QAdoptedThread(threadData); + } QT_CATCH(...) { + TlsSetValue(qt_current_thread_data_tls_index, 0); + threadData->deref(); + threadData = 0; + QT_RETHROW; + } + threadData->deref(); + threadData->isAdopted = true; + threadData->threadId.store(reinterpret_cast(quintptr(GetCurrentThreadId()))); + } + QCoreApplicationPrivate::theMainThread = threadData->thread.load(); +} +#endif + void QAdoptedThread::init() { d_func()->handle = GetCurrentThread(); -- cgit v1.2.3