diff options
author | Mitch Curtis <mitch.curtis@qt.io> | 2021-08-10 11:30:40 +0200 |
---|---|---|
committer | Mitch Curtis <mitch.curtis@qt.io> | 2021-08-13 11:07:34 +0000 |
commit | becc91d332cf8730820b3fa1f48223b88b07cee8 (patch) | |
tree | fff447fcf9bca4e8f936f143269bf61a8832e399 | |
parent | 9a2a294dd9320d077caaa5afd97eab5d12a84a44 (diff) |
Revert "Allow creation of custom QQuickPopupItem-derived types"
This reverts commit 851acd642bf9d20c452286f9790f73925b64d173.
The follow-up commit a063cd0be5e8f108a0084831856f4af8c0e9159c
causes QTBUG-94764, so we don't need this enabling change for now.
Task-number: QTBUG-83630
Task-number: QTBUG-94764
Change-Id: I1aec8571dcdcc2103d0e56c3d0bbfc4a4872d8db
(adapted from commit b69d071c10dfa4c5d7b62692b8a9d7bb659a4ab5)
Reviewed-by: Daniel Smith <Daniel.Smith@qt.io>
-rw-r--r-- | src/quicktemplates2/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/quicktemplates2/qquickmenu.cpp | 1 | ||||
-rw-r--r-- | src/quicktemplates2/qquickmenu_p_p.h | 2 | ||||
-rw-r--r-- | src/quicktemplates2/qquickpopup.cpp | 17 | ||||
-rw-r--r-- | src/quicktemplates2/qquickpopup_p_p.h | 4 | ||||
-rw-r--r-- | src/quicktemplates2/qquickpopupitem.cpp | 52 | ||||
-rw-r--r-- | src/quicktemplates2/qquickpopupitem_p.h | 119 | ||||
-rw-r--r-- | src/quicktemplates2/qquickpopupitem_p_p.h | 61 |
8 files changed, 82 insertions, 175 deletions
diff --git a/src/quicktemplates2/CMakeLists.txt b/src/quicktemplates2/CMakeLists.txt index 4456723c..47633513 100644 --- a/src/quicktemplates2/CMakeLists.txt +++ b/src/quicktemplates2/CMakeLists.txt @@ -68,7 +68,6 @@ qt_internal_add_module(QuickTemplates2 qquickpopupanchors.cpp qquickpopupanchors_p.h qquickpopupanchors_p_p.h qquickpopupitem.cpp - qquickpopupitem_p.h qquickpopupitem_p_p.h qquickpopuppositioner.cpp qquickpopuppositioner_p_p.h diff --git a/src/quicktemplates2/qquickmenu.cpp b/src/quicktemplates2/qquickmenu.cpp index c4b7c67d..58b5a640 100644 --- a/src/quicktemplates2/qquickmenu.cpp +++ b/src/quicktemplates2/qquickmenu.cpp @@ -225,7 +225,6 @@ QQuickMenuPrivate::QQuickMenuPrivate() void QQuickMenuPrivate::init() { Q_Q(QQuickMenu); - QQuickPopupPrivate::init(); contentModel = new QQmlObjectModel(q); } diff --git a/src/quicktemplates2/qquickmenu_p_p.h b/src/quicktemplates2/qquickmenu_p_p.h index df51f1f3..86701d9b 100644 --- a/src/quicktemplates2/qquickmenu_p_p.h +++ b/src/quicktemplates2/qquickmenu_p_p.h @@ -73,7 +73,7 @@ public: return menu->d_func(); } - void init() override; + void init(); QQuickItem *itemAt(int index) const; void insertItem(int index, QQuickItem *item); diff --git a/src/quicktemplates2/qquickpopup.cpp b/src/quicktemplates2/qquickpopup.cpp index 392430c5..f54b610c 100644 --- a/src/quicktemplates2/qquickpopup.cpp +++ b/src/quicktemplates2/qquickpopup.cpp @@ -275,21 +275,9 @@ QQuickPopupPrivate::QQuickPopupPrivate() void QQuickPopupPrivate::init() { Q_Q(QQuickPopup); - createPopupItem(); + popupItem = new QQuickPopupItem(q); popupItem->setVisible(false); q->setParentItem(qobject_cast<QQuickItem *>(parent)); - connectToPopupItem(); -} - -void QQuickPopupPrivate::createPopupItem() -{ - Q_Q(QQuickPopup); - popupItem = new QQuickPopupItem(q); -} - -void QQuickPopupPrivate::connectToPopupItem() -{ - Q_Q(QQuickPopup); QObject::connect(popupItem, &QQuickControl::paddingChanged, q, &QQuickPopup::paddingChanged); QObject::connect(popupItem, &QQuickControl::backgroundChanged, q, &QQuickPopup::backgroundChanged); QObject::connect(popupItem, &QQuickControl::contentItemChanged, q, &QQuickPopup::contentItemChanged); @@ -865,7 +853,8 @@ QQuickPopup::QQuickPopup(QObject *parent) QQuickPopup::QQuickPopup(QQuickPopupPrivate &dd, QObject *parent) : QObject(dd, parent) { - dd.init(); + Q_D(QQuickPopup); + d->init(); } QQuickPopup::~QQuickPopup() diff --git a/src/quicktemplates2/qquickpopup_p_p.h b/src/quicktemplates2/qquickpopup_p_p.h index 57183011..3e9d3d73 100644 --- a/src/quicktemplates2/qquickpopup_p_p.h +++ b/src/quicktemplates2/qquickpopup_p_p.h @@ -101,9 +101,7 @@ public: QQmlListProperty<QObject> contentData(); QQmlListProperty<QQuickItem> contentChildren(); - virtual void init(); - void createPopupItem(); - void connectToPopupItem(); + void init(); void closeOrReject(); bool tryClose(const QPointF &pos, QQuickPopup::ClosePolicy flags); diff --git a/src/quicktemplates2/qquickpopupitem.cpp b/src/quicktemplates2/qquickpopupitem.cpp index 0381dac2..a142b454 100644 --- a/src/quicktemplates2/qquickpopupitem.cpp +++ b/src/quicktemplates2/qquickpopupitem.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2021 The Qt Company Ltd. +** Copyright (C) 2017 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the Qt Quick Templates 2 module of the Qt Toolkit. @@ -59,30 +59,6 @@ QQuickPopupItemPrivate::QQuickPopupItemPrivate(QQuickPopup *popup) isTabFence = true; } -void QQuickPopupItemPrivate::init() -{ - Q_Q(QQuickPopupItem); - q->setParent(popup); - q->setFlag(QQuickItem::ItemIsFocusScope); - q->setAcceptedMouseButtons(Qt::AllButtons); -#if QT_CONFIG(quicktemplates2_multitouch) - q->setAcceptTouchEvents(true); -#endif -#if QT_CONFIG(cursor) - q->setCursor(Qt::ArrowCursor); -#endif - - q->connect(popup, &QQuickPopup::paletteChanged, q, &QQuickItem::paletteChanged); - q->connect(popup, &QQuickPopup::paletteCreated, q, &QQuickItem::paletteCreated); - -#if QT_CONFIG(quicktemplates2_hover) - // TODO: switch to QStyleHints::useHoverEffects in Qt 5.8 - q->setHoverEnabled(true); - // setAcceptHoverEvents(QGuiApplication::styleHints()->useHoverEffects()); - // connect(QGuiApplication::styleHints(), &QStyleHints::useHoverEffectsChanged, this, &QQuickItem::setAcceptHoverEvents); -#endif -} - void QQuickPopupItemPrivate::implicitWidthChanged() { QQuickPagePrivate::implicitWidthChanged(); @@ -151,15 +127,25 @@ void QQuickPopupItemPrivate::executeBackground(bool complete) QQuickPopupItem::QQuickPopupItem(QQuickPopup *popup) : QQuickPage(*(new QQuickPopupItemPrivate(popup)), nullptr) { - Q_D(QQuickPopupItem); - d->init(); -} + setParent(popup); + setFlag(ItemIsFocusScope); + setAcceptedMouseButtons(Qt::AllButtons); +#if QT_CONFIG(quicktemplates2_multitouch) + setAcceptTouchEvents(true); +#endif +#if QT_CONFIG(cursor) + setCursor(Qt::ArrowCursor); +#endif -QQuickPopupItem::QQuickPopupItem(QQuickPopupItemPrivate &dd) : - QQuickPage(dd, nullptr) -{ - Q_D(QQuickPopupItem); - d->init(); + connect(popup, &QQuickPopup::paletteChanged, this, &QQuickItem::paletteChanged); + connect(popup, &QQuickPopup::paletteCreated, this, &QQuickItem::paletteCreated); + +#if QT_CONFIG(quicktemplates2_hover) + // TODO: switch to QStyleHints::useHoverEffects in Qt 5.8 + setHoverEnabled(true); + // setAcceptHoverEvents(QGuiApplication::styleHints()->useHoverEffects()); + // connect(QGuiApplication::styleHints(), &QStyleHints::useHoverEffectsChanged, this, &QQuickItem::setAcceptHoverEvents); +#endif } void QQuickPopupItem::grabShortcut() diff --git a/src/quicktemplates2/qquickpopupitem_p.h b/src/quicktemplates2/qquickpopupitem_p.h deleted file mode 100644 index db444ddc..00000000 --- a/src/quicktemplates2/qquickpopupitem_p.h +++ /dev/null @@ -1,119 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2021 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the Qt Quick Templates 2 module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QQUICKPOPUPITEM_P_H -#define QQUICKPOPUPITEM_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <QtQuickTemplates2/private/qquickpage_p.h> -#include <QtQuickTemplates2/private/qquickpage_p_p.h> - -QT_BEGIN_NAMESPACE - -class QQuickPopup; -class QQuickPopupItemPrivate; - -class QQuickPopupItem : public QQuickPage -{ - Q_OBJECT - -public: - explicit QQuickPopupItem(QQuickPopup *popup); - - void grabShortcut(); - void ungrabShortcut(); - -protected: - void updatePolish() override; - - bool event(QEvent *event) override; - bool childMouseEventFilter(QQuickItem *child, QEvent *event) override; - void focusInEvent(QFocusEvent *event) override; - void focusOutEvent(QFocusEvent *event) override; - void keyPressEvent(QKeyEvent *event) override; - void keyReleaseEvent(QKeyEvent *event) override; - void mousePressEvent(QMouseEvent *event) override; - void mouseMoveEvent(QMouseEvent *event) override; - void mouseReleaseEvent(QMouseEvent *event) override; - void mouseDoubleClickEvent(QMouseEvent *event) override; - void mouseUngrabEvent() override; -#if QT_CONFIG(quicktemplates2_multitouch) - void touchEvent(QTouchEvent *event) override; - void touchUngrabEvent() override; -#endif -#if QT_CONFIG(wheelevent) - void wheelEvent(QWheelEvent *event) override; -#endif - - void contentItemChange(QQuickItem *newItem, QQuickItem *oldItem) override; - void contentSizeChange(const QSizeF &newSize, const QSizeF &oldSize) override; - void fontChange(const QFont &newFont, const QFont &oldFont) override; - void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override; - void localeChange(const QLocale &newLocale, const QLocale &oldLocale) override; - void mirrorChange() override; - void itemChange(ItemChange change, const ItemChangeData &data) override; - void paddingChange(const QMarginsF &newPadding, const QMarginsF &oldPadding) override; - void enabledChange() override; - - QFont defaultFont() const override; - -#if QT_CONFIG(accessibility) - QAccessible::Role accessibleRole() const override; - void accessibilityActiveChanged(bool active) override; -#endif - -protected: - QQuickPopupItem(QQuickPopupItemPrivate &dd); - -private: - Q_DISABLE_COPY(QQuickPopupItem) - Q_DECLARE_PRIVATE(QQuickPopupItem) - friend class QQuickPopup; -}; - -QT_END_NAMESPACE - -#endif // QQUICKPOPUPITEM_P_H diff --git a/src/quicktemplates2/qquickpopupitem_p_p.h b/src/quicktemplates2/qquickpopupitem_p_p.h index b3224be7..e4ef6d9c 100644 --- a/src/quicktemplates2/qquickpopupitem_p_p.h +++ b/src/quicktemplates2/qquickpopupitem_p_p.h @@ -48,11 +48,68 @@ // We mean it. // -#include <QtQuickTemplates2/private/qquickpopupitem_p.h> +#include <QtQuickTemplates2/private/qquickpage_p.h> +#include <QtQuickTemplates2/private/qquickpage_p_p.h> QT_BEGIN_NAMESPACE class QQuickPopup; +class QQuickPopupItemPrivate; + +class QQuickPopupItem : public QQuickPage +{ + Q_OBJECT + +public: + explicit QQuickPopupItem(QQuickPopup *popup); + + void grabShortcut(); + void ungrabShortcut(); + +protected: + void updatePolish() override; + + bool event(QEvent *event) override; + bool childMouseEventFilter(QQuickItem *child, QEvent *event) override; + void focusInEvent(QFocusEvent *event) override; + void focusOutEvent(QFocusEvent *event) override; + void keyPressEvent(QKeyEvent *event) override; + void keyReleaseEvent(QKeyEvent *event) override; + void mousePressEvent(QMouseEvent *event) override; + void mouseMoveEvent(QMouseEvent *event) override; + void mouseReleaseEvent(QMouseEvent *event) override; + void mouseDoubleClickEvent(QMouseEvent *event) override; + void mouseUngrabEvent() override; +#if QT_CONFIG(quicktemplates2_multitouch) + void touchEvent(QTouchEvent *event) override; + void touchUngrabEvent() override; +#endif +#if QT_CONFIG(wheelevent) + void wheelEvent(QWheelEvent *event) override; +#endif + + void contentItemChange(QQuickItem *newItem, QQuickItem *oldItem) override; + void contentSizeChange(const QSizeF &newSize, const QSizeF &oldSize) override; + void fontChange(const QFont &newFont, const QFont &oldFont) override; + void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override; + void localeChange(const QLocale &newLocale, const QLocale &oldLocale) override; + void mirrorChange() override; + void itemChange(ItemChange change, const ItemChangeData &data) override; + void paddingChange(const QMarginsF &newPadding, const QMarginsF &oldPadding) override; + void enabledChange() override; + + QFont defaultFont() const override; + +#if QT_CONFIG(accessibility) + QAccessible::Role accessibleRole() const override; + void accessibilityActiveChanged(bool active) override; +#endif + +private: + Q_DISABLE_COPY(QQuickPopupItem) + Q_DECLARE_PRIVATE(QQuickPopupItem) + friend class QQuickPopup; +}; class QQuickPopupItemPrivate : public QQuickPagePrivate { @@ -61,8 +118,6 @@ class QQuickPopupItemPrivate : public QQuickPagePrivate public: QQuickPopupItemPrivate(QQuickPopup *popup); - void init(); - void implicitWidthChanged() override; void implicitHeightChanged() override; |