-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqgscustomization.h
172 lines (128 loc) · 5.33 KB
/
qgscustomization.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
/***************************************************************************
qgscustomization.h - Customization
-------------------
begin : 2011-04-01
copyright : (C) 2011 Radim Blazek
email : radim dot blazek 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 QGSCUSTOMIZATION_H
#define QGSCUSTOMIZATION_H
#include "ui_qgscustomizationdialogbase.h"
#include <QDialog>
#include <QDomNode>
#include "qgis_app.h"
class QString;
class QWidget;
class QTreeWidgetItem;
class QEvent;
class QMouseEvent;
class QSettings;
class APP_EXPORT QgsCustomizationDialog : public QMainWindow, private Ui::QgsCustomizationDialogBase
{
Q_OBJECT
public:
QgsCustomizationDialog( QWidget *parent, QSettings *settings );
~QgsCustomizationDialog();
// get item by path
QTreeWidgetItem *item( const QString &path, QTreeWidgetItem *widgetItem = nullptr );
//
// return current item state for given path
bool itemChecked( const QString &path );
// set item state for given path
void setItemChecked( const QString &path, bool on );
// recursively save tree item to settings
void itemToSettings( const QString &path, QTreeWidgetItem *item, QSettings *settings );
// recursively save settings to tree items
void settingsToItem( const QString &path, QTreeWidgetItem *item, QSettings *settings );
// save current tree to settings
void treeToSettings( QSettings *settings );
// restore current tree from settings
void settingsToTree( QSettings *settings );
// switch widget item in tree
bool switchWidget( QWidget *widget, QMouseEvent *event );
// Get path of the widget
QString widgetPath( QWidget *widget, const QString &path = QString() );
void setCatch( bool on );
bool catchOn();
private slots:
//void on_btnQgisUser_clicked();
// Save to settings
void ok();
void apply();
void cancel();
// Reset values from settings
void reset();
// Save to settings to file
void on_actionSave_triggered( bool checked );
// Load settings from file
void on_actionLoad_triggered( bool checked );
void on_actionExpandAll_triggered( bool checked );
void on_actionCollapseAll_triggered( bool checked );
void on_actionSelectAll_triggered( bool checked );
void on_mCustomizationEnabledCheckBox_toggled( bool checked );
private:
void init();
QTreeWidgetItem *createTreeItemWidgets();
QTreeWidgetItem *readWidgetsXmlNode( const QDomNode &node );
QString mLastDirSettingsName;
QSettings *mSettings = nullptr;
};
class APP_EXPORT QgsCustomization : public QObject
{
Q_OBJECT
public:
enum Status
{
NotSet = 0,
User = 1, // Set by user
Default = 2 // Default customization loaded and set
};
//! Returns the instance pointer, creating the object on the first call
static QgsCustomization *instance();
void openDialog( QWidget *parent );
static void customizeWidget( QWidget *widget, QEvent *event, QSettings *settings );
static void customizeWidget( const QString &path, QWidget *widget, QSettings *settings );
static void removeFromLayout( QLayout *layout, QWidget *widget );
void updateMainWindow( QMenu *toolBarMenu );
// make sure to enable/disable before creating QgisApp in order to get it customized (or not)
void setEnabled( bool enabled ) { mEnabled = enabled; }
bool isEnabled() const { return mEnabled; }
void setSettings( QSettings *settings ) { mSettings = settings ;}
// Return the path to the splash screen
QString splashPath();
// Load and set default customization
void loadDefault();
// Internal Qt widget which has to bes kipped in paths
static QStringList sInternalWidgets;
QString statusPath() { return mStatusPath; }
public slots:
void preNotify( QObject *receiver, QEvent *event, bool *done );
protected:
QgsCustomization();
~QgsCustomization();
QgsCustomizationDialog *pDialog = nullptr;
bool mEnabled;
QSettings *mSettings = nullptr;
QString mStatusPath;
void updateMenu( QMenu *menu, QSettings *settings );
void createTreeItemMenus();
void createTreeItemToolbars();
void createTreeItemDocks();
void createTreeItemStatus();
void addTreeItemMenu( QTreeWidgetItem *parentItem, QMenu *menu );
void addTreeItemActions( QTreeWidgetItem *parentItem, const QList<QAction *> &actions );
QList<QTreeWidgetItem *> mMainWindowItems;
friend class QgsCustomizationDialog; // in order to access mMainWindowItems
private slots:
private:
static QgsCustomization *sInstance;
};
#endif // QGSCUSTOMIZATION_H