Show style name in style panel title. Fix #25724.

This commit is contained in:
Ismail Sunni 2022-02-18 16:10:25 +01:00 committed by Nyall Dawson
parent a00889b0a7
commit e8ca757b06
3 changed files with 29 additions and 0 deletions

View File

@ -1286,6 +1286,28 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipBadLayers
mMapStyleWidget = new QgsLayerStylingWidget( mMapCanvas, mInfoBar, mMapLayerPanelFactories );
mMapStylingDock->setWidget( mMapStyleWidget );
connect( mMapStyleWidget, &QgsLayerStylingWidget::styleChanged, this, &QgisApp::updateLabelToolButtons );
connect( mMapStyleWidget, &QgsLayerStylingWidget::layerChanged, this, [ = ]( QgsMapLayer * layer )
{
if ( !layer->styleManager()->isDefault( layer->styleManager()->currentStyle() ) )
{
mMapStylingDock->setWindowTitle( tr( "Layer Styling (%1)" ).arg( layer->styleManager()->currentStyle() ) );
}
else
{
mMapStylingDock->setWindowTitle( tr( "Layer Styling" ) );
}
} );
connect( mMapStyleWidget, &QgsLayerStylingWidget::layerStyleChanged, this, [ = ]( QString styleName )
{
if ( tr( "default" ) != styleName )
{
mMapStylingDock->setWindowTitle( tr( "Layer Styling (%1)" ).arg( styleName ) );
}
else
{
mMapStylingDock->setWindowTitle( tr( "Layer Styling" ) );
}
} );
connect( mMapStylingDock, &QDockWidget::visibilityChanged, mActionStyleDock, &QAction::setChecked );
addDockWidget( Qt::RightDockWidgetArea, mMapStylingDock );

View File

@ -33,6 +33,7 @@
#include "qgsrasterrendererwidget.h"
#include "qgsmapcanvas.h"
#include "qgsmaplayer.h"
#include "qgsmaplayerstylemanager.h"
#include "qgsstyle.h"
#include "qgsvectorlayer.h"
#include "qgspointcloudlayer.h"
@ -157,6 +158,7 @@ void QgsLayerStylingWidget::setLayer( QgsMapLayer *layer )
if ( mCurrentLayer )
{
disconnect( mCurrentLayer, &QgsMapLayer::styleChanged, this, &QgsLayerStylingWidget::updateCurrentWidgetLayer );
disconnect( mCurrentLayer->styleManager(), &QgsMapLayerStyleManager::currentStyleChanged, this, &QgsLayerStylingWidget::emitLayerStyleChanged );
}
if ( !layer || !layer->isSpatial() || !QgsProject::instance()->layerIsEmbedded( layer->id() ).isEmpty() )
@ -180,6 +182,7 @@ void QgsLayerStylingWidget::setLayer( QgsMapLayer *layer )
mUndoWidget->setUndoStack( layer->undoStackStyles() );
connect( mCurrentLayer, &QgsMapLayer::styleChanged, this, &QgsLayerStylingWidget::updateCurrentWidgetLayer );
connect( mCurrentLayer->styleManager(), &QgsMapLayerStyleManager::currentStyleChanged, this, &QgsLayerStylingWidget::emitLayerStyleChanged );
int lastPage = mOptionsListWidget->currentIndex().row();
mOptionsListWidget->blockSignals( true );
@ -300,6 +303,7 @@ void QgsLayerStylingWidget::setLayer( QgsMapLayer *layer )
mLastStyleXml = doc.createElement( QStringLiteral( "style" ) );
doc.appendChild( mLastStyleXml );
mCurrentLayer->writeStyle( mLastStyleXml, doc, errorMsg, QgsReadWriteContext() );
emit layerChanged( layer );
}
void QgsLayerStylingWidget::apply()

View File

@ -116,6 +116,8 @@ class APP_EXPORT QgsLayerStylingWidget : public QWidget, private Ui::QgsLayerSty
signals:
void styleChanged( QgsMapLayer *layer );
void layerChanged( QgsMapLayer *layer );
void layerStyleChanged( const QString &currentStyleName );
public slots:
void setLayer( QgsMapLayer *layer );
@ -153,6 +155,7 @@ class APP_EXPORT QgsLayerStylingWidget : public QWidget, private Ui::QgsLayerSty
private:
void pushUndoItem( const QString &name, bool triggerRepaint = true );
void emitLayerStyleChanged( const QString &currentStyleName ) {emit layerStyleChanged( currentStyleName );};
int mNotSupportedPage;
int mLayerPage;
QTimer *mAutoApplyTimer = nullptr;