Changeset View
Changeset View
Standalone View
Standalone View
src/ExportManager.cpp
Show First 20 Lines • Show All 388 Lines • ▼ Show 20 Line(s) | 381 | { | |||
---|---|---|---|---|---|
389 | if (!mTempDir) { | 389 | if (!mTempDir) { | ||
390 | mTempDir = new QTemporaryDir(QDir::tempPath() + QDir::separator() + QStringLiteral("Spectacle.XXXXXX")); | 390 | mTempDir = new QTemporaryDir(QDir::tempPath() + QDir::separator() + QStringLiteral("Spectacle.XXXXXX")); | ||
391 | } | 391 | } | ||
392 | if (mTempDir && mTempDir->isValid()) { | 392 | if (mTempDir && mTempDir->isValid()) { | ||
393 | // create the temporary file itself with normal file name and also unique one for this session | 393 | // create the temporary file itself with normal file name and also unique one for this session | ||
394 | // supports the use-case of creating multiple screenshots in a row | 394 | // supports the use-case of creating multiple screenshots in a row | ||
395 | // and exporting them to the same destination e.g. via clipboard, | 395 | // and exporting them to the same destination e.g. via clipboard, | ||
396 | // where the temp file name is used as filename suggestion | 396 | // where the temp file name is used as filename suggestion | ||
397 | const QString baseFileName = mTempDir->path() + QDir::separator() + makeAutosaveFilename(); | 397 | const QString baseFileName = mTempDir->path() + QLatin1Char('/') + | ||
398 | QUrl::fromLocalFile(makeAutosaveFilename()).fileName(); | ||||
398 | 399 | | |||
399 | QString mimetype = makeSaveMimetype(QUrl(baseFileName)); | 400 | QString mimetype = makeSaveMimetype(QUrl(baseFileName)); | ||
400 | const QString fileName = autoIncrementFilename(baseFileName, mimetype, | 401 | const QString fileName = autoIncrementFilename(baseFileName, mimetype, | ||
401 | &ExportManager::isTempFileAlreadyUsed); | 402 | &ExportManager::isTempFileAlreadyUsed); | ||
402 | QFile tmpFile(fileName); | 403 | QFile tmpFile(fileName); | ||
ngraham: Use `QLatin1Char("/")` instead of `QDir::separator()` (Qt automatically transforms a slash into… | |||||
I did use QDir::separator() because it was used before for this and is used for constructing mTempDir at the beginning of the function (Line 395). brainpower: I did use `QDir::separator()` because it was used before for this and is used for constructing… | |||||
Probably. That's unrelated to this patch though, and should be fixed in another one. ngraham: Probably. That's unrelated to this patch though, and should be fixed in another one. | |||||
403 | if (tmpFile.open(QFile::WriteOnly)) { | 404 | if (tmpFile.open(QFile::WriteOnly)) { | ||
404 | if(writeImage(&tmpFile, mimetype.toLatin1())) { | 405 | if(writeImage(&tmpFile, mimetype.toLatin1())) { | ||
405 | mTempFile = QUrl::fromLocalFile(tmpFile.fileName()); | 406 | mTempFile = QUrl::fromLocalFile(tmpFile.fileName()); | ||
ngraham: Use consistent indentation: 4 chars of whitespace, not 2 | |||||
brainpower: ok, will fix. | |||||
406 | // try to make sure 3rd-party which gets the url of the temporary file e.g. on export | 407 | // try to make sure 3rd-party which gets the url of the temporary file e.g. on export | ||
407 | // properly treats this as readonly, also hide from other users | 408 | // properly treats this as readonly, also hide from other users | ||
408 | tmpFile.setPermissions(QFile::ReadUser); | 409 | tmpFile.setPermissions(QFile::ReadUser); | ||
409 | return mTempFile; | 410 | return mTempFile; | ||
410 | } | 411 | } | ||
411 | } | 412 | } | ||
412 | } | 413 | } | ||
413 | 414 | | |||
▲ Show 20 Lines • Show All 184 Lines • Show Last 20 Lines |
Use QLatin1Char("/") instead of QDir::separator() (Qt automatically transforms a slash into the correct platform-specific separator character)