diff options
author | J-P Nurmi <jpnurmi@theqtcompany.com> | 2015-12-11 15:34:55 +0100 |
---|---|---|
committer | J-P Nurmi <jpnurmi@theqtcompany.com> | 2015-12-14 14:40:04 +0000 |
commit | cd0c04c630b6924d444f0e84e1b63477e4346aeb (patch) | |
tree | 2196a818bf085be65630ce2034b12d46da29f03b | |
parent | 96da2a94e1b2d25fa39417d9088c9889f504e934 (diff) |
Popup: rename show()/hide() to open()/close()
QML popups have traditionally used more explicit open() and close().
Renaming them to show() and hide() at this stage doesn't seem to have
any real advantages.
Change-Id: I1e7c8c4817c67e62cef965525e00f5bf125a7d76
Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
-rw-r--r-- | src/templates/qquickcombobox.cpp | 4 | ||||
-rw-r--r-- | src/templates/qquickmenu.cpp | 10 | ||||
-rw-r--r-- | src/templates/qquickmenuitem.cpp | 2 | ||||
-rw-r--r-- | src/templates/qquickpopup.cpp | 26 | ||||
-rw-r--r-- | src/templates/qquickpopup_p.h | 6 | ||||
-rw-r--r-- | tests/auto/menu/data/applicationwindow.qml | 2 | ||||
-rw-r--r-- | tests/auto/menu/tst_menu.cpp | 10 | ||||
-rw-r--r-- | tests/manual/testbench/main.qml | 2 |
8 files changed, 31 insertions, 31 deletions
diff --git a/src/templates/qquickcombobox.cpp b/src/templates/qquickcombobox.cpp index f95dd357..4465d5dc 100644 --- a/src/templates/qquickcombobox.cpp +++ b/src/templates/qquickcombobox.cpp @@ -166,7 +166,7 @@ bool QQuickComboBoxPrivate::isPopupVisible() const void QQuickComboBoxPrivate::showPopup() { if (popup && !popup->isVisible()) - popup->show(); + popup->open(); setHighlightedIndex(currentIndex); } @@ -174,7 +174,7 @@ void QQuickComboBoxPrivate::hidePopup(bool accept) { Q_Q(QQuickComboBox); if (popup && popup->isVisible()) - popup->hide(); + popup->close(); if (accept) { q->setCurrentIndex(highlightedIndex); emit q->activated(currentIndex); diff --git a/src/templates/qquickmenu.cpp b/src/templates/qquickmenu.cpp index 27c7094d..d6c6e1cb 100644 --- a/src/templates/qquickmenu.cpp +++ b/src/templates/qquickmenu.cpp @@ -67,7 +67,7 @@ QT_BEGIN_NAMESPACE Button { id: fileButton text: "File" - onClicked: menu.show() + onClicked: menu.open() } Menu { id: menu @@ -267,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, &QQuickPopup::hide); + QObject::connect(menuItem, &QQuickMenuItem::triggered, q, &QQuickPopup::close); QObjectPrivate::connect(menuItem, &QQuickItem::activeFocusChanged, p, &QQuickMenuPrivate::onItemActiveFocusChanged); } } @@ -298,8 +298,8 @@ QQuickMenu::QQuickMenu(QObject *parent) : QQuickPopup(*(new QQuickMenuPrivate), parent) { Q_D(QQuickMenu); - connect(this, &QQuickMenu::pressedOutside, this, &QQuickMenu::hide); - connect(this, &QQuickMenu::releasedOutside, this, &QQuickMenu::hide); + connect(this, &QQuickMenu::pressedOutside, this, &QQuickMenu::close); + connect(this, &QQuickMenu::releasedOutside, this, &QQuickMenu::close); QObjectPrivate::connect(this, &QQuickMenu::contentItemChanged, d, &QQuickMenuPrivate::onContentItemChanged); } @@ -445,7 +445,7 @@ bool QQuickMenu::eventFilter(QObject *object, QEvent *event) QMetaObject::invokeMethod(d->contentItem, "incrementCurrentIndex"); return true; } else if (keyEvent->key() == Qt::Key_Escape) { - hide(); + close(); return true; } diff --git a/src/templates/qquickmenuitem.cpp b/src/templates/qquickmenuitem.cpp index 74a093f8..f6cfda4c 100644 --- a/src/templates/qquickmenuitem.cpp +++ b/src/templates/qquickmenuitem.cpp @@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE Button { id: fileButton text: "File" - onClicked: menu.show() + onClicked: menu.open() } Menu { id: menu diff --git a/src/templates/qquickpopup.cpp b/src/templates/qquickpopup.cpp index 54ca6df2..f1d71ebf 100644 --- a/src/templates/qquickpopup.cpp +++ b/src/templates/qquickpopup.cpp @@ -132,11 +132,11 @@ QQuickPopup::~QQuickPopup() } /*! - \qmlmethod void Qt.labs.controls::Popup::show() + \qmlmethod void Qt.labs.controls::Popup::open() - Shows the popup. + Opens the popup. */ -void QQuickPopup::show() +void QQuickPopup::open() { Q_D(QQuickPopup); if (!d->contentItem) { @@ -145,7 +145,7 @@ void QQuickPopup::show() } if (d->overlay) { // FIXME qmlInfo needs to know about QQuickWindow and/or QObject - static_cast<QDebug>(qmlInfo(this) << "popup already showing in window") << d->overlay->window(); + static_cast<QDebug>(qmlInfo(this) << "popup already open in window") << d->overlay->window(); return; } @@ -163,7 +163,7 @@ void QQuickPopup::show() } } if (!win) { - qmlInfo(this) << "cannot find any window to show popup."; + qmlInfo(this) << "cannot find any window to open popup in."; return; } @@ -171,7 +171,7 @@ void QQuickPopup::show() d->overlay = static_cast<QQuickOverlay *>(appWin->overlay()); d->contentItem->setParentItem(d->overlay); } else { - // FIXME Maybe try to show it somehow on that window + // FIXME Maybe try to open it in that window somehow qmlInfo(this) << "is not in an ApplicationWindow."; return; } @@ -182,17 +182,17 @@ void QQuickPopup::show() } /*! - \qmlmethod void Qt.labs.controls::Popup::hide() + \qmlmethod void Qt.labs.controls::Popup::close() - Hides the popup. + Closes the popup. */ -void QQuickPopup::hide() +void QQuickPopup::close() { Q_D(QQuickPopup); if (!d->overlay) { - // TODO This could mean we showed the popup item on a plain QQuickWindow - qmlInfo(this) << "trying to hide non-visible Popup."; + // TODO This could mean we opened the popup item in a plain QQuickWindow + qmlInfo(this) << "trying to close non-visible Popup."; return; } @@ -289,7 +289,7 @@ bool QQuickPopup::isVisible() const \qmlproperty Transition Qt.labs.controls::Popup::showTransition This property holds the transition that is applied to the content item - when the popup is shown. + when the popup is opened. */ QQuickTransition *QQuickPopup::showTransition() const { @@ -309,7 +309,7 @@ void QQuickPopup::setShowTransition(QQuickTransition *t) \qmlproperty Transition Qt.labs.controls::Popup::hideTransition This property holds the transition that is applied to the content item - when the popup is hidden. + when the popup is closed. */ QQuickTransition *QQuickPopup::hideTransition() const { diff --git a/src/templates/qquickpopup_p.h b/src/templates/qquickpopup_p.h index a2edbf6b..a7e402ec 100644 --- a/src/templates/qquickpopup_p.h +++ b/src/templates/qquickpopup_p.h @@ -65,7 +65,7 @@ class Q_LABSTEMPLATES_EXPORT QQuickPopup : public QObject Q_PROPERTY(bool modal READ isModal WRITE setModal NOTIFY modalChanged) Q_PROPERTY(bool visible READ isVisible NOTIFY visibleChanged) Q_PROPERTY(QQuickTransition *showTransition READ showTransition WRITE setShowTransition NOTIFY showTransitionChanged FINAL) - Q_PROPERTY(QQuickTransition *hideTransition READ showTransition WRITE setHideTransition NOTIFY hideTransitionChanged FINAL) + Q_PROPERTY(QQuickTransition *hideTransition READ hideTransition WRITE setHideTransition NOTIFY hideTransitionChanged FINAL) public: explicit QQuickPopup(QObject *parent = Q_NULLPTR); @@ -105,8 +105,8 @@ Q_SIGNALS: public Q_SLOTS: - void show(); - void hide(); + void open(); + void close(); protected: QQuickPopup(QQuickPopupPrivate &dd, QObject *parent); diff --git a/tests/auto/menu/data/applicationwindow.qml b/tests/auto/menu/data/applicationwindow.qml index 6855d66e..cb55e3f6 100644 --- a/tests/auto/menu/data/applicationwindow.qml +++ b/tests/auto/menu/data/applicationwindow.qml @@ -76,6 +76,6 @@ ApplicationWindow { x: 250 visible: false text: "Open Menu" - onClicked: menu.show() + onClicked: menu.open() } } diff --git a/tests/auto/menu/tst_menu.cpp b/tests/auto/menu/tst_menu.cpp index 7b2b8ea6..a395e43e 100644 --- a/tests/auto/menu/tst_menu.cpp +++ b/tests/auto/menu/tst_menu.cpp @@ -83,7 +83,7 @@ void tst_menu::mouse() QVERIFY(QTest::qWaitForWindowActive(window)); QQuickMenu *menu = window->property("menu").value<QQuickMenu*>(); - menu->show(); + menu->open(); QVERIFY(menu->isVisible()); QVERIFY(window->overlay()->childItems().contains(menu->contentItem())); @@ -107,7 +107,7 @@ void tst_menu::mouse() QVERIFY(!window->overlay()->childItems().contains(menu->contentItem())); QCOMPARE(menu->contentItem()->property("currentIndex"), QVariant(-1)); - menu->show(); + menu->open(); QCOMPARE(visibleSpy.count(), 2); QVERIFY(menu->isVisible()); QVERIFY(window->overlay()->childItems().contains(menu->contentItem())); @@ -121,7 +121,7 @@ void tst_menu::mouse() QVERIFY(!menu->isVisible()); QVERIFY(!window->overlay()->childItems().contains(menu->contentItem())); - menu->show(); + menu->open(); QCOMPARE(visibleSpy.count(), 4); QVERIFY(menu->isVisible()); QVERIFY(window->overlay()->childItems().contains(menu->contentItem())); @@ -163,7 +163,7 @@ void tst_menu::contextMenuKeyboard() QSignalSpy visibleSpy(menu, SIGNAL(visibleChanged())); menu->setFocus(true); - menu->show(); + menu->open(); QCOMPARE(visibleSpy.count(), 1); QVERIFY(menu->isVisible()); QVERIFY(window->overlay()->childItems().contains(menu->contentItem())); @@ -190,7 +190,7 @@ void tst_menu::contextMenuKeyboard() QVERIFY(!secondItem->hasActiveFocus()); QCOMPARE(menu->contentItem()->property("currentIndex"), QVariant(-1)); - menu->show(); + menu->open(); QCOMPARE(visibleSpy.count(), 3); QVERIFY(menu->isVisible()); QVERIFY(window->overlay()->childItems().contains(menu->contentItem())); diff --git a/tests/manual/testbench/main.qml b/tests/manual/testbench/main.qml index 469dac26..bb36be3f 100644 --- a/tests/manual/testbench/main.qml +++ b/tests/manual/testbench/main.qml @@ -62,7 +62,7 @@ ApplicationWindow { ToolButton { text: "Normal" - onClicked: menu.visible ? menu.hide() : menu.show() + onClicked: menu.visible ? menu.close() : menu.open() } ToolButton { text: "Pressed" |