diff options
22 files changed, 242 insertions, 246 deletions
diff --git a/src/imports/controls/ComboBox.qml b/src/imports/controls/ComboBox.qml index 7f2adcb0..3d4e5ed5 100644 --- a/src/imports/controls/ComboBox.qml +++ b/src/imports/controls/ComboBox.qml @@ -85,7 +85,7 @@ T.ComboBox { width: parent.width height: parent.height opacity: control.enabled ? 1.0 : 0.2 - color: control.pressed || panel.visible ? "#585A5C" : "#353637" + color: control.pressed || popup.visible ? "#585A5C" : "#353637" } Image { @@ -96,11 +96,10 @@ T.ComboBox { } //! [background] - //! [panel] - panel: T.Panel { - id: popup + //! [popup] + popup: T.Popup { contentItem: Rectangle { - // TODO: Panel::anchors + // TODO: Popup::anchors readonly property var above: popup.visible ? control.mapToItem(null, 0, -height + 1) : Qt.point(0, 0) readonly property var below: popup.visible ? control.mapToItem(null, 0, control.height - 1) : Qt.point(0, 0) @@ -129,5 +128,5 @@ T.ComboBox { } } } - //! [panel] + //! [popup] } diff --git a/src/imports/controls/doc/images/qtlabscontrols-combobox-panel.png b/src/imports/controls/doc/images/qtlabscontrols-combobox-popup.png Binary files differindex 0e9eacbf..0e9eacbf 100644 --- a/src/imports/controls/doc/images/qtlabscontrols-combobox-panel.png +++ b/src/imports/controls/doc/images/qtlabscontrols-combobox-popup.png diff --git a/src/imports/controls/doc/snippets/qtlabscontrols-combobox-delegate.qml b/src/imports/controls/doc/snippets/qtlabscontrols-combobox-delegate.qml index 47c4f606..60f56940 100644 --- a/src/imports/controls/doc/snippets/qtlabscontrols-combobox-delegate.qml +++ b/src/imports/controls/doc/snippets/qtlabscontrols-combobox-delegate.qml @@ -31,12 +31,12 @@ import Qt.labs.controls 1.0 Item { id: root width: combo.width - height: combo.height + combo.panel.contentItem.height + height: combo.height + combo.popup.contentItem.height ComboBox { id: combo model: ["First", "Second", "Third"] - panel.contentItem.parent: root - panel.contentItem.y: combo.height + popup.contentItem.parent: root + popup.contentItem.y: combo.height delegate: ItemDelegate { width: combo.width text: modelData diff --git a/src/imports/controls/doc/snippets/qtlabscontrols-combobox-panel.qml b/src/imports/controls/doc/snippets/qtlabscontrols-combobox-popup.qml index d1788d55..0fea67d1 100644 --- a/src/imports/controls/doc/snippets/qtlabscontrols-combobox-panel.qml +++ b/src/imports/controls/doc/snippets/qtlabscontrols-combobox-popup.qml @@ -31,15 +31,15 @@ import Qt.labs.controls 1.0 Item { id: root width: combo.width - height: combo.height + combo.panel.contentItem.height + height: combo.height + combo.popup.contentItem.height ComboBox { id: combo model: ["First", "Second", "Third"] - panel.contentItem.parent: root - panel.contentItem.y: combo.height + popup.contentItem.parent: root + popup.contentItem.y: combo.height } Rectangle { - parent: combo.panel.contentItem + parent: combo.popup.contentItem anchors.fill: parent color: 'transparent' border.color: 'red' diff --git a/src/imports/controls/doc/snippets/qtlabscontrols-combobox.qml b/src/imports/controls/doc/snippets/qtlabscontrols-combobox.qml index bac6136d..4d7fe7fd 100644 --- a/src/imports/controls/doc/snippets/qtlabscontrols-combobox.qml +++ b/src/imports/controls/doc/snippets/qtlabscontrols-combobox.qml @@ -31,13 +31,13 @@ import Qt.labs.controls 1.0 Item { id: root width: combo.width - height: combo.height + combo.panel.contentItem.height + height: combo.height + combo.popup.contentItem.height //! [1] ComboBox { id: combo model: ["First", "Second", "Third"] - panel.contentItem.parent: root - panel.contentItem.y: combo.height + popup.contentItem.parent: root + popup.contentItem.y: combo.height } //! [1] } diff --git a/src/imports/controls/doc/src/qtlabscontrols-customize.qdoc b/src/imports/controls/doc/src/qtlabscontrols-customize.qdoc index eb1dc71d..524cd23a 100644 --- a/src/imports/controls/doc/src/qtlabscontrols-customize.qdoc +++ b/src/imports/controls/doc/src/qtlabscontrols-customize.qdoc @@ -99,7 +99,7 @@ \section1 Customizing ComboBox ComboBox consists of \l {Control::background}{background}, - \l {Control::contentItem}{content item}, \l {ComboBox::panel}{panel}, + \l {Control::contentItem}{content item}, \l {ComboBox::popup}{popup}, and \l {ComboBox::delegate}{delegate}. \section3 Background @@ -114,11 +114,11 @@ \snippet ComboBox.qml contentItem - \section3 Panel + \section3 Popup - \image qtlabscontrols-combobox-panel.png + \image qtlabscontrols-combobox-popup.png - \snippet ComboBox.qml panel + \snippet ComboBox.qml popup \section3 Delegate @@ -240,7 +240,7 @@ \section1 Customizing Menu - Menu consists of a \l {Panel::}{contentItem}. + Menu consists of a \l {Popup::}{contentItem}. \section3 Content item diff --git a/src/imports/controls/material/ComboBox.qml b/src/imports/controls/material/ComboBox.qml index 035863f6..13bbdf38 100644 --- a/src/imports/controls/material/ComboBox.qml +++ b/src/imports/controls/material/ComboBox.qml @@ -109,11 +109,10 @@ T.ComboBox { } //! [background] - //! [panel] - panel: T.Panel { - id: popup + //! [popup] + popup: T.Popup { contentItem: Rectangle { - // TODO: Panel::anchors + // TODO: Popup::anchors readonly property var above: popup.visible ? control.mapToItem(null, 0, -height) : Qt.point(0, 0) readonly property var below: popup.visible ? control.mapToItem(null, 0, control.height) : Qt.point(0, 0) @@ -150,5 +149,5 @@ T.ComboBox { } } } - //! [panel] + //! [popup] } diff --git a/src/imports/controls/universal/ComboBox.qml b/src/imports/controls/universal/ComboBox.qml index 0fdcb894..9b47d76a 100644 --- a/src/imports/controls/universal/ComboBox.qml +++ b/src/imports/controls/universal/ComboBox.qml @@ -86,9 +86,9 @@ T.ComboBox { border.width: 2 // ComboBoxBorderThemeThickness border.color: !control.enabled ? control.Universal.baseLowColor : - control.pressed || panel.visible ? control.Universal.baseMediumLowColor : control.Universal.baseMediumLowColor + control.pressed || popup.visible ? control.Universal.baseMediumLowColor : control.Universal.baseMediumLowColor color: !control.enabled ? control.Universal.baseLowColor : - control.pressed || panel.visible ? control.Universal.listMediumColor : control.Universal.altMediumLowColor + control.pressed || popup.visible ? control.Universal.listMediumColor : control.Universal.altMediumLowColor Rectangle { x: 2 @@ -110,11 +110,10 @@ T.ComboBox { } //! [background] - //! [panel] - panel: T.Panel { - id: popup + //! [popup] + popup: T.Popup { contentItem: Rectangle { - // TODO: Panel::anchors + // TODO: Popup::anchors readonly property var above: popup.visible ? control.mapToItem(null, 0, control.height - height) : Qt.point(0, 0) readonly property var below: popup.visible ? control.mapToItem(null, 0, 0) : Qt.point(0, 0) @@ -138,5 +137,5 @@ T.ComboBox { } } } - //! [panel] + //! [popup] } diff --git a/src/imports/templates/qtlabstemplatesplugin.cpp b/src/imports/templates/qtlabstemplatesplugin.cpp index 5e4877f8..44a08fb3 100644 --- a/src/imports/templates/qtlabstemplatesplugin.cpp +++ b/src/imports/templates/qtlabstemplatesplugin.cpp @@ -53,7 +53,7 @@ #include <QtLabsTemplates/private/qquickmenu_p.h> #include <QtLabsTemplates/private/qquickmenuitem_p.h> #include <QtLabsTemplates/private/qquickpageindicator_p.h> -#include <QtLabsTemplates/private/qquickpanel_p.h> +#include <QtLabsTemplates/private/qquickpopup_p.h> #include <QtLabsTemplates/private/qquickprogressbar_p.h> #include <QtLabsTemplates/private/qquickradiobutton_p.h> #include <QtLabsTemplates/private/qquickrangeslider_p.h> @@ -103,7 +103,7 @@ void QtLabsTemplatesPlugin::registerTypes(const char *uri) qmlRegisterType<QQuickMenu>(uri, 1, 0, "Menu"); qmlRegisterType<QQuickMenuItem>(uri, 1, 0, "MenuItem"); qmlRegisterType<QQuickPageIndicator>(uri, 1, 0, "PageIndicator"); - qmlRegisterType<QQuickPanel>(uri, 1, 0, "Panel"); + qmlRegisterType<QQuickPopup>(uri, 1, 0, "Popup"); qmlRegisterType<QQuickProgressBar>(uri, 1, 0, "ProgressBar"); qmlRegisterType<QQuickRadioButton>(uri, 1, 0, "RadioButton"); qmlRegisterType<QQuickRangeSlider>(uri, 1, 0, "RangeSlider"); diff --git a/src/templates/qquickcombobox.cpp b/src/templates/qquickcombobox.cpp index 0f56567e..7c3707a7 100644 --- a/src/templates/qquickcombobox.cpp +++ b/src/templates/qquickcombobox.cpp @@ -37,7 +37,7 @@ #include "qquickcombobox_p.h" #include "qquickcontrol_p_p.h" #include "qquickabstractbutton_p.h" -#include "qquickpanel_p.h" +#include "qquickpopup_p.h" #include <QtCore/qregexp.h> #include <QtQml/qjsvalue.h> @@ -123,12 +123,12 @@ class QQuickComboBoxPrivate : public QQuickControlPrivate public: QQuickComboBoxPrivate() : pressed(false), ownModel(false), hasDisplayText(false), hideTimer(0), highlightedIndex(-1), currentIndex(-1), delegateModel(Q_NULLPTR), - delegate(Q_NULLPTR), panel(Q_NULLPTR) { } + delegate(Q_NULLPTR), popup(Q_NULLPTR) { } - bool isPanelVisible() const; - void showPanel(); - void hidePanel(bool accept); - void togglePanel(bool accept); + bool isPopupVisible() const; + void showPopup(); + void hidePopup(bool accept); + void togglePopup(bool accept); void pressedOutside(); void itemClicked(); @@ -155,26 +155,26 @@ public: QQuickItem *pressedItem; QQmlInstanceModel *delegateModel; QQmlComponent *delegate; - QQuickPanel *panel; + QQuickPopup *popup; }; -bool QQuickComboBoxPrivate::isPanelVisible() const +bool QQuickComboBoxPrivate::isPopupVisible() const { - return panel && panel->isVisible(); + return popup && popup->isVisible(); } -void QQuickComboBoxPrivate::showPanel() +void QQuickComboBoxPrivate::showPopup() { - if (panel && !panel->isVisible()) - panel->show(); + if (popup && !popup->isVisible()) + popup->show(); setHighlightedIndex(currentIndex); } -void QQuickComboBoxPrivate::hidePanel(bool accept) +void QQuickComboBoxPrivate::hidePopup(bool accept) { Q_Q(QQuickComboBox); - if (panel && panel->isVisible()) - panel->hide(); + if (popup && popup->isVisible()) + popup->hide(); if (accept) { q->setCurrentIndex(highlightedIndex); emit q->activated(currentIndex); @@ -182,15 +182,15 @@ void QQuickComboBoxPrivate::hidePanel(bool accept) setHighlightedIndex(-1); } -void QQuickComboBoxPrivate::togglePanel(bool accept) +void QQuickComboBoxPrivate::togglePopup(bool accept) { - if (!panel) + if (!popup) return; - if (panel->isVisible()) - hidePanel(accept); + if (popup->isVisible()) + hidePopup(accept); else - showPanel(); + showPopup(); } void QQuickComboBoxPrivate::pressedOutside() @@ -207,7 +207,7 @@ void QQuickComboBoxPrivate::itemClicked() if (index != -1) { setHighlightedIndex(index); emit q->highlighted(index); - hidePanel(true); + hidePopup(true); } } @@ -246,7 +246,7 @@ void QQuickComboBoxPrivate::updateCurrentText() void QQuickComboBoxPrivate::increase() { Q_Q(QQuickComboBox); - if (isPanelVisible()) { + if (isPopupVisible()) { if (highlightedIndex < q->count() - 1) { setHighlightedIndex(highlightedIndex + 1); emit q->highlighted(highlightedIndex); @@ -262,7 +262,7 @@ void QQuickComboBoxPrivate::increase() void QQuickComboBoxPrivate::decrease() { Q_Q(QQuickComboBox); - if (isPanelVisible()) { + if (isPopupVisible()) { if (highlightedIndex > 0) { setHighlightedIndex(highlightedIndex - 1); emit q->highlighted(highlightedIndex); @@ -560,27 +560,27 @@ void QQuickComboBox::setDelegate(QQmlComponent* delegate) } /*! - \qmlproperty Panel Qt.labs.controls::ComboBox::panel + \qmlproperty Popup Qt.labs.controls::ComboBox::popup - This property holds the popup panel. + This property holds the popup. \sa {Customizing ComboBox} */ -QQuickPanel *QQuickComboBox::panel() const +QQuickPopup *QQuickComboBox::popup() const { Q_D(const QQuickComboBox); - return d->panel; + return d->popup; } -void QQuickComboBox::setPanel(QQuickPanel *panel) +void QQuickComboBox::setPopup(QQuickPopup *popup) { Q_D(QQuickComboBox); - if (d->panel != panel) { - delete d->panel; - if (panel) - QObjectPrivate::connect(panel, &QQuickPanel::pressedOutside, d, &QQuickComboBoxPrivate::pressedOutside); - d->panel = panel; - emit panelChanged(); + if (d->popup != popup) { + delete d->popup; + if (popup) + QObjectPrivate::connect(popup, &QQuickPopup::pressedOutside, d, &QQuickComboBoxPrivate::pressedOutside); + d->popup = popup; + emit popupChanged(); } } @@ -667,7 +667,7 @@ void QQuickComboBox::focusOutEvent(QFocusEvent *event) { Q_D(QQuickComboBox); QQuickItem::focusOutEvent(event); - d->hidePanel(false); + d->hidePopup(false); setPressed(false); } @@ -675,7 +675,7 @@ void QQuickComboBox::keyPressEvent(QKeyEvent *event) { Q_D(QQuickComboBox); QQuickControl::keyPressEvent(event); - if (!d->panel) + if (!d->popup) return; switch (event->key()) { @@ -686,7 +686,7 @@ void QQuickComboBox::keyPressEvent(QKeyEvent *event) break; case Qt::Key_Enter: case Qt::Key_Return: - if (d->isPanelVisible()) + if (d->isPopupVisible()) setPressed(true); event->accept(); break; @@ -709,23 +709,23 @@ void QQuickComboBox::keyReleaseEvent(QKeyEvent *event) { Q_D(QQuickComboBox); QQuickControl::keyReleaseEvent(event); - if (!d->panel || event->isAutoRepeat()) + if (!d->popup || event->isAutoRepeat()) return; switch (event->key()) { case Qt::Key_Space: - d->togglePanel(true); + d->togglePopup(true); setPressed(false); event->accept(); break; case Qt::Key_Enter: case Qt::Key_Return: - d->hidePanel(true); + d->hidePopup(true); setPressed(false); event->accept(); break; case Qt::Key_Escape: - d->hidePanel(false); + d->hidePopup(false); setPressed(false); event->accept(); break; @@ -752,9 +752,9 @@ void QQuickComboBox::mouseReleaseEvent(QMouseEvent *event) QQuickControl::mouseReleaseEvent(event); if (d->pressed) { setPressed(false); - if (!d->isPanelVisible()) + if (!d->isPopupVisible()) forceActiveFocus(Qt::MouseFocusReason); - d->togglePanel(false); + d->togglePopup(false); } } @@ -772,7 +772,7 @@ void QQuickComboBox::timerEvent(QTimerEvent *event) killTimer(d->hideTimer); d->hideTimer = 0; if (!d->pressed) - d->hidePanel(false); + d->hidePopup(false); } } diff --git a/src/templates/qquickcombobox_p.h b/src/templates/qquickcombobox_p.h index 6c80edc8..21d29714 100644 --- a/src/templates/qquickcombobox_p.h +++ b/src/templates/qquickcombobox_p.h @@ -52,7 +52,7 @@ QT_BEGIN_NAMESPACE -class QQuickPanel; +class QQuickPopup; class QQmlInstanceModel; class QQuickComboBoxPrivate; @@ -69,7 +69,7 @@ class Q_LABSTEMPLATES_EXPORT QQuickComboBox : public QQuickControl Q_PROPERTY(QString displayText READ displayText WRITE setDisplayText RESET resetDisplayText NOTIFY displayTextChanged FINAL) Q_PROPERTY(QString textRole READ textRole WRITE setTextRole NOTIFY textRoleChanged FINAL) Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged FINAL) - Q_PROPERTY(QQuickPanel *panel READ panel WRITE setPanel NOTIFY panelChanged FINAL) + Q_PROPERTY(QQuickPopup *popup READ popup WRITE setPopup NOTIFY popupChanged FINAL) public: explicit QQuickComboBox(QQuickItem *parent = Q_NULLPTR); @@ -100,8 +100,8 @@ public: QQmlComponent *delegate() const; void setDelegate(QQmlComponent *delegate); - QQuickPanel *panel() const; - void setPanel(QQuickPanel *panel); + QQuickPopup *popup() const; + void setPopup(QQuickPopup *popup); Q_INVOKABLE QString textAt(int index) const; Q_INVOKABLE int find(const QString &text, Qt::MatchFlags flags = Qt::MatchExactly) const; @@ -117,7 +117,7 @@ Q_SIGNALS: void displayTextChanged(); void textRoleChanged(); void delegateChanged(); - void panelChanged(); + void popupChanged(); void activated(int index); void highlighted(int index); diff --git a/src/templates/qquickmenu.cpp b/src/templates/qquickmenu.cpp index 7efc9765..27c7094d 100644 --- a/src/templates/qquickmenu.cpp +++ b/src/templates/qquickmenu.cpp @@ -36,7 +36,6 @@ #include "qquickmenu_p.h" #include "qquickmenu_p_p.h" -#include "qquickpanel_p_p.h" #include "qquickmenuitem_p.h" #include <QtGui/qevent.h> @@ -50,7 +49,7 @@ QT_BEGIN_NAMESPACE /*! \qmltype Menu - \inherits Panel + \inherits Popup \instantiates QQuickMenu \inqmlmodule Qt.labs.controls \ingroup qtlabscontrols-menus @@ -268,7 +267,7 @@ void QQuickMenuPrivate::contentData_append(QQmlListProperty<QObject> *prop, QObj QQuickMenuItem *menuItem = qobject_cast<QQuickMenuItem *>(item); if (menuItem) { QObjectPrivate::connect(menuItem, &QQuickMenuItem::pressed, p, &QQuickMenuPrivate::onItemPressed); - QObject::connect(menuItem, &QQuickMenuItem::triggered, q, &QQuickPanel::hide); + QObject::connect(menuItem, &QQuickMenuItem::triggered, q, &QQuickPopup::hide); QObjectPrivate::connect(menuItem, &QQuickItem::activeFocusChanged, p, &QQuickMenuPrivate::onItemActiveFocusChanged); } } @@ -296,7 +295,7 @@ void QQuickMenuPrivate::contentData_clear(QQmlListProperty<QObject> *prop) } QQuickMenu::QQuickMenu(QObject *parent) : - QQuickPanel(*(new QQuickMenuPrivate), parent) + QQuickPopup(*(new QQuickMenuPrivate), parent) { Q_D(QQuickMenu); connect(this, &QQuickMenu::pressedOutside, this, &QQuickMenu::hide); diff --git a/src/templates/qquickmenu_p.h b/src/templates/qquickmenu_p.h index cd079d4e..a9151fd7 100644 --- a/src/templates/qquickmenu_p.h +++ b/src/templates/qquickmenu_p.h @@ -50,14 +50,14 @@ #include <QtQml/qqmllist.h> -#include "qquickpanel_p.h" +#include "qquickpopup_p.h" QT_BEGIN_NAMESPACE class QQuickMenuItem; class QQuickMenuPrivate; -class Q_LABSTEMPLATES_EXPORT QQuickMenu : public QQuickPanel +class Q_LABSTEMPLATES_EXPORT QQuickMenu : public QQuickPopup { Q_OBJECT Q_PROPERTY(QVariant contentModel READ contentModel CONSTANT FINAL) diff --git a/src/templates/qquickmenu_p_p.h b/src/templates/qquickmenu_p_p.h index 166d184b..a5e99f1c 100644 --- a/src/templates/qquickmenu_p_p.h +++ b/src/templates/qquickmenu_p_p.h @@ -51,13 +51,13 @@ #include <QtCore/qvector.h> #include <QtQuick/private/qquickitemchangelistener_p.h> -#include <QtLabsTemplates/private/qquickpanel_p_p.h> +#include <QtLabsTemplates/private/qquickpopup_p_p.h> QT_BEGIN_NAMESPACE class QQmlObjectModel; -class Q_LABSTEMPLATES_EXPORT QQuickMenuPrivate : public QQuickPanelPrivate, public QQuickItemChangeListener +class Q_LABSTEMPLATES_EXPORT QQuickMenuPrivate : public QQuickPopupPrivate, public QQuickItemChangeListener { Q_DECLARE_PUBLIC(QQuickMenu) diff --git a/src/templates/qquickoverlay.cpp b/src/templates/qquickoverlay.cpp index 4a00387a..84495bf0 100644 --- a/src/templates/qquickoverlay.cpp +++ b/src/templates/qquickoverlay.cpp @@ -35,14 +35,14 @@ ****************************************************************************/ #include "qquickoverlay_p.h" -#include "qquickpanel_p.h" +#include "qquickpopup_p.h" #include <QtQml/qqmlinfo.h> #include <QtQuick/private/qquickitem_p.h> QT_BEGIN_NAMESPACE QQuickOverlay::QQuickOverlay(QQuickItem *parent) - : QQuickItem(parent), m_modalPanels(0) + : QQuickItem(parent), m_modalPopups(0) { setAcceptedMouseButtons(Qt::AllButtons); setFiltersChildMouseEvents(true); @@ -53,70 +53,70 @@ void QQuickOverlay::itemChange(ItemChange change, const ItemChangeData &data) { QQuickItem::itemChange(change, data); - QQuickItem *panelItem = const_cast<QQuickItem *>(data.item); - QQuickPanel *panel = Q_NULLPTR; + QQuickItem *contentItem = const_cast<QQuickItem *>(data.item); + QQuickPopup *popup = Q_NULLPTR; if (change == ItemChildAddedChange || change == ItemChildRemovedChange) { - panel = qobject_cast<QQuickPanel *>(panelItem->parent()); + popup = qobject_cast<QQuickPopup *>(contentItem->parent()); setVisible(!childItems().isEmpty()); } - if (!panel) + if (!popup) return; if (change == ItemChildAddedChange) { - if (QQuickPanel *prevPanel = m_panels.value(panelItem)) { - qmlInfo(panel).nospace() << "Panel is sharing item " << panelItem << " with " << prevPanel + if (QQuickPopup *prevPopup = m_popups.value(contentItem)) { + qmlInfo(popup).nospace() << "Popup is sharing item " << contentItem << " with " << prevPopup << ". This is not supported and strange things are about to happen."; return; } - m_panels.insert(panelItem, panel); - if (panel->isModal()) - ++m_modalPanels; + m_popups.insert(contentItem, popup); + if (popup->isModal()) + ++m_modalPopups; - connect(this, &QQuickOverlay::pressed, panel, &QQuickPanel::pressedOutside); - connect(this, &QQuickOverlay::released, panel, &QQuickPanel::releasedOutside); + connect(this, &QQuickOverlay::pressed, popup, &QQuickPopup::pressedOutside); + connect(this, &QQuickOverlay::released, popup, &QQuickPopup::releasedOutside); } else if (change == ItemChildRemovedChange) { - Q_ASSERT(panel == m_panels.value(panelItem)); + Q_ASSERT(popup == m_popups.value(contentItem)); - disconnect(this, &QQuickOverlay::pressed, panel, &QQuickPanel::pressedOutside); - disconnect(this, &QQuickOverlay::released, panel, &QQuickPanel::releasedOutside); + disconnect(this, &QQuickOverlay::pressed, popup, &QQuickPopup::pressedOutside); + disconnect(this, &QQuickOverlay::released, popup, &QQuickPopup::releasedOutside); - if (panel->isModal()) - --m_modalPanels; - m_panels.remove(panelItem); + if (popup->isModal()) + --m_modalPopups; + m_popups.remove(contentItem); } } void QQuickOverlay::keyPressEvent(QKeyEvent *event) { - event->setAccepted(m_modalPanels > 0); + event->setAccepted(m_modalPopups > 0); } void QQuickOverlay::keyReleaseEvent(QKeyEvent *event) { - event->setAccepted(m_modalPanels > 0); + event->setAccepted(m_modalPopups > 0); } void QQuickOverlay::mousePressEvent(QMouseEvent *event) { - event->setAccepted(m_modalPanels > 0); + event->setAccepted(m_modalPopups > 0); emit pressed(); } void QQuickOverlay::mouseMoveEvent(QMouseEvent *event) { - event->setAccepted(m_modalPanels > 0); + event->setAccepted(m_modalPopups > 0); } void QQuickOverlay::mouseReleaseEvent(QMouseEvent *event) { - event->setAccepted(m_modalPanels > 0); + event->setAccepted(m_modalPopups > 0); emit released(); } bool QQuickOverlay::childMouseEventFilter(QQuickItem *item, QEvent *event) { - if (m_modalPanels == 0) + if (m_modalPopups == 0) return false; // TODO Filter touch events if (event->type() != QEvent::MouseButtonPress) @@ -128,15 +128,15 @@ bool QQuickOverlay::childMouseEventFilter(QQuickItem *item, QEvent *event) const QQuickItemPrivate *priv = QQuickItemPrivate::get(this); const QList<QQuickItem *> &sortedChildren = priv->paintOrderChildItems(); for (int i = sortedChildren.count() - 1; i >= 0; --i) { - QQuickItem *panelItem = sortedChildren[i]; - if (panelItem == item) + QQuickItem *contentItem = sortedChildren[i]; + if (contentItem == item) break; - QQuickPanel *panel = m_panels.value(panelItem); - if (panel) { - emit panel->pressedOutside(); + QQuickPopup *popup = m_popups.value(contentItem); + if (popup) { + emit popup->pressedOutside(); - if (!modalBlocked && panel->isModal()) + if (!modalBlocked && popup->isModal()) modalBlocked = true; } } diff --git a/src/templates/qquickoverlay_p.h b/src/templates/qquickoverlay_p.h index c5f9b719..cdba2532 100644 --- a/src/templates/qquickoverlay_p.h +++ b/src/templates/qquickoverlay_p.h @@ -52,7 +52,7 @@ QT_BEGIN_NAMESPACE -class QQuickPanel; +class QQuickPopup; class QQuickOverlay : public QQuickItem { @@ -77,8 +77,8 @@ protected: private: Q_DISABLE_COPY(QQuickOverlay) - QHash<QQuickItem *, QQuickPanel *> m_panels; - int m_modalPanels; + QHash<QQuickItem *, QQuickPopup *> m_popups; + int m_modalPopups; }; QT_END_NAMESPACE diff --git a/src/templates/qquickpanel.cpp b/src/templates/qquickpopup.cpp index 38f1a73c..54ca6df2 100644 --- a/src/templates/qquickpanel.cpp +++ b/src/templates/qquickpopup.cpp @@ -34,8 +34,8 @@ ** ****************************************************************************/ -#include "qquickpanel_p.h" -#include "qquickpanel_p_p.h" +#include "qquickpopup_p.h" +#include "qquickpopup_p_p.h" #include "qquickapplicationwindow_p.h" #include "qquickoverlay_p.h" #include <QtQml/qqmlinfo.h> @@ -46,17 +46,17 @@ QT_BEGIN_NAMESPACE /*! - \qmltype Panel + \qmltype Popup \inherits QtObject - \instantiates QQuickPanel + \instantiates QQuickPopup \inqmlmodule Qt.labs.controls \ingroup qtlabscontrols-popups - \brief A popup panel. + \brief A popup control. - Panel is the base type of popup-like user interface controls. + Popup is the base type of popup-like user interface controls. */ -QQuickPanelPrivate::QQuickPanelPrivate() +QQuickPopupPrivate::QQuickPopupPrivate() : QObjectPrivate() , contentItem(Q_NULLPTR) , overlay(Q_NULLPTR) @@ -67,29 +67,29 @@ QQuickPanelPrivate::QQuickPanelPrivate() , transitionManager(this) { } -QQuickPanelPrivate::~QQuickPanelPrivate() +QQuickPopupPrivate::~QQuickPopupPrivate() { } -void QQuickPanelPrivate::finalizeShowTransition() +void QQuickPopupPrivate::finalizeShowTransition() { if (focus) contentItem->setFocus(true); } -void QQuickPanelPrivate::finalizeHideTransition() +void QQuickPopupPrivate::finalizeHideTransition() { overlay = Q_NULLPTR; contentItem->setParentItem(Q_NULLPTR); emit q_func()->visibleChanged(); } -QQuickPanelTransitionManager::QQuickPanelTransitionManager(QQuickPanelPrivate *priv) +QQuickPopupTransitionManager::QQuickPopupTransitionManager(QQuickPopupPrivate *priv) : QQuickTransitionManager() , state(Off) , pp(priv) { } -void QQuickPanelTransitionManager::transitionShow() +void QQuickPopupTransitionManager::transitionShow() { if (isRunning()) return; @@ -98,7 +98,7 @@ void QQuickPanelTransitionManager::transitionShow() transition(actions, pp->showTransition, pp->contentItem); } -void QQuickPanelTransitionManager::transitionHide() +void QQuickPopupTransitionManager::transitionHide() { if (isRunning()) return; @@ -107,7 +107,7 @@ void QQuickPanelTransitionManager::transitionHide() transition(actions, pp->hideTransition, pp->contentItem); } -void QQuickPanelTransitionManager::finished() +void QQuickPopupTransitionManager::finished() { if (state == Show) pp->finalizeShowTransition(); @@ -117,35 +117,35 @@ void QQuickPanelTransitionManager::finished() state = Off; } -QQuickPanel::QQuickPanel(QObject *parent) - : QObject(*(new QQuickPanelPrivate), parent) +QQuickPopup::QQuickPopup(QObject *parent) + : QObject(*(new QQuickPopupPrivate), parent) { } -QQuickPanel::QQuickPanel(QQuickPanelPrivate &dd, QObject *parent) +QQuickPopup::QQuickPopup(QQuickPopupPrivate &dd, QObject *parent) : QObject(dd, parent) { } -QQuickPanel::~QQuickPanel() +QQuickPopup::~QQuickPopup() { } /*! - \qmlmethod void Qt.labs.controls::Panel::show() + \qmlmethod void Qt.labs.controls::Popup::show() - Shows the panel. + Shows the popup. */ -void QQuickPanel::show() +void QQuickPopup::show() { - Q_D(QQuickPanel); + Q_D(QQuickPopup); if (!d->contentItem) { - qmlInfo(this) << "no panel content to show."; + qmlInfo(this) << "no popup content to show."; return; } if (d->overlay) { // FIXME qmlInfo needs to know about QQuickWindow and/or QObject - static_cast<QDebug>(qmlInfo(this) << "panel already showing in window") << d->overlay->window(); + static_cast<QDebug>(qmlInfo(this) << "popup already showing in window") << d->overlay->window(); return; } @@ -163,7 +163,7 @@ void QQuickPanel::show() } } if (!win) { - qmlInfo(this) << "cannot find any window to show panel."; + qmlInfo(this) << "cannot find any window to show popup."; return; } @@ -182,17 +182,17 @@ void QQuickPanel::show() } /*! - \qmlmethod void Qt.labs.controls::Panel::hide() + \qmlmethod void Qt.labs.controls::Popup::hide() - Hides the panel. + Hides the popup. */ -void QQuickPanel::hide() +void QQuickPopup::hide() { - Q_D(QQuickPanel); + Q_D(QQuickPopup); if (!d->overlay) { - // TODO This could mean we showed the panel item on a plain QQuickWindow - qmlInfo(this) << "trying to hide non-visible Panel."; + // TODO This could mean we showed the popup item on a plain QQuickWindow + qmlInfo(this) << "trying to hide non-visible Popup."; return; } @@ -202,27 +202,27 @@ void QQuickPanel::hide() } /*! - \qmlproperty Item Qt.labs.controls::Panel::contentItem + \qmlproperty Item Qt.labs.controls::Popup::contentItem - This property holds the content item of the panel. + This property holds the content item of the popup. - The content item is the visual implementation of the panel. When the - panel is made visible, the content item is automatically reparented to + The content item is the visual implementation of the popup. When the + popup is made visible, the content item is automatically reparented to the \l {ApplicationWindow::overlay}{overlay item} of its application window. */ -QQuickItem *QQuickPanel::contentItem() const +QQuickItem *QQuickPopup::contentItem() const { - Q_D(const QQuickPanel); + Q_D(const QQuickPopup); return d->contentItem; } -void QQuickPanel::setContentItem(QQuickItem *item) +void QQuickPopup::setContentItem(QQuickItem *item) { - Q_D(QQuickPanel); + Q_D(QQuickPopup); if (d->overlay) { // FIXME qmlInfo needs to know about QQuickItem and/or QObject - static_cast<QDebug>(qmlInfo(this) << "cannot set content item") << item << "while Panel is visible."; + static_cast<QDebug>(qmlInfo(this) << "cannot set content item") << item << "while Popup is visible."; return; } if (d->contentItem != item) { @@ -235,19 +235,19 @@ void QQuickPanel::setContentItem(QQuickItem *item) } /*! - \qmlproperty bool Qt.labs.controls::Panel::focus + \qmlproperty bool Qt.labs.controls::Popup::focus - This property holds whether the panel has focus. + This property holds whether the popup has focus. */ -bool QQuickPanel::hasFocus() const +bool QQuickPopup::hasFocus() const { - Q_D(const QQuickPanel); + Q_D(const QQuickPopup); return d->focus; } -void QQuickPanel::setFocus(bool focus) +void QQuickPopup::setFocus(bool focus) { - Q_D(QQuickPanel); + Q_D(QQuickPopup); if (d->focus == focus) return; d->focus = focus; @@ -255,19 +255,19 @@ void QQuickPanel::setFocus(bool focus) } /*! - \qmlproperty bool Qt.labs.controls::Panel::modal + \qmlproperty bool Qt.labs.controls::Popup::modal - This property holds whether the panel is modal. + This property holds whether the popup is modal. */ -bool QQuickPanel::isModal() const +bool QQuickPopup::isModal() const { - Q_D(const QQuickPanel); + Q_D(const QQuickPopup); return d->modal; } -void QQuickPanel::setModal(bool modal) +void QQuickPopup::setModal(bool modal) { - Q_D(QQuickPanel); + Q_D(QQuickPopup); if (d->modal == modal) return; d->modal = modal; @@ -275,30 +275,30 @@ void QQuickPanel::setModal(bool modal) } /*! - \qmlproperty bool Qt.labs.controls::Panel::visible + \qmlproperty bool Qt.labs.controls::Popup::visible - This property holds whether the panel is visible. + This property holds whether the popup is visible. */ -bool QQuickPanel::isVisible() const +bool QQuickPopup::isVisible() const { - Q_D(const QQuickPanel); + Q_D(const QQuickPopup); return d->overlay != Q_NULLPTR /*&& !d->transitionManager.isRunning()*/; } /*! - \qmlproperty Transition Qt.labs.controls::Panel::showTransition + \qmlproperty Transition Qt.labs.controls::Popup::showTransition This property holds the transition that is applied to the content item - when the panel is shown. + when the popup is shown. */ -QQuickTransition *QQuickPanel::showTransition() const +QQuickTransition *QQuickPopup::showTransition() const { return d_func()->showTransition; } -void QQuickPanel::setShowTransition(QQuickTransition *t) +void QQuickPopup::setShowTransition(QQuickTransition *t) { - Q_D(QQuickPanel); + Q_D(QQuickPopup); if (d->showTransition == t) return; d->showTransition = t; @@ -306,19 +306,19 @@ void QQuickPanel::setShowTransition(QQuickTransition *t) } /*! - \qmlproperty Transition Qt.labs.controls::Panel::hideTransition + \qmlproperty Transition Qt.labs.controls::Popup::hideTransition This property holds the transition that is applied to the content item - when the panel is hidden. + when the popup is hidden. */ -QQuickTransition *QQuickPanel::hideTransition() const +QQuickTransition *QQuickPopup::hideTransition() const { return d_func()->hideTransition; } -void QQuickPanel::setHideTransition(QQuickTransition *t) +void QQuickPopup::setHideTransition(QQuickTransition *t) { - Q_D(QQuickPanel); + Q_D(QQuickPopup); if (d->hideTransition == t) return; d->hideTransition = t; @@ -327,4 +327,4 @@ void QQuickPanel::setHideTransition(QQuickTransition *t) QT_END_NAMESPACE -#include "moc_qquickpanel_p.cpp" +#include "moc_qquickpopup_p.cpp" diff --git a/src/templates/qquickpanel_p.h b/src/templates/qquickpopup_p.h index 6d6f4df9..a2edbf6b 100644 --- a/src/templates/qquickpanel_p.h +++ b/src/templates/qquickpopup_p.h @@ -34,8 +34,8 @@ ** ****************************************************************************/ -#ifndef QQUICKPANEL_P_H -#define QQUICKPANEL_P_H +#ifndef QQUICKPOPUP_P_H +#define QQUICKPOPUP_P_H // // W A R N I N G @@ -54,10 +54,10 @@ QT_BEGIN_NAMESPACE class QQuickItem; -class QQuickPanelPrivate; +class QQuickPopupPrivate; class QQuickTransition; -class Q_LABSTEMPLATES_EXPORT QQuickPanel : public QObject +class Q_LABSTEMPLATES_EXPORT QQuickPopup : public QObject { Q_OBJECT Q_PROPERTY(QQuickItem *contentItem READ contentItem WRITE setContentItem NOTIFY contentItemChanged FINAL) @@ -68,8 +68,8 @@ class Q_LABSTEMPLATES_EXPORT QQuickPanel : public QObject Q_PROPERTY(QQuickTransition *hideTransition READ showTransition WRITE setHideTransition NOTIFY hideTransitionChanged FINAL) public: - explicit QQuickPanel(QObject *parent = Q_NULLPTR); - ~QQuickPanel(); + explicit QQuickPopup(QObject *parent = Q_NULLPTR); + ~QQuickPopup(); QQuickItem *contentItem() const; void setContentItem(QQuickItem *item); @@ -109,13 +109,13 @@ public Q_SLOTS: void hide(); protected: - QQuickPanel(QQuickPanelPrivate &dd, QObject *parent); + QQuickPopup(QQuickPopupPrivate &dd, QObject *parent); private: - Q_DISABLE_COPY(QQuickPanel) - Q_DECLARE_PRIVATE(QQuickPanel) + Q_DISABLE_COPY(QQuickPopup) + Q_DECLARE_PRIVATE(QQuickPopup) }; QT_END_NAMESPACE -#endif // QQUICKPANEL_P_H +#endif // QQUICKPOPUP_P_H diff --git a/src/templates/qquickpanel_p_p.h b/src/templates/qquickpopup_p_p.h index 42c06cd9..0997e12c 100644 --- a/src/templates/qquickpanel_p_p.h +++ b/src/templates/qquickpopup_p_p.h @@ -34,8 +34,8 @@ ** ****************************************************************************/ -#ifndef QQUICKPANEL_P_P_H -#define QQUICKPANEL_P_P_H +#ifndef QQUICKPOPUP_P_P_H +#define QQUICKPOPUP_P_P_H // // W A R N I N G @@ -56,14 +56,14 @@ QT_BEGIN_NAMESPACE class QQuickItem; class QQuickTransition; class QQuickTransitionManager; -class QQuickPanel; -class QQuickPanelPrivate; +class QQuickPopup; +class QQuickPopupPrivate; class QQuickOverlay; -class QQuickPanelTransitionManager : public QQuickTransitionManager +class QQuickPopupTransitionManager : public QQuickTransitionManager { public: - QQuickPanelTransitionManager(QQuickPanelPrivate *); + QQuickPopupTransitionManager(QQuickPopupPrivate *); void transitionShow(); void transitionHide(); @@ -76,16 +76,16 @@ private: }; TransitionState state; - QQuickPanelPrivate *pp; + QQuickPopupPrivate *pp; }; -class QQuickPanelPrivate : public QObjectPrivate +class QQuickPopupPrivate : public QObjectPrivate { - Q_DECLARE_PUBLIC(QQuickPanel) + Q_DECLARE_PUBLIC(QQuickPopup) public: - QQuickPanelPrivate(); - ~QQuickPanelPrivate(); + QQuickPopupPrivate(); + ~QQuickPopupPrivate(); void finalizeShowTransition(); void finalizeHideTransition(); @@ -96,10 +96,10 @@ public: bool modal; QQuickTransition *showTransition; QQuickTransition *hideTransition; - QQuickPanelTransitionManager transitionManager; + QQuickPopupTransitionManager transitionManager; }; QT_END_NAMESPACE -#endif // QQUICKPANEL_P_P_H +#endif // QQUICKPOPUP_P_P_H diff --git a/src/templates/templates.pri b/src/templates/templates.pri index 82e1af9e..3f608eb2 100644 --- a/src/templates/templates.pri +++ b/src/templates/templates.pri @@ -26,8 +26,8 @@ HEADERS += \ $$PWD/qquickmenuitem_p.h \ $$PWD/qquickoverlay_p.h \ $$PWD/qquickpageindicator_p.h \ - $$PWD/qquickpanel_p.h \ - $$PWD/qquickpanel_p_p.h \ + $$PWD/qquickpopup_p.h \ + $$PWD/qquickpopup_p_p.h \ $$PWD/qquickpressandholdhelper_p.h \ $$PWD/qquickprogressbar_p.h \ $$PWD/qquickradiobutton_p.h \ @@ -70,7 +70,7 @@ SOURCES += \ $$PWD/qquickmenuitem.cpp \ $$PWD/qquickoverlay.cpp \ $$PWD/qquickpageindicator.cpp \ - $$PWD/qquickpanel.cpp \ + $$PWD/qquickpopup.cpp \ $$PWD/qquickpressandholdhelper.cpp \ $$PWD/qquickprogressbar.cpp \ $$PWD/qquickradiobutton.cpp \ diff --git a/tests/auto/controls/data/tst_combobox.qml b/tests/auto/controls/data/tst_combobox.qml index a0798842..c8b720cb 100644 --- a/tests/auto/controls/data/tst_combobox.qml +++ b/tests/auto/controls/data/tst_combobox.qml @@ -104,7 +104,7 @@ TestCase { compare(control.highlightedIndex, -1) compare(control.currentText, "") verify(control.delegate) - verify(control.panel) + verify(control.popup) control.destroy() } @@ -342,7 +342,7 @@ TestCase { compare(highlightedSpy.count, 0) compare(activatedSpy.count, 0) - // show panel + // show popup keyClick(Qt.Key_Space) compare(control.currentIndex, 0) @@ -400,7 +400,7 @@ TestCase { compare(highlightedSpy.signalArguments[0][0], 1) highlightedSpy.clear() - // hide panel + // hide popup keyClick(Qt.Key_Space) compare(control.currentIndex, 1) @@ -431,54 +431,54 @@ TestCase { verify(control.activeFocus) compare(control.pressed, false) - compare(control.panel.visible, false) + compare(control.popup.visible, false) - // show panel + // show popup keyPress(data.key1) compare(control.pressed, data.showPress) - compare(control.panel.visible, false) + compare(control.popup.visible, false) keyRelease(data.key1) compare(control.pressed, false) - compare(control.panel.visible, data.showPopup) + compare(control.popup.visible, data.showPopup) - // hide panel + // hide popup keyPress(data.key2) compare(control.pressed, data.hidePress) - compare(control.panel.visible, data.showPopup) + compare(control.popup.visible, data.showPopup) keyRelease(data.key2) compare(control.pressed, false) - compare(control.panel.visible, !data.hidePopup) + compare(control.popup.visible, !data.hidePopup) control.destroy() } - function test_panel() { + function test_popup() { var control = comboBox.createObject(window.contentItem, {model: 3}) verify(control) // show below mousePress(control) compare(control.pressed, true) - compare(control.panel.visible, false) + compare(control.popup.visible, false) mouseRelease(control) compare(control.pressed, false) - compare(control.panel.visible, true) - verify(control.panel.contentItem.y >= control.y) + compare(control.popup.visible, true) + verify(control.popup.contentItem.y >= control.y) // hide mouseClick(control) compare(control.pressed, false) - compare(control.panel.visible, false) + compare(control.popup.visible, false) // show above control.y = window.height - control.height mousePress(control) compare(control.pressed, true) - compare(control.panel.visible, false) + compare(control.popup.visible, false) mouseRelease(control) compare(control.pressed, false) - compare(control.panel.visible, true) - verify(control.panel.contentItem.y < control.y) + compare(control.popup.visible, true) + verify(control.popup.contentItem.y < control.y) control.destroy() } @@ -494,9 +494,9 @@ TestCase { verify(highlightedSpy.valid) mouseClick(control) - compare(control.panel.visible, true) + compare(control.popup.visible, true) - var content = control.panel.contentItem + var content = control.popup.contentItem waitForRendering(content) // press - move - release outside - not activated - not closed @@ -509,7 +509,7 @@ TestCase { mouseRelease(content, content.width * 2) compare(activatedSpy.count, 0) compare(highlightedSpy.count, 0) - compare(control.panel.visible, true) + compare(control.popup.visible, true) // press - move - release inside - activated - closed mousePress(content) @@ -521,7 +521,7 @@ TestCase { mouseRelease(content) compare(activatedSpy.count, 1) compare(highlightedSpy.count, 1) - compare(control.panel.visible, false) + compare(control.popup.visible, false) control.destroy() } @@ -530,16 +530,16 @@ TestCase { var control = comboBox.createObject(window.contentItem, {model: 3}) verify(control) - // click - gain focus - show panel + // click - gain focus - show popup mouseClick(control) verify(control.activeFocus) - compare(control.panel.visible, true) + compare(control.popup.visible, true) - // lose focus - hide panel + // lose focus - hide popup window.contentItem.forceActiveFocus() verify(window.contentItem.activeFocus) verify(!control.activeFocus) - compare(control.panel.visible, false) + compare(control.popup.visible, false) control.destroy() } diff --git a/tests/auto/menu/tst_menu.cpp b/tests/auto/menu/tst_menu.cpp index f4df7eb5..5823767a 100644 --- a/tests/auto/menu/tst_menu.cpp +++ b/tests/auto/menu/tst_menu.cpp @@ -149,7 +149,7 @@ void tst_menu::mouse() QVERIFY(window->overlay()->childItems().contains(menu->contentItem())); // Try pressing within the menu and releasing outside of it; it should close. - // TODO: won't work until QQuickPanel::releasedOutside() actually gets emitted + // TODO: won't work until QQuickPopup::releasedOutside() actually gets emitted // QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(firstItem->width() / 2, firstItem->height() / 2)); // QVERIFY(firstItem->hasActiveFocus()); // QCOMPARE(menu->contentItem()->property("currentIndex"), QVariant(0)); |