Commit b55dff64 authored by Tusooa Zhu's avatar Tusooa Zhu

Add snapshot docker ui

parent 2153f3ba
......@@ -33,3 +33,4 @@ if(NOT APPLE AND HAVE_QT_QUICK)
endif()
add_subdirectory(logdocker)
add_subdirectory(snapshotdocker)
\ No newline at end of file
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
/*
* Copyright (c) 2019 Tusooa Zhu <tusooa@vista.aero>
*
* 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 <QMap>
#include <QList>
#include <KisDocument.h>
struct KisSnapshotModel::Private
{
Private();
QMap<KisCanvas2 *, QList<KisDocument *> > canvasDocMap;
QPointer<KisCanvas2> 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<KisCanvas2> canvas)
{
m_d->curCanvas = canvas;
}
/*
* Copyright (c) 2019 Tusooa Zhu <tusooa@vista.aero>
*
* 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 <QAbstractListModel>
#include <QScopedPointer>
#include <QPointer>
#include <kis_canvas2.h>
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<KisCanvas2> canvas);
private:
struct Private;
QScopedPointer<Private> m_d;
};
#endif // KIS_SNAPSHOT_MODEL_H_
/*
* Copyright (c) 2019 Tusooa Zhu <tusooa@vista.aero>
*
* 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 <QWidget>
#include <QListView>
#include <QToolButton>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include "KisSnapshotModel.h"
#include <kis_canvas2.h>
#include <kis_icon_utils.h>
struct SnapshotDocker::Private
{
Private();
QPointer<KisSnapshotModel> model;
QPointer<QListView> view;
QPointer<KisCanvas2> canvas;
QPointer<QToolButton> bnAdd;
QPointer<QToolButton> 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<KisCanvas2 *>(canvas);
if (c) {
if (m_d->canvas == c) {
return;
}
}
m_d->canvas = c;
}
void SnapshotDocker::unsetCanvas()
{
setCanvas(0);
}
#include "SnapshotDocker.moc"
/* This file is part of the KDE project
* Copyright (C) 2010 Matus Talcik <matus.talcik@gmail.com>
*
* 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 <QDockWidget>
#include <QScopedPointer>
#include <KoCanvasObserverBase.h>
#include <klocalizedstring.h>
#include <KoShapeController.h>
#include <KoCanvasBase.h>
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<Private> m_d;
};
#endif
/* This file is part of the KDE project
* Copyright (C) 2010 Matus Talcik <matus.talcik@gmail.com>
*
* 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 <kpluginfactory.h>
#include <klocalizedstring.h>
#include <KoDockFactoryBase.h>
#include <KoDockRegistry.h>
#include "SnapshotDocker.h"
K_PLUGIN_FACTORY_WITH_JSON(SnapshotPluginFactory, "kritasnapshotdocker.json", registerPlugin<SnapshotPlugin>();)
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"
/* This file is part of the KDE project
* Copyright (C) 2010 Matus Talcik <matus.talcik@gmail.com>
*
* 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 <QObject>
#include <QVariant>
class SnapshotPlugin : public QObject
{
Q_OBJECT
public:
SnapshotPlugin(QObject *parent, const QVariantList &);
~SnapshotPlugin() override;
};
#endif
{
"Id": "Krita Snapshot Docker plugin",
"Type": "Service",
"X-KDE-Library": "kritasnapshotdocker",
"X-KDE-ServiceTypes": [
"Krita/Dock"
],
"X-Krita-Version": "28"
}
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