Skip to content

Commit f3b7260

Browse files
committedDec 6, 2018
Add message bar to QgsSymbolWidgetContext
1 parent 89e9895 commit f3b7260

25 files changed

+223
-10
lines changed
 

‎python/gui/auto_generated/qgsfilecontentsourcelineedit.sip.in

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,21 @@ urls.
2929
QgsAbstractFileContentSourceLineEdit( QWidget *parent /TransferThis/ = 0 );
3030
%Docstring
3131
Constructor for QgsAbstractFileContentSourceLineEdit, with the specified ``parent`` widget.
32+
%End
33+
34+
void setMessageBar( QgsMessageBar *bar );
35+
%Docstring
36+
Sets the message ``bar`` associated with the widget. This allows the widget to push feedback messages
37+
to the appropriate message bar.
38+
39+
.. seealso:: :py:func:`messageBar`
40+
%End
41+
42+
QgsMessageBar *messageBar() const;
43+
%Docstring
44+
Returns the message bar associated with the widget.
45+
46+
.. seealso:: :py:func:`setMessageBar`
3247
%End
3348

3449
QString source() const;

‎python/gui/auto_generated/qgssymbolbutton.sip.in

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,25 @@ Sets a map ``canvas`` to associate with the widget. This allows the
8888
widget to fetch current settings from the map canvas, such as current scale.
8989

9090
.. seealso:: :py:func:`mapCanvas`
91+
%End
92+
93+
void setMessageBar( QgsMessageBar *bar );
94+
%Docstring
95+
Sets the message ``bar`` associated with the widget. This allows the widget to push feedback messages
96+
to the appropriate message bar.
97+
98+
.. seealso:: :py:func:`messageBar`
99+
100+
.. versionadded:: 3.6
101+
%End
102+
103+
QgsMessageBar *messageBar() const;
104+
%Docstring
105+
Returns the message bar associated with the widget.
106+
107+
.. seealso:: :py:func:`setMessageBar`
108+
109+
.. versionadded:: 3.6
91110
%End
92111

93112
QgsVectorLayer *layer() const;

‎python/gui/auto_generated/symbology/qgsrendererpropertiesdialog.sip.in

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ map scale and other properties from the canvas.
4040
:param canvas: map canvas
4141

4242
.. versionadded:: 2.12
43+
%End
44+
45+
void setContext( const QgsSymbolWidgetContext &context );
46+
%Docstring
47+
Sets the ``context`` in which the dialog is shown, e.g., the associated map canvas and expression contexts.
48+
49+
.. versionadded:: 3.6
4350
%End
4451

4552
void setDockMode( bool dockMode );

‎python/gui/auto_generated/symbology/qgssymbollayerwidget.sip.in

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Constructor for QgsSymbolLayerWidget.
2828
virtual void setSymbolLayer( QgsSymbolLayer *layer ) = 0;
2929
virtual QgsSymbolLayer *symbolLayer() = 0;
3030

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

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

408408

409+
virtual void setContext( const QgsSymbolWidgetContext &context );
410+
411+
409412
protected:
410413

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

450453
virtual QgsSymbolLayer *symbolLayer();
451454

455+
virtual void setContext( const QgsSymbolWidgetContext &context );
456+
452457

453458
protected:
454459

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

521526
virtual QgsSymbolLayer *symbolLayer();
522527

528+
virtual void setContext( const QgsSymbolWidgetContext &context );
529+
523530

524531
protected:
525532
void insertIcons();

‎python/gui/auto_generated/symbology/qgssymbolwidgetcontext.sip.in

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111

1212

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

5554
.. seealso:: :py:func:`setMapCanvas`
55+
%End
56+
57+
void setMessageBar( QgsMessageBar *bar );
58+
%Docstring
59+
Sets the message ``bar`` associated with the widget. This allows the widget to push feedback messages
60+
to the appropriate message bar.
61+
62+
.. seealso:: :py:func:`messageBar`
63+
64+
.. versionadded:: 3.6
65+
%End
66+
67+
QgsMessageBar *messageBar() const;
68+
%Docstring
69+
Returns the message bar associated with the widget.
70+
71+
.. seealso:: :py:func:`setMessageBar`
72+
73+
.. versionadded:: 3.6
5674
%End
5775

5876
void setExpressionContext( QgsExpressionContext *context );

