Skip to content

Commit

Permalink
[FEATURE] Update QgsColorButton to offer live color chooser updates a…
Browse files Browse the repository at this point in the history
…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 c966dbf
Show file tree
Hide file tree
Showing 74 changed files with 1,379 additions and 1,287 deletions.
1 change: 1 addition & 0 deletions images/images.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Binary file added images/themes/default/transp-background_8x8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions python/gui/gui.sip
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
45 changes: 25 additions & 20 deletions python/gui/qgscolorbutton.sip
Original file line number Diff line number Diff line change
@@ -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>
Expand All @@ -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();

/**
Expand Down Expand Up @@ -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:
/**
Expand All @@ -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();
};
29 changes: 29 additions & 0 deletions python/gui/qgscolordialog.sip
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. "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 );
};
2 changes: 1 addition & 1 deletion python/gui/symbology-ng/qgsrulebasedrendererv2widget.sip
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
18 changes: 9 additions & 9 deletions python/gui/symbology-ng/qgssymbollayerv2widget.sip
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -180,7 +180,7 @@ class QgsLineDecorationSymbolLayerV2Widget : QgsSymbolLayerV2Widget
virtual QgsSymbolLayerV2* symbolLayer();

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

Expand Down Expand Up @@ -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 );
Expand Down
2 changes: 1 addition & 1 deletion python/gui/symbology-ng/qgssymbolslistwidget.sip
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
21 changes: 8 additions & 13 deletions src/app/composer/qgscomposerarrowwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand All @@ -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() );

Expand Down
2 changes: 1 addition & 1 deletion src/app/composer/qgscomposerarrowwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
Loading

0 comments on commit c966dbf

Please sign in to comment.