Skip to content
Permalink
Browse files

Merge pull request #4907 from nyalldawson/symbol_button

New QgsSymbolButton widget
  • Loading branch information
nyalldawson committed Jul 24, 2017
2 parents db745df + 6202f06 commit d055def2d1dab748000d18346e8fda4f0b9a40a5
Showing with 1,666 additions and 544 deletions.
  1. +4 −4 python/core/qgscolorramp.sip
  2. +1 −1 python/core/symbology-ng/qgssymbol.sip
  3. +2 −0 python/core/symbology-ng/qgssymbollayer.sip
  4. +5 −5 python/core/symbology-ng/qgssymbollayerregistry.sip
  5. +25 −6 python/core/symbology-ng/qgssymbollayerutils.sip
  6. +1 −0 python/gui/gui_auto.sip
  7. +188 −0 python/gui/qgssymbolbutton.sip
  8. +4 −1 python/gui/symbology-ng/qgspointclusterrendererwidget.sip
  9. +4 −1 python/gui/symbology-ng/qgspointdisplacementrendererwidget.sip
  10. +9 −46 src/app/composer/qgscomposershapewidget.cpp
  11. +1 −5 src/app/composer/qgscomposershapewidget.h
  12. +10 −67 src/app/qgsannotationwidget.cpp
  13. +0 −6 src/app/qgsannotationwidget.h
  14. +10 −79 src/app/qgsdecorationgriddialog.cpp
  15. +0 −4 src/app/qgsdecorationgriddialog.h
  16. +6 −35 src/app/qgsdecorationlayoutextentdialog.cpp
  17. +0 −2 src/app/qgsdecorationlayoutextentdialog.h
  18. +1 −0 src/app/qgsformannotationdialog.cpp
  19. +1 −0 src/app/qgshtmlannotationdialog.cpp
  20. +1 −0 src/app/qgssvgannotationdialog.cpp
  21. +4 −4 src/core/qgscolorramp.h
  22. 0 src/core/qgsunittypes.cpp
  23. +1 −1 src/core/symbology-ng/qgssymbol.h
  24. +4 −0 src/core/symbology-ng/qgssymbollayer.h
  25. +5 −5 src/core/symbology-ng/qgssymbollayerregistry.h
  26. +42 −0 src/core/symbology-ng/qgssymbollayerutils.cpp
  27. +23 −6 src/core/symbology-ng/qgssymbollayerutils.h
  28. +2 −0 src/customwidgets/CMakeLists.txt
  29. +2 −1 src/customwidgets/qgiscustomwidgets.cpp
  30. +97 −0 src/customwidgets/qgssymbolbuttonplugin.cpp
  31. +51 −0 src/customwidgets/qgssymbolbuttonplugin.h
  32. +2 −0 src/gui/CMakeLists.txt
  33. +6 −32 src/gui/attributetable/qgsfieldconditionalformatwidget.cpp
  34. +0 −2 src/gui/attributetable/qgsfieldconditionalformatwidget.h
  35. +514 −0 src/gui/qgssymbolbutton.cpp
  36. +268 −0 src/gui/qgssymbolbutton.h
  37. 0 src/gui/qgsunitselectionwidget.cpp
  38. +0 −1 src/gui/symbology-ng/qgsnullsymbolrendererwidget.h
  39. +24 −46 src/gui/symbology-ng/qgspointclusterrendererwidget.cpp
  40. +6 −5 src/gui/symbology-ng/qgspointclusterrendererwidget.h
  41. +32 −53 src/gui/symbology-ng/qgspointdisplacementrendererwidget.cpp
  42. +5 −5 src/gui/symbology-ng/qgspointdisplacementrendererwidget.h
  43. +0 −1 src/gui/symbology-ng/qgsrendererwidget.h
  44. +12 −7 src/ui/composer/qgscomposershapewidgetbase.ui
  45. +5 −5 src/ui/composer/qgscompositionwidgetbase.ui
  46. +19 −2 src/ui/qgsannotationwidgetbase.ui
  47. +49 −44 src/ui/qgsdecorationgriddialog.ui
  48. +28 −23 src/ui/qgsdecorationlayoutextentdialog.ui
  49. +6 −14 src/ui/qgsfieldconditionalformatwidget.ui
  50. +26 −15 src/ui/qgspointdisplacementrendererwidgetbase.ui
  51. +19 −8 src/ui/symbollayer/qgspointclusterrendererwidgetbase.ui
  52. +1 −0 tests/src/python/CMakeLists.txt
  53. +121 −0 tests/src/python/test_qgssymbolbutton.py
  54. +19 −2 tests/src/python/test_qgssymbollayerutils.py
@@ -144,7 +144,7 @@ class QgsGradientColorRamp : QgsColorRamp
\param stops optional list of additional color stops
%End

static QgsColorRamp *create( const QgsStringMap &properties = QgsStringMap() );
static QgsColorRamp *create( const QgsStringMap &properties = QgsStringMap() ) /Factory/;
%Docstring
Creates a new QgsColorRamp from a map of properties
:rtype: QgsColorRamp
@@ -477,7 +477,7 @@ class QgsPresetSchemeColorRamp : QgsColorRamp, QgsColorScheme
not available in Python bindings - use setColors instead
%End

static QgsColorRamp *create( const QgsStringMap &properties = QgsStringMap() );
static QgsColorRamp *create( const QgsStringMap &properties = QgsStringMap() ) /Factory/;
%Docstring
Returns a new QgsPresetSchemeColorRamp color ramp created using the properties encoded in a string
map.
@@ -541,7 +541,7 @@ class QgsColorBrewerColorRamp : QgsColorRamp
\param inverted invert ramp ordering
%End

static QgsColorRamp *create( const QgsStringMap &properties = QgsStringMap() );
static QgsColorRamp *create( const QgsStringMap &properties = QgsStringMap() ) /Factory/;
%Docstring
Returns a new QgsColorBrewerColorRamp color ramp created using the properties encoded in a string
map.
@@ -647,7 +647,7 @@ class QgsCptCityColorRamp : QgsGradientColorRamp
\param doLoadFile load cpt-city ramp from file
%End

static QgsColorRamp *create( const QgsStringMap &properties = QgsStringMap() );
static QgsColorRamp *create( const QgsStringMap &properties = QgsStringMap() ) /Factory/;
%Docstring
:rtype: QgsColorRamp
%End
@@ -88,7 +88,7 @@ return new default symbol for specified geometry type
:rtype: QgsSymbolLayer
%End

int symbolLayerCount();
int symbolLayerCount() const;
%Docstring
Returns total number of symbol layers contained in the symbol.
:return: count of symbol layers
@@ -231,8 +231,10 @@ class QgsSymbolLayer

virtual QgsSymbol *subSymbol();
%Docstring
Returns the symbol's sub symbol, if present.
:rtype: QgsSymbol
%End

virtual bool setSubSymbol( QgsSymbol *symbol /Transfer/ );
%Docstring
set layer's subsymbol. takes ownership of the passed symbol
@@ -52,7 +52,7 @@ Create a symbol layer of this type given the map of properties.
Create widget for symbol layer of this type. Can return NULL if there's no GUI
:rtype: QgsSymbolLayerWidget
%End
virtual QgsSymbolLayer *createSymbolLayerFromSld( QDomElement & );
virtual QgsSymbolLayer *createSymbolLayerFromSld( QDomElement & ) /Factory/;
%Docstring
Create a symbol layer of this type given the map of properties.
:rtype: QgsSymbolLayer
@@ -85,9 +85,9 @@ Convenience metadata class that uses static functions to create symbol layer and



virtual QgsSymbolLayer *createSymbolLayer( const QgsStringMap &map );
virtual QgsSymbolLayerWidget *createSymbolLayerWidget( const QgsVectorLayer *vl );
virtual QgsSymbolLayer *createSymbolLayerFromSld( QDomElement &elem );
virtual QgsSymbolLayer *createSymbolLayer( const QgsStringMap &map ) /Factory/;
virtual QgsSymbolLayerWidget *createSymbolLayerWidget( const QgsVectorLayer *vl ) /Factory/;
virtual QgsSymbolLayer *createSymbolLayerFromSld( QDomElement &elem ) /Factory/;
virtual void resolvePaths( QgsStringMap &properties, const QgsPathResolver &pathResolver, bool saving );

protected:
@@ -133,7 +133,7 @@ create a new instance of symbol layer given symbol layer name and properties
:rtype: QgsSymbolLayer
%End

QgsSymbolLayer *createSymbolLayerFromSld( const QString &name, QDomElement &element ) const;
QgsSymbolLayer *createSymbolLayerFromSld( const QString &name, QDomElement &element ) const /Factory/;
%Docstring
create a new instance of symbol layer given symbol layer name and SLD
:rtype: QgsSymbolLayer
@@ -337,15 +337,15 @@ Writes a symbol definition to XML
:rtype: bool
%End

static QgsSymbolLayer *createFillLayerFromSld( QDomElement &element );
static QgsSymbolLayer *createFillLayerFromSld( QDomElement &element ) /Factory/;
%Docstring
:rtype: QgsSymbolLayer
%End
static QgsSymbolLayer *createLineLayerFromSld( QDomElement &element );
static QgsSymbolLayer *createLineLayerFromSld( QDomElement &element ) /Factory/;
%Docstring
:rtype: QgsSymbolLayer
%End
static QgsSymbolLayer *createMarkerLayerFromSld( QDomElement &element );
static QgsSymbolLayer *createMarkerLayerFromSld( QDomElement &element ) /Factory/;
%Docstring
:rtype: QgsSymbolLayer
%End
@@ -548,6 +548,25 @@ Writes a collection of symbols to XML with specified tagName for the top-level e

static void clearSymbolMap( QgsSymbolMap &symbols );

static QMimeData *symbolToMimeData( QgsSymbol *symbol ) /Factory/;
%Docstring
Creates new mime data from a ``symbol``.
This also sets the mime color data to match the symbol's color, so that copied symbols
can be paste in places where a color is expected.
.. seealso:: symbolFromMimeData()
.. versionadded:: 3.0
:rtype: QMimeData
%End

static QgsSymbol *symbolFromMimeData( const QMimeData *data ) /Factory/;
%Docstring
Attempts to parse ``mime`` data as a symbol. A new symbol instance will be returned
if the data was successfully converted to a symbol.
.. seealso:: symbolToMimeData()
.. versionadded:: 3.0
:rtype: QgsSymbol
%End

static QgsColorRamp *loadColorRamp( QDomElement &element ) /Factory/;
%Docstring
Creates a color ramp from the settings encoded in an XML element
@@ -577,7 +596,7 @@ Writes a collection of symbols to XML with specified tagName for the top-level e
:rtype: QVariant
%End

static QgsColorRamp *loadColorRamp( const QVariant &value );
static QgsColorRamp *loadColorRamp( const QVariant &value ) /Factory/;
%Docstring
Load a color ramp from a QVariantMap, wrapped in a QVariant.
You can use QgsXmlUtils.readVariant to load it from an XML document.
@@ -605,7 +624,7 @@ Writes a collection of symbols to XML with specified tagName for the top-level e
:rtype: list of QColor
%End

static QMimeData *colorToMimeData( const QColor &color );
static QMimeData *colorToMimeData( const QColor &color ) /Factory/;
%Docstring
Creates mime data from a color. Sets both the mime data's color data, and the
mime data's text with the color's hex code.
@@ -636,7 +655,7 @@ Writes a collection of symbols to XML with specified tagName for the top-level e
:rtype: QgsNamedColorList
%End

static QMimeData *colorListToMimeData( const QgsNamedColorList &colorList, const bool allFormats = true );
static QMimeData *colorListToMimeData( const QgsNamedColorList &colorList, const bool allFormats = true ) /Factory/;
%Docstring
Creates mime data from a list of named colors
\param colorList list of named colors
@@ -188,6 +188,7 @@
%Include qgsstatusbar.sip
%Include qgssublayersdialog.sip
%Include qgssubstitutionlistwidget.sip
%Include qgssymbolbutton.sip
%Include qgstablewidgetbase.sip
%Include qgstabwidget.sip
%Include qgstaskmanagerwidget.sip
@@ -0,0 +1,188 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/qgssymbolbutton.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/



