mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-11 00:04:09 -04:00
Also show common properties for marker/line/polygon annotation item
widgets
This commit is contained in:
parent
adcd793b89
commit
00177d5932
@ -30,7 +30,8 @@
|
|||||||
QgsAnnotationPolygonItemWidget::QgsAnnotationPolygonItemWidget( QWidget *parent )
|
QgsAnnotationPolygonItemWidget::QgsAnnotationPolygonItemWidget( QWidget *parent )
|
||||||
: QgsAnnotationItemBaseWidget( parent )
|
: QgsAnnotationItemBaseWidget( parent )
|
||||||
{
|
{
|
||||||
// setup ui
|
setupUi( this );
|
||||||
|
|
||||||
mSelector = new QgsSymbolSelectorWidget( mSymbol.get(), QgsStyle::defaultStyle(), nullptr, nullptr );
|
mSelector = new QgsSymbolSelectorWidget( mSymbol.get(), QgsStyle::defaultStyle(), nullptr, nullptr );
|
||||||
mSelector->setDockMode( dockMode() );
|
mSelector->setDockMode( dockMode() );
|
||||||
connect( mSelector, &QgsSymbolSelectorWidget::symbolModified, this, [ = ]
|
connect( mSelector, &QgsSymbolSelectorWidget::symbolModified, this, [ = ]
|
||||||
@ -40,22 +41,33 @@ QgsAnnotationPolygonItemWidget::QgsAnnotationPolygonItemWidget( QWidget *parent
|
|||||||
} );
|
} );
|
||||||
connect( mSelector, &QgsPanelWidget::showPanel, this, &QgsPanelWidget::openPanel );
|
connect( mSelector, &QgsPanelWidget::showPanel, this, &QgsPanelWidget::openPanel );
|
||||||
|
|
||||||
QVBoxLayout *layout = new QVBoxLayout( this );
|
QVBoxLayout *layout = new QVBoxLayout();
|
||||||
layout->setContentsMargins( 0, 0, 0, 0 );
|
layout->setContentsMargins( 0, 0, 0, 0 );
|
||||||
layout->addWidget( mSelector );
|
layout->addWidget( mSelector );
|
||||||
|
mSymbolSelectorFrame->setLayout( layout );
|
||||||
|
|
||||||
|
connect( mPropertiesWidget, &QgsAnnotationItemCommonPropertiesWidget::itemChanged, this, [ = ]
|
||||||
|
{
|
||||||
|
if ( !mBlockChangedSignal )
|
||||||
|
emit itemChanged();
|
||||||
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
QgsAnnotationItem *QgsAnnotationPolygonItemWidget::createItem()
|
QgsAnnotationItem *QgsAnnotationPolygonItemWidget::createItem()
|
||||||
{
|
{
|
||||||
QgsAnnotationPolygonItem *newItem = mItem->clone();
|
QgsAnnotationPolygonItem *newItem = mItem->clone();
|
||||||
newItem->setSymbol( mSymbol->clone() );
|
newItem->setSymbol( mSymbol->clone() );
|
||||||
|
mPropertiesWidget->updateItem( newItem );
|
||||||
return newItem;
|
return newItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsAnnotationPolygonItemWidget::updateItem( QgsAnnotationItem *item )
|
void QgsAnnotationPolygonItemWidget::updateItem( QgsAnnotationItem *item )
|
||||||
{
|
{
|
||||||
if ( QgsAnnotationPolygonItem *polygonItem = dynamic_cast< QgsAnnotationPolygonItem * >( item ) )
|
if ( QgsAnnotationPolygonItem *polygonItem = dynamic_cast< QgsAnnotationPolygonItem * >( item ) )
|
||||||
|
{
|
||||||
polygonItem->setSymbol( mSymbol->clone() );
|
polygonItem->setSymbol( mSymbol->clone() );
|
||||||
|
mPropertiesWidget->updateItem( polygonItem );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsAnnotationPolygonItemWidget::setDockMode( bool dockMode )
|
void QgsAnnotationPolygonItemWidget::setDockMode( bool dockMode )
|
||||||
@ -85,6 +97,7 @@ bool QgsAnnotationPolygonItemWidget::setNewItem( QgsAnnotationItem *item )
|
|||||||
mBlockChangedSignal = true;
|
mBlockChangedSignal = true;
|
||||||
mSelector->loadSymbol( mSymbol.get() );
|
mSelector->loadSymbol( mSymbol.get() );
|
||||||
mSelector->updatePreview();
|
mSelector->updatePreview();
|
||||||
|
mPropertiesWidget->setItem( mItem.get() );
|
||||||
mBlockChangedSignal = false;
|
mBlockChangedSignal = false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -98,7 +111,8 @@ bool QgsAnnotationPolygonItemWidget::setNewItem( QgsAnnotationItem *item )
|
|||||||
QgsAnnotationLineItemWidget::QgsAnnotationLineItemWidget( QWidget *parent )
|
QgsAnnotationLineItemWidget::QgsAnnotationLineItemWidget( QWidget *parent )
|
||||||
: QgsAnnotationItemBaseWidget( parent )
|
: QgsAnnotationItemBaseWidget( parent )
|
||||||
{
|
{
|
||||||
// setup ui
|
setupUi( this );
|
||||||
|
|
||||||
mSelector = new QgsSymbolSelectorWidget( mSymbol.get(), QgsStyle::defaultStyle(), nullptr, nullptr );
|
mSelector = new QgsSymbolSelectorWidget( mSymbol.get(), QgsStyle::defaultStyle(), nullptr, nullptr );
|
||||||
mSelector->setDockMode( dockMode() );
|
mSelector->setDockMode( dockMode() );
|
||||||
connect( mSelector, &QgsSymbolSelectorWidget::symbolModified, this, [ = ]
|
connect( mSelector, &QgsSymbolSelectorWidget::symbolModified, this, [ = ]
|
||||||
@ -108,22 +122,33 @@ QgsAnnotationLineItemWidget::QgsAnnotationLineItemWidget( QWidget *parent )
|
|||||||
} );
|
} );
|
||||||
connect( mSelector, &QgsPanelWidget::showPanel, this, &QgsPanelWidget::openPanel );
|
connect( mSelector, &QgsPanelWidget::showPanel, this, &QgsPanelWidget::openPanel );
|
||||||
|
|
||||||
QVBoxLayout *layout = new QVBoxLayout( this );
|
QVBoxLayout *layout = new QVBoxLayout();
|
||||||
layout->setContentsMargins( 0, 0, 0, 0 );
|
layout->setContentsMargins( 0, 0, 0, 0 );
|
||||||
layout->addWidget( mSelector );
|
layout->addWidget( mSelector );
|
||||||
|
mSymbolSelectorFrame->setLayout( layout );
|
||||||
|
|
||||||
|
connect( mPropertiesWidget, &QgsAnnotationItemCommonPropertiesWidget::itemChanged, this, [ = ]
|
||||||
|
{
|
||||||
|
if ( !mBlockChangedSignal )
|
||||||
|
emit itemChanged();
|
||||||
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
QgsAnnotationItem *QgsAnnotationLineItemWidget::createItem()
|
QgsAnnotationItem *QgsAnnotationLineItemWidget::createItem()
|
||||||
{
|
{
|
||||||
QgsAnnotationLineItem *newItem = mItem->clone();
|
QgsAnnotationLineItem *newItem = mItem->clone();
|
||||||
newItem->setSymbol( mSymbol->clone() );
|
newItem->setSymbol( mSymbol->clone() );
|
||||||
|
mPropertiesWidget->updateItem( newItem );
|
||||||
return newItem;
|
return newItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsAnnotationLineItemWidget::updateItem( QgsAnnotationItem *item )
|
void QgsAnnotationLineItemWidget::updateItem( QgsAnnotationItem *item )
|
||||||
{
|
{
|
||||||
if ( QgsAnnotationLineItem *lineItem = dynamic_cast< QgsAnnotationLineItem * >( item ) )
|
if ( QgsAnnotationLineItem *lineItem = dynamic_cast< QgsAnnotationLineItem * >( item ) )
|
||||||
|
{
|
||||||
lineItem->setSymbol( mSymbol->clone() );
|
lineItem->setSymbol( mSymbol->clone() );
|
||||||
|
mPropertiesWidget->updateItem( lineItem );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsAnnotationLineItemWidget::setDockMode( bool dockMode )
|
void QgsAnnotationLineItemWidget::setDockMode( bool dockMode )
|
||||||
@ -153,6 +178,7 @@ bool QgsAnnotationLineItemWidget::setNewItem( QgsAnnotationItem *item )
|
|||||||
mBlockChangedSignal = true;
|
mBlockChangedSignal = true;
|
||||||
mSelector->loadSymbol( mSymbol.get() );
|
mSelector->loadSymbol( mSymbol.get() );
|
||||||
mSelector->updatePreview();
|
mSelector->updatePreview();
|
||||||
|
mPropertiesWidget->setItem( mItem.get() );
|
||||||
mBlockChangedSignal = false;
|
mBlockChangedSignal = false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -166,7 +192,8 @@ bool QgsAnnotationLineItemWidget::setNewItem( QgsAnnotationItem *item )
|
|||||||
QgsAnnotationMarkerItemWidget::QgsAnnotationMarkerItemWidget( QWidget *parent )
|
QgsAnnotationMarkerItemWidget::QgsAnnotationMarkerItemWidget( QWidget *parent )
|
||||||
: QgsAnnotationItemBaseWidget( parent )
|
: QgsAnnotationItemBaseWidget( parent )
|
||||||
{
|
{
|
||||||
// setup ui
|
setupUi( this );
|
||||||
|
|
||||||
mSelector = new QgsSymbolSelectorWidget( mSymbol.get(), QgsStyle::defaultStyle(), nullptr, nullptr );
|
mSelector = new QgsSymbolSelectorWidget( mSymbol.get(), QgsStyle::defaultStyle(), nullptr, nullptr );
|
||||||
mSelector->setDockMode( dockMode() );
|
mSelector->setDockMode( dockMode() );
|
||||||
connect( mSelector, &QgsSymbolSelectorWidget::symbolModified, this, [ = ]
|
connect( mSelector, &QgsSymbolSelectorWidget::symbolModified, this, [ = ]
|
||||||
@ -176,22 +203,33 @@ QgsAnnotationMarkerItemWidget::QgsAnnotationMarkerItemWidget( QWidget *parent )
|
|||||||
} );
|
} );
|
||||||
connect( mSelector, &QgsPanelWidget::showPanel, this, &QgsPanelWidget::openPanel );
|
connect( mSelector, &QgsPanelWidget::showPanel, this, &QgsPanelWidget::openPanel );
|
||||||
|
|
||||||
QVBoxLayout *layout = new QVBoxLayout( this );
|
QVBoxLayout *layout = new QVBoxLayout();
|
||||||
layout->setContentsMargins( 0, 0, 0, 0 );
|
layout->setContentsMargins( 0, 0, 0, 0 );
|
||||||
layout->addWidget( mSelector );
|
layout->addWidget( mSelector );
|
||||||
|
mSymbolSelectorFrame->setLayout( layout );
|
||||||
|
|
||||||
|
connect( mPropertiesWidget, &QgsAnnotationItemCommonPropertiesWidget::itemChanged, this, [ = ]
|
||||||
|
{
|
||||||
|
if ( !mBlockChangedSignal )
|
||||||
|
emit itemChanged();
|
||||||
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
QgsAnnotationItem *QgsAnnotationMarkerItemWidget::createItem()
|
QgsAnnotationItem *QgsAnnotationMarkerItemWidget::createItem()
|
||||||
{
|
{
|
||||||
QgsAnnotationMarkerItem *newItem = mItem->clone();
|
QgsAnnotationMarkerItem *newItem = mItem->clone();
|
||||||
newItem->setSymbol( mSymbol->clone() );
|
newItem->setSymbol( mSymbol->clone() );
|
||||||
|
mPropertiesWidget->updateItem( newItem );
|
||||||
return newItem;
|
return newItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsAnnotationMarkerItemWidget::updateItem( QgsAnnotationItem *item )
|
void QgsAnnotationMarkerItemWidget::updateItem( QgsAnnotationItem *item )
|
||||||
{
|
{
|
||||||
if ( QgsAnnotationMarkerItem *markerItem = dynamic_cast< QgsAnnotationMarkerItem * >( item ) )
|
if ( QgsAnnotationMarkerItem *markerItem = dynamic_cast< QgsAnnotationMarkerItem * >( item ) )
|
||||||
|
{
|
||||||
markerItem->setSymbol( mSymbol->clone() );
|
markerItem->setSymbol( mSymbol->clone() );
|
||||||
|
mPropertiesWidget->updateItem( markerItem );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsAnnotationMarkerItemWidget::setDockMode( bool dockMode )
|
void QgsAnnotationMarkerItemWidget::setDockMode( bool dockMode )
|
||||||
@ -221,6 +259,7 @@ bool QgsAnnotationMarkerItemWidget::setNewItem( QgsAnnotationItem *item )
|
|||||||
mBlockChangedSignal = true;
|
mBlockChangedSignal = true;
|
||||||
mSelector->loadSymbol( mSymbol.get() );
|
mSelector->loadSymbol( mSymbol.get() );
|
||||||
mSelector->updatePreview();
|
mSelector->updatePreview();
|
||||||
|
mPropertiesWidget->setItem( mItem.get() );
|
||||||
mBlockChangedSignal = false;
|
mBlockChangedSignal = false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "ui_qgsannotationpointtextwidgetbase.h"
|
#include "ui_qgsannotationpointtextwidgetbase.h"
|
||||||
|
#include "ui_qgsannotationsymbolwidgetbase.h"
|
||||||
|
|
||||||
class QgsSymbolSelectorWidget;
|
class QgsSymbolSelectorWidget;
|
||||||
class QgsFillSymbol;
|
class QgsFillSymbol;
|
||||||
@ -37,7 +38,7 @@ class QgsTextFormatWidget;
|
|||||||
|
|
||||||
///@cond PRIVATE
|
///@cond PRIVATE
|
||||||
|
|
||||||
class QgsAnnotationPolygonItemWidget : public QgsAnnotationItemBaseWidget
|
class QgsAnnotationPolygonItemWidget : public QgsAnnotationItemBaseWidget, private Ui_QgsAnnotationSymbolWidgetBase
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@ -59,7 +60,7 @@ class QgsAnnotationPolygonItemWidget : public QgsAnnotationItemBaseWidget
|
|||||||
std::unique_ptr< QgsAnnotationPolygonItem> mItem;
|
std::unique_ptr< QgsAnnotationPolygonItem> mItem;
|
||||||
};
|
};
|
||||||
|
|
||||||
class QgsAnnotationLineItemWidget : public QgsAnnotationItemBaseWidget
|
class QgsAnnotationLineItemWidget : public QgsAnnotationItemBaseWidget, private Ui_QgsAnnotationSymbolWidgetBase
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@ -81,7 +82,7 @@ class QgsAnnotationLineItemWidget : public QgsAnnotationItemBaseWidget
|
|||||||
std::unique_ptr< QgsAnnotationLineItem> mItem;
|
std::unique_ptr< QgsAnnotationLineItem> mItem;
|
||||||
};
|
};
|
||||||
|
|
||||||
class QgsAnnotationMarkerItemWidget : public QgsAnnotationItemBaseWidget
|
class QgsAnnotationMarkerItemWidget : public QgsAnnotationItemBaseWidget, private Ui_QgsAnnotationSymbolWidgetBase
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
54
src/ui/annotations/qgsannotationsymbolwidgetbase.ui
Normal file
54
src/ui/annotations/qgsannotationsymbolwidgetbase.ui
Normal file
@ -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>
|
Loading…
x
Reference in New Issue
Block a user