Browse Source

Fix Pictures folder missing sometimes and saving failing because of it

tags/v5.0.0
ArsenArsen 5 years ago
parent
commit
96f4cf7305
  1. 12
      uploaders/uploadersingleton.cpp

12
uploaders/uploadersingleton.cpp

@ -8,7 +8,14 @@
#include <formatter.hpp>
#include <settings.hpp>
UploaderSingleton::UploaderSingleton() : QObject() {
UploaderSingleton::UploaderSingleton()
: QObject(), saveDir(QStandardPaths::writableLocation(QStandardPaths::PicturesLocation)) {
if (QStandardPaths::writableLocation(QStandardPaths::PicturesLocation).isEmpty()) {
qFatal() << "Cannot determine location for pictures";
}
if (!saveDir.exists()) {
saveDir.mkpath(QStandardPaths::writableLocation(QStandardPaths::PicturesLocation));
}
QDir configDir(QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation));
configDir.mkpath("KShare/uploaders");
configDir.cd("KShare/uploaders");
@ -49,8 +56,7 @@ void UploaderSingleton::upload(QPixmap *pixmap) {
if (settings::settings().contains("fileFormat")) {
QString format = settings::settings().value("fileFormat").toString();
if (!format.isEmpty()) {
pixmap->save(QDir(QStandardPaths::writableLocation(QStandardPaths::PicturesLocation)).absoluteFilePath(formatter::format(format) + ".png"),
"PNG");
pixmap->save(saveDir.absoluteFilePath(formatter::format(format) + ".png"), "PNG");
}
}
uploaders.value(uploader)->doUpload(pixmap);

Loading…
Cancel
Save