-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #474 from dakcarto/color-button_mk_10
[FEATURE] QgsColorButton shows a color chooser dialog on click, checkboard color when translucent, and live updates during color choosing
- Loading branch information
Showing
92 changed files
with
1,603 additions
and
1,537 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,103 @@ | ||
|
||
/** \ingroup gui | ||
* \class QgsColorButton | ||
* 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 | ||
* @note inherited base class moved from QToolButton to QPushButton in QGIS 1.9 | ||
*/ | ||
|
||
class QgsColorButton : QToolButton | ||
class QgsColorButton: QPushButton | ||
{ | ||
%TypeHeaderCode | ||
#include <qgscolorbutton.h> | ||
%End | ||
|
||
public: | ||
QgsColorButton( QWidget *parent = 0 ); | ||
/** | ||
* Construct a new color button. | ||
* | ||
* @param parent The parent QWidget for the dialog | ||
* @param cdt The title to show in the color chooser dialog | ||
* @param cdo Options for the color chooser dialog | ||
* @note changed in 1.9 | ||
*/ | ||
QgsColorButton( QWidget *parent = 0, QString cdt = "", QColorDialog::ColorDialogOptions cdo = 0 ); | ||
~QgsColorButton(); | ||
|
||
/** | ||
* Specify the current color. Will emit a colorChanged signal if the color is different to the previous. | ||
* | ||
* @param color the new color | ||
* @note added in 1.9 | ||
*/ | ||
void setColor( const QColor &color ); | ||
/** | ||
* Return the currently selected color. | ||
* | ||
* @return the currently selected color | ||
* @note added in 1.9 | ||
*/ | ||
QColor color() const; | ||
|
||
protected: | ||
void paintEvent( QPaintEvent *e ); | ||
/** | ||
* Specify the options for the color chooser dialog (e.g. alpha). | ||
* | ||
* @param cdo Options for the color chooser dialog | ||
* @note added in 1.9 | ||
*/ | ||
void setColorDialogOptions( QColorDialog::ColorDialogOptions cdo ); | ||
|
||
}; | ||
/** | ||
* Returns the options for the color chooser dialog. | ||
* | ||
* @return Options for the color chooser dialog | ||
* @note added in 1.9 | ||
*/ | ||
QColorDialog::ColorDialogOptions colorDialogOptions(); | ||
|
||
/** | ||
* Set the title, which the color chooser dialog will show. | ||
* | ||
* @param cdt Title for the color chooser dialog | ||
* @note added in 1.9 | ||
*/ | ||
void setColorDialogTitle( QString cdt ); | ||
|
||
class QgsColorButtonV2 : QPushButton | ||
{ | ||
%TypeHeaderCode | ||
#include <qgscolorbutton.h> | ||
%End | ||
/** | ||
* Returns the title, which the color chooser dialog shows. | ||
* | ||
* @return Title for the color chooser dialog | ||
* @note added in 1.9 | ||
*/ | ||
QString colorDialogTitle(); | ||
|
||
public: | ||
QgsColorButtonV2( QWidget* parent = 0 ); | ||
QgsColorButtonV2( QString text, QWidget* parent = 0 ); | ||
/** | ||
* Whether the button accepts live updates from QColorDialog. | ||
* | ||
* @note added in 1.9 | ||
*/ | ||
bool acceptLiveUpdates(); | ||
|
||
void setColor( const QColor &color ); | ||
QColor color() const; | ||
/** | ||
* Sets whether the button accepts live updates from QColorDialog. | ||
* Live updates may cause changes that are not undoable on QColorDialog cancel. | ||
* | ||
* @note added in 1.9 | ||
*/ | ||
void setAcceptLiveUpdates( bool accept ); | ||
|
||
signals: | ||
/** | ||
* 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. | ||
* | ||
* @param color New color | ||
* @note added in 1.9 | ||
*/ | ||
void colorChanged( const QColor &color ); | ||
|
||
protected: | ||
void changeEvent( QEvent* e ); | ||
void paintEvent( QPaintEvent* e ); | ||
static const QPixmap& transpBkgrd(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
|
||
/** \ingroup gui | ||
* \class QgsColorDialog | ||
* A dialog for selecting a color | ||
*/ | ||
|
||
class QgsColorDialog : QObject | ||
{ | ||
%TypeHeaderCode | ||
#include <qgscolordialog.h> | ||
%End | ||
public: | ||
QgsColorDialog(); | ||
~QgsColorDialog(); | ||
|
||
/** Return a color selection from a QColorDialog, with live updating of interim selections. | ||
* @param initialColor The initial color of the selection dialog. | ||
* @param updateObject The receiver object of the live updating. | ||
* @param updateSlot The receiver object's slot for live updating (e.g. SLOT( setValidColor( const QColor& ) ) ). | ||
* @param parent Parent widget. Usually 0 is best for native system color dialogs. | ||
* @param title The title of the QColorDialog. | ||
* @param options ColorDialogOptions passed to QColorDialog. | ||
* @return Selected color on accepted() or initialColor on rejected(). | ||
*/ | ||
static QColor getLiveColor( const QColor& initialColor, QObject* updateObject, const char* updateSlot, | ||
QWidget* parent = 0, | ||
const QString& title = "", | ||
QColorDialog::ColorDialogOptions options = 0 ); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.