Commit 900c531e authored by Victor Wåhlström's avatar Victor Wåhlström

Added initial Qt Designer plugin for Krita widgets KisColorSpaceSelector and...

Added initial Qt Designer plugin for Krita widgets KisColorSpaceSelector and KisGradientSliderPlugin. Enable building with -DBUILD_KRITA_QT_DESIGNER_PLUGINS=ON

Ref T8462

Differential Revision: https://phabricator.kde.org/D12043
parent 1df7bb73
......@@ -181,6 +181,9 @@ add_feature_info("Enable Broken Tests" KRITA_ENABLE_BROKEN_TESTS "Runs broken te
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)
#########################################################
......
......@@ -21,6 +21,7 @@ add_subdirectory( generators )
add_subdirectory( impex )
add_subdirectory( paintops )
add_subdirectory( tools )
add_subdirectory( qt )
if (HAVE_PYQT5 AND HAVE_SIP AND HAVE_PYTHONLIBS)
add_subdirectory( python )
......
if( BUILD_KRITA_QT_DESIGNER_PLUGINS )
add_subdirectory( designer )
endif()
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)
/*
* Copyright (c) 2018 Victor Wåhlström <victor.wahlstrom@initiali.se>
*
* 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 <widgets/kis_color_space_selector.h>
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 "<ui language=\"c++\">\n"
" <widget class=\"KisColorSpaceSelector\" name=\"colorSpaceSelector\">\n"
" <property name=\"geometry\">\n"
" <rect>\n"
" <x>0</x>\n"
" <y>0</y>\n"
" <width>100</width>\n"
" <height>25</height>\n"
" </rect>\n"
" </property>\n"
" <property name=\"toolTip\" >\n"
" <string></string>\n"
" </property>\n"
" <property name=\"whatsThis\" >\n"
" <string></string>\n"
" </property>\n"
" </widget>\n"
"</ui>\n";
}
QString KisColorSpaceSelectorPlugin::includeFile() const
{
return "<widgets/kis_color_space_selector.h>";
}
/*
* Copyright (c) 2018 Victor Wåhlström <victor.wahlstrom@initiali.se>
*
* 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 <QtCore/QObject>
#include <QtUiPlugin/QDesignerCustomWidgetInterface>
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_
/*
* Copyright (c) 2018 Victor Wåhlström <victor.wahlstrom@initiali.se>
*
* 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 <KisGradientSlider.h>
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 "<ui language=\"c++\">\n"
" <widget class=\"KisGradientSlider\" name=\"gradientSlider\">\n"
" <property name=\"geometry\">\n"
" <rect>\n"
" <x>0</x>\n"
" <y>0</y>\n"
" <width>100</width>\n"
" <height>25</height>\n"
" </rect>\n"
" </property>\n"
" <property name=\"toolTip\" >\n"
" <string></string>\n"
" </property>\n"
" <property name=\"whatsThis\" >\n"
" <string></string>\n"
" </property>\n"
" </widget>\n"
"</ui>\n";
}
QString KisGradientSliderPlugin::includeFile() const
{
return "<KisGradientSlider.h>";
}
/*
* Copyright (c) 2018 Victor Wåhlström <victor.wahlstrom@initiali.se>
*
* 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 <QtCore/QObject>
#include <QtUiPlugin/QDesignerCustomWidgetInterface>
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_
/*
* Copyright (c) 2018 Victor Wåhlström <victor.wahlstrom@initiali.se>
*
* 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<QDesignerCustomWidgetInterface*> KritaDesignerPluginCollection::customWidgets() const
{
return m_widgets;
}
/*
* Copyright (c) 2018 Victor Wåhlström <victor.wahlstrom@initiali.se>
*
* 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 <QtDesigner/QtDesigner>
#include <QtCore/qplugin.h>
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<QDesignerCustomWidgetInterface*> customWidgets() const override;
private:
QList<QDesignerCustomWidgetInterface*> m_widgets;
};
#endif // _KRITADESIGNERPLUGINCOLLECTION_H_
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment