Skip to content
Permalink
Browse files

[FEATURE] Update QgsColorButton to offer live color chooser updates a…

…nd show transparent checkerboard background

- Add option to Options for live color chooser support (QgsColorDialog)
- Add ability to define whether QgsColorButton accepts live updates (default: true)
- Move QgsColorButton to single subclass of QPushButton
- Show different button types relative to whether button has text
- Add transparent checkerboard background for chosen colors with alpha < 255
- Fix triple-modal window issue for Mac (with regards to using native color dialog)

- Composer item frame now supports transparency
- Composer item background transparency support moved to color dialog
- Composer composition grid now supports transparency
  • Loading branch information
dakcarto committed Mar 21, 2013
1 parent 661df0e commit c966dbf69bee25de40f9e7c75b9e2d1b766bafa9
Showing with 1,379 additions and 1,287 deletions.
  1. +1 −0 images/images.qrc
  2. BIN images/themes/default/transp-background_8x8.png
  3. +1 −0 python/gui/gui.sip
  4. +25 −20 python/gui/qgscolorbutton.sip
  5. +29 −0 python/gui/qgscolordialog.sip
  6. +1 −1 python/gui/symbology-ng/qgsrulebasedrendererv2widget.sip
  7. +9 −9 python/gui/symbology-ng/qgssymbollayerv2widget.sip
  8. +1 −1 python/gui/symbology-ng/qgssymbolslistwidget.sip
  9. +2 −2 python/gui/symbology-ng/qgsvectorgradientcolorrampv2dialog.sip
  10. +8 −13 src/app/composer/qgscomposerarrowwidget.cpp
  11. +1 −1 src/app/composer/qgscomposerarrowwidget.h
  12. +60 −50 src/app/composer/qgscomposeritemwidget.cpp
  13. +11 −3 src/app/composer/qgscomposeritemwidget.h
  14. +3 −11 src/app/composer/qgscomposertablewidget.cpp
  15. +1 −1 src/app/composer/qgscomposertablewidget.h
  16. +2 −0 src/app/composer/qgscompositionwidget.cpp
  17. +0 −2 src/app/qgscontinuouscolordialog.cpp
  18. +5 −10 src/app/qgsdecorationcopyrightdialog.cpp
  19. +1 −1 src/app/qgsdecorationcopyrightdialog.h
  20. +7 −0 src/app/qgslabelinggui.cpp
  21. +70 −23 src/app/qgslabelpropertydialog.cpp
  22. +5 −0 src/app/qgsoptions.cpp
  23. +0 −2 src/app/qgssinglesymboldialog.cpp
  24. +3 −0 src/gui/CMakeLists.txt
  25. +199 −61 src/gui/qgscolorbutton.cpp
  26. +43 −19 src/gui/qgscolorbutton.h
  27. +53 −0 src/gui/qgscolordialog.cpp
  28. +53 −0 src/gui/qgscolordialog.h
  29. +14 −18 src/gui/symbology-ng/qgsellipsesymbollayerv2widget.cpp
  30. +2 −2 src/gui/symbology-ng/qgsellipsesymbollayerv2widget.h
  31. +4 −22 src/gui/symbology-ng/qgspointdisplacementrendererwidget.cpp
  32. +2 −2 src/gui/symbology-ng/qgspointdisplacementrendererwidget.h
  33. +7 −4 src/gui/symbology-ng/qgsrulebasedrendererv2widget.cpp
  34. +1 −1 src/gui/symbology-ng/qgsrulebasedrendererv2widget.h
  35. +3 −0 src/gui/symbology-ng/qgsstylev2managerdialog.cpp
  36. +42 −133 src/gui/symbology-ng/qgssymbollayerv2widget.cpp
  37. +12 −12 src/gui/symbology-ng/qgssymbollayerv2widget.h
  38. +7 −15 src/gui/symbology-ng/qgssymbolslistwidget.cpp
  39. +1 −1 src/gui/symbology-ng/qgssymbolslistwidget.h
  40. +3 −0 src/gui/symbology-ng/qgssymbolv2selectordialog.cpp
  41. +52 −44 src/gui/symbology-ng/qgsvectorgradientcolorrampv2dialog.cpp
  42. +5 −2 src/gui/symbology-ng/qgsvectorgradientcolorrampv2dialog.h
  43. +4 −10 src/plugins/grass/qgsgrassregion.cpp
  44. +1 −1 src/plugins/grass/qgsgrassregion.h
  45. +22 −16 src/plugins/grass/qgsgrassregionbase.ui
  46. +24 −42 src/ui/qgsannotationwidgetbase.ui
  47. +1 −1 src/ui/qgscategorizedsymbolrendererv2widget.ui
  48. +7 −2 src/ui/qgscomposerarrowwidgetbase.ui
  49. +32 −68 src/ui/qgscomposeritemwidgetbase.ui
  50. +7 −32 src/ui/qgscomposertablewidgetbase.ui
  51. +19 −50 src/ui/qgscompositionwidgetbase.ui
  52. +16 −30 src/ui/qgscontinuouscolordialogbase.ui
  53. +11 −24 src/ui/qgsdecorationcopyrightdialog.ui
  54. +8 −24 src/ui/qgsdecorationscalebardialog.ui
  55. +25 −49 src/ui/qgsdiagrampropertiesbase.ui
  56. +1 −1 src/ui/qgsgraduatedsymbolrendererv2widget.ui
  57. +27 −135 src/ui/qgslabelingguibase.ui
  58. +19 −19 src/ui/qgslabelpropertydialogbase.ui
  59. +148 −77 src/ui/qgsoptionsbase.ui
  60. +3 −15 src/ui/qgspointdisplacementrendererwidgetbase.ui
  61. +74 −45 src/ui/qgsprojectpropertiesbase.ui
  62. +15 −15 src/ui/qgssinglesymboldialogbase.ui
  63. +16 −7 src/ui/qgstextannotationdialogbase.ui
  64. +41 −42 src/ui/qgsvectorgradientcolorrampv2dialogbase.ui
  65. +5 −5 src/ui/symbollayer/widget_ellipse.ui
  66. +3 −3 src/ui/symbollayer/widget_fontmarker.ui
  67. +3 −3 src/ui/symbollayer/widget_linedecoration.ui
  68. +3 −3 src/ui/symbollayer/widget_linepatternfill.ui
  69. +5 −5 src/ui/symbollayer/widget_simplefill.ui
  70. +72 −59 src/ui/symbollayer/widget_simpleline.ui
  71. +5 −5 src/ui/symbollayer/widget_simplemarker.ui
  72. +5 −5 src/ui/symbollayer/widget_svgfill.ui
  73. +5 −5 src/ui/symbollayer/widget_svgmarker.ui
  74. +3 −3 src/ui/symbollayer/widget_symbolslist.ui
@@ -279,6 +279,7 @@
<file>themes/default/symbologyUp.png</file>
<file>themes/default/tracking.png</file>
<file>themes/default/transformed.png</file>
<file>themes/default/transp-background_8x8.png</file>
<file>themes/default/user.png</file>
<file>themes/default/mActionAddHtml.png</file>
<file>themes/gis/mActionAddArrow.png</file>
Binary file not shown.
@@ -12,6 +12,7 @@
%Include qgsattributeeditor.sip
%Include qgscollapsiblegroupbox.sip
%Include qgscolorbutton.sip
%Include qgscolordialog.sip
%Include qgscomposerview.sip
%Include qgscredentialdialog.sip
%Include qgsdetaileditemdata.sip
@@ -1,6 +1,12 @@

/** \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>
@@ -15,7 +21,7 @@ class QgsColorButton : QToolButton
* @param cdo Options for the color chooser dialog
* @note changed in 1.9
*/
QgsColorButton( QWidget *parent = 0, QString cdt = "Select Color", QColorDialog::ColorDialogOptions cdo = 0 );
QgsColorButton( QWidget *parent = 0, QString cdt = "", QColorDialog::ColorDialogOptions cdo = 0 );
~QgsColorButton();

/**
@@ -65,11 +71,20 @@ class QgsColorButton : QToolButton
*/
QString colorDialogTitle();

protected:
void paintEvent( QPaintEvent *e );
/**
* Whether the button accepts live updates from QColorDialog.
*
* @note added in 1.9
*/
bool acceptLiveUpdates();

public slots:
void onButtonClicked();
/**
* 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:
/**
@@ -80,19 +95,9 @@ class QgsColorButton : QToolButton
* @note added in 1.9
*/
void colorChanged( const QColor &color );
};


class QgsColorButtonV2 : QPushButton
{
%TypeHeaderCode
#include <qgscolorbutton.h>
%End

public:
QgsColorButtonV2( QWidget* parent = 0 );
QgsColorButtonV2( QString text, QWidget* parent = 0 );

void setColor( const QColor &color );
QColor color() const;
protected:
void changeEvent( QEvent* e );
void paintEvent( QPaintEvent* e );
static const QPixmap& transpBkgrd();
};
@@ -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. "setColor( 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 );
};
@@ -96,7 +96,7 @@ class QgsRendererRulePropsDialog : QDialog
%End

public:
QgsRendererRulePropsDialog( QgsRuleBasedRendererV2::Rule* rule, QgsVectorLayer* layer, QgsStyleV2* style );
QgsRendererRulePropsDialog( QgsRuleBasedRendererV2::Rule* rule, QgsVectorLayer* layer, QgsStyleV2* style, QWidget* parent = 0 );
~QgsRendererRulePropsDialog();

QgsRuleBasedRendererV2::Rule* rule();
@@ -34,7 +34,7 @@ class QgsSimpleLineSymbolLayerV2Widget : QgsSymbolLayerV2Widget

public slots:
void penWidthChanged();
void colorChanged();
void colorChanged( const QColor& color );
void penStyleChanged();
void offsetChanged();
void on_mCustomCheckBox_stateChanged( int state );
@@ -65,8 +65,8 @@ class QgsSimpleMarkerSymbolLayerV2Widget : QgsSymbolLayerV2Widget

