Skip to content
Permalink
Browse files

Add message bar to QgsSymbolWidgetContext

  • Loading branch information
nyalldawson committed Dec 6, 2018
1 parent 89e9895 commit f3b72608a11028f6bb9cb45aaf18800fac3afd1f
@@ -29,6 +29,21 @@ urls.
QgsAbstractFileContentSourceLineEdit( QWidget *parent /TransferThis/ = 0 );
%Docstring
Constructor for QgsAbstractFileContentSourceLineEdit, with the specified ``parent`` widget.
%End

void setMessageBar( QgsMessageBar *bar );
%Docstring
Sets the message ``bar`` associated with the widget. This allows the widget to push feedback messages
to the appropriate message bar.

.. seealso:: :py:func:`messageBar`
%End

QgsMessageBar *messageBar() const;
%Docstring
Returns the message bar associated with the widget.

.. seealso:: :py:func:`setMessageBar`
%End

QString source() const;
@@ -88,6 +88,25 @@ Sets a map ``canvas`` to associate with the widget. This allows the
widget to fetch current settings from the map canvas, such as current scale.

.. seealso:: :py:func:`mapCanvas`
%End

void setMessageBar( QgsMessageBar *bar );
%Docstring
Sets the message ``bar`` associated with the widget. This allows the widget to push feedback messages
to the appropriate message bar.

.. seealso:: :py:func:`messageBar`

.. versionadded:: 3.6
%End

QgsMessageBar *messageBar() const;
%Docstring
Returns the message bar associated with the widget.

.. seealso:: :py:func:`setMessageBar`

.. versionadded:: 3.6
%End

QgsVectorLayer *layer() const;
@@ -40,6 +40,13 @@ map scale and other properties from the canvas.
:param canvas: map canvas

.. versionadded:: 2.12
%End

void setContext( const QgsSymbolWidgetContext &context );
%Docstring
Sets the ``context`` in which the dialog is shown, e.g., the associated map canvas and expression contexts.

.. versionadded:: 3.6
%End

void setDockMode( bool dockMode );
@@ -28,7 +28,7 @@ Constructor for QgsSymbolLayerWidget.
virtual void setSymbolLayer( QgsSymbolLayer *layer ) = 0;
virtual QgsSymbolLayer *symbolLayer() = 0;

void setContext( const QgsSymbolWidgetContext &context );
virtual void setContext( const QgsSymbolWidgetContext &context );
%Docstring
Sets the context in which the symbol widget is shown, e.g., the associated map canvas and expression contexts.

@@ -406,6 +406,9 @@ Creates a new QgsSvgMarkerSymbolLayerWidget.
virtual QgsSymbolLayer *symbolLayer();


virtual void setContext( const QgsSymbolWidgetContext &context );


protected:

void populateList();
@@ -449,6 +452,8 @@ Creates a new QgsRasterMarkerSymbolLayerWidget.

virtual QgsSymbolLayer *symbolLayer();

virtual void setContext( const QgsSymbolWidgetContext &context );


protected:

@@ -520,6 +525,8 @@ Creates a new QgsSVGFillSymbolLayerWidget.

virtual QgsSymbolLayer *symbolLayer();

virtual void setContext( const QgsSymbolWidgetContext &context );


protected:
void insertIcons();
@@ -10,7 +10,6 @@




