qt_kde.patch 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  1. diff --git a/src/imports/platform/widgets/qwidgetplatformmenu.cpp b/src/imports/platform/widgets/qwidgetplatformmenu.cpp
  2. index e5fe734f7..e36922775 100644
  3. --- a/src/imports/platform/widgets/qwidgetplatformmenu.cpp
  4. +++ b/src/imports/platform/widgets/qwidgetplatformmenu.cpp
  5. @@ -38,6 +38,7 @@
  6. #include "qwidgetplatformmenuitem_p.h"
  7. #include <QtGui/qwindow.h>
  8. +#include <QtGui/private/qhighdpiscaling_p.h>
  9. #include <QtWidgets/qmenu.h>
  10. #include <QtWidgets/qaction.h>
  11. @@ -145,7 +146,7 @@ void QWidgetPlatformMenu::showPopup(const QWindow *window, const QRect &targetRe
  12. QPoint targetPos = targetRect.bottomLeft();
  13. if (window)
  14. - targetPos = window->mapToGlobal(targetPos);
  15. + targetPos = window->mapToGlobal(QHighDpi::fromNativeLocalPosition(targetPos, window));
  16. const QWidgetPlatformMenuItem *widgetItem = qobject_cast<const QWidgetPlatformMenuItem *>(item);
  17. m_menu->popup(targetPos, widgetItem ? widgetItem->action() : nullptr);
  18. diff --git a/src/quicktemplates2/qquickabstractbutton.cpp b/src/quicktemplates2/qquickabstractbutton.cpp
  19. index 20cf59c1a..43af47a94 100644
  20. --- a/src/quicktemplates2/qquickabstractbutton.cpp
  21. +++ b/src/quicktemplates2/qquickabstractbutton.cpp
  22. @@ -1201,6 +1201,12 @@ QAccessible::Role QQuickAbstractButton::accessibleRole() const
  23. }
  24. return QAccessible::Button;
  25. }
  26. +
  27. +void QQuickAbstractButton::accessiblePressAction()
  28. +{
  29. + Q_D(QQuickAbstractButton);
  30. + d->trigger();
  31. +}
  32. #endif
  33. QT_END_NAMESPACE
  34. diff --git a/src/quicktemplates2/qquickabstractbutton_p.h b/src/quicktemplates2/qquickabstractbutton_p.h
  35. index 0fa48980e..ab66220d0 100644
  36. --- a/src/quicktemplates2/qquickabstractbutton_p.h
  37. +++ b/src/quicktemplates2/qquickabstractbutton_p.h
  38. @@ -209,6 +209,7 @@ protected:
  39. #if QT_CONFIG(accessibility)
  40. void accessibilityActiveChanged(bool active) override;
  41. QAccessible::Role accessibleRole() const override;
  42. + Q_INVOKABLE void accessiblePressAction();
  43. #endif
  44. private:
  45. diff --git a/src/quicktemplates2/qquickcontainer.cpp b/src/quicktemplates2/qquickcontainer.cpp
  46. index f38c2b09c..6eed2a024 100644
  47. --- a/src/quicktemplates2/qquickcontainer.cpp
  48. +++ b/src/quicktemplates2/qquickcontainer.cpp
  49. @@ -225,6 +225,7 @@ void QQuickContainerPrivate::cleanup()
  50. QObject::disconnect(contentModel, &QQmlObjectModel::countChanged, q, &QQuickContainer::countChanged);
  51. QObject::disconnect(contentModel, &QQmlObjectModel::childrenChanged, q, &QQuickContainer::contentChildrenChanged);
  52. delete contentModel;
  53. + contentModel = nullptr;
  54. }
  55. QQuickItem *QQuickContainerPrivate::itemAt(int index) const
  56. @@ -436,7 +437,7 @@ void QQuickContainerPrivate::contentChildren_clear(QQmlListProperty<QQuickItem>
  57. void QQuickContainerPrivate::updateContentWidth()
  58. {
  59. Q_Q(QQuickContainer);
  60. - if (hasContentWidth || qFuzzyCompare(contentWidth, implicitContentWidth))
  61. + if (hasContentWidth || qFuzzyCompare(contentWidth, implicitContentWidth) || !contentModel)
  62. return;
  63. contentWidth = implicitContentWidth;
  64. @@ -446,7 +447,7 @@ void QQuickContainerPrivate::updateContentWidth()
  65. void QQuickContainerPrivate::updateContentHeight()
  66. {
  67. Q_Q(QQuickContainer);
  68. - if (hasContentHeight || qFuzzyCompare(contentHeight, implicitContentHeight))
  69. + if (hasContentHeight || qFuzzyCompare(contentHeight, implicitContentHeight) || !contentModel)
  70. return;
  71. contentHeight = implicitContentHeight;
  72. diff --git a/src/quicktemplates2/qquickcontrol.cpp b/src/quicktemplates2/qquickcontrol.cpp
  73. index a719efd34..768691dac 100644
  74. --- a/src/quicktemplates2/qquickcontrol.cpp
  75. +++ b/src/quicktemplates2/qquickcontrol.cpp
  76. @@ -2334,12 +2334,13 @@ QAccessible::Role QQuickControl::accessibleRole() const
  77. void QQuickControl::accessibilityActiveChanged(bool active)
  78. {
  79. + Q_D(QQuickControl);
  80. if (!active)
  81. return;
  82. QQuickAccessibleAttached *accessibleAttached = qobject_cast<QQuickAccessibleAttached *>(qmlAttachedPropertiesObject<QQuickAccessibleAttached>(this, true));
  83. Q_ASSERT(accessibleAttached);
  84. - accessibleAttached->setRole(accessibleRole());
  85. + accessibleAttached->setRole(d->effectiveAccessibleRole());
  86. }
  87. #endif
  88. diff --git a/src/quicktemplates2/qquickdialogbuttonbox.cpp b/src/quicktemplates2/qquickdialogbuttonbox.cpp
  89. index e6db14eb5..6197d1547 100644
  90. --- a/src/quicktemplates2/qquickdialogbuttonbox.cpp
  91. +++ b/src/quicktemplates2/qquickdialogbuttonbox.cpp
  92. @@ -237,7 +237,7 @@ static QRectF alignedRect(Qt::LayoutDirection direction, Qt::Alignment alignment
  93. void QQuickDialogButtonBoxPrivate::resizeContent()
  94. {
  95. Q_Q(QQuickDialogButtonBox);
  96. - if (!contentItem)
  97. + if (!contentItem || !contentModel)
  98. return;
  99. QRectF geometry = q->boundingRect().adjusted(q->leftPadding(), q->topPadding(), -q->rightPadding(), -q->bottomPadding());
  100. @@ -322,6 +322,9 @@ void QQuickDialogButtonBoxPrivate::updateLayout()
  101. qreal QQuickDialogButtonBoxPrivate::getContentWidth() const
  102. {
  103. Q_Q(const QQuickDialogButtonBox);
  104. + if (!contentModel)
  105. + return 0;
  106. +
  107. const int count = contentModel->count();
  108. const qreal totalSpacing = qMax(0, count - 1) * spacing;
  109. qreal totalWidth = totalSpacing;
  110. @@ -341,6 +344,9 @@ qreal QQuickDialogButtonBoxPrivate::getContentWidth() const
  111. qreal QQuickDialogButtonBoxPrivate::getContentHeight() const
  112. {
  113. Q_Q(const QQuickDialogButtonBox);
  114. + if (!contentModel)
  115. + return 0;
  116. +
  117. const int count = contentModel->count();
  118. qreal maxHeight = 0;
  119. for (int i = 0; i < count; ++i) {
  120. diff --git a/src/quicktemplates2/qquicklabel.cpp b/src/quicktemplates2/qquicklabel.cpp
  121. index 71b60a2bc..2bc621674 100644
  122. --- a/src/quicktemplates2/qquicklabel.cpp
  123. +++ b/src/quicktemplates2/qquicklabel.cpp
  124. @@ -263,7 +263,7 @@ void QQuickLabelPrivate::accessibilityActiveChanged(bool active)
  125. Q_Q(QQuickLabel);
  126. QQuickAccessibleAttached *accessibleAttached = qobject_cast<QQuickAccessibleAttached *>(qmlAttachedPropertiesObject<QQuickAccessibleAttached>(q, true));
  127. Q_ASSERT(accessibleAttached);
  128. - accessibleAttached->setRole(accessibleRole());
  129. + accessibleAttached->setRole(effectiveAccessibleRole());
  130. maybeSetAccessibleName(text);
  131. }
  132. diff --git a/src/quicktemplates2/qquickoverlay.cpp b/src/quicktemplates2/qquickoverlay.cpp
  133. index 91bd59184..0ce518f84 100644
  134. --- a/src/quicktemplates2/qquickoverlay.cpp
  135. +++ b/src/quicktemplates2/qquickoverlay.cpp
  136. @@ -399,8 +399,11 @@ void QQuickOverlay::itemChange(ItemChange change, const ItemChangeData &data)
  137. Q_D(QQuickOverlay);
  138. QQuickItem::itemChange(change, data);
  139. - if (change == ItemChildAddedChange || change == ItemChildRemovedChange)
  140. + if (change == ItemChildAddedChange || change == ItemChildRemovedChange) {
  141. setVisible(!d->allDrawers.isEmpty() || !childItems().isEmpty());
  142. + if (data.item->parent() == d->mouseGrabberPopup)
  143. + d->setMouseGrabberPopup(nullptr);
  144. + }
  145. }
  146. void QQuickOverlay::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
  147. diff --git a/src/quicktemplates2/qquickpopup.cpp b/src/quicktemplates2/qquickpopup.cpp
  148. index 7df80a047..bfaa84e30 100644
  149. --- a/src/quicktemplates2/qquickpopup.cpp
  150. +++ b/src/quicktemplates2/qquickpopup.cpp
  151. @@ -46,6 +46,7 @@
  152. #include <QtQml/qqmlinfo.h>
  153. #include <QtQuick/qquickitem.h>
  154. +#include <QtQuick/private/qquickaccessibleattached_p.h>
  155. #include <QtQuick/private/qquicktransition_p.h>
  156. #include <QtQuick/private/qquickitem_p.h>
  157. @@ -2720,6 +2721,19 @@ QPalette QQuickPopup::defaultPalette() const
  158. }
  159. #if QT_CONFIG(accessibility)
  160. +QAccessible::Role QQuickPopup::effectiveAccessibleRole() const
  161. +{
  162. + auto *attached = qmlAttachedPropertiesObject<QQuickAccessibleAttached>(this, false);
  163. +
  164. + auto role = QAccessible::NoRole;
  165. + if (auto *accessibleAttached = qobject_cast<QQuickAccessibleAttached *>(attached))
  166. + role = accessibleAttached->role();
  167. + if (role == QAccessible::NoRole)
  168. + role = accessibleRole();
  169. +
  170. + return role;
  171. +}
  172. +
  173. QAccessible::Role QQuickPopup::accessibleRole() const
  174. {
  175. return QAccessible::Dialog;
  176. diff --git a/src/quicktemplates2/qquickpopup_p.h b/src/quicktemplates2/qquickpopup_p.h
  177. index dc3ebf6f8..a3773be3e 100644
  178. --- a/src/quicktemplates2/qquickpopup_p.h
  179. +++ b/src/quicktemplates2/qquickpopup_p.h
  180. @@ -454,7 +454,10 @@ protected:
  181. virtual QPalette defaultPalette() const;
  182. #if QT_CONFIG(accessibility)
  183. + QAccessible::Role effectiveAccessibleRole() const;
  184. +private:
  185. virtual QAccessible::Role accessibleRole() const;
  186. +protected:
  187. virtual void accessibilityActiveChanged(bool active);
  188. #endif
  189. diff --git a/src/quicktemplates2/qquickpopupitem.cpp b/src/quicktemplates2/qquickpopupitem.cpp
  190. index 0069b9fc1..143c37fc3 100644
  191. --- a/src/quicktemplates2/qquickpopupitem.cpp
  192. +++ b/src/quicktemplates2/qquickpopupitem.cpp
  193. @@ -404,7 +404,7 @@ QPalette QQuickPopupItem::defaultPalette() const
  194. QAccessible::Role QQuickPopupItem::accessibleRole() const
  195. {
  196. Q_D(const QQuickPopupItem);
  197. - return d->popup->accessibleRole();
  198. + return d->popup->effectiveAccessibleRole();
  199. }
  200. void QQuickPopupItem::accessibilityActiveChanged(bool active)
  201. diff --git a/src/quicktemplates2/qquicktextarea.cpp b/src/quicktemplates2/qquicktextarea.cpp
  202. index 64fc631dd..fba3f6b70 100644
  203. --- a/src/quicktemplates2/qquicktextarea.cpp
  204. +++ b/src/quicktemplates2/qquicktextarea.cpp
  205. @@ -512,7 +512,7 @@ void QQuickTextAreaPrivate::accessibilityActiveChanged(bool active)
  206. Q_Q(QQuickTextArea);
  207. QQuickAccessibleAttached *accessibleAttached = qobject_cast<QQuickAccessibleAttached *>(qmlAttachedPropertiesObject<QQuickAccessibleAttached>(q, true));
  208. Q_ASSERT(accessibleAttached);
  209. - accessibleAttached->setRole(accessibleRole());
  210. + accessibleAttached->setRole(effectiveAccessibleRole());
  211. accessibleAttached->set_readOnly(q->isReadOnly());
  212. accessibleAttached->setDescription(placeholder);
  213. }
  214. diff --git a/src/quicktemplates2/qquicktextfield.cpp b/src/quicktemplates2/qquicktextfield.cpp
  215. index 8fa04bd3a..e83346cbd 100644
  216. --- a/src/quicktemplates2/qquicktextfield.cpp
  217. +++ b/src/quicktemplates2/qquicktextfield.cpp
  218. @@ -359,7 +359,7 @@ void QQuickTextFieldPrivate::accessibilityActiveChanged(bool active)
  219. Q_Q(QQuickTextField);
  220. QQuickAccessibleAttached *accessibleAttached = qobject_cast<QQuickAccessibleAttached *>(qmlAttachedPropertiesObject<QQuickAccessibleAttached>(q, true));
  221. Q_ASSERT(accessibleAttached);
  222. - accessibleAttached->setRole(accessibleRole());
  223. + accessibleAttached->setRole(effectiveAccessibleRole());
  224. accessibleAttached->set_readOnly(m_readOnly);
  225. accessibleAttached->set_passwordEdit((m_echoMode == QQuickTextField::Password || m_echoMode == QQuickTextField::PasswordEchoOnEdit) ? true : false);
  226. accessibleAttached->setDescription(placeholder);
  227. diff --git a/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml b/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml
  228. new file mode 100644
  229. index 000000000..9e4598b9f
  230. --- /dev/null
  231. +++ b/tests/auto/qquickpopup/data/releaseAfterExitTransition.qml
  232. @@ -0,0 +1,78 @@
  233. +/****************************************************************************
  234. +**
  235. +** Copyright (C) 2021 The Qt Company Ltd.
  236. +** Contact: https://www.qt.io/licensing/
  237. +**
  238. +** This file is part of the test suite of the Qt Toolkit.
  239. +**
  240. +** $QT_BEGIN_LICENSE:BSD$
  241. +** Commercial License Usage
  242. +** Licensees holding valid commercial Qt licenses may use this file in
  243. +** accordance with the commercial license agreement provided with the
  244. +** Software or, alternatively, in accordance with the terms contained in
  245. +** a written agreement between you and The Qt Company. For licensing terms
  246. +** and conditions see https://www.qt.io/terms-conditions. For further
  247. +** information use the contact form at https://www.qt.io/contact-us.
  248. +**
  249. +** BSD License Usage
  250. +** Alternatively, you may use this file under the terms of the BSD license
  251. +** as follows:
  252. +**
  253. +** "Redistribution and use in source and binary forms, with or without
  254. +** modification, are permitted provided that the following conditions are
  255. +** met:
  256. +** * Redistributions of source code must retain the above copyright
  257. +** notice, this list of conditions and the following disclaimer.
  258. +** * Redistributions in binary form must reproduce the above copyright
  259. +** notice, this list of conditions and the following disclaimer in
  260. +** the documentation and/or other materials provided with the
  261. +** distribution.
  262. +** * Neither the name of The Qt Company Ltd nor the names of its
  263. +** contributors may be used to endorse or promote products derived
  264. +** from this software without specific prior written permission.
  265. +**
  266. +**
  267. +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  268. +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  269. +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  270. +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  271. +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  272. +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  273. +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  274. +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  275. +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  276. +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  277. +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
  278. +**
  279. +** $QT_END_LICENSE$
  280. +**
  281. +****************************************************************************/
  282. +
  283. +import QtQuick 2.15
  284. +import QtQuick.Controls 2.15
  285. +
  286. +ApplicationWindow {
  287. + id: window
  288. + width: 400
  289. + height: 400
  290. + title: "releaseAfterExitTransition"
  291. +
  292. + property alias popup: popup
  293. + property alias modalPopup: modalPopup
  294. +
  295. + Popup {
  296. + id: popup
  297. + y: parent.height - height
  298. + width: 50
  299. + height: 50
  300. + }
  301. +
  302. + Popup {
  303. + id: modalPopup
  304. + modal: true
  305. + y: parent.height - height
  306. + width: 50
  307. + height: 50
  308. + exit: Transition { PauseAnimation { duration: 100 } }
  309. + }
  310. +}
  311. diff --git a/tests/auto/qquickpopup/tst_qquickpopup.cpp b/tests/auto/qquickpopup/tst_qquickpopup.cpp
  312. index 54952d128..3d50e2dd4 100644
  313. --- a/tests/auto/qquickpopup/tst_qquickpopup.cpp
  314. +++ b/tests/auto/qquickpopup/tst_qquickpopup.cpp
  315. @@ -100,6 +100,7 @@ private slots:
  316. void invisibleToolTipOpen();
  317. void centerInOverlayWithinStackViewItem();
  318. void destroyDuringExitTransition();
  319. + void releaseAfterExitTransition();
  320. };
  321. void tst_QQuickPopup::initTestCase()
  322. @@ -1575,6 +1576,34 @@ void tst_QQuickPopup::destroyDuringExitTransition()
  323. QVERIFY(!button->isDown());
  324. }
  325. +void tst_QQuickPopup::releaseAfterExitTransition()
  326. +{
  327. + QQuickApplicationHelper helper(this, "releaseAfterExitTransition.qml");
  328. + QVERIFY2(helper.ready, helper.failureMessage());
  329. +
  330. + QQuickWindow *window = helper.window;
  331. + window->show();
  332. + QVERIFY(QTest::qWaitForWindowActive(window));
  333. +
  334. + QQuickOverlay *overlay = QQuickOverlay::overlay(window);
  335. + QQuickPopup *modalPopup = window->property("modalPopup").value<QQuickPopup *>();
  336. + QQuickPopup *popup = window->property("popup").value<QQuickPopup *>();
  337. +
  338. + modalPopup->open();
  339. + QTRY_VERIFY(modalPopup->isOpened());
  340. +
  341. + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
  342. + // wait until the transition is finished and the overlay hides itself
  343. + QTRY_VERIFY(!overlay->isVisible());
  344. + QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
  345. +
  346. + popup->open();
  347. + QTRY_VERIFY(popup->isOpened());
  348. + QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1));
  349. + QTRY_VERIFY(!popup->isOpened());
  350. +}
  351. +
  352. +
  353. QTEST_QUICKCONTROLS_MAIN(tst_QQuickPopup)
  354. #include "tst_qquickpopup.moc"