diff --git a/plugins/dockers/CMakeLists.txt b/plugins/dockers/CMakeLists.txt index 6952b67468..add898a795 100644 --- a/plugins/dockers/CMakeLists.txt +++ b/plugins/dockers/CMakeLists.txt @@ -1,35 +1,36 @@ add_subdirectory(layerdocker) if(HAVE_OPENEXR) add_subdirectory(smallcolorselector) endif() add_subdirectory(specificcolorselector) add_subdirectory(digitalmixer) add_subdirectory(advancedcolorselector) add_subdirectory(presetdocker) add_subdirectory(historydocker) add_subdirectory(channeldocker) add_subdirectory(artisticcolorselector) add_subdirectory(tasksetdocker) add_subdirectory(compositiondocker) add_subdirectory(patterndocker) add_subdirectory(griddocker) add_subdirectory(arrangedocker) if(HAVE_OCIO) add_subdirectory(lut) endif() add_subdirectory(overview) add_subdirectory(palettedocker) add_subdirectory(animation) add_subdirectory(presethistory) add_subdirectory(svgcollectiondocker) add_subdirectory(histogram) add_subdirectory(gamutmask) if(NOT APPLE AND HAVE_QT_QUICK) add_subdirectory(touchdocker) option(ENABLE_CPU_THROTTLE "Build the CPU Throttle Docker" OFF) if (ENABLE_CPU_THROTTLE) add_subdirectory(throttle) endif() endif() add_subdirectory(logdocker) +add_subdirectory(snapshotdocker) \ No newline at end of file diff --git a/plugins/dockers/snapshotdocker/CMakeLists.txt b/plugins/dockers/snapshotdocker/CMakeLists.txt new file mode 100644 index 0000000000..7516df8e14 --- /dev/null +++ b/plugins/dockers/snapshotdocker/CMakeLists.txt @@ -0,0 +1,9 @@ +set(kritasnapshotdocker_SOURCES + KisSnapshotModel.cpp + SnapshotDocker.cpp + SnapshotPlugin.cpp + ) + +add_library(kritasnapshotdocker MODULE ${kritasnapshotdocker_SOURCES}) +target_link_libraries(kritasnapshotdocker kritaimage kritaui) +install(TARGETS kritasnapshotdocker DESTINATION ${KRITA_PLUGIN_INSTALL_DIR}) \ No newline at end of file diff --git a/plugins/dockers/snapshotdocker/KisSnapshotModel.cpp b/plugins/dockers/snapshotdocker/KisSnapshotModel.cpp new file mode 100644 index 0000000000..44ee689472 --- /dev/null +++ b/plugins/dockers/snapshotdocker/KisSnapshotModel.cpp @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2019 Tusooa Zhu + * + * 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 "KisSnapshotModel.h" + +#include +#include + +#include + +struct KisSnapshotModel::Private +{ + Private(); + + QMap > canvasDocMap; + QPointer curCanvas; +}; + +KisSnapshotModel::Private::Private() +{ +} + +KisSnapshotModel::KisSnapshotModel() + : QAbstractListModel() + , m_d(new Private) +{ +} + +KisSnapshotModel::~KisSnapshotModel() +{ +} + +int KisSnapshotModel::rowCount(const QModelIndex &parent) const +{ + return 0; +} + +QVariant KisSnapshotModel::data(const QModelIndex &index, int role) const +{ + return QVariant(); +} + +void KisSnapshotModel::setCanvas(QPointer canvas) +{ + m_d->curCanvas = canvas; +} + diff --git a/plugins/dockers/snapshotdocker/KisSnapshotModel.h b/plugins/dockers/snapshotdocker/KisSnapshotModel.h new file mode 100644 index 0000000000..e4976cc78b --- /dev/null +++ b/plugins/dockers/snapshotdocker/KisSnapshotModel.h @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2019 Tusooa Zhu + * + * 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 KIS_SNAPSHOT_MODEL_H_ +#define KIS_SNAPSHOT_MODEL_H_ + +#include +#include +#include + +#include + +class KisSnapshotModel : public QAbstractListModel +{ +public: + KisSnapshotModel(); + ~KisSnapshotModel() override; + + int rowCount(const QModelIndex &parent) const override; + QVariant data(const QModelIndex &index, int role) const override; + void setCanvas(QPointer canvas); +private: + struct Private; + QScopedPointer m_d; +}; + +#endif // KIS_SNAPSHOT_MODEL_H_ diff --git a/plugins/dockers/snapshotdocker/SnapshotDocker.cpp b/plugins/dockers/snapshotdocker/SnapshotDocker.cpp new file mode 100644 index 0000000000..7a5a471499 --- /dev/null +++ b/plugins/dockers/snapshotdocker/SnapshotDocker.cpp @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2019 Tusooa Zhu + * + * 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 "SnapshotDocker.h" + +#include +#include +#include +#include +#include + +#include "KisSnapshotModel.h" + +#include +#include + +struct SnapshotDocker::Private +{ + Private(); + + QPointer model; + QPointer view; + QPointer canvas; + QPointer bnAdd; + QPointer bnRemove; +}; + +SnapshotDocker::Private::Private() + : model(new KisSnapshotModel) + , view(new QListView) + , canvas(0) + , bnAdd(new QToolButton) + , bnRemove(new QToolButton) +{ +} + +SnapshotDocker::SnapshotDocker() + : QDockWidget() + , m_d(new Private) +{ + QWidget *widget = new QWidget(this); + QVBoxLayout *mainLayout = new QVBoxLayout(widget); + mainLayout->addWidget(m_d->view); + + QHBoxLayout *buttonsLayout = new QHBoxLayout(widget); + m_d->bnAdd->setIcon(KisIconUtils::loadIcon("addlayer")); + buttonsLayout->addWidget(m_d->bnAdd); + m_d->bnRemove->setIcon(KisIconUtils::loadIcon("deletelayer")); + buttonsLayout->addWidget(m_d->bnRemove); + mainLayout->addLayout(buttonsLayout); + + setWidget(widget); + setWindowTitle(i18n("Snapshot Docker")); +} + +SnapshotDocker::~SnapshotDocker() +{ +} + +void SnapshotDocker::setCanvas(KoCanvasBase *canvas) +{ + KisCanvas2 *c = dynamic_cast(canvas); + if (c) { + if (m_d->canvas == c) { + return; + } + } + m_d->canvas = c; +} + +void SnapshotDocker::unsetCanvas() +{ + setCanvas(0); +} + +#include "SnapshotDocker.moc" diff --git a/plugins/dockers/snapshotdocker/SnapshotDocker.h b/plugins/dockers/snapshotdocker/SnapshotDocker.h new file mode 100644 index 0000000000..9227ea4d4f --- /dev/null +++ b/plugins/dockers/snapshotdocker/SnapshotDocker.h @@ -0,0 +1,49 @@ +/* This file is part of the KDE project + * Copyright (C) 2010 Matus Talcik + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ +#ifndef SNAPSHOT_DOCKER_H_ +#define SNAPSHOT_DOCKER_H_ + +#include +#include + +#include +#include + +#include +#include + +class SnapshotDocker : public QDockWidget, public KoCanvasObserverBase +{ + Q_OBJECT +public: + SnapshotDocker(); + ~SnapshotDocker() override; + + QString observerName() override { return "SnapshotDocker"; } + void setCanvas(KoCanvasBase *canvas) override; + void unsetCanvas() override; + +private Q_SLOTS: + +private: + struct Private; + QScopedPointer m_d; +}; + +#endif diff --git a/plugins/dockers/snapshotdocker/SnapshotPlugin.cpp b/plugins/dockers/snapshotdocker/SnapshotPlugin.cpp new file mode 100644 index 0000000000..a7eae99da2 --- /dev/null +++ b/plugins/dockers/snapshotdocker/SnapshotPlugin.cpp @@ -0,0 +1,70 @@ +/* This file is part of the KDE project + * Copyright (C) 2010 Matus Talcik + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ +#include "SnapshotPlugin.h" + + +#include +#include + +#include +#include + +#include "SnapshotDocker.h" + +K_PLUGIN_FACTORY_WITH_JSON(SnapshotPluginFactory, "kritasnapshotdocker.json", registerPlugin();) + +class SnapshotDockFactory : public KoDockFactoryBase +{ +public: + SnapshotDockFactory() { + } + + QString id() const override { + return QString("Snapshot"); + } + + virtual Qt::DockWidgetArea defaultDockWidgetArea() const { + return Qt::RightDockWidgetArea; + } + + QDockWidget *createDockWidget() override { + SnapshotDocker *dockWidget = new SnapshotDocker(); + dockWidget->setObjectName(id()); + + return dockWidget; + } + + DockPosition defaultDockPosition() const override { + return DockRight; + } +}; + + +SnapshotPlugin::SnapshotPlugin(QObject *parent, const QVariantList &) + : QObject(parent) +{ + + KoDockRegistry::instance()->add(new SnapshotDockFactory()); +} + +SnapshotPlugin::~SnapshotPlugin() +{ +} + +#include "SnapshotPlugin.moc" diff --git a/plugins/dockers/snapshotdocker/SnapshotPlugin.h b/plugins/dockers/snapshotdocker/SnapshotPlugin.h new file mode 100644 index 0000000000..bd3d32c463 --- /dev/null +++ b/plugins/dockers/snapshotdocker/SnapshotPlugin.h @@ -0,0 +1,34 @@ +/* This file is part of the KDE project + * Copyright (C) 2010 Matus Talcik + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef SNAPSHOT_PLUGIN_H_ +#define SNAPSHOT_PLUGIN_H_ + +#include +#include + +class SnapshotPlugin : public QObject +{ + Q_OBJECT +public: + SnapshotPlugin(QObject *parent, const QVariantList &); + ~SnapshotPlugin() override; +}; + +#endif diff --git a/plugins/dockers/snapshotdocker/kritasnapshotdocker.json b/plugins/dockers/snapshotdocker/kritasnapshotdocker.json new file mode 100644 index 0000000000..c81539b4a0 --- /dev/null +++ b/plugins/dockers/snapshotdocker/kritasnapshotdocker.json @@ -0,0 +1,9 @@ +{ + "Id": "Krita Snapshot Docker plugin", + "Type": "Service", + "X-KDE-Library": "kritasnapshotdocker", + "X-KDE-ServiceTypes": [ + "Krita/Dock" + ], + "X-Krita-Version": "28" +}