mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-15 00:04:00 -04:00
Use symbol button for overview frame symbol
This commit is contained in:
parent
8bc57f773c
commit
aa2b73d425
@ -67,6 +67,7 @@ class QgsLayoutItem : QgsLayoutObject, QGraphicsRectItem, QgsLayoutUndoObjectInt
|
||||
UndoAtlasMargin,
|
||||
UndoMapRotation,
|
||||
UndoZoomContent,
|
||||
UndoOverviewStyle,
|
||||
};
|
||||
|
||||
explicit QgsLayoutItem( QgsLayout *layout, bool manageZValue = true );
|
||||
|
@ -43,7 +43,6 @@ QgsLayoutMapWidget::QgsLayoutMapWidget( QgsLayoutItemMap *item )
|
||||
connect( mKeepLayerListCheckBox, &QCheckBox::stateChanged, this, &QgsLayoutMapWidget::mKeepLayerListCheckBox_stateChanged );
|
||||
connect( mKeepLayerStylesCheckBox, &QCheckBox::stateChanged, this, &QgsLayoutMapWidget::mKeepLayerStylesCheckBox_stateChanged );
|
||||
connect( mDrawCanvasItemsCheckBox, &QCheckBox::stateChanged, this, &QgsLayoutMapWidget::mDrawCanvasItemsCheckBox_stateChanged );
|
||||
connect( mOverviewFrameStyleButton, &QPushButton::clicked, this, &QgsLayoutMapWidget::mOverviewFrameStyleButton_clicked );
|
||||
connect( mOverviewBlendModeComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutMapWidget::mOverviewBlendModeComboBox_currentIndexChanged );
|
||||
connect( mOverviewInvertCheckbox, &QCheckBox::toggled, this, &QgsLayoutMapWidget::mOverviewInvertCheckbox_toggled );
|
||||
connect( mOverviewCenterCheckbox, &QCheckBox::toggled, this, &QgsLayoutMapWidget::mOverviewCenterCheckbox_toggled );
|
||||
@ -90,6 +89,8 @@ QgsLayoutMapWidget::QgsLayoutMapWidget( QgsLayoutItemMap *item )
|
||||
mCrsSelector->setOptionVisible( QgsProjectionSelectionWidget::CrsNotSet, true );
|
||||
mCrsSelector->setNotSetText( tr( "Use project CRS" ) );
|
||||
|
||||
mOverviewFrameStyleButton->setSymbolType( QgsSymbol::Fill );
|
||||
|
||||
// follow preset combo
|
||||
mFollowVisibilityPresetCombo->setModel( new QStringListModel( mFollowVisibilityPresetCombo ) );
|
||||
connect( mFollowVisibilityPresetCombo, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutMapWidget::followVisibilityPresetSelected );
|
||||
@ -104,6 +105,8 @@ QgsLayoutMapWidget::QgsLayoutMapWidget( QgsLayoutItemMap *item )
|
||||
mLayerListFromPresetButton->setToolTip( tr( "Set layer list from a map theme" ) );
|
||||
connect( menuKeepLayers, &QMenu::aboutToShow, this, &QgsLayoutMapWidget::aboutToShowKeepLayersVisibilityPresetsMenu );
|
||||
|
||||
mOverviewFrameMapComboBox->setItemType( QgsLayoutItemRegistry::LayoutMap );
|
||||
|
||||
if ( item )
|
||||
{
|
||||
connect( item, &QgsLayoutObject::changed, this, &QgsLayoutMapWidget::updateGuiElements );
|
||||
@ -120,12 +123,12 @@ QgsLayoutMapWidget::QgsLayoutMapWidget( QgsLayoutItemMap *item )
|
||||
}
|
||||
#endif
|
||||
mOverviewFrameMapComboBox->setCurrentLayout( item->layout() );
|
||||
mOverviewFrameMapComboBox->setItemType( QgsLayoutItemRegistry::LayoutMap );
|
||||
|
||||
connect( mOverviewFrameMapComboBox, &QgsLayoutItemComboBox::itemChanged, this, &QgsLayoutMapWidget::overviewMapChanged );
|
||||
mOverviewFrameStyleButton->registerExpressionContextGenerator( item );
|
||||
}
|
||||
|
||||
connect( mOverviewFrameMapComboBox, &QgsLayoutItemComboBox::itemChanged, this, &QgsLayoutMapWidget::overviewMapChanged );
|
||||
connect( mCrsSelector, &QgsProjectionSelectionWidget::crsChanged, this, &QgsLayoutMapWidget::mapCrsChanged );
|
||||
connect( mOverviewFrameStyleButton, &QgsSymbolButton::changed, this, &QgsLayoutMapWidget::overviewSymbolChanged );
|
||||
|
||||
registerDataDefinedButton( mScaleDDBtn, QgsLayoutObject::MapScale );
|
||||
registerDataDefinedButton( mMapRotationDDBtn, QgsLayoutObject::MapRotation );
|
||||
@ -151,9 +154,20 @@ bool QgsLayoutMapWidget::setNewItem( QgsLayoutItem *item )
|
||||
if ( item->type() != QgsLayoutItemRegistry::LayoutMap )
|
||||
return false;
|
||||
|
||||
if ( mMapItem )
|
||||
{
|
||||
disconnect( mMapItem, &QgsLayoutObject::changed, this, &QgsLayoutMapWidget::updateGuiElements );
|
||||
}
|
||||
|
||||
mMapItem = qobject_cast< QgsLayoutItemMap * >( item );
|
||||
mItemPropertiesWidget->setItem( mMapItem );
|
||||
|
||||
if ( mMapItem )
|
||||
{
|
||||
connect( mMapItem, &QgsLayoutObject::changed, this, &QgsLayoutMapWidget::updateGuiElements );
|
||||
mOverviewFrameStyleButton->registerExpressionContextGenerator( mMapItem );
|
||||
}
|
||||
|
||||
updateGuiElements();
|
||||
|
||||
return true;
|
||||
@ -274,40 +288,6 @@ void QgsLayoutMapWidget::onMapThemesChanged()
|
||||
}
|
||||
}
|
||||
|
||||
void QgsLayoutMapWidget::updateOverviewFrameStyleFromWidget()
|
||||
{
|
||||
QgsLayoutItemMapOverview *overview = currentOverview();
|
||||
if ( !overview )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QgsSymbolSelectorWidget *w = qobject_cast<QgsSymbolSelectorWidget *>( sender() );
|
||||
overview->setFrameSymbol( dynamic_cast< QgsFillSymbol * >( w->symbol()->clone() ) );
|
||||
mMapItem->update();
|
||||
}
|
||||
|
||||
void QgsLayoutMapWidget::cleanUpOverviewFrameStyleSelector( QgsPanelWidget *container )
|
||||
{
|
||||
Q_UNUSED( container );
|
||||
QgsSymbolSelectorWidget *w = qobject_cast<QgsSymbolSelectorWidget *>( container );
|
||||
if ( !w )
|
||||
return;
|
||||
|
||||
delete w->symbol();
|
||||
|
||||
QgsLayoutItemMapOverview *overview = currentOverview();
|
||||
if ( !overview )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
updateOverviewFrameSymbolMarker( overview );
|
||||
#if 0 //TODO
|
||||
mMapItem->endCommand();
|
||||
#endif
|
||||
}
|
||||
|
||||
void QgsLayoutMapWidget::mapCrsChanged( const QgsCoordinateReferenceSystem &crs )
|
||||
{
|
||||
if ( !mMapItem )
|
||||
@ -343,6 +323,18 @@ void QgsLayoutMapWidget::mapCrsChanged( const QgsCoordinateReferenceSystem &crs
|
||||
mMapItem->invalidateCache();
|
||||
}
|
||||
|
||||
void QgsLayoutMapWidget::overviewSymbolChanged()
|
||||
{
|
||||
QgsLayoutItemMapOverview *overview = currentOverview();
|
||||
if ( !overview )
|
||||
return;
|
||||
|
||||
mMapItem->beginCommand( tr( "Change Overview Style" ), QgsLayoutItem::UndoOverviewStyle );
|
||||
overview->setFrameSymbol( mOverviewFrameStyleButton->clonedSymbol<QgsFillSymbol>() );
|
||||
mMapItem->endCommand();
|
||||
mMapItem->update();
|
||||
}
|
||||
|
||||
void QgsLayoutMapWidget::mAtlasCheckBox_toggled( bool checked )
|
||||
{
|
||||
if ( !mMapItem )
|
||||
@ -1505,22 +1497,11 @@ void QgsLayoutMapWidget::setOverviewItems( QgsLayoutItemMapOverview *overview )
|
||||
//center overview
|
||||
mOverviewCenterCheckbox->setChecked( overview->centered() );
|
||||
|
||||
//frame style
|
||||
updateOverviewFrameSymbolMarker( overview );
|
||||
mOverviewFrameStyleButton->setSymbol( overview->frameSymbol()->clone() );
|
||||
|
||||
blockOverviewItemsSignals( false );
|
||||
}
|
||||
|
||||
void QgsLayoutMapWidget::updateOverviewFrameSymbolMarker( const QgsLayoutItemMapOverview *overview )
|
||||
{
|
||||
if ( overview )
|
||||
{
|
||||
QgsFillSymbol *nonConstSymbol = const_cast<QgsFillSymbol *>( overview->frameSymbol() ); //bad
|
||||
QIcon icon = QgsSymbolLayerUtils::symbolPreviewIcon( nonConstSymbol, mOverviewFrameStyleButton->iconSize() );
|
||||
mOverviewFrameStyleButton->setIcon( icon );
|
||||
}
|
||||
}
|
||||
|
||||
void QgsLayoutMapWidget::storeCurrentLayerSet()
|
||||
{
|
||||
if ( !mMapItem )
|
||||
@ -1626,34 +1607,6 @@ void QgsLayoutMapWidget::overviewMapChanged( QgsLayoutItem *item )
|
||||
mMapItem->endCommand();
|
||||
}
|
||||
|
||||
void QgsLayoutMapWidget::mOverviewFrameStyleButton_clicked()
|
||||
{
|
||||
QgsLayoutItemMapOverview *overview = currentOverview();
|
||||
if ( !overview )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QgsVectorLayer *coverageLayer = nullptr;
|
||||
#if 0 //TODO
|
||||
// use the atlas coverage layer, if any
|
||||
QgsVectorLayer *coverageLayer = atlasCoverageLayer();
|
||||
#endif
|
||||
|
||||
QgsFillSymbol *newSymbol = static_cast<QgsFillSymbol *>( overview->frameSymbol()->clone() );
|
||||
QgsExpressionContext context = mMapItem->createExpressionContext();
|
||||
|
||||
QgsSymbolSelectorWidget *d = new QgsSymbolSelectorWidget( newSymbol, QgsStyle::defaultStyle(), coverageLayer, nullptr );
|
||||
QgsSymbolWidgetContext symbolContext;
|
||||
symbolContext.setExpressionContext( &context );
|
||||
d->setContext( symbolContext );
|
||||
|
||||
connect( d, &QgsPanelWidget::widgetChanged, this, &QgsLayoutMapWidget::updateOverviewFrameStyleFromWidget );
|
||||
connect( d, &QgsPanelWidget::panelAccepted, this, &QgsLayoutMapWidget::cleanUpOverviewFrameStyleSelector );
|
||||
openPanel( d );
|
||||
mMapItem->beginCommand( tr( "Change Overview Style" ) );
|
||||
}
|
||||
|
||||
void QgsLayoutMapWidget::mOverviewBlendModeComboBox_currentIndexChanged( int index )
|
||||
{
|
||||
Q_UNUSED( index );
|
||||
|
@ -47,7 +47,6 @@ class QgsLayoutMapWidget: public QgsLayoutItemBaseWidget, private Ui::QgsLayoutM
|
||||
void mKeepLayerStylesCheckBox_stateChanged( int state );
|
||||
void mDrawCanvasItemsCheckBox_stateChanged( int state );
|
||||
void overviewMapChanged( QgsLayoutItem *item );
|
||||
void mOverviewFrameStyleButton_clicked();
|
||||
void mOverviewBlendModeComboBox_currentIndexChanged( int index );
|
||||
void mOverviewInvertCheckbox_toggled( bool state );
|
||||
void mOverviewCenterCheckbox_toggled( bool state );
|
||||
@ -113,11 +112,8 @@ class QgsLayoutMapWidget: public QgsLayoutItemBaseWidget, private Ui::QgsLayoutM
|
||||
|
||||
void onMapThemesChanged();
|
||||
|
||||
void updateOverviewFrameStyleFromWidget();
|
||||
void cleanUpOverviewFrameStyleSelector( QgsPanelWidget *container );
|
||||
|
||||
void mapCrsChanged( const QgsCoordinateReferenceSystem &crs );
|
||||
|
||||
void overviewSymbolChanged();
|
||||
private:
|
||||
QgsLayoutItemMap *mMapItem = nullptr;
|
||||
QgsLayoutItemPropertiesWidget *mItemPropertiesWidget = nullptr;
|
||||
@ -162,8 +158,6 @@ class QgsLayoutMapWidget: public QgsLayoutItemBaseWidget, private Ui::QgsLayoutM
|
||||
|
||||
void loadOverviewEntries();
|
||||
|
||||
void updateOverviewFrameSymbolMarker( const QgsLayoutItemMapOverview *overview );
|
||||
|
||||
void storeCurrentLayerSet();
|
||||
|
||||
};
|
||||
|
@ -41,6 +41,7 @@ QgsLayoutPolygonWidget::QgsLayoutPolygonWidget( QgsLayoutItemPolygon *polygon )
|
||||
if ( mPolygon )
|
||||
{
|
||||
connect( mPolygon, &QgsLayoutObject::changed, this, &QgsLayoutPolygonWidget::setGuiElementValues );
|
||||
mPolygonStyleButton->registerExpressionContextGenerator( mPolygon );
|
||||
}
|
||||
|
||||
setGuiElementValues();
|
||||
@ -54,9 +55,19 @@ bool QgsLayoutPolygonWidget::setNewItem( QgsLayoutItem *item )
|
||||
if ( item->type() != QgsLayoutItemRegistry::LayoutPolygon )
|
||||
return false;
|
||||
|
||||
if ( mPolygon )
|
||||
{
|
||||
disconnect( mPolygon, &QgsLayoutObject::changed, this, &QgsLayoutPolygonWidget::setGuiElementValues );
|
||||
}
|
||||
|
||||
mPolygon = qobject_cast< QgsLayoutItemPolygon * >( item );
|
||||
mItemPropertiesWidget->setItem( mPolygon );
|
||||
|
||||
if ( mPolygon )
|
||||
{
|
||||
connect( mPolygon, &QgsLayoutObject::changed, this, &QgsLayoutPolygonWidget::setGuiElementValues );
|
||||
mPolygonStyleButton->registerExpressionContextGenerator( mPolygon );
|
||||
}
|
||||
setGuiElementValues();
|
||||
|
||||
return true;
|
||||
|
@ -41,6 +41,7 @@ QgsLayoutPolylineWidget::QgsLayoutPolylineWidget( QgsLayoutItemPolyline *polylin
|
||||
if ( mPolyline )
|
||||
{
|
||||
connect( mPolyline, &QgsLayoutObject::changed, this, &QgsLayoutPolylineWidget::setGuiElementValues );
|
||||
mLineStyleButton->registerExpressionContextGenerator( mPolyline );
|
||||
}
|
||||
setGuiElementValues();
|
||||
|
||||
@ -54,9 +55,20 @@ bool QgsLayoutPolylineWidget::setNewItem( QgsLayoutItem *item )
|
||||
if ( item->type() != QgsLayoutItemRegistry::LayoutPolyline )
|
||||
return false;
|
||||
|
||||
if ( mPolyline )
|
||||
{
|
||||
disconnect( mPolyline, &QgsLayoutObject::changed, this, &QgsLayoutPolylineWidget::setGuiElementValues );
|
||||
}
|
||||
|
||||
mPolyline = qobject_cast< QgsLayoutItemPolyline * >( item );
|
||||
mItemPropertiesWidget->setItem( mPolyline );
|
||||
|
||||
if ( mPolyline )
|
||||
{
|
||||
connect( mPolyline, &QgsLayoutObject::changed, this, &QgsLayoutPolylineWidget::setGuiElementValues );
|
||||
mLineStyleButton->registerExpressionContextGenerator( mPolyline );
|
||||
}
|
||||
|
||||
setGuiElementValues();
|
||||
|
||||
return true;
|
||||
|
@ -70,9 +70,20 @@ bool QgsLayoutShapeWidget::setNewItem( QgsLayoutItem *item )
|
||||
if ( item->type() != QgsLayoutItemRegistry::LayoutShape )
|
||||
return false;
|
||||
|
||||
if ( mShape )
|
||||
{
|
||||
disconnect( mShape, &QgsLayoutObject::changed, this, &QgsLayoutShapeWidget::setGuiElementValues );
|
||||
}
|
||||
|
||||
mShape = qobject_cast< QgsLayoutItemShape * >( item );
|
||||
mItemPropertiesWidget->setItem( mShape );
|
||||
|
||||
if ( mShape )
|
||||
{
|
||||
connect( mShape, &QgsLayoutObject::changed, this, &QgsLayoutShapeWidget::setGuiElementValues );
|
||||
mShapeStyleButton->registerExpressionContextGenerator( mShape );
|
||||
}
|
||||
|
||||
setGuiElementValues();
|
||||
|
||||
return true;
|
||||
|
@ -100,6 +100,7 @@ class CORE_EXPORT QgsLayoutItem : public QgsLayoutObject, public QGraphicsRectIt
|
||||
UndoAtlasMargin, //!< Map atlas margin changed
|
||||
UndoMapRotation, //!< Map rotation changed
|
||||
UndoZoomContent, //!< Item content zoomed
|
||||
UndoOverviewStyle, //!< Map overview style
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -63,9 +63,9 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<y>-1556</y>
|
||||
<width>627</width>
|
||||
<height>2272</height>
|
||||
<height>2265</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
@ -735,13 +735,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QPushButton" name="mOverviewFrameStyleButton">
|
||||
<property name="text">
|
||||
<string>Change...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="mOverviewBlendModeLabel">
|
||||
<property name="text">
|
||||
@ -766,6 +759,19 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QgsSymbolButton" name="mOverviewFrameStyleButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Change...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
@ -780,6 +786,12 @@
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>QgsScrollArea</class>
|
||||
<extends>QScrollArea</extends>
|
||||
<header>qgsscrollarea.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>QgsPropertyOverrideButton</class>
|
||||
<extends>QToolButton</extends>
|
||||
@ -807,9 +819,9 @@
|
||||
<header>qgsblendmodecombobox.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>QgsScrollArea</class>
|
||||
<extends>QScrollArea</extends>
|
||||
<header>qgsscrollarea.h</header>
|
||||
<class>QgsProjectionSelectionWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>qgsprojectionselectionwidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
@ -818,10 +830,9 @@
|
||||
<header>qgslayoutitemcombobox.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>QgsProjectionSelectionWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>qgsprojectionselectionwidget.h</header>
|
||||
<container>1</container>
|
||||
<class>QgsSymbolButton</class>
|
||||
<extends>QToolButton</extends>
|
||||
<header>qgssymbolbutton.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
@ -907,6 +918,8 @@
|
||||
<include location="../../../images/images.qrc"/>
|
||||
<include location="../../../images/images.qrc"/>
|
||||
<include location="../../../images/images.qrc"/>
|
||||
<include location="../../../images/images.qrc"/>
|
||||
<include location="../../../images/images.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
Loading…
x
Reference in New Issue
Block a user