Write inside .cache folder in home, instead of just home
Back when testing !745, i was using `kdesrc-run` and this bug slipped through my fingers: It began to create folder named after the file inside the home (or in this case, kdesrc-run home) folder. This fixes that. Now the clipboard image files go correctly to `~/.cache/KDE/screenshots/` folder. Anyhow, my bad, should've done more print debugging.. 😓
This commit is contained in:
committed by
Tobias Fella
parent
93f7def532
commit
f2ec6e1d4c
@@ -33,13 +33,14 @@ QImage Clipboard::image() const
|
|||||||
|
|
||||||
QString Clipboard::saveImage(QString localPath) const
|
QString Clipboard::saveImage(QString localPath) const
|
||||||
{
|
{
|
||||||
if (!QDir().exists(QStringLiteral("%1/screenshots").arg(QStandardPaths::writableLocation(QStandardPaths::CacheLocation)))) {
|
QString imageDir(QStringLiteral("%1/screenshots").arg(QStandardPaths::writableLocation(QStandardPaths::CacheLocation)));
|
||||||
QDir().mkdir(QStringLiteral("%1/screenshots").arg(QStandardPaths::writableLocation(QStandardPaths::CacheLocation)));
|
|
||||||
|
if (!QDir().exists(imageDir)) {
|
||||||
|
QDir().mkdir(imageDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (localPath.isEmpty()) {
|
if (localPath.isEmpty()) {
|
||||||
localPath = QStringLiteral("file://%1/screenshots/%2.png")
|
localPath = QStringLiteral("file://%1/%2.png").arg(imageDir, QDateTime::currentDateTime().toString(QStringLiteral("yyyy-MM-dd-hh-mm-ss")));
|
||||||
.arg(QStandardPaths::writableLocation(QStandardPaths::CacheLocation),
|
|
||||||
QDateTime::currentDateTime().toString(QStringLiteral("yyyy-MM-dd-hh-mm-ss")));
|
|
||||||
}
|
}
|
||||||
QUrl url(localPath);
|
QUrl url(localPath);
|
||||||
if (!url.isLocalFile()) {
|
if (!url.isLocalFile()) {
|
||||||
@@ -51,14 +52,11 @@ QString Clipboard::saveImage(QString localPath) const
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
QDir dir;
|
if (image.save(url.toLocalFile())) {
|
||||||
if (!dir.exists(QFileInfo(url.fileName()).absoluteFilePath())) {
|
return localPath;
|
||||||
dir.mkpath(QFileInfo(url.fileName()).absoluteFilePath());
|
} else {
|
||||||
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
image.save(url.toLocalFile());
|
|
||||||
|
|
||||||
return localPath;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Clipboard::saveText(QString message)
|
void Clipboard::saveText(QString message)
|
||||||
|
|||||||
Reference in New Issue
Block a user