diff --git a/CMakeLists.txt b/CMakeLists.txt index df10802..cbab9bd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,7 @@ ###| Cmake qtermwidget |### +option(BUILD_DESIGNER_PLUGIN "Build Qt4 designer plugin" ON) + #| Setting required version cmake_minimum_required( VERSION 2.4 ) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index d348090..c6196a9 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -150,3 +150,40 @@ install(FILES ${HDRS_DISTRIB} DESTINATION include) # keyboard layouts install(DIRECTORY kb-layouts/ DESTINATION ${KB_LAYOUT_DIR} FILES_MATCHING PATTERN "*.keytab" ) + +# +# Qt4 designer plugin +# +if (BUILD_DESIGNER_PLUGIN) + message(STATUS "Building Qt designer plugin") + + include_directories(designer + ${QT_QTDESIGNER_INCLUDE_DIR}) + + set(DESIGNER_SRC designer/qtermwidgetplugin.cpp) + QT4_WRAP_CPP( DESIGNER_MOC designer/qtermwidgetplugin.h) + QT4_ADD_RESOURCES( DESIGNER_QRC designer/qtermwidgetplugin.qrc) + + link_directories(${CMAKE_BINARY_DIR}) + add_library( qtermwidgetplugin SHARED + ${DESIGNER_MOC} + ${DESIGNER_QRC} + ${DESIGNER_SRC} + ) + + target_link_libraries( qtermwidgetplugin + ${QT_QTCORE_LIBRARY} + ${QT_QTDESIGNER_LIBRARY} + ${QT_QTDESIGNERCOMPONENTS_LIBRARY} + qtermwidget + ) + + if (APPLE) + # this is a must to load the lib correctly + set_target_properties( qtermwidgetplugin PROPERTIES + INSTALL_NAME_DIR ${QT_PLUGINS_DIR}/designer ) + endif (APPLE) + + install( TARGETS qtermwidgetplugin DESTINATION ${QT_PLUGINS_DIR}/designer ) + +endif (BUILD_DESIGNER_PLUGIN) diff --git a/lib/designer/qtermwidget.png b/lib/designer/qtermwidget.png new file mode 100644 index 0000000..7b9abcc Binary files /dev/null and b/lib/designer/qtermwidget.png differ diff --git a/lib/designer/qtermwidgetplugin.cpp b/lib/designer/qtermwidgetplugin.cpp new file mode 100644 index 0000000..bb9ad91 --- /dev/null +++ b/lib/designer/qtermwidgetplugin.cpp @@ -0,0 +1,102 @@ + +#include "qtermwidgetplugin.h" + +#include + +#include "qtermwidget.h" + + +QTermWidgetPlugin::QTermWidgetPlugin(QObject *parent) + : QObject(parent), initialized(false) +{ + Q_INIT_RESOURCE(qtermwidgetplugin); +} + + +QTermWidgetPlugin::~QTermWidgetPlugin() +{ +} + + +void QTermWidgetPlugin::initialize(QDesignerFormEditorInterface * /* core */) +{ + initialized = true; +} + + +bool QTermWidgetPlugin::isInitialized() const +{ + return initialized; +} + + +QWidget *QTermWidgetPlugin::createWidget(QWidget *parent) +{ + return new QTermWidget(0, parent); +} + + +QString QTermWidgetPlugin::name() const +{ + return "QTermWidget"; +} + + +QString QTermWidgetPlugin::group() const +{ + return "Input Widgets"; +} + + +QIcon QTermWidgetPlugin::icon() const +{ + return QIcon(":qtermwidget.png"); +} + + +QString QTermWidgetPlugin::toolTip() const +{ + return "QTermWidget component/widget"; +} + + +QString QTermWidgetPlugin::whatsThis() const +{ + return "Qt based terminal emulator"; +} + + +bool QTermWidgetPlugin::isContainer() const +{ + return false; +} + + +QString QTermWidgetPlugin::domXml() const +{ + return "\n" + " \n" + " \n" + " 0\n" + " 0\n" + " 400\n" + " 200\n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + "\n"; +} + + +QString QTermWidgetPlugin::includeFile() const +{ + return "qtermwidget.h"; +} + + +Q_EXPORT_PLUGIN2(QTermWidgetPlugin, QTermWidgetPlugin) diff --git a/lib/designer/qtermwidgetplugin.h b/lib/designer/qtermwidgetplugin.h new file mode 100644 index 0000000..8a216de --- /dev/null +++ b/lib/designer/qtermwidgetplugin.h @@ -0,0 +1,33 @@ + +#ifndef QTERMWIDGETPLUGIN_H +#define QTERMWIDGETPLUGIN_H + +#include + + +class QTermWidgetPlugin : public QObject, public QDesignerCustomWidgetInterface +{ + Q_OBJECT + Q_INTERFACES(QDesignerCustomWidgetInterface) + +public: + QTermWidgetPlugin(QObject *parent = 0); + virtual ~QTermWidgetPlugin(); + + bool isContainer() const; + bool isInitialized() const; + QIcon icon() const; + QString domXml() const; + QString group() const; + QString includeFile() const; + QString name() const; + QString toolTip() const; + QString whatsThis() const; + QWidget *createWidget(QWidget *parent); + void initialize(QDesignerFormEditorInterface *core); + +private: + bool initialized; +}; + +#endif diff --git a/lib/designer/qtermwidgetplugin.qrc b/lib/designer/qtermwidgetplugin.qrc new file mode 100644 index 0000000..fbf222c --- /dev/null +++ b/lib/designer/qtermwidgetplugin.qrc @@ -0,0 +1,6 @@ + + + + qtermwidget.png + +