‎src/app/decorations/qgsdecorationgriddialog.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ QgsDecorationGridDialog::QgsDecorationGridDialog( QgsDecorationGrid &deco, QWidg
7474
connect( mAnnotationFontButton, &QgsFontButton::changed, this, &QgsDecorationGridDialog::annotationFontChanged );
7575

7676
mMarkerSymbolButton->setMapCanvas( QgisApp::instance()->mapCanvas() );
77+
mMarkerSymbolButton->setMessageBar( QgisApp::instance()->messageBar() );
7778
mLineSymbolButton->setMapCanvas( QgisApp::instance()->mapCanvas() );
79+
mLineSymbolButton->setMessageBar( QgisApp::instance()->messageBar() );
7880
}
7981

8082
void QgsDecorationGridDialog::updateGuiElements()

‎src/app/decorations/qgsdecorationlayoutextentdialog.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ QgsDecorationLayoutExtentDialog::QgsDecorationLayoutExtentDialog( QgsDecorationL
4848
connect( buttonBox, &QDialogButtonBox::helpRequested, this, &QgsDecorationLayoutExtentDialog::showHelp );
4949

5050
mSymbolButton->setMapCanvas( QgisApp::instance()->mapCanvas() );
51+
mSymbolButton->setMessageBar( QgisApp::instance()->messageBar() );
5152
}
5253

5354
void QgsDecorationLayoutExtentDialog::updateGuiElements()

‎src/app/qgisapp.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,7 @@ void QgisApp::layerTreeViewDoubleClicked( const QModelIndex &index )
564564
QgsSymbolSelectorDialog dlg( symbol.get(), QgsStyle::defaultStyle(), vlayer, this );
565565
QgsSymbolWidgetContext context;
566566
context.setMapCanvas( mMapCanvas );
567+
context.setMessageBar( mInfoBar );
567568
dlg.setContext( context );
568569
if ( dlg.exec() )
569570
{
@@ -987,7 +988,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
987988
showStylingDock->setObjectName( QStringLiteral( "ShowLayerStylingPanel" ) );
988989
showStylingDock->setWhatsThis( tr( "Show Style Panel" ) );
989990

990-
mMapStyleWidget = new QgsLayerStylingWidget( mMapCanvas, mMapLayerPanelFactories );
991+
mMapStyleWidget = new QgsLayerStylingWidget( mMapCanvas, mInfoBar, mMapLayerPanelFactories );
991992
mMapStylingDock->setWidget( mMapStyleWidget );
992993
connect( mMapStyleWidget, &QgsLayerStylingWidget::styleChanged, this, &QgisApp::updateLabelToolButtons );
993994
connect( mMapStylingDock, &QDockWidget::visibilityChanged, mActionStyleDock, &QAction::setChecked );

‎src/app/qgsannotationwidget.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ QgsAnnotationWidget::QgsAnnotationWidget( QgsMapCanvasAnnotationItem *item, QWid
7171
blockAllSignals( false );
7272
}
7373
mMapMarkerButton->setMapCanvas( QgisApp::instance()->mapCanvas() );
74+
mMapMarkerButton->setMessageBar( QgisApp::instance()->messageBar() );
7475
mFrameStyleButton->setMapCanvas( QgisApp::instance()->mapCanvas() );
76+
mFrameStyleButton->setMessageBar( QgisApp::instance()->messageBar() );
7577
}
7678

7779
void QgsAnnotationWidget::apply()

