diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -181,6 +181,9 @@ option(ENABLE_PYTHON_2 "Enables the compiler to look for Python 2.7 instead of Python 3. Some packaged scripts are not compatible with Python 2 and this should only be used if you really have to use 2.7." OFF) +option(BUILD_KRITA_QT_DESIGNER_PLUGINS "Build Qt Designer plugins for Krita widgets" OFF) +add_feature_info("Build Qt Designer plugins" BUILD_KRITA_QT_DESIGNER_PLUGINS "Builds Qt Designer plugins for Krita widgets (use -DBUILD_KRITA_QT_DESIGNER_PLUGINS=ON to enable).") + include(MacroJPEG) ######################################################### diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -21,6 +21,7 @@ add_subdirectory( impex ) add_subdirectory( paintops ) add_subdirectory( tools ) +add_subdirectory( qt ) if (HAVE_PYQT5 AND HAVE_SIP AND HAVE_PYTHONLIBS) add_subdirectory( python ) diff --git a/plugins/qt/CMakeLists.txt b/plugins/qt/CMakeLists.txt new file mode 100644 --- /dev/null +++ b/plugins/qt/CMakeLists.txt @@ -0,0 +1,3 @@ +if( BUILD_KRITA_QT_DESIGNER_PLUGINS ) + add_subdirectory( designer ) +endif() diff --git a/plugins/qt/designer/CMakeLists.txt b/plugins/qt/designer/CMakeLists.txt new file mode 100644 --- /dev/null +++ b/plugins/qt/designer/CMakeLists.txt @@ -0,0 +1,16 @@ +find_package(Qt5 ${MIN_QT_VERSION} + REQUIRED COMPONENTS + Designer +) + +include_directories(${Qt5Designer_INCLUDE_DIRS}) + +set(KritaDesignerPlugin_SOURCES + KisColorSpaceSelectorPlugin.cpp + KisGradientSliderPlugin.cpp + KritaDesignerPluginCollection.cpp +) + +add_library(kritadesignerplugin MODULE ${KritaDesignerPlugin_SOURCES}) + +target_link_libraries(kritadesignerplugin kritaui) diff --git a/plugins/qt/designer/KisColorSpaceSelectorPlugin.h b/plugins/qt/designer/KisColorSpaceSelectorPlugin.h new file mode 100644 --- /dev/null +++ b/plugins/qt/designer/KisColorSpaceSelectorPlugin.h @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2018 Victor Wåhlström + * + * 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. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef _KISCOLORSPACESELECTORPLUGIN_H_ +#define _KISCOLORSPACESELECTORPLUGIN_H_ + +#include +#include + +class KisColorSpaceSelectorPlugin : public QObject, public QDesignerCustomWidgetInterface +{ + Q_OBJECT + Q_INTERFACES(QDesignerCustomWidgetInterface) +public: + explicit KisColorSpaceSelectorPlugin(QObject *parent = nullptr); + + bool isContainer() const override; + bool isInitialized() const override; + QIcon icon() const override; + QString domXml() const override; + QString group() const override; + QString includeFile() const override; + QString name() const override; + QString toolTip() const override; + QString whatsThis() const override; + QWidget *createWidget(QWidget *parent) override; + void initialize(QDesignerFormEditorInterface *core) override; + +private: + bool m_initialized; +}; + +#endif // _KISCOLORSPACESELECTORPLUGIN_H_ diff --git a/plugins/qt/designer/KisColorSpaceSelectorPlugin.cpp b/plugins/qt/designer/KisColorSpaceSelectorPlugin.cpp new file mode 100644 --- /dev/null +++ b/plugins/qt/designer/KisColorSpaceSelectorPlugin.cpp @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2018 Victor Wåhlström + * + * 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. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "KisColorSpaceSelectorPlugin.h" +#include + + +KisColorSpaceSelectorPlugin::KisColorSpaceSelectorPlugin(QObject *parent) + : QObject(parent), + m_initialized(false) +{ +} + +void KisColorSpaceSelectorPlugin::initialize(QDesignerFormEditorInterface*) +{ + if (m_initialized) + return; + + m_initialized = true; +} + +bool KisColorSpaceSelectorPlugin::isInitialized() const +{ + return m_initialized; +} + +QWidget* KisColorSpaceSelectorPlugin::createWidget(QWidget *parent) +{ + return new KisColorSpaceSelector(parent); +} + +QString KisColorSpaceSelectorPlugin::name() const +{ + return "KisColorSpaceSelector"; +} + +QString KisColorSpaceSelectorPlugin::group() const +{ + return "Krita"; +} + +QIcon KisColorSpaceSelectorPlugin::icon() const +{ + return QIcon(); +} + +QString KisColorSpaceSelectorPlugin::toolTip() const +{ + return tr("Krita widget for selecting color spaces."); +} + +QString KisColorSpaceSelectorPlugin::whatsThis() const +{ + return tr("Krita widget for selecting color spaces."); +} + +bool KisColorSpaceSelectorPlugin::isContainer() const +{ + return false; +} + +QString KisColorSpaceSelectorPlugin::domXml() const +{ + return "\n" + " \n" + " \n" + " \n" + " 0\n" + " 0\n" + " 100\n" + " 25\n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + "\n"; +} + +QString KisColorSpaceSelectorPlugin::includeFile() const +{ + return ""; +} diff --git a/plugins/qt/designer/KisGradientSliderPlugin.h b/plugins/qt/designer/KisGradientSliderPlugin.h new file mode 100644 --- /dev/null +++ b/plugins/qt/designer/KisGradientSliderPlugin.h @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2018 Victor Wåhlström + * + * 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. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef _KISGRADIENTSLIDERPLUGIN_H_ +#define _KISGRADIENTSLIDERPLUGIN_H_ + +#include +#include + +class KisGradientSliderPlugin : public QObject, public QDesignerCustomWidgetInterface +{ + Q_OBJECT + Q_INTERFACES(QDesignerCustomWidgetInterface) +public: + explicit KisGradientSliderPlugin(QObject *parent = nullptr); + + bool isContainer() const override; + bool isInitialized() const override; + QIcon icon() const override; + QString domXml() const override; + QString group() const override; + QString includeFile() const override; + QString name() const override; + QString toolTip() const override; + QString whatsThis() const override; + QWidget *createWidget(QWidget *parent) override; + void initialize(QDesignerFormEditorInterface *core) override; + +private: + bool m_initialized; +}; + +#endif // _KISGRADIENTSLIDERPLUGIN_H_ diff --git a/plugins/qt/designer/KisGradientSliderPlugin.cpp b/plugins/qt/designer/KisGradientSliderPlugin.cpp new file mode 100644 --- /dev/null +++ b/plugins/qt/designer/KisGradientSliderPlugin.cpp @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2018 Victor Wåhlström + * + * 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. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "KisGradientSliderPlugin.h" +#include + + +KisGradientSliderPlugin::KisGradientSliderPlugin(QObject *parent) + : QObject(parent), + m_initialized(false) +{ +} + +void KisGradientSliderPlugin::initialize(QDesignerFormEditorInterface*) +{ + if (m_initialized) + return; + + m_initialized = true; +} + +bool KisGradientSliderPlugin::isInitialized() const +{ + return m_initialized; +} + +QWidget* KisGradientSliderPlugin::createWidget(QWidget *parent) +{ + return new KisGradientSlider(parent); +} + +QString KisGradientSliderPlugin::name() const +{ + return "KisGradientSlider"; +} + +QString KisGradientSliderPlugin::group() const +{ + return "Krita"; +} + +QIcon KisGradientSliderPlugin::icon() const +{ + return QIcon(); +} + +QString KisGradientSliderPlugin::toolTip() const +{ + return tr("A gradient slider."); +} + +QString KisGradientSliderPlugin::whatsThis() const +{ + return tr("A gradient slider."); +} + +bool KisGradientSliderPlugin::isContainer() const +{ + return false; +} + +QString KisGradientSliderPlugin::domXml() const +{ + return "\n" + " \n" + " \n" + " \n" + " 0\n" + " 0\n" + " 100\n" + " 25\n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + "\n"; +} + +QString KisGradientSliderPlugin::includeFile() const +{ + return ""; +} diff --git a/plugins/qt/designer/KritaDesignerPluginCollection.h b/plugins/qt/designer/KritaDesignerPluginCollection.h new file mode 100644 --- /dev/null +++ b/plugins/qt/designer/KritaDesignerPluginCollection.h @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2018 Victor Wåhlström + * + * 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. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef _KRITADESIGNERPLUGINCOLLECTION_H_ +#define _KRITADESIGNERPLUGINCOLLECTION_H_ + +#include +#include + + +class KritaDesignerPluginCollection : public QObject, public QDesignerCustomWidgetCollectionInterface +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDesignerCustomWidgetCollectionInterface") + Q_INTERFACES(QDesignerCustomWidgetCollectionInterface) + +public: + KritaDesignerPluginCollection(QObject *parent = nullptr); + + QList customWidgets() const override; + +private: + QList m_widgets; +}; + +#endif // _KRITADESIGNERPLUGINCOLLECTION_H_ diff --git a/plugins/qt/designer/KritaDesignerPluginCollection.cpp b/plugins/qt/designer/KritaDesignerPluginCollection.cpp new file mode 100644 --- /dev/null +++ b/plugins/qt/designer/KritaDesignerPluginCollection.cpp @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2018 Victor Wåhlström + * + * 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. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "KritaDesignerPluginCollection.h" + +#include "KisColorSpaceSelectorPlugin.h" +#include "KisGradientSliderPlugin.h" + +KritaDesignerPluginCollection::KritaDesignerPluginCollection(QObject *parent) + : QObject(parent) +{ + m_widgets.append(new KisColorSpaceSelectorPlugin(this)); + m_widgets.append(new KisGradientSliderPlugin(this)); +} + +QList KritaDesignerPluginCollection::customWidgets() const +{ + return m_widgets; +}