Skip to content

Commit db9db4e

Browse files
author
wonder
committed
PyQGIS: added QgsColorButton and QgsColorButtonV2
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@12771 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 3a96ec9 commit db9db4e

File tree

5 files changed

+44
-1
lines changed

5 files changed

+44
-1
lines changed

python/gui/gui.sip

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
%Import core/core.sip
99

10+
%Include qgscolorbutton.sip
1011
%Include qgslegendinterface.sip
1112
%Include qgisinterface.sip
1213
%Include qgscomposerview.sip

python/gui/qgscolorbutton.sip

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
3+
class QgsColorButton : QToolButton
4+
{
5+
%TypeHeaderCode
6+
#include <qgscolorbutton.h>
7+
%End
8+
9+
public:
10+
QgsColorButton( QWidget *parent = 0 );
11+
~QgsColorButton();
12+
13+
void setColor( const QColor &color );
14+
QColor color() const;
15+
16+
protected:
17+
void paintEvent( QPaintEvent *e );
18+
19+
};
20+
21+
22+
class QgsColorButtonV2 : QPushButton
23+
{
24+
%TypeHeaderCode
25+
#include <qgscolorbutton.h>
26+
%End
27+
28+
public:
29+
QgsColorButtonV2( QWidget* parent = 0 );
30+
QgsColorButtonV2( QString text, QWidget* parent = 0 );
31+
32+
void setColor( const QColor &color );
33+
QColor color() const;
34+
};

src/gui/qgscolorbutton.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ QgsColorButtonV2::QgsColorButtonV2( QWidget* parent )
7575
{
7676
}
7777

78+
QgsColorButtonV2::QgsColorButtonV2( QString text, QWidget* parent )
79+
: QPushButton( text, parent )
80+
{
81+
}
82+
7883
void QgsColorButtonV2::setColor( const QColor &color )
7984
{
8085
mColor = color;

src/gui/qgscolorbutton.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,11 @@ class GUI_EXPORT QgsColorButton: public QToolButton
3939
};
4040

4141

42-
class QgsColorButtonV2 : public QPushButton
42+
class GUI_EXPORT QgsColorButtonV2 : public QPushButton
4343
{
4444
public:
4545
QgsColorButtonV2( QWidget* parent = 0 );
46+
QgsColorButtonV2( QString text, QWidget* parent = 0 );
4647

4748
void setColor( const QColor &color );
4849
QColor color() const { return mColor; }

src/gui/symbology-ng/qgssymbolv2propertiesdialog.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,8 @@ void QgsSymbolV2PropertiesDialog::layerTypeChanged()
330330

331331
// change layer to a new (with different type)
332332
QgsSymbolLayerV2* newLayer = am->createSymbolLayer( QgsStringMap() );
333+
if ( newLayer == NULL )
334+
return;
333335
mSymbol->changeSymbolLayer( currentLayerIndex(), newLayer );
334336

335337
updateSymbolLayerWidget( newLayer );

0 commit comments

Comments
 (0)