1 /***************************************************************************
2                              qgslayoutnewitempropertiesdialog.h
3                              ----------------------------------
4     Date                 : July 2017
5     Copyright            : (C) 2017 Nyall Dawson
6     Email                : nyall dot dawson at gmail dot com
7  ***************************************************************************
8  *                                                                         *
9  *   This program is free software; you can redistribute it and/or modify  *
10  *   it under the terms of the GNU General Public License as published by  *
11  *   the Free Software Foundation; either version 2 of the License, or     *
12  *   (at your option) any later version.                                   *
13  *                                                                         *
14  ***************************************************************************/
15 
16 #ifndef QGSLAYOUTNEWITEMPROPERTIESDIALOG_H
17 #define QGSLAYOUTNEWITEMPROPERTIESDIALOG_H
18 
19 #include "qgis_sip.h"
20 #include "qgis_gui.h"
21 #include "ui_qgslayoutnewitemproperties.h"
22 
23 #include "qgslayoutsize.h"
24 #include "qgslayoutpoint.h"
25 #include "qgslayoutitem.h"
26 
27 /**
28  * \ingroup gui
29  * \brief A dialog for configuring properties like the size and position of layout items.
30  *
31  * This is usually used only when constructing new layout items, allowing users to precisely
32  * enter their sizes and positions.
33  *
34  * \since QGIS 3.0
35  */
36 class GUI_EXPORT QgsLayoutItemPropertiesDialog : public QDialog, private Ui::QgsLayoutNewItemPropertiesDialog
37 {
38     Q_OBJECT
39 
40   public:
41 
42     /**
43      * Constructor for QgsLayoutNewItemPropertiesDialog.
44      */
45     QgsLayoutItemPropertiesDialog( QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags() );
46 
47     /**
48      * Sets the item \a position to show in the dialog.
49      * \see itemPosition()
50      */
51     void setItemPosition( QgsLayoutPoint position );
52 
53     /**
54      * Returns the current item position defined by the dialog.
55      * \see setItemPosition()
56      */
57     QgsLayoutPoint itemPosition() const;
58 
59     /**
60      * Returns the page number for the new item.
61      */
62     int page() const;
63 
64     /**
65      * Sets the item \a size to show in the dialog.
66      * \see itemSize()
67      */
68     void setItemSize( QgsLayoutSize size );
69 
70     /**
71      * Returns the item size defined by the dialog.
72      * \see setItemSize()
73      */
74     QgsLayoutSize itemSize() const;
75 
76     /**
77      * Returns the item reference point defined by the dialog.
78      * \see setReferencePoint()
79      */
80     QgsLayoutItem::ReferencePoint referencePoint() const;
81 
82     /**
83      * Sets the item reference \a point defined to show in the dialog.
84      * \see referencePoint()
85      */
86     void setReferencePoint( QgsLayoutItem::ReferencePoint point );
87 
88     /**
89      * Sets the \a layout associated with the dialog. This allows the dialog
90      * to retrieve properties from the layout and perform tasks like automatic
91      * conversion of units.
92      */
93     void setLayout( QgsLayout *layout );
94 
95   private:
96 
97     QgsLayout *mLayout = nullptr;
98 
99   private slots:
100     void showHelp();
101 
102 };
103 
104 #endif // QGSLAYOUTNEWITEMPROPERTIESDIALOG_H
105