-
-
Notifications
You must be signed in to change notification settings - Fork 3k
/
qgswidgetstatehelper_p.h
63 lines (54 loc) · 2.3 KB
/
qgswidgetstatehelper_p.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/***************************************************************************
qgswidgetstatehelper_p.h - QgsWidgetStateHelper
---------------------
begin : 3.12.2017
copyright : (C) 2017 by Nathan Woodrow
Email : woodrow.nathan at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSWIDGETSTATEHELPER_P_H
#define QGSWIDGETSTATEHELPER_P_H
#include <QMap>
#include <QObject>
#define SIP_NO_FILE
/**
* \ingroup gui
* QgsWidgetStateHelper is a helper class to save and restore the geometry of QWidgets in the application.
* This removes the need for devs to remember to call saveGeometry() and restoreGeometry() when writing new widgets.
*
* This helper is internal and should only be called via QgsGui::enabledAutoGeometryRestore
* \since QGIS 3.0
*/
class QgsWidgetStateHelper : public QObject
{
Q_OBJECT
public:
/**
* QgsWidgetStateHelper
* @param parent Parent object
*/
explicit QgsWidgetStateHelper( QObject *parent = 0 );
/**
* Event filter to catch events from registered widgets.
* \param object Object getting the event.
* \param event Event sent from Qt.
* \return Always returns True so that widget still gets event.
*/
bool eventFilter( QObject *object, QEvent *event );
/**
* Register a widget to have it geometry state automatically saved and restored.
* \param widget The widget to save. Must have objectName() set.
* \param key The override settings key name to use if objectName() isn't to be used.
* objectName() is the default if not set.
*/
void registerWidget( QWidget *widget, const QString &key = QString() );
private:
QMap<QString, QString> mKeys;
};
#endif // QGSWIDGETSTATEHELPER_P_H