diff --git a/plugins/tools/CMakeLists.txt b/plugins/tools/CMakeLists.txt index 3afdb4ebdc..e438277d3e 100644 --- a/plugins/tools/CMakeLists.txt +++ b/plugins/tools/CMakeLists.txt @@ -1,12 +1,13 @@ add_subdirectory( basictools ) add_subdirectory( defaulttool ) add_subdirectory( selectiontools ) add_subdirectory( tool_crop ) add_subdirectory( tool_polygon ) add_subdirectory( tool_polyline ) add_subdirectory( tool_transform2 ) add_subdirectory( tool_dyna ) add_subdirectory( tool_text ) add_subdirectory( karbonplugins ) add_subdirectory( tool_lazybrush ) add_subdirectory( tool_smart_patch ) +add_subdirectory( tool_referenceimages ) diff --git a/plugins/tools/tool_referenceimages/CMakeLists.txt b/plugins/tools/tool_referenceimages/CMakeLists.txt new file mode 100644 index 0000000000..b58f4ef0e6 --- /dev/null +++ b/plugins/tools/tool_referenceimages/CMakeLists.txt @@ -0,0 +1,14 @@ +set(kritatoolreferenceimages_SOURCES + Plugin.cpp + ToolReferenceImages.cpp + #ToolReferenceImagesWidget.cpp + ) + +#ki18n_wrap_ui(kritatoolreferenceimages_SOURCES WdgToolReferenceImagesOptions.ui) + +add_library(kritatoolreferenceimages MODULE ${kritatoolreferenceimages_SOURCES}) + +target_link_libraries(kritatoolreferenceimages kritaui) + +install(TARGETS kritatoolreferenceimages DESTINATION ${KRITA_PLUGIN_INSTALL_DIR}) + diff --git a/plugins/tools/tool_referenceimages/Plugin.cpp b/plugins/tools/tool_referenceimages/Plugin.cpp new file mode 100644 index 0000000000..d743dfd194 --- /dev/null +++ b/plugins/tools/tool_referenceimages/Plugin.cpp @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2017 Boudewijn Rempt + * + * 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 "Plugin.h" +#include + +#include +#include + +#include +#include + +#include "kis_paint_device.h" + +#include "ToolReferenceImages.h" + + +K_PLUGIN_FACTORY_WITH_JSON(DefaultToolsFactory, "kritatoolreferenceimages.json", registerPlugin();) + + +Plugin::Plugin(QObject *parent, const QVariantList &) + : QObject(parent) +{ + KoToolRegistry::instance()->add(new ToolReferenceImagesFactory()); +} + +Plugin::~Plugin() +{ +} + +#include "Plugin.moc" diff --git a/plugins/tools/tool_referenceimages/Plugin.h b/plugins/tools/tool_referenceimages/Plugin.h new file mode 100644 index 0000000000..19c9fbcd4b --- /dev/null +++ b/plugins/tools/tool_referenceimages/Plugin.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2017 Boudewijn Rempt + * + * 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 PLUGIN_H_ +#define PLUGIN_H_ + +#include +#include + +class Plugin : public QObject +{ + Q_OBJECT +public: + Plugin(QObject *parent, const QVariantList &); + ~Plugin() override; + +}; + +#endif diff --git a/plugins/tools/tool_referenceimages/ToolReferenceImages.cpp b/plugins/tools/tool_referenceimages/ToolReferenceImages.cpp new file mode 100644 index 0000000000..ff460986e8 --- /dev/null +++ b/plugins/tools/tool_referenceimages/ToolReferenceImages.cpp @@ -0,0 +1,155 @@ + +/* + * Copyright (c) 2017 Boudewijn Rempt + * + * This library is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; version 2.1 of the License. + * + * This library 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser 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 + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "kis_global.h" + +#include + +ToolReferenceImages::ToolReferenceImages(KoCanvasBase * canvas) + : KisTool(canvas, KisCursor::arrowCursor()) +{ + setObjectName("ToolReferenceImages"); +} + +ToolReferenceImages::~ToolReferenceImages() +{ +} + +void ToolReferenceImages::activate(ToolActivation toolActivation, const QSet &shapes) +{ + // Add code here to initialize your tool when it got activated + KisTool::activate(toolActivation, shapes); +} + +void ToolReferenceImages::deactivate() +{ + KisTool::deactivate(); +} + +void ToolReferenceImages::beginPrimaryAction(KoPointerEvent *event) +{ +} + +void ToolReferenceImages::continuePrimaryAction(KoPointerEvent *event) +{ +} + +void ToolReferenceImages::endPrimaryAction(KoPointerEvent *event) +{ + setMode(KisTool::HOVER_MODE); + event->ignore(); +} + +void ToolReferenceImages::mouseMoveEvent(KoPointerEvent *event) +{ +} + +void ToolReferenceImages::paint(QPainter& _gc, const KoViewConverter &_converter) +{ + +} + +void ToolReferenceImages::removeAllReferenceImages() +{ +} + +void ToolReferenceImages::loadReferenceImages() +{ +/* + KoFileDialog dialog(m_canvas->viewManager()->mainWindow(), KoFileDialog::OpenFile, "OpenReferenceImage"); + dialog.setCaption(i18n("Select a Reference Image")); + dialog.setDefaultDir(QDesktopServices::storageLocation(QDesktopServices::PicturesLocation)); + // dialog.setMimeTypeFilters(QStringList() << "application/x-krita-assistant", "application/x-krita-"); + QString filename = dialog.filename(); + if (filename.isEmpty()) return; + if (!QFileInfo(filename).exists()) return; + + QFile file(filename); + file.open(QIODevice::ReadOnly); + + m_canvas->updateCanvas(); +*/ +} + +void ToolReferenceImages::saveReferenceImages() +{ +} + + + +QWidget *ToolReferenceImages::createOptionWidget() +{ +/* + if (!m_optionsWidget) { + m_optionsWidget = new QWidget; + m_options.setupUi(m_optionsWidget); + + // See https://bugs.kde.org/show_bug.cgi?id=316896 + QWidget *specialSpacer = new QWidget(m_optionsWidget); + specialSpacer->setObjectName("SpecialSpacer"); + specialSpacer->setFixedSize(0, 0); + m_optionsWidget->layout()->addWidget(specialSpacer); + + m_options.loadButton->setIcon(KisIconUtils::loadIcon("document-open")); + m_options.saveButton->setIcon(KisIconUtils::loadIcon("document-save")); + m_options.deleteButton->setIcon(KisIconUtils::loadIcon("edit-delete")); + + QList assistants; + Q_FOREACH (const QString& key, KisPaintingAssistantFactoryRegistry::instance()->keys()) { + QString name = KisPaintingAssistantFactoryRegistry::instance()->get(key)->name(); + assistants << KoID(key, name); + } + qSort(assistants.begin(), assistants.end(), KoID::compareNames); + Q_FOREACH(const KoID &id, assistants) { + m_options.comboBox->addItem(id.name(), id.id()); + } + + connect(m_options.saveButton, SIGNAL(clicked()), SLOT(saveAssistants())); + connect(m_options.loadButton, SIGNAL(clicked()), SLOT(loadAssistants())); + connect(m_options.deleteButton, SIGNAL(clicked()), SLOT(removeAllAssistants())); + } + return m_optionsWidget; +*/ + return 0; +} + diff --git a/plugins/tools/tool_referenceimages/ToolReferenceImages.h b/plugins/tools/tool_referenceimages/ToolReferenceImages.h new file mode 100644 index 0000000000..3861a8e381 --- /dev/null +++ b/plugins/tools/tool_referenceimages/ToolReferenceImages.h @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2017 Boudewijn Rempt + * + * This library is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; version 2.1 of the License. + * + * This library 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser 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 TOOL_REFERENCE_IMAGES_H +#define TOOL_REFERENCE_IMAGES_H + +#include + +#include +#include + +#include +#include "kis_painting_assistant.h" +#include +#include + +class ToolReferenceImages : public KisTool +{ + Q_OBJECT + +public: + ToolReferenceImages(KoCanvasBase * canvas); + ~ToolReferenceImages() override; + + virtual quint32 priority() { + return 3; + } + void beginPrimaryAction(KoPointerEvent *event) override; + void continuePrimaryAction(KoPointerEvent *event) override; + void endPrimaryAction(KoPointerEvent *event) override; + void mouseMoveEvent(KoPointerEvent *event) override; + + QWidget *createOptionWidget() override; + +public Q_SLOTS: + + void activate(ToolActivation toolActivation, const QSet &shapes) override; + void deactivate() override; + +private Q_SLOTS: + + void removeAllReferenceImages(); + void saveReferenceImages(); + void loadReferenceImages(); + +protected: + + void paint(QPainter& gc, const KoViewConverter &converter) override; + +private: + +}; + + +class ToolReferenceImagesFactory : public KoToolFactoryBase +{ +public: + ToolReferenceImagesFactory() + : KoToolFactoryBase("ToolReferenceImages") { + setToolTip(i18n("Reference Images Tool")); + setSection(TOOL_TYPE_VIEW); + setIconName(koIconNameCStr("krita_tool_reference_images")); + setPriority(0); + setActivationShapeId(KRITA_TOOL_ACTIVATION_ID); + }; + + + ~ToolReferenceImagesFactory() override {} + + KoToolBase * createTool(KoCanvasBase * canvas) override { + return new ToolReferenceImages(canvas); + } + +}; + + +#endif + diff --git a/plugins/tools/tool_referenceimages/kritatoolreferenceimages.json b/plugins/tools/tool_referenceimages/kritatoolreferenceimages.json new file mode 100644 index 0000000000..2a072aab06 --- /dev/null +++ b/plugins/tools/tool_referenceimages/kritatoolreferenceimages.json @@ -0,0 +1,9 @@ +{ + "Id": "ReferenceImageSTool", + "Type": "Service", + "X-KDE-Library": "kritatoolreferenceimages", + "X-KDE-ServiceTypes": [ + "Krita/Tool" + ], + "X-Krita-Version": "28" +}