Skip to content
Permalink
Browse files
Also show common properties for marker/line/polygon annotation item
widgets
  • Loading branch information
nyalldawson committed Sep 7, 2021
1 parent adcd793 commit 00177d5932eb418df10163f6814127306ec19b6c
@@ -30,7 +30,8 @@
QgsAnnotationPolygonItemWidget::QgsAnnotationPolygonItemWidget( QWidget *parent )
: QgsAnnotationItemBaseWidget( parent )
{
// setup ui
setupUi( this );

mSelector = new QgsSymbolSelectorWidget( mSymbol.get(), QgsStyle::defaultStyle(), nullptr, nullptr );
mSelector->setDockMode( dockMode() );
connect( mSelector, &QgsSymbolSelectorWidget::symbolModified, this, [ = ]
@@ -40,22 +41,33 @@ QgsAnnotationPolygonItemWidget::QgsAnnotationPolygonItemWidget( QWidget *parent
} );
connect( mSelector, &QgsPanelWidget::showPanel, this, &QgsPanelWidget::openPanel );

QVBoxLayout *layout = new QVBoxLayout( this );
QVBoxLayout *layout = new QVBoxLayout();
layout->setContentsMargins( 0, 0, 0, 0 );
layout->addWidget( mSelector );
mSymbolSelectorFrame->setLayout( layout );

connect( mPropertiesWidget, &QgsAnnotationItemCommonPropertiesWidget::itemChanged, this, [ = ]
{
if ( !mBlockChangedSignal )
emit itemChanged();
} );
}

QgsAnnotationItem *QgsAnnotationPolygonItemWidget::createItem()
{
QgsAnnotationPolygonItem *newItem = mItem->clone();
newItem->setSymbol( mSymbol->clone() );
mPropertiesWidget->updateItem( newItem );
return newItem;
}

void QgsAnnotationPolygonItemWidget::updateItem( QgsAnnotationItem *item )
{
if ( QgsAnnotationPolygonItem *polygonItem = dynamic_cast< QgsAnnotationPolygonItem * >( item ) )
{
polygonItem->setSymbol( mSymbol->clone() );
mPropertiesWidget->updateItem( polygonItem );
}
}

void QgsAnnotationPolygonItemWidget::setDockMode( bool dockMode )
@@ -85,6 +97,7 @@ bool QgsAnnotationPolygonItemWidget::setNewItem( QgsAnnotationItem *item )
mBlockChangedSignal = true;
mSelector->loadSymbol( mSymbol.get() );
mSelector->updatePreview();
mPropertiesWidget->setItem( mItem.get() );
mBlockChangedSignal = false;

return true;
@@ -98,7 +111,8 @@ bool QgsAnnotationPolygonItemWidget::setNewItem( QgsAnnotationItem *item )
QgsAnnotationLineItemWidget::QgsAnnotationLineItemWidget( QWidget *parent )
: QgsAnnotationItemBaseWidget( parent )
{
// setup ui
setupUi( this );

mSelector = new QgsSymbolSelectorWidget( mSymbol.get(), QgsStyle::defaultStyle(), nullptr, nullptr );
mSelector->setDockMode( dockMode() );
connect( mSelector, &QgsSymbolSelectorWidget::symbolModified, this, [ = ]
@@ -108,22 +122,33 @@ QgsAnnotationLineItemWidget::QgsAnnotationLineItemWidget( QWidget *parent )
} );
connect( mSelector, &QgsPanelWidget::showPanel, this, &QgsPanelWidget::openPanel );

QVBoxLayout *layout = new QVBoxLayout( this );
QVBoxLayout *layout = new QVBoxLayout();
layout->setContentsMargins( 0, 0, 0, 0 );
layout->addWidget( mSelector );
mSymbolSelectorFrame->setLayout( layout );

connect( mPropertiesWidget, &QgsAnnotationItemCommonPropertiesWidget::itemChanged, this, [ = ]
{
if ( !mBlockChangedSignal )
emit itemChanged();
} );
}

QgsAnnotationItem *QgsAnnotationLineItemWidget::createItem()
{
QgsAnnotationLineItem *newItem = mItem->clone();
newItem->setSymbol( mSymbol->clone() );
mPropertiesWidget->updateItem( newItem );
return newItem;
}

void QgsAnnotationLineItemWidget::updateItem( QgsAnnotationItem *item )
{
if ( QgsAnnotationLineItem *lineItem = dynamic_cast< QgsAnnotationLineItem * >( item ) )
{
lineItem->setSymbol( mSymbol->clone() );
mPropertiesWidget->updateItem( lineItem );
}
}

void QgsAnnotationLineItemWidget::setDockMode( bool dockMode )
@@ -153,6 +178,7 @@ bool QgsAnnotationLineItemWidget::setNewItem( QgsAnnotationItem *item )
mBlockChangedSignal = true;
mSelector->loadSymbol( mSymbol.get() );
mSelector->updatePreview();
mPropertiesWidget->setItem( mItem.get() );
mBlockChangedSignal = false;

