/
qgslayoutdesignerdialog.h
325 lines (253 loc) · 8.71 KB
/
qgslayoutdesignerdialog.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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
/***************************************************************************
qgslayoutdesignerdialog.h
-------------------------
begin : July 2017
copyright : (C) 2017 by Nyall Dawson
email : nyall dot dawson 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 QGSLAYOUTDESIGNERDIALOG_H
#define QGSLAYOUTDESIGNERDIALOG_H
#include "ui_qgslayoutdesignerbase.h"
#include "qgslayoutdesignerinterface.h"
#include <QToolButton>
class QgsLayoutDesignerDialog;
class QgsLayoutView;
class QgsLayoutViewToolAddItem;
class QgsLayoutViewToolPan;
class QgsLayoutViewToolZoom;
class QgsLayoutViewToolSelect;
class QgsLayoutRuler;
class QComboBox;
class QSlider;
class QLabel;
class QgsLayoutAppMenuProvider;
class QgsLayoutItem;
class QgsPanelWidgetStack;
class QgsDockWidget;
class QUndoView;
class QTreeView;
class QgsLayoutItemsListView;
class QgsAppLayoutDesignerInterface : public QgsLayoutDesignerInterface
{
Q_OBJECT
public:
QgsAppLayoutDesignerInterface( QgsLayoutDesignerDialog *dialog );
QgsLayout *layout() override;
QgsLayoutView *view() override;
public slots:
void close() override;
private:
QgsLayoutDesignerDialog *mDesigner = nullptr;
};
/**
* \ingroup app
* \brief A window for designing layouts.
*/
class QgsLayoutDesignerDialog: public QMainWindow, private Ui::QgsLayoutDesignerBase
{
Q_OBJECT
public:
QgsLayoutDesignerDialog( QWidget *parent = nullptr, Qt::WindowFlags flags = 0 );
/**
* Returns the designer interface for the dialog.
*/
QgsAppLayoutDesignerInterface *iface();
/**
* Returns the current layout associated with the designer.
* \see setCurrentLayout()
*/
QgsLayout *currentLayout();
/**
* Returns the layout view utilized by the designer.
*/
QgsLayoutView *view();
/**
* Sets the current \a layout to edit in the designer.
* \see currentLayout()
*/
void setCurrentLayout( QgsLayout *layout );
/**
* Sets the icon \a size for the dialog.
*/
void setIconSizes( int size );
/**
* Shows the configuration widget for the specified layout \a item.
*
* If \a bringPanelToFront is true, then the item properties panel will be automatically
* shown and raised to the top of the interface.
*/
void showItemOptions( QgsLayoutItem *item, bool bringPanelToFront = true );
public slots:
/**
* Opens the dialog, and sets default view.
*/
void open();
/**
* Raise, unminimize and activate this window.
*/
void activate();
/**
* Toggles whether or not the rulers should be \a visible.
*/
void showRulers( bool visible );
/**
* Toggles whether the page grid should be \a visible.
*/
void showGrid( bool visible );
/**
* Toggles whether the item bounding boxes should be \a visible.
*/
void showBoxes( bool visible );
/**
* Toggles whether the layout pages should be \a visible.
*/
void showPages( bool visible );
/**
* Toggles whether snapping to the page grid is \a enabled.
*/
void snapToGrid( bool enabled );
/**
* Toggles whether the page guides should be \a visible.
*/
void showGuides( bool visible );
/**
* Toggles whether snapping to the page guides is \a enabled.
*/
void snapToGuides( bool enabled );
/**
* Toggles whether snapping to the item guides ("smart" guides) is \a enabled.
*/
void snapToItems( bool enabled );
/**
* Unlocks all locked items in the layout.
* \see lockSelectedItems()
*/
void unlockAllItems();
/**
* Locks any selected items in the layout.
* \see unlockAllItems()
*/
void lockSelectedItems();
/**
* Sets whether the dock panels are \a hidden.
*/
void setPanelVisibility( bool hidden );
/**
* Raises the selected items up the z-order.
* \see lowerSelectedItems()
* \see moveSelectedItemsToTop()
* \see moveSelectedItemsToBottom()
*/
void raiseSelectedItems();
/**
* Lowers the selected items down the z-order.
* \see raiseSelectedItems()
* \see moveSelectedItemsToTop()
* \see moveSelectedItemsToBottom()
*/
void lowerSelectedItems();
/**
* Raises the selected items to the top of the z-order.
* \see raiseSelectedItems()
* \see lowerSelectedItems()
* \see moveSelectedItemsToBottom()
*/
void moveSelectedItemsToTop();
/**
* Lowers the selected items to the bottom of the z-order.
* \see raiseSelectedItems()
* \see lowerSelectedItems()
* \see moveSelectedItemsToTop()
*/
void moveSelectedItemsToBottom();
/**
* Forces the layout, and all items contained within it, to refresh. For instance, this causes maps to redraw
* and rebuild cached images, html items to reload their source url, and attribute tables
* to refresh their contents. Calling this also triggers a recalculation of all data defined
* attributes within the layout.
*/
void refreshLayout();
signals:
/**
* Emitted when the dialog is about to close.
*/
void aboutToClose();
protected:
virtual void closeEvent( QCloseEvent * ) override;
private slots:
void itemTypeAdded( int type );
void statusZoomCombo_currentIndexChanged( int index );
void statusZoomCombo_zoomEntered();
void sliderZoomChanged( int value );
//! Updates zoom level in status bar
void updateStatusZoom();
//! Updates cursor position in status bar
void updateStatusCursorPos( QPointF position );
void toggleFullScreen( bool enabled );
void addPages();
void statusMessageReceived( const QString &message );
void dockVisibilityChanged( bool visible );
private:
static bool sInitializedRegistry;
QgsAppLayoutDesignerInterface *mInterface = nullptr;
QgsLayout *mLayout = nullptr;
QActionGroup *mToolsActionGroup = nullptr;
QgsLayoutView *mView = nullptr;
QgsLayoutRuler *mHorizontalRuler = nullptr;
QgsLayoutRuler *mVerticalRuler = nullptr;
QWidget *mRulerLayoutFix = nullptr;
//! Combobox in status bar which shows/adjusts current zoom level
QComboBox *mStatusZoomCombo = nullptr;
QSlider *mStatusZoomSlider = nullptr;
//! Labels in status bar which shows current mouse position
QLabel *mStatusCursorXLabel = nullptr;
QLabel *mStatusCursorYLabel = nullptr;
QLabel *mStatusCursorPageLabel = nullptr;
static QList<double> sStatusZoomLevelsList;
QgsLayoutViewToolAddItem *mAddItemTool = nullptr;
QgsLayoutViewToolPan *mPanTool = nullptr;
QgsLayoutViewToolZoom *mZoomTool = nullptr;
QgsLayoutViewToolSelect *mSelectTool = nullptr;
QMap< QString, QToolButton * > mItemGroupToolButtons;
QMap< QString, QMenu * > mItemGroupSubmenus;
QgsLayoutAppMenuProvider *mMenuProvider = nullptr;
QgsDockWidget *mItemDock = nullptr;
QgsPanelWidgetStack *mItemPropertiesStack = nullptr;
QgsDockWidget *mGeneralDock = nullptr;
QgsPanelWidgetStack *mGeneralPropertiesStack = nullptr;
QgsDockWidget *mGuideDock = nullptr;
QgsPanelWidgetStack *mGuideStack = nullptr;
QUndoView *mUndoView = nullptr;
QgsDockWidget *mUndoDock = nullptr;
QgsDockWidget *mItemsDock = nullptr;
QgsLayoutItemsListView *mItemsTreeView = nullptr;
QAction *mUndoAction = nullptr;
QAction *mRedoAction = nullptr;
struct PanelStatus
{
PanelStatus( bool visible = true, bool active = false )
: isVisible( visible )
, isActive( active )
{}
bool isVisible;
bool isActive;
};
QMap< QString, PanelStatus > mPanelStatus;
//! Save window state
void saveWindowState();
//! Restore the window and toolbar state
void restoreWindowState();
//! Switch to new item creation tool, for a new item of the specified \a type.
void activateNewItemCreationTool( int type );
void createLayoutPropertiesWidget();
void initializeRegistry();
};
#endif // QGSLAYOUTDESIGNERDIALOG_H