File indexing completed on 2024-05-05 17:33:57
0001 /* 0002 * SPDX-FileCopyrightText: 2008-2012 Matthias Fuchs <mat69@gmx.net> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "comicsaver.h" 0008 #include "comicdata.h" 0009 #include "comicinfo.h" 0010 0011 #include <QDebug> 0012 #include <QFileDialog> 0013 #include <QTemporaryFile> 0014 0015 #include <KIO/Job> 0016 0017 ComicSaver::ComicSaver(SavingDir *savingDir) 0018 : mSavingDir(savingDir) 0019 { 0020 } 0021 0022 bool ComicSaver::save(const ComicData &comic) 0023 { 0024 const QString title = comic.title(); 0025 0026 const QString name = title + QLatin1String(" - ") + comic.current() + QLatin1String(".png"); 0027 QUrl destUrl = QUrl::fromLocalFile(mSavingDir->getDir() + QLatin1Char('/') + name); 0028 0029 destUrl = QFileDialog::getSaveFileUrl(nullptr, QString(), destUrl, QStringLiteral("*.png")); 0030 0031 if (!destUrl.isValid()) { 0032 return false; 0033 } 0034 0035 mSavingDir->setDir(destUrl.path()); 0036 comic.image().save(destUrl.toLocalFile(), "PNG"); 0037 0038 return true; 0039 }