mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-17 00:04:02 -04:00
Add method to toggle user visibility of QgsDockWidgets
This commit is contained in:
parent
c95e1c67f0
commit
a2ef677912
@ -45,6 +45,8 @@ Returns true if the dock is both opened and raised to the front (ie not hidden b
|
|||||||
any other tabs.
|
any other tabs.
|
||||||
|
|
||||||
.. seealso:: :py:func:`setUserVisible`
|
.. seealso:: :py:func:`setUserVisible`
|
||||||
|
|
||||||
|
.. seealso:: :py:func:`toggleUserVisible`
|
||||||
%End
|
%End
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
@ -64,6 +66,21 @@ Sets the dock widget as visible to a user, ie both shown and raised to the front
|
|||||||
- hiding a dock which is closed has no effect and raises no signals
|
- hiding a dock which is closed has no effect and raises no signals
|
||||||
|
|
||||||
.. seealso:: :py:func:`isUserVisible`
|
.. seealso:: :py:func:`isUserVisible`
|
||||||
|
|
||||||
|
.. seealso:: :py:func:`toggleUserVisible`
|
||||||
|
%End
|
||||||
|
|
||||||
|
void toggleUserVisible();
|
||||||
|
%Docstring
|
||||||
|
Toggles whether the dock is user visible. If the dock is not currently user
|
||||||
|
visible (i.e. opened and activated as a tab) then the dock will be opened
|
||||||
|
and raised. If it is currently user visible it will be closed.
|
||||||
|
|
||||||
|
.. seealso:: :py:func:`setUserVisible`
|
||||||
|
|
||||||
|
.. seealso:: :py:func:`isUserVisible`
|
||||||
|
|
||||||
|
.. versionadded:: 3.2
|
||||||
%End
|
%End
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -47,6 +47,11 @@ void QgsDockWidget::setUserVisible( bool visible )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QgsDockWidget::toggleUserVisible()
|
||||||
|
{
|
||||||
|
setUserVisible( !isUserVisible() );
|
||||||
|
}
|
||||||
|
|
||||||
bool QgsDockWidget::isUserVisible() const
|
bool QgsDockWidget::isUserVisible() const
|
||||||
{
|
{
|
||||||
return mVisibleAndActive;
|
return mVisibleAndActive;
|
||||||
|
@ -53,6 +53,7 @@ class GUI_EXPORT QgsDockWidget : public QDockWidget
|
|||||||
* Returns true if the dock is both opened and raised to the front (ie not hidden by
|
* Returns true if the dock is both opened and raised to the front (ie not hidden by
|
||||||
* any other tabs.
|
* any other tabs.
|
||||||
* \see setUserVisible()
|
* \see setUserVisible()
|
||||||
|
* \see toggleUserVisible()
|
||||||
*/
|
*/
|
||||||
bool isUserVisible() const;
|
bool isUserVisible() const;
|
||||||
|
|
||||||
@ -70,9 +71,21 @@ class GUI_EXPORT QgsDockWidget : public QDockWidget
|
|||||||
* be closed
|
* be closed
|
||||||
* - hiding a dock which is closed has no effect and raises no signals
|
* - hiding a dock which is closed has no effect and raises no signals
|
||||||
* \see isUserVisible()
|
* \see isUserVisible()
|
||||||
|
* \see toggleUserVisible()
|
||||||
*/
|
*/
|
||||||
void setUserVisible( bool visible );
|
void setUserVisible( bool visible );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Toggles whether the dock is user visible. If the dock is not currently user
|
||||||
|
* visible (i.e. opened and activated as a tab) then the dock will be opened
|
||||||
|
* and raised. If it is currently user visible it will be closed.
|
||||||
|
*
|
||||||
|
* \see setUserVisible()
|
||||||
|
* \see isUserVisible()
|
||||||
|
* \since QGIS 3.2
|
||||||
|
*/
|
||||||
|
void toggleUserVisible();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void closeEvent( QCloseEvent * ) override;
|
void closeEvent( QCloseEvent * ) override;
|
||||||
|
@ -32,6 +32,7 @@ class TestQgsDockWidget: public QObject
|
|||||||
void testSignals();
|
void testSignals();
|
||||||
void testUserVisible();
|
void testUserVisible();
|
||||||
void testSetUserVisible();
|
void testSetUserVisible();
|
||||||
|
void testToggleUserVisible();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@ -176,5 +177,48 @@ void TestQgsDockWidget::testSetUserVisible()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TestQgsDockWidget::testToggleUserVisible()
|
||||||
|
{
|
||||||
|
QMainWindow *w = new QMainWindow();
|
||||||
|
QApplication::setActiveWindow( w ); //required for focus events
|
||||||
|
QgsDockWidget *d1 = new QgsDockWidget( w );
|
||||||
|
QgsDockWidget *d2 = new QgsDockWidget( w );
|
||||||
|
w->addDockWidget( Qt::RightDockWidgetArea, d1 );
|
||||||
|
w->addDockWidget( Qt::RightDockWidgetArea, d2 );
|
||||||
|
w->tabifyDockWidget( d1, d2 );
|
||||||
|
w->show();
|
||||||
|
|
||||||
|
QVERIFY( d2->isUserVisible() );
|
||||||
|
QVERIFY( !d1->isUserVisible() );
|
||||||
|
|
||||||
|
d1->toggleUserVisible();
|
||||||
|
QVERIFY( !d2->isUserVisible() );
|
||||||
|
QVERIFY( d2->isVisible() );
|
||||||
|
QVERIFY( d1->isUserVisible() );
|
||||||
|
QVERIFY( d1->isVisible() );
|
||||||
|
|
||||||
|
d2->hide();
|
||||||
|
d2->toggleUserVisible();
|
||||||
|
QVERIFY( d2->isUserVisible() );
|
||||||
|
QVERIFY( d2->isVisible() );
|
||||||
|
QVERIFY( !d1->isUserVisible() );
|
||||||
|
QVERIFY( d1->isVisible() );
|
||||||
|
|
||||||
|
d2->hide();
|
||||||
|
d1->raise(); //shouldn't be necessary outside of tests
|
||||||
|
QVERIFY( !d2->isUserVisible() );
|
||||||
|
QVERIFY( !d2->isVisible() );
|
||||||
|
QVERIFY( d1->isUserVisible() );
|
||||||
|
QVERIFY( d1->isVisible() );
|
||||||
|
|
||||||
|
d1->toggleUserVisible();
|
||||||
|
QVERIFY( !d2->isVisible() );
|
||||||
|
QVERIFY( !d1->isUserVisible() );
|
||||||
|
QVERIFY( !d1->isVisible() );
|
||||||
|
|
||||||
|
delete w;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
QGSTEST_MAIN( TestQgsDockWidget )
|
QGSTEST_MAIN( TestQgsDockWidget )
|
||||||
#include "testqgsdockwidget.moc"
|
#include "testqgsdockwidget.moc"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user