-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add custom widgets for QgsExternalResourceWidget and QgsFilePickerWidget
- Loading branch information
Showing
5 changed files
with
308 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |