Skip to content

Commit b2414d8

Browse files
committedNov 7, 2017
Start porting item properties widget
1 parent d3836e5 commit b2414d8

15 files changed

+4629
-7
lines changed
 

‎python/core/layout/qgslayoutitem.sip

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ class QgsLayoutItem : QgsLayoutObject, QGraphicsRectItem, QgsLayoutUndoObjectInt
5353
enum UndoCommand
5454
{
5555
UndoIncrementalMove,
56+
UndoStrokeColor,
57+
UndoStrokeWidth,
58+
UndoBackgroundColor,
59+
UndoOpacity,
60+
UndoSetId,
61+
UndoRotation,
5662
};
5763

5864
explicit QgsLayoutItem( QgsLayout *layout, bool manageZValue = true );

‎python/core/layout/qgslayoutobject.sip

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,13 @@ class QgsLayoutObject: QObject, QgsExpressionContextGenerator
166166
Refreshes the object, causing a recalculation of any property overrides.
167167
%End
168168

169+
signals:
170+
171+
void changed();
172+
%Docstring
173+
Emitted when the object's properties change.
174+
%End
175+
169176
protected:
170177

171178
bool writeObjectPropertiesToElement( QDomElement &parentElement, QDomDocument &document, const QgsReadWriteContext &context ) const;

‎python/gui/layout/qgslayoutitemwidget.sip

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,43 @@ class QgsLayoutItemBaseWidget: QgsPanelWidget
9797

9898
};
9999

100+
101+
class QgsLayoutItemPropertiesWidget: QWidget
102+
{
103+
%Docstring
104+
A widget for controlling the common properties of layout items (e.g. position and size, background, stroke, frame).
105+
This widget can be embedded into other layout item widgets.
106+
.. versionadded:: 3.0
107+
%End
108+
109+
%TypeHeaderCode
110+
#include "qgslayoutitemwidget.h"
111+
%End
112+
public:
113+
QgsLayoutItemPropertiesWidget( QWidget *parent, QgsLayoutItem *item );
114+
115+
QgsLayoutItem::ReferencePoint positionMode() const;
116+
%Docstring
117+
:rtype: QgsLayoutItem.ReferencePoint
118+
%End
119+
120+
void showBackgroundGroup( bool showGroup );
121+
122+
void showFrameGroup( bool showGroup );
123+
124+
protected slots:
125+
void initializeDataDefinedButtons();
126+
%Docstring
127+
Initializes data defined buttons to current atlas coverage layer
128+
%End
129+
void populateDataDefinedButtons();
130+
%Docstring
131+
Sets data defined button state to match item
132+
%End
133+
134+
};
135+
136+
100137
/************************************************************************
101138
* This file has been generated automatically from *
102139
* *

‎src/app/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ SET(QGIS_APP_SRCS
178178
layout/qgslayoutdesignerdialog.cpp
179179
layout/qgslayoutguidewidget.cpp
180180
layout/qgslayoutappmenuprovider.cpp
181+
layout/qgslayoutmapwidget.cpp
181182
layout/qgslayoutpagepropertieswidget.cpp
182183
layout/qgslayoutpropertieswidget.cpp
183184

@@ -373,6 +374,7 @@ SET (QGIS_APP_MOC_HDRS
373374
layout/qgslayoutappmenuprovider.h
374375
layout/qgslayoutdesignerdialog.h
375376
layout/qgslayoutguidewidget.h
377+
layout/qgslayoutmapwidget.h
376378
layout/qgslayoutpagepropertieswidget.h
377379
layout/qgslayoutpropertieswidget.h
378380

‎src/app/layout/qgslayoutapputils.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
#include "qgslayoutitemguiregistry.h"
1919
#include "qgslayoutitemregistry.h"
2020
#include "qgslayoutviewrubberband.h"
21+
#include "qgslayoutmapwidget.h"
22+
#include "qgslayoutitemmap.h"
2123

2224
void QgsLayoutAppUtils::registerGuiForKnownItemTypes()
2325
{
@@ -40,7 +42,11 @@ void QgsLayoutAppUtils::registerGuiForKnownItemTypes()
4042

4143
registry->addLayoutItemGuiMetadata( new QgsLayoutItemGuiMetadata( QgsLayoutItemRegistry::LayoutItem + 1002, QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddLabel.svg" ) ), nullptr, createRubberBand ) );
4244

43-
registry->addLayoutItemGuiMetadata( new QgsLayoutItemGuiMetadata( QgsLayoutItemRegistry::LayoutMap, QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddMap.svg" ) ), nullptr, createRubberBand ) );
45+
registry->addLayoutItemGuiMetadata( new QgsLayoutItemGuiMetadata( QgsLayoutItemRegistry::LayoutMap, QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddMap.svg" ) ),
46+
[ = ]( QgsLayoutItem * item )->QgsLayoutItemBaseWidget *
47+
{
48+
return new QgsLayoutMapWidget( qobject_cast< QgsLayoutItemMap * >( item ) );
49+
}, createRubberBand ) );
4450

4551
registry->addLayoutItemGuiMetadata( new QgsLayoutItemGuiMetadata( QgsLayoutItemRegistry::LayoutRectangle, QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddBasicRectangle.svg" ) ), nullptr, createRubberBand, QStringLiteral( "shapes" ) ) );
4652
registry->addLayoutItemGuiMetadata( new QgsLayoutItemGuiMetadata( QgsLayoutItemRegistry::LayoutEllipse, QgsApplication::getThemeIcon( QStringLiteral( "/mActionAddBasicCircle.svg" ) ), nullptr, createEllipseBand, QStringLiteral( "shapes" ) ) );

0 commit comments

Comments
 (0)
Please sign in to comment.