Commit b69d071c authored by Mitch Curtis's avatar Mitch Curtis
Browse files

Revert "Allow creation of custom QQuickPopupItem-derived types"

This reverts commit 6b8a9673.

The follow-up commit a063cd0b


causes QTBUG-94764, so we don't need this enabling change for now.

Task-number: QTBUG-83630
Task-number: QTBUG-94764
Pick-to: 5.15 6.1 6.2
Change-Id: I1aec8571dcdcc2103d0e56c3d0bbfc4a4872d8db
Reviewed-by: default avatarRichard Moe Gustavsen <richard.gustavsen@qt.io>
parent ebad2bf1
......@@ -71,7 +71,6 @@ qt_internal_add_qml_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
......
......@@ -225,7 +225,6 @@ QQuickMenuPrivate::QQuickMenuPrivate()
void QQuickMenuPrivate::init()
{
Q_Q(QQuickMenu);
QQuickPopupPrivate::init();
contentModel = new QQmlObjectModel(q);
}
......
......@@ -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);
......
......@@ -277,21 +277,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);
......@@ -880,7 +868,8 @@ QQuickPopup::QQuickPopup(QObject *parent)
QQuickPopup::QQuickPopup(QQuickPopupPrivate &dd, QObject *parent)
: QObject(dd, parent)
{
dd.init();
Q_D(QQuickPopup);
d->init();
}
QQuickPopup::~QQuickPopup()
......
......@@ -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);
......
/****************************************************************************
**
** 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()
......
/****************************************************************************
**
** 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 Q_QUICKTEMPLATES2_PRIVATE_EXPORT 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
......@@ -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 Q_QUICKTEMPLATES2_PRIVATE_EXPORT 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 Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickPopupItemPrivate : public QQuickPagePrivate
{
......@@ -61,8 +118,6 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickPopupItemPrivate : public QQuickPag
public:
QQuickPopupItemPrivate(QQuickPopup *popup);
void init();
void implicitWidthChanged() override;
void implicitHeightChanged() override;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment