1 /* 2 Drawpile - a collaborative drawing program. 3 4 Copyright (C) 2018 Calle Laakkonen 5 6 Drawpile is free software: you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation, either version 3 of the License, or 9 (at your option) any later version. 10 11 Drawpile is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with Drawpile. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 #ifndef CANVASSAVERRUNNABLE_H 20 #define CANVASSAVERRUNNABLE_H 21 22 #include <QObject> 23 #include <QRunnable> 24 25 namespace paintcore { 26 class LayerStack; 27 } 28 29 namespace canvas { 30 31 class CanvasModel; 32 33 /** 34 * @brief A runnable for saving a canvas in a background thread 35 * 36 * When constructed, a copy of the layerstack is made. 37 */ 38 class CanvasSaverRunnable : public QObject, public QRunnable 39 { 40 Q_OBJECT 41 public: 42 CanvasSaverRunnable(const CanvasModel *canvas, const QString &filename, QObject *parent = nullptr); 43 44 void run() override; 45 46 signals: 47 /** 48 * @brief Emitted once the file has been saved 49 * @param error the error message (blank string if no error occurred) 50 */ 51 void saveComplete(const QString &error); 52 53 private: 54 paintcore::LayerStack *m_layerstack; 55 QString m_filename; 56 }; 57 58 } 59 60 #endif 61