/
qgslayoutdesignerdialog.h
582 lines (461 loc) · 16.6 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
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
/***************************************************************************
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 "qgslayoutexporter.h"
#include "qgslayoutpagecollection.h"
#include <QToolButton>
class QgsLayoutDesignerDialog;
class QgsLayoutView;
class QgsLayoutViewToolAddItem;
class QgsLayoutViewToolAddNodeItem;
class QgsLayoutViewToolPan;
class QgsLayoutViewToolZoom;
class QgsLayoutViewToolSelect;
class QgsLayoutViewToolEditNodes;
class QgsLayoutViewToolMoveItemContent;
class QgsLayoutRuler;
class QComboBox;
class QSlider;
class QLabel;
class QProgressBar;
class QgsLayoutAppMenuProvider;
class QgsLayoutItem;
class QgsPanelWidgetStack;
class QgsDockWidget;
class QUndoView;
class QTreeView;
class QgsLayoutItemsListView;
class QgsLayoutPropertiesWidget;
class QgsMessageBar;
class QgsLayoutAtlas;
class QgsFeature;
class QgsMasterLayoutInterface;
class QgsLayoutGuideWidget;
class QgsAppLayoutDesignerInterface : public QgsLayoutDesignerInterface
{
Q_OBJECT
public:
QgsAppLayoutDesignerInterface( QgsLayoutDesignerDialog *dialog );
QWidget *window() override;
QgsLayout *layout() override;
QgsMasterLayoutInterface *masterLayout() override;
QgsLayoutView *view() override;
QgsMessageBar *messageBar() override;
void selectItems( const QList< QgsLayoutItem * > &items ) override;
void setAtlasPreviewEnabled( bool enabled ) override;
void setAtlasFeature( const QgsFeature &feature ) override;
bool atlasPreviewEnabled() const override;
void showItemOptions( QgsLayoutItem *item, bool bringPanelToFront = true ) override;
QMenu *layoutMenu() override;
QMenu *editMenu() override;
QMenu *viewMenu() override;
QMenu *itemsMenu() override;
QMenu *atlasMenu() override;
QMenu *reportMenu() override;
QMenu *settingsMenu() override;
QToolBar *layoutToolbar() override;
QToolBar *navigationToolbar() override;
QToolBar *actionsToolbar() override;
QToolBar *atlasToolbar() override;
void addDockWidget( Qt::DockWidgetArea area, QDockWidget *dock ) override;
void removeDockWidget( QDockWidget *dock ) override;
void activateTool( StandardTool tool ) override;
QgsLayoutDesignerInterface::ExportResults *lastExportResults() const override;
public slots:
void close() override;
void showRulers( bool visible ) override;
private:
QgsLayoutDesignerDialog *mDesigner = nullptr;
};
/**
* \ingroup app
* \brief A window for designing layouts.
*/
class QgsLayoutDesignerDialog: public QMainWindow, public Ui::QgsLayoutDesignerBase
{
Q_OBJECT
public:
QgsLayoutDesignerDialog( QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags() );
~QgsLayoutDesignerDialog() override;
/**
* 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 master \a layout to edit in the designer.
* \see masterLayout()
*/
void setMasterLayout( QgsMasterLayoutInterface *layout );
/**
* Returns the current master layout associated with the designer.
* \see setMasterLayout()
*/
QgsMasterLayoutInterface *masterLayout();
/**
* 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 );
/**
* Selects the specified \a items.
*/
void selectItems( const QList<QgsLayoutItem *> &items );
/**
* Returns the designer's message bar.
*/
QgsMessageBar *messageBar();
/**
* Toggles whether the atlas preview mode should be \a enabled in the designer.
*
* \see atlasPreviewModeEnabled()
*/
void setAtlasPreviewEnabled( bool enabled );
/**
* Returns whether the atlas preview mode is enabled in the designer.
*
* \see setAtlasPreviewEnabled()
*/
bool atlasPreviewEnabled() const;
/**
* Sets the specified feature as the current atlas feature
*/
void setAtlasFeature( const QgsFeature &feature );
/**
* Sets a section \a title, to use to update the dialog title to display
* the currently edited section.
*/
void setSectionTitle( const QString &title );
/**
* Overloaded function used to sort menu entries alphabetically
*/
QMenu *createPopupMenu() override;
/**
* Returns the dialog's guide manager widget, if it exists.
*/
QgsLayoutGuideWidget *guideWidget();
/**
* Toggles the visibility of the guide manager dock widget.
*/
void showGuideDock( bool show );
/**
* Returns the results of the last export operation performed in the designer.
*
* May be NULLPTR if no export has been performed in the designer.
*/
std::unique_ptr< QgsLayoutDesignerInterface::ExportResults > lastExportResults() const;
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();
/**
* Pastes items from the clipboard to the current layout.
* \see pasteInPlace()
*/
void paste();
/**
* Pastes item (in place) from the clipboard to the current layout.
* \see paste()
*/
void pasteInPlace();
signals:
/**
* Emitted when the dialog is about to close.
*/
void aboutToClose();
/**
* Emitted whenever a layout is exported from the layout designer.
*
*/
void layoutExported();
protected:
void closeEvent( QCloseEvent * ) override;
void dropEvent( QDropEvent *event ) override;
void dragEnterEvent( QDragEnterEvent *event ) override;
private slots:
void setTitle( const QString &title );
void itemTypeAdded( int id );
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 );
void undoRedoOccurredForItems( const QSet< QString > &itemUuids );
void saveAsTemplate();
void addItemsFromTemplate();
void duplicate();
void saveProject();
void newLayout();
void showManager();
void renameLayout();
void deleteLayout();
void print();
void exportToRaster();
void exportToPdf();
void exportToSvg();
void atlasPreviewTriggered( bool checked );
void atlasPageComboEditingFinished();
void atlasNext();
void atlasPrevious();
void atlasFirst();
void atlasLast();
void printAtlas();
void exportAtlasToRaster();
void exportAtlasToSvg();
void exportAtlasToPdf();
void exportReportToRaster();
void exportReportToSvg();
void exportReportToPdf();
void printReport();
void pageSetup();
//! Sets the printer page orientation when the page orientation changes
void pageOrientationChanged();
//! Populate layouts menu from main app's
void populateLayoutsMenu();
void updateWindowTitle();
void backgroundTaskCountChanged( int total );
private:
static bool sInitializedRegistry;
QgsAppLayoutDesignerInterface *mInterface = nullptr;
QgsMasterLayoutInterface *mMasterLayout = nullptr;
QgsLayout *mLayout = nullptr;
QgsMessageBar *mMessageBar = 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;
QgsLayoutViewToolAddItem *mAddItemTool = nullptr;
QgsLayoutViewToolAddNodeItem *mAddNodeItemTool = nullptr;
QgsLayoutViewToolPan *mPanTool = nullptr;
QgsLayoutViewToolZoom *mZoomTool = nullptr;
QgsLayoutViewToolSelect *mSelectTool = nullptr;
QgsLayoutViewToolEditNodes *mNodesTool = nullptr;
QgsLayoutViewToolMoveItemContent *mMoveContentTool = 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;
QgsDockWidget *mAtlasDock = nullptr;
QgsLayoutPropertiesWidget *mLayoutPropertiesWidget = nullptr;
QUndoView *mUndoView = nullptr;
QgsDockWidget *mUndoDock = nullptr;
QgsDockWidget *mItemsDock = nullptr;
QgsLayoutItemsListView *mItemsTreeView = nullptr;
QgsDockWidget *mReportDock = nullptr;
QAction *mUndoAction = nullptr;
QAction *mRedoAction = nullptr;
//! Copy/cut/paste actions
QAction *mActionCut = nullptr;
QAction *mActionCopy = nullptr;
QAction *mActionPaste = nullptr;
QProgressBar *mStatusProgressBar = nullptr;
QMenu *mDynamicTextMenu = nullptr;
struct PanelStatus
{
PanelStatus( bool visible = true, bool active = false )
: isVisible( visible )
, isActive( active )
{}
bool isVisible;
bool isActive;
};
QMap< QString, PanelStatus > mPanelStatus;
bool mBlockItemOptions = false;
QComboBox *mAtlasPageComboBox = nullptr;
//! Page & Printer Setup
std::unique_ptr< QPrinter > mPrinter;
bool mSetPageOrientation = false;
QString mTitle;
QString mSectionTitle;
QgsLayoutGuideWidget *mGuideWidget = nullptr;
bool mIsExportingAtlas = false;
void storeExportResults( QgsLayoutExporter::ExportResult result, QgsLayoutExporter *exporter = nullptr );
std::unique_ptr< QgsLayoutDesignerInterface::ExportResults> mLastExportResults;
QMap< QString, QgsLabelingResults *> mLastExportLabelingResults;
//! 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 id.
void activateNewItemCreationTool( int id, bool nodeBasedItem );
void createLayoutPropertiesWidget();
void createAtlasWidget();
void createReportWidget();
void initializeRegistry();
bool containsWmsLayers() const;
//! Displays a warning because of possible min/max size in WMS
void showWmsPrintingWarning();
void showSvgExportWarning();
//! Displays a warning because of incompatibility between blend modes and QPrinter
void showRasterizationWarning();
void showForceVectorWarning();
bool showFileSizeWarning();
bool getRasterExportSettings( QgsLayoutExporter::ImageExportSettings &settings, QSize &imageSize );
bool getSvgExportSettings( QgsLayoutExporter::SvgExportSettings &settings );
bool getPdfExportSettings( QgsLayoutExporter::PdfExportSettings &settings, bool allowGeoPdfExport = true, const QString &geoPdfReason = QString() );
void toggleAtlasActions( bool enabled );
/**
* Toggles the state of the atlas preview and navigation controls
*/
void toggleAtlasControls( bool atlasEnabled );
/**
* Repopulates the atlas page combo box with valid items.
*/
void updateAtlasPageComboBox( int pageCount );
void atlasFeatureChanged( const QgsFeature &feature );
//! Load predefined scales from the project's properties
void loadPredefinedScalesFromProject();
QgsLayoutAtlas *atlas();
void toggleActions( bool layoutAvailable );
void setPrinterPageOrientation( QgsLayoutItemPage::Orientation orientation );
QPrinter *printer();
QString reportTypeString();
void updateActionNames( QgsMasterLayoutInterface::Type type );
QString defaultExportPath() const;
void setLastExportPath( const QString &path ) const;
bool checkBeforeExport();
//! update default action of toolbutton
void toolButtonActionTriggered( QAction * );
friend class QgsAtlasExportGuard;
};
#endif // QGSLAYOUTDESIGNERDIALOG_H