Skip to content

Commit 8105545

Browse files
committed
custom widget for new color button
1 parent efab05b commit 8105545

File tree

3 files changed

+148
-0
lines changed

3 files changed

+148
-0
lines changed

src/customwidgets/CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ SET (QGIS_CUSTOMWIDGETS_SRCS
1717
qgiscustomwidgets.cpp
1818
qgscollapsiblegroupboxplugin.cpp
1919
qgscolorbuttonplugin.cpp
20+
qgscolorbuttonv2plugin.cpp
2021
qgsdatadefinedbuttonplugin.cpp
2122
qgsfieldcomboboxplugin.cpp
2223
qgsfieldexpressionwidgetplugin.cpp
@@ -28,6 +29,7 @@ SET (QGIS_CUSTOMWIDGETS_MOC_HDRS
2829
qgiscustomwidgets.h
2930
qgscollapsiblegroupboxplugin.h
3031
qgscolorbuttonplugin.h
32+
qgscolorbuttonv2plugin.h
3133
qgsdatadefinedbuttonplugin.h
3234
qgsfieldcomboboxplugin.h
3335
qgsfieldexpressionwidgetplugin.h
@@ -47,6 +49,7 @@ SET(QGIS_CUSTOMWIDGETS_HDRS
4749
qgiscustomwidgets.h
4850
qgscollapsiblegroupboxplugin.h
4951
qgscolorbuttonplugin.h
52+
qgscolorbuttonv2plugin.h
5053
qgsdatadefinedbuttonplugin.h
5154
qgsfieldcomboboxplugin.h
5255
qgsfieldexpressionwidgetplugin.h
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
/***************************************************************************
2+
qgscolorbuttonv2plugin.cpp
3+
--------------------------------------
4+
Date : 18.08.2014
5+
Copyright : (C) 2014 Denis Rouzaud
6+
Email : denis.rouzaud@gmail.com
7+
***************************************************************************
8+
* *
9+
* This program is free software; you can redistribute it and/or modify *
10+
* it under the terms of the GNU General Public License as published by *
11+
* the Free Software Foundation; either version 2 of the License, or *
12+
* (at your option) any later version. *
13+
* *
14+
***************************************************************************/
15+
16+
#include "qgiscustomwidgets.h"
17+
#include "qgscolorbuttonv2plugin.h"
18+
#include "qgscolorbuttonv2.h"
19+
20+
21+
QgsColorButtonV2Plugin::QgsColorButtonV2Plugin( QObject *parent )
22+
: QObject( parent )
23+
, mInitialized( false )
24+
{
25+
}
26+
27+
28+
QString QgsColorButtonV2Plugin::name() const
29+
{
30+
return "QgsColorButtonV2";
31+
}
32+
33+
QString QgsColorButtonV2Plugin::group() const
34+
{
35+
return QgisCustomWidgets::groupName();
36+
}
37+
38+
QString QgsColorButtonV2Plugin::includeFile() const
39+
{
40+
return "qgscolorbuttonv2.h";
41+
}
42+
43+
QIcon QgsColorButtonV2Plugin::icon() const
44+
{
45+
return QIcon();
46+
}
47+
48+
bool QgsColorButtonV2Plugin::isContainer() const
49+
{
50+
return false;
51+
}
52+
53+
QWidget *QgsColorButtonV2Plugin::createWidget( QWidget *parent )
54+
{
55+
return new QgsColorButtonV2( parent );
56+
}
57+
58+
bool QgsColorButtonV2Plugin::isInitialized() const
59+
{
60+
return mInitialized;
61+
}
62+
63+
void QgsColorButtonV2Plugin::initialize( QDesignerFormEditorInterface *core )
64+
{
65+
Q_UNUSED( core );
66+
if ( mInitialized )
67+
return;
68+
mInitialized = true;
69+
}
70+
71+
72+
QString QgsColorButtonV2Plugin::toolTip() const
73+
{
74+
return "Select color";
75+
}
76+
77+
QString QgsColorButtonV2Plugin::whatsThis() const
78+
{
79+
return "";
80+
}
81+
82+
QString QgsColorButtonV2Plugin::domXml() const
83+
{
84+
return QString( "<ui language=\"c++\">\n"
85+
" <widget class=\"%1\" name=\"mColorButton\">\n"
86+
" <property name=\"geometry\">\n"
87+
" <rect>\n"
88+
" <x>0</x>\n"
89+
" <y>0</y>\n"
90+
" <width>27</width>\n"
91+
" <height>27</height>\n"
92+
" </rect>\n"
93+
" </property>\n"
94+
" </widget>\n"
95+
"</ui>\n" )
96+
.arg( name() );
97+
}
+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/***************************************************************************
2+
qgscolorbuttonv2plugin.h
3+
--------------------------------------
4+
Date : 18.08.2014
5+
Copyright : (C) 2014 Denis Rouzaud
6+
Email : denis.rouzaud@gmail.com
7+
***************************************************************************
8+
* *
9+
* This program is free software; you can redistribute it and/or modify *
10+
* it under the terms of the GNU General Public License as published by *
11+
* the Free Software Foundation; either version 2 of the License, or *
12+
* (at your option) any later version. *
13+
* *
14+
***************************************************************************/
15+
16+
#ifndef QGSCOLORBUTTONV2PLUGIN_H
17+
#define QGSCOLORBUTTONV2PLUGIN_H
18+
19+
#include <QDesignerExportWidget>
20+
#include <QDesignerCustomWidgetInterface>
21+
22+
23+
class CUSTOMWIDGETS_EXPORT QgsColorButtonV2Plugin : public QObject, public QDesignerCustomWidgetInterface
24+
{
25+
Q_OBJECT
26+
Q_INTERFACES( QDesignerCustomWidgetInterface )
27+
28+
public:
29+
explicit QgsColorButtonV2Plugin( QObject *parent = 0 );
30+
31+
private:
32+
bool mInitialized;
33+
34+
// QDesignerCustomWidgetInterface interface
35+
public:
36+
QString name() const;
37+
QString group() const;
38+
QString includeFile() const;
39+
QIcon icon() const;
40+
bool isContainer() const;
41+
QWidget *createWidget( QWidget *parent );
42+
bool isInitialized() const;
43+
void initialize( QDesignerFormEditorInterface *core );
44+
QString toolTip() const;
45+
QString whatsThis() const;
46+
QString domXml() const;
47+
};
48+
#endif // QGSCOLORBUTTONV2PLUGIN_H

0 commit comments

Comments
 (0)