Skip to content

Commit

Permalink
add custom widgets for QgsExternalResourceWidget and QgsFilePickerWidget
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Jan 13, 2016
1 parent 3ce6454 commit 586b607
Show file tree
Hide file tree
Showing 5 changed files with 308 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/customwidgets/CMakeLists.txt
Expand Up @@ -31,8 +31,10 @@ SET (QGIS_CUSTOMWIDGETS_SRCS
qgsdoublespinboxplugin.cpp
qgsexpressionbuilderwidgetplugin.cpp
qgsextentgroupboxplugin.cpp
qgsexternalresourcewidgetplugin.cpp
qgsfieldcomboboxplugin.cpp
qgsfieldexpressionwidgetplugin.cpp
qgsfilepickerwidgetplugin.cpp
qgsfilterlineeditplugin.cpp
qgsmaplayercomboboxplugin.cpp
qgsprojectionselectionwidgetplugin.cpp
Expand All @@ -53,8 +55,10 @@ SET (QGIS_CUSTOMWIDGETS_MOC_HDRS
qgsdoublespinboxplugin.h
qgsexpressionbuilderwidgetplugin.h
qgsextentgroupboxplugin.h
qgsexternalresourcewidgetplugin.h
qgsfieldcomboboxplugin.h
qgsfieldexpressionwidgetplugin.h
qgsfilepickerwidgetplugin.h
qgsfilterlineeditplugin.h
qgsmaplayercomboboxplugin.h
qgsprojectionselectionwidgetplugin.h
Expand All @@ -81,8 +85,10 @@ SET(QGIS_CUSTOMWIDGETS_HDRS
qgsdoublespinboxplugin.h
qgsexpressionbuilderwidgetplugin.h
qgsextentgroupboxplugin.h
qgsexternalresourcewidgetplugin.h
qgsfieldcomboboxplugin.h
qgsfieldexpressionwidgetplugin.h
qgsfilepickerwidgetplugin.h
qgsfilterlineeditplugin.h
qgsmaplayercomboboxplugin.h
qgsprojectionselectionwidgetplugin.h
Expand Down
96 changes: 96 additions & 0 deletions src/customwidgets/qgsexternalresourcewidgetplugin.cpp
@@ -0,0 +1,96 @@
/***************************************************************************
qgsexternalresourcewidgetplugin.cpp
--------------------------------------
Date : 13.01.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 "qgsexternalresourcewidgetplugin.h"
#include "qgsexternalresourcewidget.h"


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

QString QgsExternalResourceWidgetPlugin::name() const
{
return "QgsExternalResourceWidget";
}

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

QString QgsExternalResourceWidgetPlugin::includeFile() const
{
return "qgsexternalresourcewidget.h";
}

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

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

QWidget *QgsExternalResourceWidgetPlugin::createWidget( QWidget *parent )
{
return new QgsExternalResourceWidget( parent );
}

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

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


QString QgsExternalResourceWidgetPlugin::toolTip() const
{
return "";
}

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

QString QgsExternalResourceWidgetPlugin::domXml() const
{
return QString( "<ui language=\"c++\">\n"
" <widget class=\"%1\" name=\"mQgsExternalResourceWidget\">\n"
" <property name=\"geometry\">\n"
" <rect>\n"
" <x>0</x>\n"
" <y>0</y>\n"
" <width>90</width>\n"
" <height>27</height>\n"
" </rect>\n"
" </property>\n"
" </widget>\n"
"</ui>\n" )
.arg( name() );
}
55 changes: 55 additions & 0 deletions src/customwidgets/qgsexternalresourcewidgetplugin.h
@@ -0,0 +1,55 @@
/***************************************************************************
qgsexternalresourcewidgetplugin.h
--------------------------------------
Date : 13.01.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 QGSEXTERNALRESOURCEWIDGETPLUGIN_H
#define QGSEXTERNALRESOURCEWIDGETPLUGIN_H


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


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

public:
explicit QgsExternalResourceWidgetPlugin( 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 // QGSEXTERNALRESOURCEWIDGETPLUGIN_H
96 changes: 96 additions & 0 deletions src/customwidgets/qgsfilepickerwidgetplugin.cpp
@@ -0,0 +1,96 @@
/***************************************************************************
qgsfilepickerwidgetplugin.cpp
--------------------------------------
Date : 13.01.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 "qgsfilepickerwidgetplugin.h"
#include "qgsfilepickerwidget.h"


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

QString QgsFilePickerWidgetPlugin::name() const
{
return "QgsFilePickerWidget";
}

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

QString QgsFilePickerWidgetPlugin::includeFile() const
{
return "qgsfilepickerwidget.h";
}

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

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

QWidget *QgsFilePickerWidgetPlugin::createWidget( QWidget *parent )
{
return new QgsFilePickerWidget( parent );
}

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

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


QString QgsFilePickerWidgetPlugin::toolTip() const
{
return "";
}

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

QString QgsFilePickerWidgetPlugin::domXml() const
{
return QString( "<ui language=\"c++\">\n"
" <widget class=\"%1\" name=\"mQgsFilePickerWidget\">\n"
" <property name=\"geometry\">\n"
" <rect>\n"
" <x>0</x>\n"
" <y>0</y>\n"
" <width>90</width>\n"
" <height>27</height>\n"
" </rect>\n"
" </property>\n"
" </widget>\n"
"</ui>\n" )
.arg( name() );
}
55 changes: 55 additions & 0 deletions src/customwidgets/qgsfilepickerwidgetplugin.h
@@ -0,0 +1,55 @@
/***************************************************************************
qgsfilepickerwidgetplugin.h
--------------------------------------
Date : 13.01.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 QGSFILEPICKERWIDGETPLUGIN_H
#define QGSFILEPICKERWIDGETPLUGIN_H


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


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

public:
explicit QgsFilePickerWidgetPlugin( 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 // QGSFILEPICKERWIDGETPLUGIN_H

0 comments on commit 586b607

Please sign in to comment.