class QgsSymbolWidgetContext
{
%Docstring
@@ -53,6 +52,25 @@ map scale and other properties from the canvas.
Returns the map canvas associated with the widget.

.. seealso:: :py:func:`setMapCanvas`
%End

void setMessageBar( QgsMessageBar *bar );
%Docstring
Sets the message ``bar`` associated with the widget. This allows the widget to push feedback messages
to the appropriate message bar.

.. seealso:: :py:func:`messageBar`

.. versionadded:: 3.6
%End

QgsMessageBar *messageBar() const;
%Docstring
Returns the message bar associated with the widget.

.. seealso:: :py:func:`setMessageBar`

.. versionadded:: 3.6
%End

void setExpressionContext( QgsExpressionContext *context );
@@ -74,7 +74,9 @@ QgsDecorationGridDialog::QgsDecorationGridDialog( QgsDecorationGrid &deco, QWidg
connect( mAnnotationFontButton, &QgsFontButton::changed, this, &QgsDecorationGridDialog::annotationFontChanged );

mMarkerSymbolButton->setMapCanvas( QgisApp::instance()->mapCanvas() );
mMarkerSymbolButton->setMessageBar( QgisApp::instance()->messageBar() );
mLineSymbolButton->setMapCanvas( QgisApp::instance()->mapCanvas() );
mLineSymbolButton->setMessageBar( QgisApp::instance()->messageBar() );
}

void QgsDecorationGridDialog::updateGuiElements()
@@ -48,6 +48,7 @@ QgsDecorationLayoutExtentDialog::QgsDecorationLayoutExtentDialog( QgsDecorationL
connect( buttonBox, &QDialogButtonBox::helpRequested, this, &QgsDecorationLayoutExtentDialog::showHelp );

mSymbolButton->setMapCanvas( QgisApp::instance()->mapCanvas() );
mSymbolButton->setMessageBar( QgisApp::instance()->messageBar() );
}

void QgsDecorationLayoutExtentDialog::updateGuiElements()
@@ -564,6 +564,7 @@ void QgisApp::layerTreeViewDoubleClicked( const QModelIndex &index )
QgsSymbolSelectorDialog dlg( symbol.get(), QgsStyle::defaultStyle(), vlayer, this );
QgsSymbolWidgetContext context;
context.setMapCanvas( mMapCanvas );
context.setMessageBar( mInfoBar );
dlg.setContext( context );
if ( dlg.exec() )
{
@@ -987,7 +988,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
showStylingDock->setObjectName( QStringLiteral( "ShowLayerStylingPanel" ) );
showStylingDock->setWhatsThis( tr( "Show Style Panel" ) );

mMapStyleWidget = new QgsLayerStylingWidget( mMapCanvas, mMapLayerPanelFactories );
mMapStyleWidget = new QgsLayerStylingWidget( mMapCanvas, mInfoBar, mMapLayerPanelFactories );
mMapStylingDock->setWidget( mMapStyleWidget );
connect( mMapStyleWidget, &QgsLayerStylingWidget::styleChanged, this, &QgisApp::updateLabelToolButtons );
connect( mMapStylingDock, &QDockWidget::visibilityChanged, mActionStyleDock, &QAction::setChecked );
@@ -71,7 +71,9 @@ QgsAnnotationWidget::QgsAnnotationWidget( QgsMapCanvasAnnotationItem *item, QWid
blockAllSignals( false );
}
mMapMarkerButton->setMapCanvas( QgisApp::instance()->mapCanvas() );
mMapMarkerButton->setMessageBar( QgisApp::instance()->messageBar() );
mFrameStyleButton->setMapCanvas( QgisApp::instance()->mapCanvas() );
mFrameStyleButton->setMessageBar( QgisApp::instance()->messageBar() );
}

void QgsAnnotationWidget::apply()
@@ -691,6 +691,7 @@ void QgsAppLayerTreeViewMenuProvider::editVectorSymbol()
dlg.setWindowTitle( tr( "Symbol Selector" ) );
QgsSymbolWidgetContext context;
context.setMapCanvas( mCanvas );
context.setMessageBar( QgisApp::instance()->messageBar() );
dlg.setContext( context );
if ( dlg.exec() )
{
@@ -768,6 +769,7 @@ void QgsAppLayerTreeViewMenuProvider::editSymbolLegendNodeSymbol()
dlg.setWindowTitle( tr( "Symbol Selector" ) );
QgsSymbolWidgetContext context;
context.setMapCanvas( mCanvas );
context.setMessageBar( QgisApp::instance()->messageBar() );
dlg.setContext( context );
if ( dlg.exec() )
{
@@ -47,17 +47,19 @@
#include "qgsruntimeprofiler.h"
#include "qgsrasterminmaxwidget.h"
#include "qgisapp.h"
#include "qgssymbolwidgetcontext.h"

#ifdef HAVE_3D
#include "qgsvectorlayer3drendererwidget.h"
#endif


QgsLayerStylingWidget::QgsLayerStylingWidget( QgsMapCanvas *canvas, const QList<QgsMapLayerConfigWidgetFactory *> &pages, QWidget *parent )
QgsLayerStylingWidget::QgsLayerStylingWidget( QgsMapCanvas *canvas, QgsMessageBar *messageBar, const QList<QgsMapLayerConfigWidgetFactory *> &pages, QWidget *parent )
: QWidget( parent )
, mNotSupportedPage( 0 )
, mLayerPage( 1 )
, mMapCanvas( canvas )
, mMessageBar( messageBar )
, mBlockAutoApply( false )
, mPageFactories( pages )
{
@@ -382,7 +384,10 @@ void QgsLayerStylingWidget::updateCurrentWidgetLayer()
case 0: // Style
{
QgsRendererPropertiesDialog *styleWidget = new QgsRendererPropertiesDialog( vlayer, QgsStyle::defaultStyle(), true, mStackedWidget );
styleWidget->setMapCanvas( mMapCanvas );
QgsSymbolWidgetContext context;
context.setMapCanvas( mMapCanvas );
context.setMessageBar( mMessageBar );
styleWidget->setContext( context );
styleWidget->setDockMode( true );
connect( styleWidget, &QgsRendererPropertiesDialog::widgetChanged, this, &QgsLayerStylingWidget::autoApply );
QgsPanelWidgetWrapper *wrapper = new QgsPanelWidgetWrapper( styleWidget, mStackedWidget );
@@ -41,6 +41,7 @@ class QgsUndoWidget;
class QgsRasterHistogramWidget;
class QgsMapLayerStyleManagerWidget;
class QgsVectorLayer3DRendererWidget;
class QgsMessageBar;

class APP_EXPORT QgsLayerStyleManagerWidgetFactory : public QgsMapLayerConfigWidgetFactory
{
@@ -90,7 +91,7 @@ class APP_EXPORT QgsLayerStylingWidget : public QWidget, private Ui::QgsLayerSty
Symbology3D,
};

QgsLayerStylingWidget( QgsMapCanvas *canvas, const QList<QgsMapLayerConfigWidgetFactory *> &pages, QWidget *parent = nullptr );
QgsLayerStylingWidget( QgsMapCanvas *canvas, QgsMessageBar *messageBar, const QList<QgsMapLayerConfigWidgetFactory *> &pages, QWidget *parent = nullptr );
~QgsLayerStylingWidget() override;
QgsMapLayer *layer() { return mCurrentLayer; }

@@ -133,6 +134,7 @@ class APP_EXPORT QgsLayerStylingWidget : public QWidget, private Ui::QgsLayerSty
QTimer *mAutoApplyTimer = nullptr;
QDomNode mLastStyleXml;
QgsMapCanvas *mMapCanvas = nullptr;
QgsMessageBar *mMessageBar = nullptr;
bool mBlockAutoApply;
QgsUndoWidget *mUndoWidget = nullptr;
QgsMapLayer *mCurrentLayer = nullptr;
@@ -68,6 +68,7 @@
#include "qgsgeometrycheckregistry.h"
#include "qgsgeometrycheck.h"
#include "qgsanalysis.h"
#include "qgssymbolwidgetcontext.h"

#include "layertree/qgslayertreelayer.h"
#include "qgslayertree.h"
@@ -1515,7 +1516,10 @@ void QgsVectorLayerProperties::updateSymbologyPage()
{
mRendererDialog = new QgsRendererPropertiesDialog( mLayer, QgsStyle::defaultStyle(), true, this );
mRendererDialog->setDockMode( false );
mRendererDialog->setMapCanvas( QgisApp::instance()->mapCanvas() );
QgsSymbolWidgetContext context;
context.setMapCanvas( QgisApp::instance()->mapCanvas() );
context.setMessageBar( QgisApp::instance()->messageBar() );
mRendererDialog->setContext( context );
connect( mRendererDialog, &QgsRendererPropertiesDialog::showPanel, this, &QgsVectorLayerProperties::openPanel );
connect( mRendererDialog, &QgsRendererPropertiesDialog::layerVariablesChanged, this, &QgsVectorLayerProperties::updateVariableEditor );
connect( mRendererDialog, &QgsRendererPropertiesDialog::widgetChanged, this, [ = ] { updateAuxiliaryStoragePage(); } );
@@ -308,3 +308,13 @@ QString QgsImageSourceLineEdit::defaultSettingsKey() const
}

///@endcond

void QgsAbstractFileContentSourceLineEdit::setMessageBar( QgsMessageBar *bar )
{
mMessageBar = bar;
}

QgsMessageBar *QgsAbstractFileContentSourceLineEdit::messageBar() const
{
return mMessageBar;
}
@@ -23,6 +23,7 @@

class QLineEdit;
class QToolButton;
class QgsMessageBar;

/**
* \ingroup gui
@@ -52,6 +53,19 @@ class GUI_EXPORT QgsAbstractFileContentSourceLineEdit : public QWidget SIP_ABSTR
*/
QgsAbstractFileContentSourceLineEdit( QWidget *parent SIP_TRANSFERTHIS = nullptr );

/**
* Sets the message \a bar associated with the widget. This allows the widget to push feedback messages
* to the appropriate message bar.
* \see messageBar()
*/
void setMessageBar( QgsMessageBar *bar );

/**
* Returns the message bar associated with the widget.
* \see setMessageBar()
*/
QgsMessageBar *messageBar() const;

/**
* Returns the current file source.
* \see setSource()
@@ -138,6 +152,7 @@ class GUI_EXPORT QgsAbstractFileContentSourceLineEdit : public QWidget SIP_ABSTR
QToolButton *mFileToolButton = nullptr;
QString mLastPathKey;
QString mBase64;
QgsMessageBar *mMessageBar = nullptr;

QString defaultPath() const;
QString settingsKey() const;
@@ -100,6 +100,7 @@ void QgsSymbolButton::showSettingsDialog()
QgsSymbolWidgetContext symbolContext;
symbolContext.setExpressionContext( &context );
symbolContext.setMapCanvas( mMapCanvas );
symbolContext.setMessageBar( mMessageBar );

QgsPanelWidget *panel = QgsPanelWidget::findParentPanel( this );
if ( panel && panel->dockMode() )
@@ -154,6 +155,16 @@ void QgsSymbolButton::setMapCanvas( QgsMapCanvas *mapCanvas )
mMapCanvas = mapCanvas;
}

void QgsSymbolButton::setMessageBar( QgsMessageBar *bar )
{
mMessageBar = bar;
}

QgsMessageBar *QgsSymbolButton::messageBar() const
{
return mMessageBar;
}

QgsVectorLayer *QgsSymbolButton::layer() const
{
return mLayer;
@@ -26,6 +26,7 @@ class QgsMapCanvas;
class QgsVectorLayer;
class QgsExpressionContextGenerator;
class QgsPanelWidget;
class QgsMessageBar;

/**
* \ingroup gui
@@ -122,6 +123,21 @@ class GUI_EXPORT QgsSymbolButton : public QToolButton
*/
void setMapCanvas( QgsMapCanvas *canvas );

/**
* Sets the message \a bar associated with the widget. This allows the widget to push feedback messages
* to the appropriate message bar.
* \see messageBar()
* \since QGIS 3.6
*/
void setMessageBar( QgsMessageBar *bar );

/**
* Returns the message bar associated with the widget.
* \see setMessageBar()
* \since QGIS 3.6
*/
QgsMessageBar *messageBar() const;

/**
* Returns the layer associated with the widget.
* \see setLayer()
@@ -234,6 +250,7 @@ class GUI_EXPORT QgsSymbolButton : public QToolButton
QgsSymbol::SymbolType mType = QgsSymbol::Fill;

QgsMapCanvas *mMapCanvas = nullptr;
QgsMessageBar *mMessageBar = nullptr;

QPoint mDragStartPosition;

@@ -123,7 +123,10 @@ void QgsPointClusterRendererWidget::setContext( const QgsSymbolWidgetContext &co
if ( mDistanceUnitWidget )
mDistanceUnitWidget->setMapCanvas( context.mapCanvas() );
if ( mCenterSymbolToolButton )
{
mCenterSymbolToolButton->setMapCanvas( context.mapCanvas() );
mCenterSymbolToolButton->setMessageBar( context.messageBar() );
}
}

void QgsPointClusterRendererWidget::mRendererComboBox_currentIndexChanged( int index )

0 comments on commit f3b7260

Please sign in to comment.
You can’t perform that action at this time.