|
QGIS API Documentation
master-28efcda
|
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. More...
#include <qgscolorbutton.h>
Public Slots | |
| void | setButtonBackground () |
| Sets the background pixmap for the button based upon set color and transparency. | |
Signals | |
| void | colorChanged (const QColor &color) |
| Is emitted, whenever a new color is accepted. | |
Public Member Functions | |
| QgsColorButton (QWidget *parent=0, QString cdt="", QColorDialog::ColorDialogOptions cdo=0) | |
| Construct a new color button. | |
| ~QgsColorButton () | |
| bool | acceptLiveUpdates () |
| Whether the button accepts live updates from QColorDialog. | |
| QColor | color () const |
| Return the currently selected color. | |
| QColorDialog::ColorDialogOptions | colorDialogOptions () |
| Returns the options for the color chooser dialog. | |
| QString | colorDialogTitle () |
| Returns the title, which the color chooser dialog shows. | |
| void | setAcceptLiveUpdates (bool accept) |
| Sets whether the button accepts live updates from QColorDialog. | |
| void | setColor (const QColor &color) |
| Specify the current color. | |
| void | setColorDialogOptions (QColorDialog::ColorDialogOptions cdo) |
| Specify the options for the color chooser dialog (e.g. | |
| void | setColorDialogTitle (QString cdt) |
| Set the title, which the color chooser dialog will show. | |
Protected Member Functions | |
| void | changeEvent (QEvent *e) |
| void | showEvent (QShowEvent *e) |
Static Protected Member Functions | |
| static const QPixmap & | transpBkgrd () |
Private Slots | |
| void | onButtonClicked () |
| void | setValidColor (const QColor &newColor) |
| Sets color for button, if valid. | |
Private Attributes | |
| bool | mAcceptLiveUpdates |
| QColor | mColor |
| QColorDialog::ColorDialogOptions | mColorDialogOptions |
| QString | mColorDialogTitle |
| QTemporaryFile | mTempPNG |
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.
A cross platform button subclass for selecting colors.
A subclass of QPushButton is needed to draw the button content because some platforms such as Mac OS X and Windows XP enforce a consistent GUI look by always using the button color of the current style and not allowing button backgrounds to be changed on a button by button basis. Therefore, a wholely stylesheet-based button is used for the no-text variant.
This class is a simplified version of QtColorButton, an internal class used by Qt Designer to do the same thing.
Will open a color chooser dialog when clicked. Offers live updates to button from color chooser dialog
Definition at line 30 of file qgscolorbutton.h.
| QgsColorButton::QgsColorButton | ( | QWidget * | parent = 0, |
| QString | cdt = "", |
||
| QColorDialog::ColorDialogOptions | cdo = 0 |
||
| ) |
Construct a new color button.
| parent | The parent QWidget for the dialog |
| cdt | The title to show in the color chooser dialog |
| cdo | Options for the color chooser dialog |
Definition at line 41 of file qgscolorbutton.cpp.
References onButtonClicked().
Definition at line 52 of file qgscolorbutton.cpp.
References mTempPNG.
| bool QgsColorButton::acceptLiveUpdates | ( | ) | [inline] |
Whether the button accepts live updates from QColorDialog.
Definition at line 98 of file qgscolorbutton.h.
| void QgsColorButton::changeEvent | ( | QEvent * | e | ) | [protected] |
Definition at line 101 of file qgscolorbutton.cpp.
References setButtonBackground().
| QColor QgsColorButton::color | ( | void | ) | const |
Return the currently selected color.
Definition at line 271 of file qgscolorbutton.cpp.
References mColor.
Referenced by onButtonClicked(), setColor(), and QgsAttributeEditor::updateColor().
| void QgsColorButton::colorChanged | ( | const QColor & | color | ) | [signal] |
Is emitted, whenever a new color is accepted.
The color is always valid. In case the new color is the same, no signal is emitted, to avoid infinite loops.
| color | New color |
Referenced by setColor().
| QColorDialog::ColorDialogOptions QgsColorButton::colorDialogOptions | ( | ) |
Returns the options for the color chooser dialog.
Definition at line 281 of file qgscolorbutton.cpp.
References mColorDialogOptions.
| QString QgsColorButton::colorDialogTitle | ( | ) |
Returns the title, which the color chooser dialog shows.
Definition at line 291 of file qgscolorbutton.cpp.
References mColorDialogTitle.
| void QgsColorButton::onButtonClicked | ( | ) | [private, slot] |
Definition at line 68 of file qgscolorbutton.cpp.
References color(), QgsColorDialog::getLiveColor(), mAcceptLiveUpdates, mColorDialogOptions, mColorDialogTitle, and setValidColor().
Referenced by QgsColorButton().
| void QgsColorButton::setAcceptLiveUpdates | ( | bool | accept | ) | [inline] |
Sets whether the button accepts live updates from QColorDialog.
Live updates may cause changes that are not undoable on QColorDialog cancel.
Definition at line 106 of file qgscolorbutton.h.
| void QgsColorButton::setButtonBackground | ( | ) | [slot] |
Sets the background pixmap for the button based upon set 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
Definition at line 149 of file qgscolorbutton.cpp.
References mColor, mColorDialogOptions, mTempPNG, and transpBkgrd().
Referenced by changeEvent(), setColor(), and showEvent().
| void QgsColorButton::setColor | ( | const QColor & | color | ) |
Specify the current color.
Will emit a colorChanged signal if the color is different to the previous.
| color | the new color |
Definition at line 128 of file qgscolorbutton.cpp.
References color(), colorChanged(), mColor, and setButtonBackground().
Referenced by setValidColor(), QgsAttributeEditor::setValue(), and QgsAttributeEditor::updateColor().
| void QgsColorButton::setColorDialogOptions | ( | QColorDialog::ColorDialogOptions | cdo | ) |
Specify the options for the color chooser dialog (e.g.
alpha).
| cdo | Options for the color chooser dialog |
Definition at line 276 of file qgscolorbutton.cpp.
References mColorDialogOptions.
| void QgsColorButton::setColorDialogTitle | ( | QString | cdt | ) |
Set the title, which the color chooser dialog will show.
| cdt | Title for the color chooser dialog |
Definition at line 286 of file qgscolorbutton.cpp.
References mColorDialogTitle.
| void QgsColorButton::setValidColor | ( | const QColor & | newColor | ) | [private, slot] |
Sets color for button, if valid.
Definition at line 93 of file qgscolorbutton.cpp.
References setColor().
Referenced by onButtonClicked().
| void QgsColorButton::showEvent | ( | QShowEvent * | e | ) | [protected] |
Definition at line 122 of file qgscolorbutton.cpp.
References setButtonBackground().
| const QPixmap & QgsColorButton::transpBkgrd | ( | ) | [static, protected] |
Definition at line 58 of file qgscolorbutton.cpp.
References QgsApplication::getThemePixmap().
Referenced by setButtonBackground().
bool QgsColorButton::mAcceptLiveUpdates [private] |
Definition at line 141 of file qgscolorbutton.h.
Referenced by onButtonClicked().
QColor QgsColorButton::mColor [private] |
Definition at line 139 of file qgscolorbutton.h.
Referenced by color(), setButtonBackground(), and setColor().
QColorDialog::ColorDialogOptions QgsColorButton::mColorDialogOptions [private] |
Definition at line 140 of file qgscolorbutton.h.
Referenced by colorDialogOptions(), onButtonClicked(), setButtonBackground(), and setColorDialogOptions().
QString QgsColorButton::mColorDialogTitle [private] |
Definition at line 138 of file qgscolorbutton.h.
Referenced by colorDialogTitle(), onButtonClicked(), and setColorDialogTitle().
QTemporaryFile QgsColorButton::mTempPNG [private] |
Definition at line 142 of file qgscolorbutton.h.
Referenced by setButtonBackground(), and ~QgsColorButton().