QGIS API Documentation
2.6.0-Brighton
|
A cross platform button subclass for selecting colors. More...
#include <qgscolorbuttonv2.h>
Public Types | |
enum | Behaviour { ShowDialog = 0, SignalOnly } |
Public Slots | |
void | setColor (const QColor &color) |
Sets the current color for the button. | |
void | setButtonBackground (const QColor color=QColor()) |
Sets the background pixmap for the button based upon color and transparency. | |
void | copyColor () |
Copies the current color to the clipboard. | |
void | pasteColor () |
Pastes a color from the clipboard to the color button. | |
void | activatePicker () |
Activates the color picker tool, which allows for sampling a color from anywhere on the screen. | |
void | setToNoColor () |
Sets color to a totally transparent color. | |
void | setToDefaultColor () |
Sets color to the button's default color, if set. |
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 () |
virtual QSize | sizeHint () const |
QColor | color () const |
Return the currently selected color. | |
void | setAllowAlpha (const bool allowAlpha) |
Sets whether alpha modification (transparency) is permitted for the color. | |
bool | allowAlpha () const |
Returns whether alpha modification (transparency) is permitted for the color. | |
void | setColorDialogTitle (const QString title) |
Set the title for the color chooser dialog window. | |
QString | colorDialogTitle () const |
Returns the title for the color chooser dialog window. | |
bool | acceptLiveUpdates () const |
Returns whether the button accepts live updates from QColorDialog. | |
void | setAcceptLiveUpdates (const bool accept) |
Sets whether the button accepts live updates from QColorDialog. | |
void | setShowMenu (const bool showMenu) |
Sets whether the drop down menu should be shown for the button. | |
bool | showMenu () const |
Returns whether the drop down menu is shown for the button. | |
void | setBehaviour (const Behaviour behaviour) |
Sets the behaviour for when the button is clicked. | |
Behaviour | behaviour () const |
Returns the behaviour for when the button is clicked. | |
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. | |
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. | |
void | setShowNoColor (const bool showNoColorOption) |
Sets whether the "no color" option should be shown in the button's drop down menu. | |
bool | showNoColor () const |
Returns whether the "no color" option is shown in the button's drop down menu. | |
void | setNoColorString (const QString noColorString) |
Sets the string to use for the "no color" option in the button's drop down menu. | |
QString | noColorString () const |
Returns the string used for the "no color" option in the button's drop down menu. | |
void | setContext (const QString context) |
Sets the context string for the color button. | |
QString | context () const |
Returns the context string for the color button. | |
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. | |
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. |
Protected Member Functions | |
void | changeEvent (QEvent *e) |
void | showEvent (QShowEvent *e) |
void | resizeEvent (QResizeEvent *event) |
void | mousePressEvent (QMouseEvent *e) |
Reimplemented to detect right mouse button clicks on the color button and allow dragging colors. | |
void | mouseMoveEvent (QMouseEvent *e) |
Reimplemented to allow dragging colors from button. | |
void | mouseReleaseEvent (QMouseEvent *e) |
Reimplemented to allow color picking. | |
void | keyPressEvent (QKeyEvent *e) |
Reimplemented to allow cancelling color pick via keypress, and sample via space bar press. | |
void | dragEnterEvent (QDragEnterEvent *e) |
Reimplemented to accept dragged colors. | |
void | dragLeaveEvent (QDragLeaveEvent *e) |
Reimplemented to reset button appearance after drag leave. | |
void | dropEvent (QDropEvent *e) |
Reimplemented to accept dropped colors. |
Static Protected Member Functions | |
static const QPixmap & | transparentBackground () |
Returns a checkboard pattern pixmap for use as a background to transparent colors. |
Properties | |
QString | colorDialogTitle |
bool | acceptLiveUpdates |
QColor | color |
bool | allowAlpha |
bool | showMenu |
Behaviour | behaviour |
QColor | defaultColor |
bool | showNoColor |
QString | noColorString |
QString | context |
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.
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 |
|
virtual |
|
inline |
Returns whether the button accepts live updates from QColorDialog.
|
slot |
Activates the color picker tool, which allows for sampling a color from anywhere on the screen.
|
inline |
Returns whether alpha modification (transparency) is permitted for the color.
|
inline |
Returns the behaviour for when the button is clicked.
|
protected |
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.
|
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.
|
slot |
Copies the current color to the clipboard.
|
inline |
Returns the default color for the button, which is shown in the button's drop down menu for the "default color" option.
|
protected |
Reimplemented to accept dragged colors.
|
protected |
Reimplemented to reset button appearance after drag leave.
|
protected |
Reimplemented to accept dropped colors.
|
protected |
Reimplemented to allow cancelling color pick via keypress, and sample via space bar press.
|
protected |
Reimplemented to allow dragging colors from button.
|
protected |
Reimplemented to detect right mouse button clicks on the color button and allow dragging colors.
|
protected |
Reimplemented to allow color picking.
|
inline |
Returns the string used for the "no color" option in the button's drop down menu.
|
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.
|
protected |
|
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 |
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 |
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 |
|
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 |
|
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 |
void QgsColorButtonV2::setColorDialogTitle | ( | const QString | title | ) |
Set the title for the color chooser dialog window.
title | Title for the color chooser dialog |
|
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. |
|
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 |
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. |
|
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 |
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 |
|
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. |
|
slot |
Sets color to the button's default color, if set.
|
slot |
Sets color to a totally transparent color.
|
protected |
|
inline |
Returns whether the drop down menu is shown for the button.
|
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.
|
virtual |
|
staticprotected |
Returns a checkboard pattern pixmap for use as a background to transparent colors.
|
readwrite |
|
readwrite |
|
readwrite |
|
readwrite |
|
readwrite |
|
readwrite |
|
readwrite |
|
readwrite |
|
readwrite |
|
readwrite |