19 #include <QColorDialog>
26 connect( mShapeListWidget, &QListWidget::itemSelectionChanged,
this, &QgsEllipseSymbolLayerWidget::mShapeListWidget_itemSelectionChanged );
27 connect( mWidthSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsEllipseSymbolLayerWidget::mWidthSpinBox_valueChanged );
28 connect( mHeightSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsEllipseSymbolLayerWidget::mHeightSpinBox_valueChanged );
29 connect( mRotationSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsEllipseSymbolLayerWidget::mRotationSpinBox_valueChanged );
30 connect( mStrokeStyleComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsEllipseSymbolLayerWidget::mStrokeStyleComboBox_currentIndexChanged );
31 connect( mStrokeWidthSpinBox,
static_cast < void ( QDoubleSpinBox::* )(
double )
> ( &QDoubleSpinBox::valueChanged ),
this, &QgsEllipseSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged );
38 connect( mHorizontalAnchorComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsEllipseSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged );
39 connect( mVerticalAnchorComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsEllipseSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged );
50 btnChangeColorFill->setAllowOpacity(
true );
51 btnChangeColorFill->setColorDialogTitle( tr(
"Select Fill Color" ) );
52 btnChangeColorFill->setContext( QStringLiteral(
"symbology" ) );
53 btnChangeColorFill->setShowNoColor(
true );
54 btnChangeColorFill->setNoColorString( tr(
"Transparent Fill" ) );
55 btnChangeColorStroke->setAllowOpacity(
true );
56 btnChangeColorStroke->setColorDialogTitle( tr(
"Select Stroke Color" ) );
57 btnChangeColorStroke->setContext( QStringLiteral(
"symbology" ) );
58 btnChangeColorStroke->setShowNoColor(
true );
59 btnChangeColorStroke->setNoColorString( tr(
"Transparent Stroke" ) );
61 mFillColorDDBtn->registerLinkedWidget( btnChangeColorFill );
62 mStrokeColorDDBtn->registerLinkedWidget( btnChangeColorStroke );
64 spinOffsetX->setClearValue( 0.0 );
65 spinOffsetY->setClearValue( 0.0 );
66 mRotationSpinBox->setClearValue( 0.0 );
69 names << QStringLiteral(
"circle" ) << QStringLiteral(
"rectangle" ) << QStringLiteral(
"diamond" ) << QStringLiteral(
"cross" ) << QStringLiteral(
"triangle" ) << QStringLiteral(
"right_half_triangle" ) << QStringLiteral(
"left_half_triangle" ) << QStringLiteral(
"semi_circle" );
71 int size = mShapeListWidget->iconSize().width();
72 #if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
73 size = std::max( 30,
static_cast< int >( std::round(
Qgis::UI_SCALE_FACTOR * fontMetrics().width(
'X' ) * 3 ) ) );
75 size = std::max( 30,
static_cast< int >( std::round(
Qgis::UI_SCALE_FACTOR * fontMetrics().horizontalAdvance(
'X' ) * 3 ) ) );
77 mShapeListWidget->setGridSize( QSize( size * 1.2, size * 1.2 ) );
78 mShapeListWidget->setIconSize( QSize( size, size ) );
80 double markerSize = size * 0.8;
81 const auto constNames = names;
82 for (
const QString &name : constNames )
93 QListWidgetItem *item =
new QListWidgetItem( icon, QString(), mShapeListWidget );
94 item->setToolTip( name );
95 item->setData( Qt::UserRole, name );
99 mShapeListWidget->setMinimumHeight( mShapeListWidget->gridSize().height() * 2.1 );
101 connect( spinOffsetX,
static_cast < void (
QgsDoubleSpinBox::* )(
double )
> ( &QgsDoubleSpinBox::valueChanged ),
this, &QgsEllipseSymbolLayerWidget::setOffset );
102 connect( spinOffsetY,
static_cast < void (
QgsDoubleSpinBox::* )(
double )
> ( &QgsDoubleSpinBox::valueChanged ),
this, &QgsEllipseSymbolLayerWidget::setOffset );
103 connect( cboJoinStyle,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsEllipseSymbolLayerWidget::penJoinStyleChanged );
108 if ( !layer || layer->
layerType() != QLatin1String(
"EllipseMarker" ) )
122 QList<QListWidgetItem *> symbolItemList = mShapeListWidget->findItems(
mLayer->
symbolName(), Qt::MatchExactly );
123 if ( !symbolItemList.isEmpty() )
125 mShapeListWidget->setCurrentItem( symbolItemList.at( 0 ) );
129 blockComboSignals(
true );
139 spinOffsetX->setValue( offsetPt.x() );
140 spinOffsetY->setValue( offsetPt.y() );
144 blockComboSignals(
false );
166 void QgsEllipseSymbolLayerWidget::mShapeListWidget_itemSelectionChanged()
170 QListWidgetItem *item = mShapeListWidget->currentItem();
179 void QgsEllipseSymbolLayerWidget::mWidthSpinBox_valueChanged(
double d )
188 void QgsEllipseSymbolLayerWidget::mHeightSpinBox_valueChanged(
double d )
197 void QgsEllipseSymbolLayerWidget::mRotationSpinBox_valueChanged(
double d )
206 void QgsEllipseSymbolLayerWidget::mStrokeStyleComboBox_currentIndexChanged(
int index )
217 void QgsEllipseSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged(
double d )
226 void QgsEllipseSymbolLayerWidget::btnChangeColorStroke_colorChanged(
const QColor &newColor )
237 void QgsEllipseSymbolLayerWidget::btnChangeColorFill_colorChanged(
const QColor &newColor )
248 void QgsEllipseSymbolLayerWidget::mSymbolWidthUnitWidget_changed()
258 void QgsEllipseSymbolLayerWidget::mStrokeWidthUnitWidget_changed()
268 void QgsEllipseSymbolLayerWidget::mSymbolHeightUnitWidget_changed()
278 void QgsEllipseSymbolLayerWidget::mOffsetUnitWidget_changed()
288 void QgsEllipseSymbolLayerWidget::penJoinStyleChanged()
294 void QgsEllipseSymbolLayerWidget::blockComboSignals(
bool block )
296 mSymbolWidthUnitWidget->blockSignals( block );
297 mStrokeWidthUnitWidget->blockSignals( block );
298 mSymbolHeightUnitWidget->blockSignals( block );
299 mHorizontalAnchorComboBox->blockSignals( block );
300 mVerticalAnchorComboBox->blockSignals( block );
301 mSymbolWidthUnitWidget->blockSignals( block );
302 mStrokeWidthUnitWidget->blockSignals( block );
303 mSymbolHeightUnitWidget->blockSignals( block );
304 mOffsetUnitWidget->blockSignals( block );
305 cboJoinStyle->blockSignals( block );
308 void QgsEllipseSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged(
int index )
317 void QgsEllipseSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged(
int index )
326 void QgsEllipseSymbolLayerWidget::setOffset()
328 mLayer->
setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );