Skip to content

Commit

Permalink
Merge pull request #4907 from nyalldawson/symbol_button
Browse files Browse the repository at this point in the history
New QgsSymbolButton widget
  • Loading branch information
nyalldawson committed Jul 24, 2017
2 parents db745df + 6202f06 commit d055def
Show file tree
Hide file tree
Showing 54 changed files with 1,666 additions and 544 deletions.
8 changes: 4 additions & 4 deletions python/core/qgscolorramp.sip
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion python/core/symbology-ng/qgssymbol.sip
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions python/core/symbology-ng/qgssymbollayer.sip
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions python/core/symbology-ng/qgssymbollayerregistry.sip
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
31 changes: 25 additions & 6 deletions python/core/symbology-ng/qgssymbollayerutils.sip
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions python/gui/gui_auto.sip
Expand Up @@ -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
Expand Down
188 changes: 188 additions & 0 deletions python/gui/qgssymbolbutton.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 *
************************************************************************/
5 changes: 4 additions & 1 deletion python/gui/symbology-ng/qgspointclusterrendererwidget.sip
Expand Up @@ -11,7 +11,7 @@



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


virtual QgsExpressionContext createExpressionContext() const;


};

/************************************************************************
Expand Down
Expand Up @@ -10,7 +10,7 @@



class QgsPointDisplacementRendererWidget: QgsRendererWidget
class QgsPointDisplacementRendererWidget: QgsRendererWidget, QgsExpressionContextGenerator
{

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


virtual QgsExpressionContext createExpressionContext() const;


};

/************************************************************************
Expand Down

0 comments on commit d055def

Please sign in to comment.