QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
qgsdockwidget.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsdockwidget.cpp
3  -----------------
4  begin : June 2016
5  copyright : (C) 2016 by Nyall Dawson
6  email : nyall dot dawson at gmail dot com
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 
19 #include "qgsdockwidget.h"
20 
21 
23  : QDockWidget( parent, flags )
24  , mVisibleAndActive( false )
25 {
26  connect( this, SIGNAL( visibilityChanged( bool ) ), this, SLOT( handleVisibilityChanged( bool ) ) );
27 }
28 
30  : QDockWidget( title, parent, flags )
31  , mVisibleAndActive( false )
32 {
33  connect( this, SIGNAL( visibilityChanged( bool ) ), this, SLOT( handleVisibilityChanged( bool ) ) );
34 }
35 
37 {
38  if ( visible )
39  {
40  if ( mVisibleAndActive )
41  return;
42 
43  show();
44  raise();
45  }
46  else
47  {
48  if ( !mVisibleAndActive )
49  return;
50 
51  hide();
52  }
53 }
54 
56 {
57  return mVisibleAndActive;
58 }
59 
61 {
62  emit closed();
63  emit closedStateChanged( true );
64  emit openedStateChanged( false );
66 }
67 
69 {
70  emit opened();
71  emit closedStateChanged( false );
72  emit openedStateChanged( true );
74 }
75 
76 void QgsDockWidget::handleVisibilityChanged( bool visible )
77 {
78  mVisibleAndActive = visible;
79 }
80 
void closedStateChanged(bool wasClosed)
Emitted when dock widget is closed (or opened).
void visibilityChanged(bool visible)
virtual void closeEvent(QCloseEvent *) override
virtual void closeEvent(QCloseEvent *event)
virtual void showEvent(QShowEvent *event)
void setUserVisible(bool visible)
Sets the dock widget as visible to a user, ie both shown and raised to the front. ...
bool isUserVisible() const
Returns true if the dock is both opened and raised to the front (ie not hidden by any other tabs...
void hide()
virtual void showEvent(QShowEvent *event) override
void openedStateChanged(bool wasOpened)
Emitted when dock widget is opened (or closed).
void closed()
Emitted when dock widget is closed.
QgsDockWidget(QWidget *parent=nullptr, Qt::WindowFlags flags=0)
Constructor for QgsDockWidget.
typedef WindowFlags
void show()
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QObject * parent() const
void opened()
Emitted when dock widget is opened.