return true;
@@ -166,7 +192,8 @@ bool QgsAnnotationLineItemWidget::setNewItem( QgsAnnotationItem *item )
QgsAnnotationMarkerItemWidget::QgsAnnotationMarkerItemWidget( QWidget *parent )
: QgsAnnotationItemBaseWidget( parent )
{
// setup ui
setupUi( this );

mSelector = new QgsSymbolSelectorWidget( mSymbol.get(), QgsStyle::defaultStyle(), nullptr, nullptr );
mSelector->setDockMode( dockMode() );
connect( mSelector, &QgsSymbolSelectorWidget::symbolModified, this, [ = ]
@@ -176,22 +203,33 @@ QgsAnnotationMarkerItemWidget::QgsAnnotationMarkerItemWidget( QWidget *parent )
} );
connect( mSelector, &QgsPanelWidget::showPanel, this, &QgsPanelWidget::openPanel );

QVBoxLayout *layout = new QVBoxLayout( this );
QVBoxLayout *layout = new QVBoxLayout();
layout->setContentsMargins( 0, 0, 0, 0 );
layout->addWidget( mSelector );
mSymbolSelectorFrame->setLayout( layout );

connect( mPropertiesWidget, &QgsAnnotationItemCommonPropertiesWidget::itemChanged, this, [ = ]
{
if ( !mBlockChangedSignal )
emit itemChanged();
} );
}

QgsAnnotationItem *QgsAnnotationMarkerItemWidget::createItem()
{
QgsAnnotationMarkerItem *newItem = mItem->clone();
newItem->setSymbol( mSymbol->clone() );
mPropertiesWidget->updateItem( newItem );
return newItem;
}

void QgsAnnotationMarkerItemWidget::updateItem( QgsAnnotationItem *item )
{
if ( QgsAnnotationMarkerItem *markerItem = dynamic_cast< QgsAnnotationMarkerItem * >( item ) )
{
markerItem->setSymbol( mSymbol->clone() );
mPropertiesWidget->updateItem( markerItem );
}
}

void QgsAnnotationMarkerItemWidget::setDockMode( bool dockMode )
@@ -221,6 +259,7 @@ bool QgsAnnotationMarkerItemWidget::setNewItem( QgsAnnotationItem *item )
mBlockChangedSignal = true;
mSelector->loadSymbol( mSymbol.get() );
mSelector->updatePreview();
mPropertiesWidget->setItem( mItem.get() );
mBlockChangedSignal = false;

return true;
@@ -22,6 +22,7 @@
#include <memory>

#include "ui_qgsannotationpointtextwidgetbase.h"
#include "ui_qgsannotationsymbolwidgetbase.h"

class QgsSymbolSelectorWidget;
class QgsFillSymbol;
@@ -37,7 +38,7 @@ class QgsTextFormatWidget;

///@cond PRIVATE

class QgsAnnotationPolygonItemWidget : public QgsAnnotationItemBaseWidget
class QgsAnnotationPolygonItemWidget : public QgsAnnotationItemBaseWidget, private Ui_QgsAnnotationSymbolWidgetBase
{
Q_OBJECT

@@ -59,7 +60,7 @@ class QgsAnnotationPolygonItemWidget : public QgsAnnotationItemBaseWidget
std::unique_ptr< QgsAnnotationPolygonItem> mItem;
};

class QgsAnnotationLineItemWidget : public QgsAnnotationItemBaseWidget
class QgsAnnotationLineItemWidget : public QgsAnnotationItemBaseWidget, private Ui_QgsAnnotationSymbolWidgetBase
{
Q_OBJECT

@@ -81,7 +82,7 @@ class QgsAnnotationLineItemWidget : public QgsAnnotationItemBaseWidget
std::unique_ptr< QgsAnnotationLineItem> mItem;
};

class QgsAnnotationMarkerItemWidget : public QgsAnnotationItemBaseWidget
class QgsAnnotationMarkerItemWidget : public QgsAnnotationItemBaseWidget, private Ui_QgsAnnotationSymbolWidgetBase
{
Q_OBJECT

@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QgsAnnotationSymbolWidgetBase</class>
<widget class="QWidget" name="QgsAnnotationSymbolWidgetBase">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>321</width>
<height>325</height>
</rect>
</property>
<property name="windowTitle">
<string>Marker Annotation</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QFrame" name="mSymbolSelectorFrame">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QgsAnnotationItemCommonPropertiesWidget" name="mPropertiesWidget" native="true"/>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QgsAnnotationItemCommonPropertiesWidget</class>
<extends>QWidget</extends>
<header>qgsannotationitemcommonpropertieswidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

0 comments on commit 00177d5

Please sign in to comment.