mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
[ui] Add a set to null / clear current symbol action to the symbol button
This commit is contained in:
parent
3ed4b3c3ec
commit
0a53f86206
@ -179,6 +179,52 @@ Pastes a color from the clipboard to the symbol. If clipboard does not contain a
|
||||
color or string representation of a color, then no change is applied.
|
||||
|
||||
.. seealso:: :py:func:`copyColor`
|
||||
%End
|
||||
|
||||
void setShowNull( bool showNull );
|
||||
%Docstring
|
||||
Sets whether a set to null (clear) option is shown in the button's drop-down menu.
|
||||
|
||||
:param showNull: set to ``True`` to show a null option
|
||||
|
||||
.. seealso:: :py:func:`showNull`
|
||||
|
||||
.. seealso:: :py:func:`isNull`
|
||||
|
||||
.. versionadded:: 3.26
|
||||
%End
|
||||
|
||||
bool showNull() const;
|
||||
%Docstring
|
||||
Returns whether the set to null (clear) option is shown in the button's drop-down menu.
|
||||
|
||||
.. seealso:: :py:func:`setShowNull`
|
||||
|
||||
.. seealso:: :py:func:`isNull`
|
||||
|
||||
.. versionadded:: 3.26
|
||||
%End
|
||||
|
||||
bool isNull() const;
|
||||
%Docstring
|
||||
Returns ``True`` if the current color is null.
|
||||
|
||||
.. seealso:: :py:func:`setShowNull`
|
||||
|
||||
.. seealso:: :py:func:`showNull`
|
||||
|
||||
.. versionadded:: 3.26
|
||||
%End
|
||||
|
||||
void setToNull();
|
||||
%Docstring
|
||||
Sets symbol to to null.
|
||||
|
||||
.. seealso:: :py:func:`setShowNull`
|
||||
|
||||
.. seealso:: :py:func:`showNull`
|
||||
|
||||
.. versionadded:: 3.26
|
||||
%End
|
||||
|
||||
signals:
|
||||
|
@ -421,6 +421,14 @@ void QgsSymbolButton::prepareMenu()
|
||||
mMenu->addAction( pasteSymbolAction );
|
||||
connect( pasteSymbolAction, &QAction::triggered, this, &QgsSymbolButton::pasteSymbol );
|
||||
|
||||
if ( mShowNull )
|
||||
{
|
||||
QAction *nullAction = new QAction( tr( "Clear Current Symbol" ), this );
|
||||
nullAction->setEnabled( !isNull() );
|
||||
mMenu->addAction( nullAction );
|
||||
connect( nullAction, &QAction::triggered, this, &QgsSymbolButton::setToNull );
|
||||
}
|
||||
|
||||
mMenu->addSeparator();
|
||||
|
||||
QgsColorWheel *colorWheel = new QgsColorWheel( mMenu );
|
||||
@ -717,3 +725,23 @@ QgsSymbol *QgsSymbolButton::symbol()
|
||||
{
|
||||
return mSymbol.get();
|
||||
}
|
||||
|
||||
void QgsSymbolButton::setShowNull( bool showNull )
|
||||
{
|
||||
mShowNull = showNull;
|
||||
}
|
||||
|
||||
bool QgsSymbolButton::showNull() const
|
||||
{
|
||||
return mShowNull;
|
||||
}
|
||||
|
||||
bool QgsSymbolButton::isNull() const
|
||||
{
|
||||
return !mSymbol;
|
||||
}
|
||||
|
||||
void QgsSymbolButton::setToNull()
|
||||
{
|
||||
setSymbol( nullptr );
|
||||
}
|
||||
|
@ -204,6 +204,39 @@ class GUI_EXPORT QgsSymbolButton : public QToolButton
|
||||
*/
|
||||
void pasteColor();
|
||||
|
||||
/**
|
||||
* Sets whether a set to null (clear) option is shown in the button's drop-down menu.
|
||||
* \param showNull set to TRUE to show a null option
|
||||
* \see showNull()
|
||||
* \see isNull()
|
||||
* \since QGIS 3.26
|
||||
*/
|
||||
void setShowNull( bool showNull );
|
||||
|
||||
/**
|
||||
* Returns whether the set to null (clear) option is shown in the button's drop-down menu.
|
||||
* \see setShowNull()
|
||||
* \see isNull()
|
||||
* \since QGIS 3.26
|
||||
*/
|
||||
bool showNull() const;
|
||||
|
||||
/**
|
||||
* Returns TRUE if the current color is null.
|
||||
* \see setShowNull()
|
||||
* \see showNull()
|
||||
* \since QGIS 3.26
|
||||
*/
|
||||
bool isNull() const;
|
||||
|
||||
/**
|
||||
* Sets symbol to to null.
|
||||
* \see setShowNull()
|
||||
* \see showNull()
|
||||
* \since QGIS 3.26
|
||||
*/
|
||||
void setToNull();
|
||||
|
||||
signals:
|
||||
|
||||
/**
|
||||
@ -277,6 +310,8 @@ class GUI_EXPORT QgsSymbolButton : public QToolButton
|
||||
|
||||
bool mPickingColor = false;
|
||||
|
||||
bool mShowNull = false;
|
||||
|
||||
/**
|
||||
* Regenerates the text preview. If \a color is specified, a temporary color preview
|
||||
* is shown instead.
|
||||
|
Loading…
x
Reference in New Issue
Block a user