Skip to content
Permalink
Browse files

add custom widget for QgsDockWidget

  • Loading branch information
3nids committed Jun 10, 2016
1 parent 8394b57 commit 37598bdf52affb05dccd6e89880bd78ba870a87e
@@ -28,6 +28,7 @@ SET (QGIS_CUSTOMWIDGETS_SRCS
qgscolorbuttonv2plugin.cpp
qgsdatetimeeditplugin.cpp
qgsdatadefinedbuttonplugin.cpp
qgsdockwidgetplugin.cpp
qgsdoublespinboxplugin.cpp
qgsexpressionbuilderwidgetplugin.cpp
qgsextentgroupboxplugin.cpp
@@ -52,6 +53,7 @@ SET (QGIS_CUSTOMWIDGETS_MOC_HDRS
qgscolorbuttonv2plugin.h
qgsdatetimeeditplugin.h
qgsdatadefinedbuttonplugin.h
qgsdockwidgetplugin.h
qgsdoublespinboxplugin.h
qgsexpressionbuilderwidgetplugin.h
qgsextentgroupboxplugin.h
@@ -82,6 +84,7 @@ SET(QGIS_CUSTOMWIDGETS_HDRS
qgscolorbuttonv2plugin.h
qgsdatetimeeditplugin.h
qgsdatadefinedbuttonplugin.h
qgsdockwidgetplugin.h
qgsdoublespinboxplugin.h
qgsexpressionbuilderwidgetplugin.h
qgsextentgroupboxplugin.h
@@ -16,12 +16,12 @@
#include "qplugin.h"

#include "qgiscustomwidgets.h"

#include "qgscollapsiblegroupboxplugin.h"
#include "qgscolorbuttonplugin.h"
#include "qgscolorbuttonv2plugin.h"
#include "qgsdatadefinedbuttonplugin.h"
#include "qgsdatetimeeditplugin.h"
#include "qgsdockwidgetplugin.h"
#include "qgsdoublespinboxplugin.h"
#include "qgsexpressionbuilderwidgetplugin.h"
#include "qgsextentgroupboxplugin.h"
@@ -45,6 +45,7 @@ QgisCustomWidgets::QgisCustomWidgets( QObject *parent )
mWidgets.append( new QgsColorButtonV2Plugin( this ) );
mWidgets.append( new QgsDataDefinedButtonPlugin( this ) );
mWidgets.append( new QgsDateTimeEditPlugin( this ) );
mWidgets.append( new QgsDockWidgetPlugin( this ) );
mWidgets.append( new QgsDoubleSpinBoxPlugin( this ) );
mWidgets.append( new QgsExpressionBuilderWidgetPlugin( this ) );
mWidgets.append( new QgsExtentGroupBoxPlugin( this ) );
@@ -0,0 +1,97 @@
/***************************************************************************
qgsdockwidgetplugin.cpp
--------------------------------------
Date : 10.06.2016
Copyright : (C) 2016 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 "qgsdockwidget.h"
#include "qgsdockwidgetplugin.h"


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


QString QgsDockWidgetPlugin::name() const
{
return "QgsDockWidget";
}

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

QString QgsDockWidgetPlugin::includeFile() const
{
return "qgsdockwidget.h";
}

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

bool QgsDockWidgetPlugin::isContainer() const
{
return true;
}

QWidget *QgsDockWidgetPlugin::createWidget( QWidget *parent )
{
return new QgsDockWidget( parent );
}

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

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


QString QgsDockWidgetPlugin::toolTip() const
{
return tr( "A dock widget" );
}

QString QgsDockWidgetPlugin::whatsThis() const
{
return tr( "A dock widget" );
}

QString QgsDockWidgetPlugin::domXml() const
{
return QString( "<ui language=\"c++\">\n"
" <widget class=\"%1\" name=\"mDockWidget\">\n"
" <property name=\"geometry\">\n"
" <rect>\n"
" <x>0</x>\n"
" <y>0</y>\n"
" <width>300</width>\n"
" <height>500</height>\n"
" </rect>\n"
" </property>\n"
" </widget>\n"
"</ui>\n" )
.arg( name() );
}
@@ -0,0 +1,54 @@
/***************************************************************************
qgsdockwidgetplugin.h
--------------------------------------
Date : 10.06.2016
Copyright : (C) 2016 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 QGSDOCKWIDGETPLUGIN_H
#define QGSDOCKWIDGETPLUGIN_H


#include <QtGlobal>
#if QT_VERSION < 0x050000
#include <QDesignerCustomWidgetCollectionInterface>
#include <QDesignerExportWidget>
#else
#include <QtUiPlugin/QDesignerCustomWidgetInterface>
#include <QtUiPlugin/QDesignerExportWidget>
#endif

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

public:
explicit QgsDockWidgetPlugin( 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 // QGSDOCKWIDGETPLUGIN_H

0 comments on commit 37598bd

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