Fix Pictures folder missing sometimes and saving failing because of it
This commit is contained in:
parent
76bca57047
commit
96f4cf7305
@ -8,7 +8,14 @@
|
|||||||
#include <formatter.hpp>
|
#include <formatter.hpp>
|
||||||
#include <settings.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));
|
QDir configDir(QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation));
|
||||||
configDir.mkpath("KShare/uploaders");
|
configDir.mkpath("KShare/uploaders");
|
||||||
configDir.cd("KShare/uploaders");
|
configDir.cd("KShare/uploaders");
|
||||||
@ -49,8 +56,7 @@ void UploaderSingleton::upload(QPixmap *pixmap) {
|
|||||||
if (settings::settings().contains("fileFormat")) {
|
if (settings::settings().contains("fileFormat")) {
|
||||||
QString format = settings::settings().value("fileFormat").toString();
|
QString format = settings::settings().value("fileFormat").toString();
|
||||||
if (!format.isEmpty()) {
|
if (!format.isEmpty()) {
|
||||||
pixmap->save(QDir(QStandardPaths::writableLocation(QStandardPaths::PicturesLocation)).absoluteFilePath(formatter::format(format) + ".png"),
|
pixmap->save(saveDir.absoluteFilePath(formatter::format(format) + ".png"), "PNG");
|
||||||
"PNG");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
uploaders.value(uploader)->doUpload(pixmap);
|
uploaders.value(uploader)->doUpload(pixmap);
|
||||||
|
Loading…
Reference in New Issue
Block a user