‎src/app/qgsapplayertreeviewmenuprovider.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,7 @@ void QgsAppLayerTreeViewMenuProvider::editVectorSymbol()
691691
dlg.setWindowTitle( tr( "Symbol Selector" ) );
692692
QgsSymbolWidgetContext context;
693693
context.setMapCanvas( mCanvas );
694+
context.setMessageBar( QgisApp::instance()->messageBar() );
694695
dlg.setContext( context );
695696
if ( dlg.exec() )
696697
{
@@ -768,6 +769,7 @@ void QgsAppLayerTreeViewMenuProvider::editSymbolLegendNodeSymbol()
768769
dlg.setWindowTitle( tr( "Symbol Selector" ) );
769770
QgsSymbolWidgetContext context;
770771
context.setMapCanvas( mCanvas );
772+
context.setMessageBar( QgisApp::instance()->messageBar() );
771773
dlg.setContext( context );
772774
if ( dlg.exec() )
773775
{

‎src/app/qgslayerstylingwidget.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,19 @@
4747
#include "qgsruntimeprofiler.h"
4848
#include "qgsrasterminmaxwidget.h"
4949
#include "qgisapp.h"
50+
#include "qgssymbolwidgetcontext.h"
5051

5152
#ifdef HAVE_3D
5253
#include "qgsvectorlayer3drendererwidget.h"
5354
#endif
5455

5556

56-
QgsLayerStylingWidget::QgsLayerStylingWidget( QgsMapCanvas *canvas, const QList<QgsMapLayerConfigWidgetFactory *> &pages, QWidget *parent )
57+
QgsLayerStylingWidget::QgsLayerStylingWidget( QgsMapCanvas *canvas, QgsMessageBar *messageBar, const QList<QgsMapLayerConfigWidgetFactory *> &pages, QWidget *parent )
5758
: QWidget( parent )
5859
, mNotSupportedPage( 0 )
5960
, mLayerPage( 1 )
6061
, mMapCanvas( canvas )
62+
, mMessageBar( messageBar )
6163
, mBlockAutoApply( false )
6264
, mPageFactories( pages )
6365
{
@@ -382,7 +384,10 @@ void QgsLayerStylingWidget::updateCurrentWidgetLayer()
382384
case 0: // Style
383385
{
384386
QgsRendererPropertiesDialog *styleWidget = new QgsRendererPropertiesDialog( vlayer, QgsStyle::defaultStyle(), true, mStackedWidget );
385-
styleWidget->setMapCanvas( mMapCanvas );
387+
QgsSymbolWidgetContext context;
388+
context.setMapCanvas( mMapCanvas );
389+
context.setMessageBar( mMessageBar );
390+
styleWidget->setContext( context );
386391
styleWidget->setDockMode( true );
387392
connect( styleWidget, &QgsRendererPropertiesDialog::widgetChanged, this, &QgsLayerStylingWidget::autoApply );
388393
QgsPanelWidgetWrapper *wrapper = new QgsPanelWidgetWrapper( styleWidget, mStackedWidget );

‎src/app/qgslayerstylingwidget.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class QgsUndoWidget;
4141
class QgsRasterHistogramWidget;
4242
class QgsMapLayerStyleManagerWidget;
4343
class QgsVectorLayer3DRendererWidget;
44+
class QgsMessageBar;
4445

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

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

@@ -133,6 +134,7 @@ class APP_EXPORT QgsLayerStylingWidget : public QWidget, private Ui::QgsLayerSty
133134
QTimer *mAutoApplyTimer = nullptr;
134135
QDomNode mLastStyleXml;
135136
QgsMapCanvas *mMapCanvas = nullptr;
137+
QgsMessageBar *mMessageBar = nullptr;
136138
bool mBlockAutoApply;
137139
QgsUndoWidget *mUndoWidget = nullptr;
138140
QgsMapLayer *mCurrentLayer = nullptr;

‎src/app/qgsvectorlayerproperties.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
#include "qgsgeometrycheckregistry.h"
6969
#include "qgsgeometrycheck.h"
7070
#include "qgsanalysis.h"
71+
#include "qgssymbolwidgetcontext.h"
7172

7273
#include "layertree/qgslayertreelayer.h"
7374
#include "qgslayertree.h"
@@ -1515,7 +1516,10 @@ void QgsVectorLayerProperties::updateSymbologyPage()
15151516
{
15161517
mRendererDialog = new QgsRendererPropertiesDialog( mLayer, QgsStyle::defaultStyle(), true, this );
15171518
mRendererDialog->setDockMode( false );
1518-
mRendererDialog->setMapCanvas( QgisApp::instance()->mapCanvas() );
1519+
QgsSymbolWidgetContext context;
1520+
context.setMapCanvas( QgisApp::instance()->mapCanvas() );
1521+
context.setMessageBar( QgisApp::instance()->messageBar() );
1522+
mRendererDialog->setContext( context );
15191523
connect( mRendererDialog, &QgsRendererPropertiesDialog::showPanel, this, &QgsVectorLayerProperties::openPanel );
15201524
connect( mRendererDialog, &QgsRendererPropertiesDialog::layerVariablesChanged, this, &QgsVectorLayerProperties::updateVariableEditor );
15211525
connect( mRendererDialog, &QgsRendererPropertiesDialog::widgetChanged, this, [ = ] { updateAuxiliaryStoragePage(); } );

‎src/gui/qgsfilecontentsourcelineedit.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,3 +308,13 @@ QString QgsImageSourceLineEdit::defaultSettingsKey() const
308308
}
309309

310310
///@endcond
311+
312+
void QgsAbstractFileContentSourceLineEdit::setMessageBar( QgsMessageBar *bar )
313+
{
314+
mMessageBar = bar;
315+
}
316+
317+
QgsMessageBar *QgsAbstractFileContentSourceLineEdit::messageBar() const
318+
{
319+
return mMessageBar;
320+
}

‎src/gui/qgsfilecontentsourcelineedit.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
class QLineEdit;
2525
class QToolButton;
26+
class QgsMessageBar;
2627

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

56+
/**
57+
* Sets the message \a bar associated with the widget. This allows the widget to push feedback messages
58+
* to the appropriate message bar.
59+
* \see messageBar()
60+
*/
61+
void setMessageBar( QgsMessageBar *bar );
62+
63+
/**
64+
* Returns the message bar associated with the widget.
65+
* \see setMessageBar()
66+
*/
67+
QgsMessageBar *messageBar() const;
68+
5569
/**
5670
* Returns the current file source.
5771
* \see setSource()
@@ -138,6 +152,7 @@ class GUI_EXPORT QgsAbstractFileContentSourceLineEdit : public QWidget SIP_ABSTR
138152
QToolButton *mFileToolButton = nullptr;
139153
QString mLastPathKey;
140154
QString mBase64;
155+
QgsMessageBar *mMessageBar = nullptr;
141156

142157
QString defaultPath() const;
143158
QString settingsKey() const;

‎src/gui/qgssymbolbutton.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ void QgsSymbolButton::showSettingsDialog()
100100
QgsSymbolWidgetContext symbolContext;
101101
symbolContext.setExpressionContext( &context );
102102
symbolContext.setMapCanvas( mMapCanvas );
103+
symbolContext.setMessageBar( mMessageBar );
103104

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

158+
void QgsSymbolButton::setMessageBar( QgsMessageBar *bar )
159+
{
160+
mMessageBar = bar;
161+
}
162+
163+
QgsMessageBar *QgsSymbolButton::messageBar() const
164+
{
165+
return mMessageBar;
166+
}
167+
157168
QgsVectorLayer *QgsSymbolButton::layer() const
158169
{
159170
return mLayer;

‎src/gui/qgssymbolbutton.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class QgsMapCanvas;
2626
class QgsVectorLayer;
2727
class QgsExpressionContextGenerator;
2828
class QgsPanelWidget;
29+
class QgsMessageBar;
2930

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

126+
/**
127+
* Sets the message \a bar associated with the widget. This allows the widget to push feedback messages
128+
* to the appropriate message bar.
129+
* \see messageBar()
130+
* \since QGIS 3.6
131+
*/
132+
void setMessageBar( QgsMessageBar *bar );
133+
134+
/**
135+
* Returns the message bar associated with the widget.
136+
* \see setMessageBar()
137+
* \since QGIS 3.6
138+
*/
139+
QgsMessageBar *messageBar() const;
140+
125141
/**
126142
* Returns the layer associated with the widget.
127143
* \see setLayer()
@@ -234,6 +250,7 @@ class GUI_EXPORT QgsSymbolButton : public QToolButton
234250
QgsSymbol::SymbolType mType = QgsSymbol::Fill;
235251

236252
QgsMapCanvas *mMapCanvas = nullptr;
253+
QgsMessageBar *mMessageBar = nullptr;
237254

238255
QPoint mDragStartPosition;
239256

‎src/gui/symbology/qgspointclusterrendererwidget.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,10 @@ void QgsPointClusterRendererWidget::setContext( const QgsSymbolWidgetContext &co
123123
if ( mDistanceUnitWidget )
124124
mDistanceUnitWidget->setMapCanvas( context.mapCanvas() );
125125
if ( mCenterSymbolToolButton )
126+
{
126127
mCenterSymbolToolButton->setMapCanvas( context.mapCanvas() );
128+
mCenterSymbolToolButton->setMessageBar( context.messageBar() );
129+
}
127130
}
128131

129132
void QgsPointClusterRendererWidget::mRendererComboBox_currentIndexChanged( int index )

0 commit comments

Comments
 (0)
Please sign in to comment.