QGIS API Documentation
3.16.0-Hannover (43b64b13f3)
|
A cross platform button subclass for selecting color ramps. More...
#include <qgscolorrampbutton.h>
Public Slots | |
void | setButtonBackground (QgsColorRamp *colorramp=nullptr) |
Sets the background pixmap for the button based upon current color ramp. More... | |
void | setColorRamp (QgsColorRamp *colorramp) |
Sets the current color ramp for the button. More... | |
void | setColorRampFromName (const QString &name=QString()) |
Sets the current color ramp for the button using a saved color ramp name. More... | |
void | setRandomColorRamp () |
Sets the current color ramp for the button to random colors. More... | |
void | setToDefaultColorRamp () |
Sets color ramp to the button's default color ramp, if set. More... | |
void | setToNull () |
Sets color ramp to null. More... | |
Signals | |
void | colorRampChanged () |
Emitted whenever a new color ramp is set for the button. More... | |
Public Member Functions | |
QgsColorRampButton (QWidget *parent=nullptr, const QString &dialogTitle=QString()) | |
Construct a new color ramp button. More... | |
~QgsColorRampButton () override | |
bool | acceptLiveUpdates () const |
Returns whether the button accepts live updates from QgsColorRampDialog. More... | |
QgsColorRamp * | colorRamp () const |
Returns a copy of the current color ramp. More... | |
QString | colorRampDialogTitle () const |
Returns the title for the color ramp dialog window. More... | |
QString | colorRampName () const |
Returns the name of the current color ramp when it's available in the style manager. More... | |
QString | context () const |
Returns the context string for the color ramp button. More... | |
QgsColorRamp * | defaultColorRamp () const |
Returns a copy of the default color ramp for the button, which is shown in the button's drop-down menu for the "default color ramp" option. More... | |
bool | isNull () const |
Returns true if the current color is null. More... | |
bool | isRandomColorRamp () const |
Returns true if the current color is null. More... | |
void | setAcceptLiveUpdates (const bool accept) |
Sets whether the button accepts live updates from QgsColorRampDialog. More... | |
void | setColorRampDialogTitle (const QString &title) |
Set the title for the color ramp dialog window. More... | |
void | setColorRampName (const QString &name) |
Sets the name of the current color ramp when it's available in the style manager. More... | |
void | setContext (const QString &context) |
Sets the context string for the color ramp button. More... | |
void | setDefaultColorRamp (QgsColorRamp *colorramp) |
Sets the default color ramp for the button, which is shown in the button's drop-down menu for the "default color ramp" option. More... | |
void | setShowGradientOnly (bool gradientonly) |
Sets whether the color ramp button only shows gradient type ramps. More... | |
void | setShowMenu (bool showMenu) |
Sets whether the drop-down menu should be shown for the button. More... | |
void | setShowNull (bool showNull) |
Sets whether a set to null (clear) option is shown in the button's drop-down menu. More... | |
void | setShowRandomColorRamp (bool showRandom) |
Sets whether a random colors option is shown in the button's drop-down menu. More... | |
bool | showGradientOnly () const |
Returns true if the color ramp button only shows gradient type ramps. More... | |
bool | showMenu () const |
Returns whether the drop-down menu is shown for the button. More... | |
bool | showNull () const |
Returns whether the set to null (clear) option is shown in the button's drop-down menu. More... | |
bool | showRandomColorRamp () const |
Returns whether random colors option is shown in the button's drop-down menu. More... | |
QSize | sizeHint () const override |
Protected Member Functions | |
void | changeEvent (QEvent *e) override |
bool | event (QEvent *e) override |
void | mousePressEvent (QMouseEvent *e) override |
Reimplemented to detect right mouse button clicks on the color ramp button. More... | |
void | resizeEvent (QResizeEvent *event) override |
void | showEvent (QShowEvent *e) override |
Properties | |
bool | acceptLiveUpdates |
QString | colorRampDialogTitle |
QString | context |
QgsColorRamp * | defaultColorRamp |
bool | showMenu |
A cross platform button subclass for selecting color ramps.
Will open color ramp dialogs when clicked. Offers live updates to button from color ramp dialog. An attached drop-down menu allows for access to saved color ramps, as well as option to invert the current color ramp and create new ramps.
Definition at line 36 of file qgscolorrampbutton.h.
QgsColorRampButton::QgsColorRampButton | ( | QWidget * | parent = nullptr , |
const QString & | dialogTitle = QString() |
||
) |
Construct a new color ramp button.
Use parent to attach a parent QWidget to the dialog. Use dialogTitle string to define the title to show in the color ramp dialog
Definition at line 38 of file qgscolorrampbutton.cpp.
|
overridedefault |
|
inline |
Returns whether the button accepts live updates from QgsColorRampDialog.
true
if the button will be accepted immediately when the dialog's color ramp changes Definition at line 83 of file qgscolorrampbutton.h.
|
overrideprotected |
Definition at line 434 of file qgscolorrampbutton.cpp.
QgsColorRamp * QgsColorRampButton::colorRamp | ( | ) | const |
Returns a copy of the current color ramp.
Definition at line 575 of file qgscolorrampbutton.cpp.
|
signal |
Emitted whenever a new color ramp is set for the button.
The color ramp is always valid. In case the new color ramp is the same, no signal is emitted to avoid infinite loops.
QString QgsColorRampButton::colorRampDialogTitle | ( | ) | const |
Returns the title for the color ramp dialog window.
Definition at line 585 of file qgscolorrampbutton.cpp.
|
inline |
Returns the name of the current color ramp when it's available in the style manager.
Definition at line 210 of file qgscolorrampbutton.h.
|
inline |
Returns the context string for the color ramp button.
The context string is passed to all color ramp preview icons shown in the button's drop-down menu, to (eventually) allow them to customize their display colors based on the context.
Definition at line 184 of file qgscolorrampbutton.h.
QgsColorRamp * QgsColorRampButton::defaultColorRamp | ( | ) | const |
Returns a copy of the default color ramp for the button, which is shown in the button's drop-down menu for the "default color ramp" option.
nullptr
if the default color ramp option is disabled. Caller takes ownership of the returned object. Definition at line 609 of file qgscolorrampbutton.cpp.
|
overrideprotected |
Definition at line 183 of file qgscolorrampbutton.cpp.
bool QgsColorRampButton::isNull | ( | ) | const |
Returns true
if the current color is null.
Definition at line 629 of file qgscolorrampbutton.cpp.
bool QgsColorRampButton::isRandomColorRamp | ( | ) | const |
Returns true
if the current color is null.
Definition at line 614 of file qgscolorrampbutton.cpp.
|
overrideprotected |
Reimplemented to detect right mouse button clicks on the color ramp button.
Definition at line 195 of file qgscolorrampbutton.cpp.
|
overrideprotected |
Definition at line 461 of file qgscolorrampbutton.cpp.
|
inline |
Sets whether the button accepts live updates from QgsColorRampDialog.
Live updates may cause changes that are not undoable on QColorRampDialog cancel.
accept | set to true to enable live updates |
Definition at line 91 of file qgscolorrampbutton.h.
|
slot |
Sets the background pixmap for the button based upon current color ramp.
colorramp | Color ramp for button background. If no color ramp is specified, the button's current color ramp will be used |
Definition at line 504 of file qgscolorrampbutton.cpp.
|
slot |
Sets the current color ramp for the button.
Will emit a colorRampChanged() signal if the color ramp is different to the previous color ramp.
colorramp | New color ramp for the button. The ramp will be cloned and ownership is not transferred. |
Definition at line 469 of file qgscolorrampbutton.cpp.
void QgsColorRampButton::setColorRampDialogTitle | ( | const QString & | title | ) |
Set the title for the color ramp dialog window.
title | Title for the color ramp dialog |
Definition at line 580 of file qgscolorrampbutton.cpp.
|
slot |
Sets the current color ramp for the button using a saved color ramp name.
Will emit a colorRampChanged() signal if the color ramp is different to the previous color ramp.
name | Name of saved color ramp |
Definition at line 483 of file qgscolorrampbutton.cpp.
|
inline |
Sets the name of the current color ramp when it's available in the style manager.
name | Name of the saved color ramp |
Definition at line 204 of file qgscolorrampbutton.h.
|
inline |
Sets the context string for the color ramp button.
The context string is passed to all color ramp preview icons shown in the button's drop-down menu, to (eventually) allow them to customize their display colors based on the context.
context | context string for the color dialog button's color ramp preview icons |
Definition at line 175 of file qgscolorrampbutton.h.
void QgsColorRampButton::setDefaultColorRamp | ( | QgsColorRamp * | colorramp | ) |
Sets the default color ramp for the button, which is shown in the button's drop-down menu for the "default color ramp" option.
colorramp | default color ramp for the button. Set to nullptr to disable the default color ramp option. The ramp will be cloned and ownership is not transferred. |
Definition at line 604 of file qgscolorrampbutton.cpp.
|
slot |
Sets the current color ramp for the button to random colors.
Will emit a colorRampChanged() signal if the color ramp is different to the previous color ramp.
Definition at line 495 of file qgscolorrampbutton.cpp.
|
inline |
Sets whether the color ramp button only shows gradient type ramps.
gradientonly | set to true to show only gradient type ramps |
Definition at line 191 of file qgscolorrampbutton.h.
void QgsColorRampButton::setShowMenu | ( | bool | showMenu | ) |
Sets whether the drop-down menu should be shown for the button.
The default behavior is to show the menu.
showMenu | set to false to hide the drop-down menu |
Definition at line 590 of file qgscolorrampbutton.cpp.
void QgsColorRampButton::setShowNull | ( | bool | showNull | ) |
Sets whether a set to null (clear) option is shown in the button's drop-down menu.
showNull | set to true to show a null option |
Definition at line 619 of file qgscolorrampbutton.cpp.
|
inline |
Sets whether a random colors option is shown in the button's drop-down menu.
showRandom | set to true to show a random colors option |
Definition at line 131 of file qgscolorrampbutton.h.
|
slot |
Sets color ramp to the button's default color ramp, if set.
Definition at line 168 of file qgscolorrampbutton.cpp.
|
slot |
Sets color ramp to null.
Definition at line 178 of file qgscolorrampbutton.cpp.
|
overrideprotected |
Definition at line 455 of file qgscolorrampbutton.cpp.
|
inline |
Returns true
if the color ramp button only shows gradient type ramps.
Definition at line 197 of file qgscolorrampbutton.h.
bool QgsColorRampButton::showMenu | ( | ) | const |
Returns whether the drop-down menu is shown for the button.
true
if drop-down menu is shown Definition at line 599 of file qgscolorrampbutton.cpp.
bool QgsColorRampButton::showNull | ( | ) | const |
Returns whether the set to null (clear) option is shown in the button's drop-down menu.
Definition at line 624 of file qgscolorrampbutton.cpp.
|
inline |
Returns whether random colors option is shown in the button's drop-down menu.
Definition at line 137 of file qgscolorrampbutton.h.
|
override |
Definition at line 61 of file qgscolorrampbutton.cpp.
|
readwrite |
Definition at line 1 of file qgscolorrampbutton.h.
|
readwrite |
Definition at line 1 of file qgscolorrampbutton.h.
|
readwrite |
Definition at line 1 of file qgscolorrampbutton.h.
|
readwrite |
Definition at line 1 of file qgscolorrampbutton.h.
|
readwrite |
Definition at line 1 of file qgscolorrampbutton.h.