Skip to content
Permalink
Browse files

Custom widget plugin for QgsSymbolButton

  • Loading branch information
nyalldawson committed Jul 23, 2017
1 parent f7ada81 commit 43d094eab3815ec43fe909d013527cb15ae09b83
@@ -38,6 +38,7 @@ SET (QGIS_CUSTOMWIDGETS_SRCS
qgsscalewidgetplugin.cpp
qgsscrollareawidgetplugin.cpp
qgsspinboxplugin.cpp
qgssymbolbuttonplugin.cpp
)

SET (QGIS_CUSTOMWIDGETS_MOC_HDRS
@@ -68,6 +69,7 @@ SET (QGIS_CUSTOMWIDGETS_MOC_HDRS
qgsscalewidgetplugin.h
qgsscrollareawidgetplugin.h
qgsspinboxplugin.h
qgssymbolbuttonplugin.h
)

IF(MSVC)
@@ -41,7 +41,7 @@
#include "qgsscalewidgetplugin.h"
#include "qgsscrollareawidgetplugin.h"
#include "qgsspinboxplugin.h"

#include "qgssymbolbuttonplugin.h"

QgisCustomWidgets::QgisCustomWidgets( QObject *parent )
: QObject( parent )
@@ -71,6 +71,7 @@ QgisCustomWidgets::QgisCustomWidgets( QObject *parent )
mWidgets.append( new QgsScaleWidgetPlugin( this ) );
mWidgets.append( new QgsScrollAreaWidgetPlugin( this ) );
mWidgets.append( new QgsSpinBoxPlugin( this ) );
mWidgets.append( new QgsSymbolButtonPlugin( this ) );
}

QList<QDesignerCustomWidgetInterface *> QgisCustomWidgets::customWidgets() const
@@ -0,0 +1,97 @@
/***************************************************************************
qgssymbolbuttonplugin.cpp
------------------------
Date : 23.07.2017
Copyright : (C) 2017 Nyall Dawson
Email : nyall dot dawson at gmail dot 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 "qgssymbolbuttonplugin.h"
#include "qgssymbolbutton.h"


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


QString QgsSymbolButtonPlugin::name() const
{
return "QgsSymbolButton";
}

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

QString QgsSymbolButtonPlugin::includeFile() const
{
return "qgssymbolbutton.h";
}

QIcon QgsSymbolButtonPlugin::icon() const
{
return QIcon( ":/images/icons/qgis-icon-60x60.png" );
}

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

QWidget *QgsSymbolButtonPlugin::createWidget( QWidget *parent )
{
return new QgsSymbolButton( parent );
}

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

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


QString QgsSymbolButtonPlugin::toolTip() const
{
return tr( "Select symbol" );
}

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

QString QgsSymbolButtonPlugin::domXml() const
{
return QString( "<ui language=\"c++\">\n"
" <widget class=\"%1\" name=\"mSymbolButton\">\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() );
}
@@ -0,0 +1,51 @@
/***************************************************************************
qgssymbolbuttonplugin.h
----------------------
Date : 23.07.2017
Copyright : (C) 2017 Nyall Dawson
Email : nyall dot dawson at gmail dot 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 QGSSYMBOLBUTTONPLUGIN_H
#define QGSSYMBOLBUTTONPLUGIN_H


#include <QtGlobal>
#include <QtUiPlugin/QDesignerCustomWidgetInterface>
#include <QtUiPlugin/QDesignerExportWidget>
#include "qgis_customwidgets.h"


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

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

private:
bool mInitialized;

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

0 comments on commit 43d094e

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