QGIS API Documentation  3.12.1-BucureČ™ti (121cc00ff0)
qgslayoutpicturewidget.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgslayoutpicturewidget.h
3  --------------------------
4  begin : October 2017
5  copyright : (C) 2017 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 #ifndef QGSLAYOUTPICTUREWIDGET_H
19 #define QGSLAYOUTPICTUREWIDGET_H
20 
21 // We don't want to expose this in the public API
22 #define SIP_NO_FILE
23 
24 #include "qgis_gui.h"
25 #include "ui_qgslayoutpicturewidgetbase.h"
26 #include "qgslayoutitemwidget.h"
27 
29 
37 class GUI_EXPORT QgsLayoutPictureWidget: public QgsLayoutItemBaseWidget, private Ui::QgsLayoutPictureWidgetBase
38 {
39  Q_OBJECT
40 
41  public:
43  explicit QgsLayoutPictureWidget( QgsLayoutItemPicture *picture );
44  void setMasterLayout( QgsMasterLayoutInterface *masterLayout ) override;
45 
47  void addStandardDirectoriesToPreview();
48 
49  private slots:
50  void mPictureBrowseButton_clicked();
51  void mPictureLineEdit_editingFinished();
52  void mPictureRotationSpinBox_valueChanged( double d );
53  void mPreviewListWidget_currentItemChanged( QListWidgetItem *current, QListWidgetItem *previous );
54  void mAddDirectoryButton_clicked();
55  void mRemoveDirectoryButton_clicked();
56  void mRotationFromComposerMapCheckBox_stateChanged( int state );
57  void mapChanged( QgsLayoutItem *item );
58  void mResizeModeComboBox_currentIndexChanged( int index );
59  void mAnchorPointComboBox_currentIndexChanged( int index );
60 
61  protected:
62 
63  bool setNewItem( QgsLayoutItem *item ) override;
64 
65  void resizeEvent( QResizeEvent *event ) override;
66 
67  protected slots:
69  void populateDataDefinedButtons();
70 
71  private slots:
73  void setGuiElementValues();
74 
76  void setPicRotationSpinValue( double r );
77 
81  void loadPicturePreviews( bool collapsed );
82 
83  void mFillColorButton_colorChanged( const QColor &color );
84  void mStrokeColorButton_colorChanged( const QColor &color );
85  void mStrokeWidthSpinBox_valueChanged( double d );
86  void mPictureRotationOffsetSpinBox_valueChanged( double d );
87  void mNorthTypeComboBox_currentIndexChanged( int index );
88 
89  private:
90  QPointer< QgsLayoutItemPicture > mPicture;
91  QgsLayoutItemPropertiesWidget *mItemPropertiesWidget = nullptr;
92 
93 
95  bool mPreviewsLoaded = false;
96 
98  int addDirectoryToPreview( const QString &path );
99 
101  bool testSvgFile( const QString &filename ) const;
103  bool testImageFile( const QString &filename ) const;
104 
106  QIcon svgToIcon( const QString &filePath ) const;
107 
108  void updateSvgParamGui( bool resetValues = true );
109 };
110 
111 #endif // QGSLAYOUTPICTUREWIDGET_H
Base class for graphical items within a QgsLayout.
A layout item subclass that displays SVG files or raster format images (jpg, png, ...
A widget for controlling the common properties of layout items (e.g.
virtual void setMasterLayout(QgsMasterLayoutInterface *masterLayout)
Sets the master layout associated with the item.
A widget for configuring layout picture items.
virtual bool setNewItem(QgsLayoutItem *item)
Attempts to update the widget to show the properties for the specified item.
A base class for property widgets for layout items.
Interface for master layout type objects, such as print layouts and reports.