QGIS API Documentation  3.0.2-Girona (307d082)
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 
22 QgsDockWidget::QgsDockWidget( QWidget *parent, Qt::WindowFlags flags )
23  : QDockWidget( parent, flags )
24 {
25  connect( this, &QDockWidget::visibilityChanged, this, &QgsDockWidget::handleVisibilityChanged );
26 }
27 
28 QgsDockWidget::QgsDockWidget( const QString &title, QWidget *parent, Qt::WindowFlags flags )
29  : QDockWidget( title, parent, flags )
30 {
31  connect( this, &QDockWidget::visibilityChanged, this, &QgsDockWidget::handleVisibilityChanged );
32 }
33 
34 void QgsDockWidget::setUserVisible( bool visible )
35 {
36  if ( visible )
37  {
38  show();
39  raise();
40  }
41  else
42  {
43  if ( !mVisibleAndActive )
44  return;
45 
46  hide();
47  }
48 }
49 
51 {
52  return mVisibleAndActive;
53 }
54 
55 void QgsDockWidget::closeEvent( QCloseEvent *e )
56 {
57  emit closed();
58  emit closedStateChanged( true );
59  emit openedStateChanged( false );
60  QDockWidget::closeEvent( e );
61 }
62 
63 void QgsDockWidget::showEvent( QShowEvent *e )
64 {
65  emit opened();
66  emit closedStateChanged( false );
67  emit openedStateChanged( true );
68  QDockWidget::showEvent( e );
69 }
70 
71 void QgsDockWidget::handleVisibilityChanged( bool visible )
72 {
73  mVisibleAndActive = visible;
74 }
75 
void closedStateChanged(bool wasClosed)
Emitted when dock widget is closed (or opened).
void closeEvent(QCloseEvent *) override
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 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=nullptr)
Constructor for QgsDockWidget.
void opened()
Emitted when dock widget is opened.