class QgsSymbolButton : QToolButton
{
%Docstring
A button for creating and modifying QgsSymbol settings.

The button shows a preview icon for the current symbol, and will open a detailed symbol editor dialog (or
panel widget) when clicked.

.. versionadded:: 3.0
%End

%TypeHeaderCode
#include "qgssymbolbutton.h"
%End
public:

QgsSymbolButton( QWidget *parent /TransferThis/ = 0, const QString &dialogTitle = QString() );
%Docstring
Construct a new symbol button.
Use ``dialogTitle`` string to define the title to show in the symbol settings dialog.
%End

virtual QSize minimumSizeHint() const;

void setSymbolType( QgsSymbol::SymbolType type );
%Docstring
Sets the symbol ``type`` which the button requires.
If the type differs from the current symbol type, the symbol will be reset
to a default symbol style of the new type.
.. seealso:: symbolType()
%End

QgsSymbol::SymbolType symbolType() const;
%Docstring
Returns the symbol type which the button requires.
.. seealso:: setSymbolType()
:rtype: QgsSymbol.SymbolType
%End

void setDialogTitle( const QString &title );
%Docstring
Sets the ``title`` for the symbol settings dialog window.
.. seealso:: dialogTitle()
%End

QString dialogTitle() const;
%Docstring
Returns the title for the symbol settings dialog window.
.. seealso:: setDialogTitle()
:rtype: str
%End

QgsSymbol *symbol();
%Docstring
Returns the current symbol defined by the button.
.. seealso:: setSymbol()
.. seealso:: changed()
:rtype: QgsSymbol
%End


QgsMapCanvas *mapCanvas() const;
%Docstring
Returns the map canvas associated with the widget.
.. seealso:: setMapCanvas()
:rtype: QgsMapCanvas
%End

void setMapCanvas( QgsMapCanvas *canvas );
%Docstring
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:: mapCanvas()
%End

QgsVectorLayer *layer() const;
%Docstring
Returns the layer associated with the widget.
.. seealso:: setLayer()
:rtype: QgsVectorLayer
%End

void setLayer( QgsVectorLayer *layer );
%Docstring
Sets a ``layer`` to associate with the widget. This allows the
widget to setup layer related settings within the symbol settings dialog,
such as correctly populating data defined override buttons.
.. seealso:: layer()
%End

void registerExpressionContextGenerator( QgsExpressionContextGenerator *generator );
%Docstring
Register an expression context generator class that will be used to retrieve
an expression context for the button when required.
%End

public slots:

void setSymbol( QgsSymbol *symbol /Transfer/ );
%Docstring
Sets the ``symbol`` for the button. Ownership of ``symbol`` is transferred to the
button.
.. seealso:: symbol()
.. seealso:: changed()
%End

void setColor( const QColor &color );
%Docstring
Sets the current ``color`` for the symbol. Will emit a changed() signal if the color is different
to the previous symbol color.
%End

void copySymbol();
%Docstring
Copies the current symbol to the clipboard.
.. seealso:: pasteSymbol()
%End

void pasteSymbol();
%Docstring
Pastes a symbol from the clipboard. If clipboard does not contain a valid
symbol then no change is applied.
.. seealso:: copySymbol()
%End

void copyColor();
%Docstring
Copies the current symbol color to the clipboard.
.. seealso:: pasteColor()
%End

void pasteColor();
%Docstring
Pastes a color from the clipboard to the symbol. If clipboard does not contain a valid
color or string representation of a color, then no change is applied.
.. seealso:: copyColor()
%End

signals:

void changed();
%Docstring
Emitted when the symbol's settings are changed.
.. seealso:: symbol()
.. seealso:: setSymbol()
%End

protected:

virtual void changeEvent( QEvent *e );

virtual void showEvent( QShowEvent *e );

virtual void resizeEvent( QResizeEvent *event );


virtual void mousePressEvent( QMouseEvent *e );

virtual void mouseMoveEvent( QMouseEvent *e );

virtual void dragEnterEvent( QDragEnterEvent *e );


virtual void dragLeaveEvent( QDragLeaveEvent *e );


virtual void dropEvent( QDropEvent *e );


};

/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/qgssymbolbutton.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
@@ -11,7 +11,7 @@



class QgsPointClusterRendererWidget: QgsRendererWidget
class QgsPointClusterRendererWidget: QgsRendererWidget, QgsExpressionContextGenerator
{
%Docstring
A widget which allows configuration of the properties for a QgsPointClusterRenderer.
@@ -48,6 +48,9 @@ class QgsPointClusterRendererWidget: QgsRendererWidget
virtual void setContext( const QgsSymbolWidgetContext &context );


virtual QgsExpressionContext createExpressionContext() const;


};

/************************************************************************
@@ -10,7 +10,7 @@



class QgsPointDisplacementRendererWidget: QgsRendererWidget
class QgsPointDisplacementRendererWidget: QgsRendererWidget, QgsExpressionContextGenerator
{

%TypeHeaderCode
@@ -29,6 +29,9 @@ class QgsPointDisplacementRendererWidget: QgsRendererWidget
virtual void setContext( const QgsSymbolWidgetContext &context );


virtual QgsExpressionContext createExpressionContext() const;


};

/************************************************************************

0 comments on commit d055def

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