public slots:
void setName();
void setColorBorder();
void setColorFill();
void setColorBorder( const QColor& color );
void setColorFill( const QColor& color );
void setSize();
void setAngle();
void setOffset();
@@ -90,8 +90,8 @@ class QgsSimpleFillSymbolLayerV2Widget : QgsSymbolLayerV2Widget
virtual QgsSymbolLayerV2* symbolLayer();

public slots:
void setColor();
void setBorderColor();
void setColor( const QColor& color );
void setBorderColor( const QColor& color );
void setBrushStyle();
void borderWidthChanged();
void borderStyleChanged();
@@ -150,8 +150,8 @@ class QgsSvgMarkerSymbolLayerV2Widget : QgsSymbolLayerV2Widget
void setOffset();
void on_mFileToolButton_clicked();
void on_mFileLineEdit_textEdited( const QString& text );
void on_mChangeColorButton_clicked();
void on_mChangeBorderColorButton_clicked();
void on_mChangeColorButton_colorChanged( const QColor& color );
void on_mChangeBorderColorButton_colorChanged( const QColor& color );
void on_mBorderWidthSpinBox_valueChanged( double d );

protected:
@@ -180,7 +180,7 @@ class QgsLineDecorationSymbolLayerV2Widget : QgsSymbolLayerV2Widget
virtual QgsSymbolLayerV2* symbolLayer();

public slots:
void colorChanged();
void colorChanged( const QColor& color );
void penWidthChanged();
};

@@ -252,7 +252,7 @@ class QgsFontMarkerSymbolLayerV2Widget : QgsSymbolLayerV2Widget

public slots:
void setFontFamily( const QFont& font );
void setColor();
void setColor( const QColor& color );
void setSize( double size );
void setAngle( double angle );
void setCharacter( const QChar& chr );
@@ -8,7 +8,7 @@ class QgsSymbolsListWidget : QWidget

public slots:
void setSymbolFromStyle( const QModelIndex & index );
void setSymbolColor();
void setSymbolColor( const QColor& color );
void setMarkerAngle( double angle );
void setMarkerSize( double size );
void setLineWidth( double width );
@@ -8,8 +8,8 @@ class QgsVectorGradientColorRampV2Dialog : QDialog
QgsVectorGradientColorRampV2Dialog( QgsVectorGradientColorRampV2* ramp, QWidget* parent = NULL );

public slots:
void setColor1();
void setColor2();
void setColor1( const QColor& color );
void setColor2( const QColor& color );

void toggledStops( bool on );
void addStop();
@@ -77,25 +77,17 @@ void QgsComposerArrowWidget::on_mArrowHeadWidthSpinBox_valueChanged( double d )
mArrow->endCommand();
}

void QgsComposerArrowWidget::on_mArrowColorButton_clicked()
void QgsComposerArrowWidget::on_mArrowColorButton_colorChanged( const QColor& newColor )
{
if ( !mArrow )
{
return;
}

#if QT_VERSION >= 0x040500
QColor newColor = QColorDialog::getColor( mArrow->arrowColor(), 0, tr( "Arrow color" ), QColorDialog::ShowAlphaChannel );
#else
QColor newColor = QColorDialog::getColor( mArrow->arrowColor() );
#endif
if ( newColor.isValid() )
{
mArrow->beginCommand( tr( "Arrow color changed" ) );
mArrow->setArrowColor( newColor );
mArrow->update();
mArrow->endCommand();
}
mArrow->beginCommand( tr( "Arrow color changed" ) );
mArrow->setArrowColor( newColor );
mArrow->update();
mArrow->endCommand();
}

void QgsComposerArrowWidget::blockAllSignals( bool block )
@@ -120,6 +112,9 @@ void QgsComposerArrowWidget::setGuiElementValues()
}

blockAllSignals( true );
mArrowColorButton->setColor( mArrow->arrowColor() );
mArrowColorButton->setColorDialogTitle( tr( "Select arrow color" ) );
mArrowColorButton->setColorDialogOptions( QColorDialog::ShowAlphaChannel );
mOutlineWidthSpinBox->setValue( mArrow->outlineWidth() );
mArrowHeadWidthSpinBox->setValue( mArrow->arrowHeadWidth() );

@@ -42,7 +42,7 @@ class QgsComposerArrowWidget: public QWidget, private Ui::QgsComposerArrowWidget
private slots:
void on_mOutlineWidthSpinBox_valueChanged( double d );
void on_mArrowHeadWidthSpinBox_valueChanged( double d );
void on_mArrowColorButton_clicked();
void on_mArrowColorButton_colorChanged( const QColor& newColor );
void on_mDefaultMarkerRadioButton_toggled( bool toggled );
void on_mNoMarkerRadioButton_toggled( bool toggled );
void on_mSvgMarkerRadioButton_toggled( bool toggled );

0 comments on commit c966dbf

Please sign in to comment.
You can’t perform that action at this time.