QGIS API Documentation
2.8.2-Wien
|
A cross platform button subclass for selecting colors. More...
#include <qgscolorbuttonv2.h>
Public Types | |
enum | Behaviour { ShowDialog = 0, SignalOnly } |
Public Slots | |
void | activatePicker () |
Activates the color picker tool, which allows for sampling a color from anywhere on the screen. | |
void | copyColor () |
Copies the current color to the clipboard. | |
void | pasteColor () |
Pastes a color from the clipboard to the color button. | |
void | setButtonBackground (const QColor &color=QColor()) |
Sets the background pixmap for the button based upon color and transparency. | |
void | setColor (const QColor &color) |
Sets the current color for the button. | |
void | setToDefaultColor () |
Sets color to the button's default color, if set. | |
void | setToNoColor () |
Sets color to a totally transparent color. |
Signals | |
void | colorChanged (const QColor &color) |
Is emitted whenever a new color is set for the button. | |
void | colorClicked (const QColor &color) |
Emitted when the button is clicked, if the button's behaviour is set to SignalOnly. |
Public Member Functions | |
QgsColorButtonV2 (QWidget *parent=0, QString cdt="", QgsColorSchemeRegistry *registry=0) | |
Construct a new color button. | |
virtual | ~QgsColorButtonV2 () |
bool | acceptLiveUpdates () const |
Returns whether the button accepts live updates from QColorDialog. | |
bool | allowAlpha () const |
Returns whether alpha modification (transparency) is permitted for the color. | |
Behaviour | behaviour () const |
Returns the behaviour for when the button is clicked. | |
QColor | color () const |
Return the currently selected color. | |
QString | colorDialogTitle () const |
Returns the title for the color chooser dialog window. | |
QgsColorSchemeRegistry * | colorSchemeRegistry () |
Returns the color scheme registry for the button, which controls the color swatch grids that are shown in the button's drop down menu. | |
QString | context () const |
Returns the context string for the color button. | |
QColor | defaultColor () const |
Returns the default color for the button, which is shown in the button's drop down menu for the "default color" option. | |
QString | noColorString () const |
Returns the string used for the "no color" option in the button's drop down menu. | |
void | setAcceptLiveUpdates (const bool accept) |
Sets whether the button accepts live updates from QColorDialog. | |
void | setAllowAlpha (const bool allowAlpha) |
Sets whether alpha modification (transparency) is permitted for the color. | |
void | setBehaviour (const Behaviour behaviour) |
Sets the behaviour for when the button is clicked. | |
void | setColorDialogTitle (const QString title) |
Set the title for the color chooser dialog window. | |
void | setColorSchemeRegistry (QgsColorSchemeRegistry *registry) |
Sets the color scheme registry for the button, which controls the color swatch grids that are shown in the button's drop down menu. | |
void | setContext (const QString context) |
Sets the context string for the color button. | |
void | setDefaultColor (const QColor color) |
Sets the default color for the button, which is shown in the button's drop down menu for the "default color" option. | |
void | setNoColorString (const QString noColorString) |
Sets the string to use for the "no color" option in the button's drop down menu. | |
void | setShowMenu (const bool showMenu) |
Sets whether the drop down menu should be shown for the button. | |
void | setShowNoColor (const bool showNoColorOption) |
Sets whether the "no color" option should be shown in the button's drop down menu. | |
bool | showMenu () const |
Returns whether the drop down menu is shown for the button. | |
bool | showNoColor () const |
Returns whether the "no color" option is shown in the button's drop down menu. | |
virtual QSize | sizeHint () const override |
Protected Member Functions | |
void | changeEvent (QEvent *e) override |
void | dragEnterEvent (QDragEnterEvent *e) override |
Reimplemented to accept dragged colors. | |
void | dragLeaveEvent (QDragLeaveEvent *e) override |
Reimplemented to reset button appearance after drag leave. | |
void | dropEvent (QDropEvent *e) override |
Reimplemented to accept dropped colors. | |
void | keyPressEvent (QKeyEvent *e) override |
Reimplemented to allow cancelling color pick via keypress, and sample via space bar press. | |
void | mouseMoveEvent (QMouseEvent *e) override |
Reimplemented to allow dragging colors from button. | |
void | mousePressEvent (QMouseEvent *e) override |
Reimplemented to detect right mouse button clicks on the color button and allow dragging colors. | |
void | mouseReleaseEvent (QMouseEvent *e) override |
Reimplemented to allow color picking. | |
void | resizeEvent (QResizeEvent *event) override |
void | showEvent (QShowEvent *e) override |
Static Protected Member Functions | |
static const QPixmap & | transparentBackground () |
Returns a checkboard pattern pixmap for use as a background to transparent colors. |
Properties | |
bool | acceptLiveUpdates |
bool | allowAlpha |
Behaviour | behaviour |
QColor | color |
QString | colorDialogTitle |
QString | context |
QColor | defaultColor |
QString | noColorString |
bool | showMenu |
bool | showNoColor |
A cross platform button subclass for selecting colors.
Will open a color chooser dialog when clicked. Offers live updates to button from color chooser dialog. An attached drop down menu allows for copying and pasting colors, picking colors from the screen, and selecting colors from color swatch grids.
Definition at line 34 of file qgscolorbuttonv2.h.
Specifies the behaviour when the button is clicked
ShowDialog |
show a color picker dialog when clicked |
SignalOnly |
emit colorClicked signal only, no dialog |
Definition at line 52 of file qgscolorbuttonv2.h.
QgsColorButtonV2::QgsColorButtonV2 | ( | QWidget * | parent = 0 , |
QString | cdt = "" , |
||
QgsColorSchemeRegistry * | registry = 0 |
||
) |
Construct a new color button.
parent | The parent QWidget for the dialog |
cdt | The title to show in the color chooser dialog |
registry | a color scheme registry for color swatch grids to show in the drop down menu. If not specified, the button will use the global color scheme registry |
Definition at line 41 of file qgscolorbuttonv2.cpp.
|
virtual |
Definition at line 70 of file qgscolorbuttonv2.cpp.
|
inline |
Returns whether the button accepts live updates from QColorDialog.
Definition at line 106 of file qgscolorbuttonv2.h.
|
slot |
Activates the color picker tool, which allows for sampling a color from anywhere on the screen.
Definition at line 640 of file qgscolorbuttonv2.cpp.
|
inline |
Returns whether alpha modification (transparency) is permitted for the color.
Definition at line 88 of file qgscolorbuttonv2.h.
|
inline |
Returns the behaviour for when the button is clicked.
Definition at line 139 of file qgscolorbuttonv2.h.
|
overrideprotected |
Definition at line 460 of file qgscolorbuttonv2.cpp.
QColor QgsColorButtonV2::color | ( | ) | const |
|
signal |
Is emitted whenever a new color is set for the button.
The color is always valid. In case the new color is the same no signal is emitted, to avoid infinite loops.
color | New color |
|
signal |
Emitted when the button is clicked, if the button's behaviour is set to SignalOnly.
color | button color |
QString QgsColorButtonV2::colorDialogTitle | ( | ) | const |
Returns the title for the color chooser dialog window.
|
inline |
Returns the color scheme registry for the button, which controls the color swatch grids that are shown in the button's drop down menu.
Definition at line 225 of file qgscolorbuttonv2.h.
|
inline |
Returns the context string for the color button.
The context string is passed to all color swatch grids shown in the button's drop down menu, to allow them to customise their display colors based on the context.
Definition at line 209 of file qgscolorbuttonv2.h.
|
slot |
Copies the current color to the clipboard.
Definition at line 623 of file qgscolorbuttonv2.cpp.
|
inline |
Returns the default color for the button, which is shown in the button's drop down menu for the "default color" option.
Definition at line 155 of file qgscolorbuttonv2.h.
|
overrideprotected |
Reimplemented to accept dragged colors.
Definition at line 302 of file qgscolorbuttonv2.cpp.
|
overrideprotected |
Reimplemented to reset button appearance after drag leave.
Definition at line 316 of file qgscolorbuttonv2.cpp.
|
overrideprotected |
Reimplemented to accept dropped colors.
Definition at line 323 of file qgscolorbuttonv2.cpp.
|
overrideprotected |
Reimplemented to allow cancelling color pick via keypress, and sample via space bar press.
Definition at line 289 of file qgscolorbuttonv2.cpp.
|
overrideprotected |
Reimplemented to allow dragging colors from button.
Definition at line 212 of file qgscolorbuttonv2.cpp.
|
overrideprotected |
Reimplemented to detect right mouse button clicks on the color button and allow dragging colors.
Definition at line 166 of file qgscolorbuttonv2.cpp.
|
overrideprotected |
Reimplemented to allow color picking.
Definition at line 254 of file qgscolorbuttonv2.cpp.
|
inline |
Returns the string used for the "no color" option in the button's drop down menu.
Definition at line 193 of file qgscolorbuttonv2.h.
|
slot |
Pastes a color from the clipboard to the color button.
If clipboard does not contain a valid color or string representation of a color, then no change is applied.
Definition at line 629 of file qgscolorbuttonv2.cpp.
|
overrideprotected |
Definition at line 487 of file qgscolorbuttonv2.cpp.
|
inline |
Sets whether the button accepts live updates from QColorDialog.
Live updates may cause changes that are not undoable on QColorDialog cancel.
accept | set to true to enable live updates |
Definition at line 113 of file qgscolorbuttonv2.h.
void QgsColorButtonV2::setAllowAlpha | ( | const bool | allowAlpha | ) |
Sets whether alpha modification (transparency) is permitted for the color.
Defaults to false.
allowAlpha | set to true to allow alpha modification |
Definition at line 655 of file qgscolorbuttonv2.cpp.
void QgsColorButtonV2::setBehaviour | ( | const Behaviour | behaviour | ) |
Sets the behaviour for when the button is clicked.
The default behaviour is to show a color picker dialog.
behaviour | behaviour when button is clicked |
Definition at line 679 of file qgscolorbuttonv2.cpp.
|
slot |
Sets the background pixmap for the button based upon color and transparency.
Call directly to update background after adding/removing QColorDialog::ShowAlphaChannel option but the color has not changed, i.e. setColor() wouldn't update button and you want the button to retain the set color's alpha component regardless
color | Color for button background. If no color is specified, the button's current color will be used |
Definition at line 550 of file qgscolorbuttonv2.cpp.
|
slot |
Sets the current color for the button.
Will emit a colorChanged signal if the color is different to the previous color.
color | new color for the button |
Definition at line 495 of file qgscolorbuttonv2.cpp.
void QgsColorButtonV2::setColorDialogTitle | ( | const QString | title | ) |
Set the title for the color chooser dialog window.
title | Title for the color chooser dialog |
Definition at line 660 of file qgscolorbuttonv2.cpp.
|
inline |
Sets the color scheme registry for the button, which controls the color swatch grids that are shown in the button's drop down menu.
registry | color scheme registry for the button. Set to 0 to hide all color swatch grids from the button's drop down menu. |
Definition at line 217 of file qgscolorbuttonv2.h.
|
inline |
Sets the context string for the color button.
The context string is passed to all color swatch grids shown in the button's drop down menu, to allow them to customise their display colors based on the context.
context | context string for the color button's color swatch grids |
Definition at line 201 of file qgscolorbuttonv2.h.
void QgsColorButtonV2::setDefaultColor | ( | const QColor | color | ) |
Sets the default color for the button, which is shown in the button's drop down menu for the "default color" option.
color | default color for the button. Set to an invalid QColor to disable the default color option. |
Definition at line 684 of file qgscolorbuttonv2.cpp.
|
inline |
Sets the string to use for the "no color" option in the button's drop down menu.
noColorString | string to use for the "no color" menu option |
Definition at line 184 of file qgscolorbuttonv2.h.
void QgsColorButtonV2::setShowMenu | ( | const bool | showMenu | ) |
Sets whether the drop down menu should be shown for the button.
The default behaviour is to show the menu.
showMenu | set to false to hide the drop down menu |
Definition at line 670 of file qgscolorbuttonv2.cpp.
|
inline |
Sets whether the "no color" option should be shown in the button's drop down menu.
If selected, the "no color" option sets the color button's color to a totally transparent color.
showNoColorOption | set to true to show the no color option. This is disabled by default. |
Definition at line 165 of file qgscolorbuttonv2.h.
|
slot |
Sets color to the button's default color, if set.
Definition at line 148 of file qgscolorbuttonv2.cpp.
|
slot |
Sets color to a totally transparent color.
Definition at line 158 of file qgscolorbuttonv2.cpp.
|
overrideprotected |
Definition at line 481 of file qgscolorbuttonv2.cpp.
|
inline |
Returns whether the drop down menu is shown for the button.
Definition at line 126 of file qgscolorbuttonv2.h.
|
inline |
Returns whether the "no color" option is shown in the button's drop down menu.
If selected, the "no color" option sets the color button's color to a totally transparent color.
Definition at line 175 of file qgscolorbuttonv2.h.
|
overridevirtual |
Definition at line 74 of file qgscolorbuttonv2.cpp.
|
staticprotected |
Returns a checkboard pattern pixmap for use as a background to transparent colors.
Definition at line 84 of file qgscolorbuttonv2.cpp.
|
readwrite |
Definition at line 38 of file qgscolorbuttonv2.h.
|
readwrite |
Definition at line 40 of file qgscolorbuttonv2.h.
|
readwrite |
Definition at line 42 of file qgscolorbuttonv2.h.
|
readwrite |
Definition at line 39 of file qgscolorbuttonv2.h.
|
readwrite |
Definition at line 37 of file qgscolorbuttonv2.h.
|
readwrite |
Definition at line 46 of file qgscolorbuttonv2.h.
|
readwrite |
Definition at line 43 of file qgscolorbuttonv2.h.
|
readwrite |
Definition at line 45 of file qgscolorbuttonv2.h.
|
readwrite |
Definition at line 41 of file qgscolorbuttonv2.h.
|
readwrite |
Definition at line 44 of file qgscolorbuttonv2.h.