diff --git a/libs/ui/tool/KisToolChangesTracker.cpp b/libs/ui/tool/KisToolChangesTracker.cpp index b740644148..2ea8dd0997 100644 --- a/libs/ui/tool/KisToolChangesTracker.cpp +++ b/libs/ui/tool/KisToolChangesTracker.cpp @@ -1,46 +1,64 @@ +/* + * Copyright (c) 2018 Dmitry Kazakov + * + * 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 "KisToolChangesTracker.h" #include "kis_global.h" #include struct KisToolChangesTracker::Private { QList undoStack; }; KisToolChangesTracker::KisToolChangesTracker() : m_d(new Private) { } KisToolChangesTracker::~KisToolChangesTracker() { } void KisToolChangesTracker::commitConfig(KisToolChangesTrackerDataSP state) { m_d->undoStack.append(state); } void KisToolChangesTracker::requestUndo() { if (m_d->undoStack.size() > 1) { m_d->undoStack.removeLast(); emit sigConfigChanged(m_d->undoStack.last()); } } KisToolChangesTrackerDataSP KisToolChangesTracker::lastState() const { return !m_d->undoStack.isEmpty() ? m_d->undoStack.last() : 0; } void KisToolChangesTracker::reset() { m_d->undoStack.clear(); } bool KisToolChangesTracker::isEmpty() const { return m_d->undoStack.isEmpty(); } diff --git a/libs/ui/tool/KisToolChangesTracker.h b/libs/ui/tool/KisToolChangesTracker.h index e81c568512..3d4fb5ac5a 100644 --- a/libs/ui/tool/KisToolChangesTracker.h +++ b/libs/ui/tool/KisToolChangesTracker.h @@ -1,31 +1,49 @@ +/* + * Copyright (c) 2018 Dmitry Kazakov + * + * 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 KISTOOLCHANGESTRACKER_H #define KISTOOLCHANGESTRACKER_H #include "kritaui_export.h" #include #include "KisToolChangesTrackerData.h" class KRITAUI_EXPORT KisToolChangesTracker :public QObject { Q_OBJECT public: KisToolChangesTracker(); ~KisToolChangesTracker(); void commitConfig(KisToolChangesTrackerDataSP state); void requestUndo(); KisToolChangesTrackerDataSP lastState() const; void reset(); bool isEmpty() const; Q_SIGNALS: void sigConfigChanged(KisToolChangesTrackerDataSP state); private: struct Private; const QScopedPointer m_d; }; #endif // KISTOOLCHANGESTRACKER_H diff --git a/libs/ui/tool/KisToolChangesTrackerData.cpp b/libs/ui/tool/KisToolChangesTrackerData.cpp index 3cce59c497..f0c3fc51e8 100644 --- a/libs/ui/tool/KisToolChangesTrackerData.cpp +++ b/libs/ui/tool/KisToolChangesTrackerData.cpp @@ -1,18 +1,36 @@ +/* + * Copyright (c) 2018 Dmitry Kazakov + * + * 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 "KisToolChangesTrackerData.h" struct KisToolChangesTrackerDataSPRegistrar { KisToolChangesTrackerDataSPRegistrar() { qRegisterMetaType("KisToolChangesTrackerDataSP"); } }; static KisToolChangesTrackerDataSPRegistrar __registrar; KisToolChangesTrackerData::~KisToolChangesTrackerData() { } KisToolChangesTrackerData *KisToolChangesTrackerData::clone() const { return new KisToolChangesTrackerData(*this); } diff --git a/libs/ui/tool/KisToolChangesTrackerData.h b/libs/ui/tool/KisToolChangesTrackerData.h index 6f879a91b5..cfcb7d866d 100644 --- a/libs/ui/tool/KisToolChangesTrackerData.h +++ b/libs/ui/tool/KisToolChangesTrackerData.h @@ -1,19 +1,37 @@ +/* + * Copyright (c) 2018 Dmitry Kazakov + * + * 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 KISTOOLCHANGESTRACKERDATA_H #define KISTOOLCHANGESTRACKERDATA_H #include #include "kritaui_export.h" #include class KRITAUI_EXPORT KisToolChangesTrackerData { public: virtual ~KisToolChangesTrackerData(); virtual KisToolChangesTrackerData* clone() const; }; typedef QSharedPointer KisToolChangesTrackerDataSP; Q_DECLARE_METATYPE(KisToolChangesTrackerDataSP) #endif // KISTOOLCHANGESTRACKERDATA_H