Skip to content

Commit

Permalink
Move internals of QgsColorDialogV2 to new QgsCompoundColorWidget widget
Browse files Browse the repository at this point in the history
This allows reuse of the full options from the color dialog when
required in a widget form.
  • Loading branch information
nyalldawson committed May 12, 2016
1 parent 0332157 commit 77fc122
Show file tree
Hide file tree
Showing 10 changed files with 2,032 additions and 1,677 deletions.
1 change: 1 addition & 0 deletions python/gui/gui.sip
Expand Up @@ -53,6 +53,7 @@
%Include qgscomposeritemcombobox.sip
%Include qgscomposerruler.sip
%Include qgscomposerview.sip
%Include qgscompoundcolorwidget.sip
%Include qgscredentialdialog.sip
%Include qgsdatadefinedbutton.sip
%Include qgsdetaileditemdata.sip
Expand Down
7 changes: 0 additions & 7 deletions python/gui/qgscolordialog.sip
Expand Up @@ -114,11 +114,4 @@ class QgsColorDialogV2 : QDialog

void closeEvent( QCloseEvent* e );

void mousePressEvent( QMouseEvent* e );

void mouseMoveEvent( QMouseEvent *e );

void mouseReleaseEvent( QMouseEvent *e );

void keyPressEvent( QKeyEvent *e );
};
64 changes: 64 additions & 0 deletions python/gui/qgscompoundcolorwidget.sip
@@ -0,0 +1,64 @@

/** \ingroup gui
* \class QgsCompoundColorWidget
* A custom QGIS widget for selecting a color, including options for selecting colors via
* hue wheel, color swatches, and a color sampler.
* \note Added in version 2.16
*/

class QgsCompoundColorWidget : QWidget
{
%TypeHeaderCode
#include <qgscompoundcolorwidget.h>
%End

public:

/** Constructor for QgsCompoundColorWidget
* @param parent parent widget
* @param color initial color for dialog
*/
QgsCompoundColorWidget( QWidget *parent /TransferThis/ = nullptr, const QColor& color = QColor() );

~QgsCompoundColorWidget();

/** Returns the current color for the dialog
* @returns dialog color
*/
QColor color() const;

/** Sets whether alpha modification (transparency) is permitted
* for the color dialog. Defaults to true.
* @param allowAlpha set to false to disable alpha modification
*/
void setAllowAlpha( const bool allowAlpha );

signals:

/** Emitted when the dialog's color changes
* @param color current color
*/
void currentColorChanged( const QColor &color );

public slots:

/** Sets the current color for the dialog
* @param color desired color
*/
void setColor( const QColor &color );

/** Sets the color to show in an optional "previous color" section
* @param color previous color
*/
void setPreviousColor( const QColor& color );

protected:

void mousePressEvent( QMouseEvent* e );

void mouseMoveEvent( QMouseEvent *e );

void mouseReleaseEvent( QMouseEvent *e );

void keyPressEvent( QKeyEvent *e );
};
2 changes: 2 additions & 0 deletions src/gui/CMakeLists.txt
Expand Up @@ -181,6 +181,7 @@ SET(QGIS_GUI_SRCS
qgscomposeritemcombobox.cpp
qgscomposerruler.cpp
qgscomposerview.cpp
qgscompoundcolorwidget.cpp
qgscredentialdialog.cpp
qgscursors.cpp
qgsdatadefinedbutton.cpp
Expand Down Expand Up @@ -328,6 +329,7 @@ SET(QGIS_GUI_MOC_HDRS
qgscomposeritemcombobox.h
qgscomposerruler.h
qgscomposerview.h
qgscompoundcolorwidget.h
qgscredentialdialog.h
qgsdatadefinedbutton.h
qgsdatumtransformdialog.h
Expand Down

0 comments on commit 77fc122

Please sign in to comment.