Skip to content

Commit

Permalink
custom widget for new color button
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Aug 18, 2014
1 parent efab05b commit 8105545
Show file tree
Hide file tree
Showing 3 changed files with 148 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/customwidgets/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ SET (QGIS_CUSTOMWIDGETS_SRCS
qgiscustomwidgets.cpp
qgscollapsiblegroupboxplugin.cpp
qgscolorbuttonplugin.cpp
qgscolorbuttonv2plugin.cpp
qgsdatadefinedbuttonplugin.cpp
qgsfieldcomboboxplugin.cpp
qgsfieldexpressionwidgetplugin.cpp
Expand All @@ -28,6 +29,7 @@ SET (QGIS_CUSTOMWIDGETS_MOC_HDRS
qgiscustomwidgets.h
qgscollapsiblegroupboxplugin.h
qgscolorbuttonplugin.h
qgscolorbuttonv2plugin.h
qgsdatadefinedbuttonplugin.h
qgsfieldcomboboxplugin.h
qgsfieldexpressionwidgetplugin.h
Expand All @@ -47,6 +49,7 @@ SET(QGIS_CUSTOMWIDGETS_HDRS
qgiscustomwidgets.h
qgscollapsiblegroupboxplugin.h
qgscolorbuttonplugin.h
qgscolorbuttonv2plugin.h
qgsdatadefinedbuttonplugin.h
qgsfieldcomboboxplugin.h
qgsfieldexpressionwidgetplugin.h
Expand Down
97 changes: 97 additions & 0 deletions src/customwidgets/qgscolorbuttonv2plugin.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/***************************************************************************
qgscolorbuttonv2plugin.cpp
--------------------------------------
Date : 18.08.2014
Copyright : (C) 2014 Denis Rouzaud
Email : denis.rouzaud@gmail.com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#include "qgiscustomwidgets.h"
#include "qgscolorbuttonv2plugin.h"
#include "qgscolorbuttonv2.h"


QgsColorButtonV2Plugin::QgsColorButtonV2Plugin( QObject *parent )
: QObject( parent )
, mInitialized( false )
{
}


QString QgsColorButtonV2Plugin::name() const
{
return "QgsColorButtonV2";
}

QString QgsColorButtonV2Plugin::group() const
{
return QgisCustomWidgets::groupName();
}

QString QgsColorButtonV2Plugin::includeFile() const
{
return "qgscolorbuttonv2.h";
}

QIcon QgsColorButtonV2Plugin::icon() const
{
return QIcon();
}

bool QgsColorButtonV2Plugin::isContainer() const
{
return false;
}

QWidget *QgsColorButtonV2Plugin::createWidget( QWidget *parent )
{
return new QgsColorButtonV2( parent );
}

bool QgsColorButtonV2Plugin::isInitialized() const
{
return mInitialized;
}

void QgsColorButtonV2Plugin::initialize( QDesignerFormEditorInterface *core )
{
Q_UNUSED( core );
if ( mInitialized )
return;
mInitialized = true;
}


QString QgsColorButtonV2Plugin::toolTip() const
{
return "Select color";
}

QString QgsColorButtonV2Plugin::whatsThis() const
{
return "";
}

QString QgsColorButtonV2Plugin::domXml() const
{
return QString( "<ui language=\"c++\">\n"
" <widget class=\"%1\" name=\"mColorButton\">\n"
" <property name=\"geometry\">\n"
" <rect>\n"
" <x>0</x>\n"
" <y>0</y>\n"
" <width>27</width>\n"
" <height>27</height>\n"
" </rect>\n"
" </property>\n"
" </widget>\n"
"</ui>\n" )
.arg( name() );
}
48 changes: 48 additions & 0 deletions src/customwidgets/qgscolorbuttonv2plugin.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/***************************************************************************
qgscolorbuttonv2plugin.h
--------------------------------------
Date : 18.08.2014
Copyright : (C) 2014 Denis Rouzaud
Email : denis.rouzaud@gmail.com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#ifndef QGSCOLORBUTTONV2PLUGIN_H
#define QGSCOLORBUTTONV2PLUGIN_H

#include <QDesignerExportWidget>
#include <QDesignerCustomWidgetInterface>


class CUSTOMWIDGETS_EXPORT QgsColorButtonV2Plugin : public QObject, public QDesignerCustomWidgetInterface
{
Q_OBJECT
Q_INTERFACES( QDesignerCustomWidgetInterface )

public:
explicit QgsColorButtonV2Plugin( QObject *parent = 0 );

private:
bool mInitialized;

// QDesignerCustomWidgetInterface interface
public:
QString name() const;
QString group() const;
QString includeFile() const;
QIcon icon() const;
bool isContainer() const;
QWidget *createWidget( QWidget *parent );
bool isInitialized() const;
void initialize( QDesignerFormEditorInterface *core );
QString toolTip() const;
QString whatsThis() const;
QString domXml() const;
};
#endif // QGSCOLORBUTTONV2PLUGIN_H

0 comments on commit 8105545

Please sign in to comment.