QGIS API Documentation
4.3.0-Master (16eddb2670e)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
gui
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
#include <QAction>
22
23
#include "moc_qgsdockwidget.cpp"
24
25
QgsDockWidget::QgsDockWidget
( QWidget *parent, Qt::WindowFlags flags )
26
: QDockWidget( parent, flags )
27
{
28
connect(
this
, &QDockWidget::visibilityChanged,
this
, &QgsDockWidget::handleVisibilityChanged );
29
}
30
31
QgsDockWidget::QgsDockWidget
(
const
QString &title, QWidget *parent, Qt::WindowFlags flags )
32
: QDockWidget( title, parent, flags )
33
{
34
connect(
this
, &QDockWidget::visibilityChanged,
this
, &QgsDockWidget::handleVisibilityChanged );
35
}
36
37
void
QgsDockWidget::setUserVisible
(
bool
visible )
38
{
39
if
( visible )
40
{
41
show();
42
raise();
43
}
44
else
45
{
46
if
( !mVisibleAndActive )
47
return
;
48
49
hide();
50
}
51
}
52
53
void
QgsDockWidget::toggleUserVisible
()
54
{
55
setUserVisible
( !
isUserVisible
() );
56
}
57
58
bool
QgsDockWidget::isUserVisible
()
const
59
{
60
return
mVisibleAndActive;
61
}
62
63
void
QgsDockWidget::setToggleVisibilityAction
( QAction *action )
64
{
65
mAction = action;
66
if
( !mAction->isCheckable() )
67
mAction->setCheckable(
true
);
68
mAction->setChecked(
isUserVisible
() );
69
connect( mAction, &QAction::toggled,
this
, [
this
](
bool
visible ) {
setUserVisible
( visible ); } );
70
connect(
this
, &QgsDockWidget::visibilityChanged, mAction, [
this
](
bool
visible ) { mAction->setChecked( visible ); } );
71
}
72
73
QAction *
QgsDockWidget::toggleVisibilityAction
()
74
{
75
return
mAction;
76
}
77
78
void
QgsDockWidget::closeEvent
( QCloseEvent *e )
79
{
80
emit
closed
();
81
emit
closedStateChanged
(
true
);
82
emit
openedStateChanged
(
false
);
83
QDockWidget::closeEvent( e );
84
}
85
86
void
QgsDockWidget::showEvent
( QShowEvent *e )
87
{
88
emit
opened
();
89
emit
closedStateChanged
(
false
);
90
emit
openedStateChanged
(
true
);
91
QDockWidget::showEvent( e );
92
}
93
94
void
QgsDockWidget::handleVisibilityChanged(
bool
visible )
95
{
96
mVisibleAndActive = visible;
97
}
QgsDockWidget::closed
void closed()
Emitted when dock widget is closed.
QgsDockWidget::toggleVisibilityAction
QAction * toggleVisibilityAction()
Returns the action linked to the dock.
Definition
qgsdockwidget.cpp:73
QgsDockWidget::closedStateChanged
void closedStateChanged(bool wasClosed)
Emitted when dock widget is closed (or opened).
QgsDockWidget::QgsDockWidget
QgsDockWidget(QWidget *parent=nullptr, Qt::WindowFlags flags=Qt::WindowFlags())
Constructor for QgsDockWidget.
Definition
qgsdockwidget.cpp:25
QgsDockWidget::isUserVisible
bool isUserVisible() const
Returns true if the dock is both opened and raised to the front (ie not hidden by any other tabs.
Definition
qgsdockwidget.cpp:58
QgsDockWidget::setUserVisible
void setUserVisible(bool visible)
Sets the dock widget as visible to a user, ie both shown and raised to the front.
Definition
qgsdockwidget.cpp:37
QgsDockWidget::toggleUserVisible
void toggleUserVisible()
Toggles whether the dock is user visible.
Definition
qgsdockwidget.cpp:53
QgsDockWidget::closeEvent
void closeEvent(QCloseEvent *) override
Definition
qgsdockwidget.cpp:78
QgsDockWidget::opened
void opened()
Emitted when dock widget is opened.
QgsDockWidget::showEvent
void showEvent(QShowEvent *event) override
Definition
qgsdockwidget.cpp:86
QgsDockWidget::setToggleVisibilityAction
void setToggleVisibilityAction(QAction *action)
Links an action to the dock, so that toggling the action will automatically set the dock's visibility...
Definition
qgsdockwidget.cpp:63
QgsDockWidget::openedStateChanged
void openedStateChanged(bool wasOpened)
Emitted when dock widget is opened (or closed).
qgsdockwidget.h
Generated on
for QGIS API Documentation by
1.17.0