diff options
author | J-P Nurmi <jpnurmi@gmail.com> | 2009-10-01 18:41:44 (GMT) |
---|---|---|
committer | Thierry Bastian <thierry.bastian@nokia.com> | 2009-12-08 11:16:03 (GMT) |
commit | e1c515f73eca4e85211fffc718b3d9e27f21eb19 (patch) | |
tree | 9209182ae72f8a2e02cd95377ad439aba79ff484 | |
parent | 0c9aa0cc58e3cf3f477024b35291b407be059c01 (diff) | |
download | Qt-e1c515f73eca4e85211fffc718b3d9e27f21eb19.zip Qt-e1c515f73eca4e85211fffc718b3d9e27f21eb19.tar.gz Qt-e1c515f73eca4e85211fffc718b3d9e27f21eb19.tar.bz2 |
Added QToolBar::visibilityChanged(bool) signal.
Reviewed-By: Thierry
-rw-r--r-- | src/gui/widgets/qtoolbar.cpp | 9 | ||||
-rw-r--r-- | src/gui/widgets/qtoolbar.h | 1 | ||||
-rw-r--r-- | tests/auto/qtoolbar/tst_qtoolbar.cpp | 31 |
3 files changed, 41 insertions, 0 deletions
diff --git a/src/gui/widgets/qtoolbar.cpp b/src/gui/widgets/qtoolbar.cpp index 58a3d28..47c4698 100644 --- a/src/gui/widgets/qtoolbar.cpp +++ b/src/gui/widgets/qtoolbar.cpp @@ -534,6 +534,14 @@ void QToolBarPrivate::plug(const QRect &r) /*! + \fn void QToolBar::visibilityChanged(bool visible) + \since 4.7 + + This signal is emitted when the toolbar becomes \a visible (or + invisible). This happens when the widget is hidden or shown. +*/ + +/*! Constructs a QToolBar with the given \a parent. */ QToolBar::QToolBar(QWidget *parent) @@ -1123,6 +1131,7 @@ bool QToolBar::event(QEvent *event) // fallthrough intended case QEvent::Show: d->toggleViewAction->setChecked(event->type() == QEvent::Show); + emit visibilityChanged(event->type() == QEvent::Show); #if defined(Q_WS_MAC) if (toolbarInUnifiedToolBar(this)) { // I can static_cast because I did the qobject_cast in the if above, therefore diff --git a/src/gui/widgets/qtoolbar.h b/src/gui/widgets/qtoolbar.h index a1a24f0..9712637 100644 --- a/src/gui/widgets/qtoolbar.h +++ b/src/gui/widgets/qtoolbar.h @@ -143,6 +143,7 @@ Q_SIGNALS: void iconSizeChanged(const QSize &iconSize); void toolButtonStyleChanged(Qt::ToolButtonStyle toolButtonStyle); void topLevelChanged(bool topLevel); + void visibilityChanged(bool visible); protected: void actionEvent(QActionEvent *event); diff --git a/tests/auto/qtoolbar/tst_qtoolbar.cpp b/tests/auto/qtoolbar/tst_qtoolbar.cpp index ac86fd9..93dfca5 100644 --- a/tests/auto/qtoolbar/tst_qtoolbar.cpp +++ b/tests/auto/qtoolbar/tst_qtoolbar.cpp @@ -102,6 +102,7 @@ private slots: void orientationChanged(); void iconSizeChanged(); void toolButtonStyleChanged(); + void visibilityChanged(); void actionOwnership(); void widgetAction(); void accel(); @@ -998,6 +999,36 @@ void tst_QToolBar::iconSizeChanged() void tst_QToolBar::toolButtonStyleChanged() { DEPENDS_ON("toolButtonStyle()"); } +void tst_QToolBar::visibilityChanged() +{ + QMainWindow mw; + QToolBar tb; + QSignalSpy spy(&tb, SIGNAL(visibilityChanged(bool))); + + mw.addToolBar(&tb); + mw.show(); + + QCOMPARE(spy.count(), 1); + QCOMPARE(spy.at(0).at(0).toBool(), true); + spy.clear(); + + tb.hide(); + QCOMPARE(spy.count(), 1); + QCOMPARE(spy.at(0).at(0).toBool(), false); + spy.clear(); + + tb.hide(); + QCOMPARE(spy.count(), 0); + + tb.show(); + QCOMPARE(spy.count(), 1); + QCOMPARE(spy.at(0).at(0).toBool(), true); + spy.clear(); + + tb.show(); + QCOMPARE(spy.count(), 0); +} + void tst_QToolBar::actionOwnership() { { |