17#include "ScreenshotDirectory.h"
21#include <QStandardPaths>
22#include <QTemporaryDir>
26ScreenshotDirectory::ScreenshotDirectory(QObject *parent)
30 if (qEnvironmentVariableIsSet(
"LOMIRI_TESTING")) {
32 tDir.setAutoRemove(
false);
33 screenshotsDir = tDir.path();
35 screenshotsDir = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation);
37 screenshotsDir.mkpath(QStringLiteral(
"Screenshots"));
38 screenshotsDir.cd(QStringLiteral(
"Screenshots"));
39 if (screenshotsDir.exists()) {
40 m_fileNamePrefix = screenshotsDir.absolutePath();
41 m_fileNamePrefix.append(
"/screenshot");
43 qWarning() <<
"ScreenshotDirectory: failed to create directory at:" << screenshotsDir.absolutePath();
47QString ScreenshotDirectory::makeFileName()
const
49 if (m_fileNamePrefix.isEmpty()) {
53 QString fileName(m_fileNamePrefix);
54 fileName.append(QDateTime::currentDateTime().toString(QStringLiteral(
"yyyyMMdd_hhmmsszzz")));
56 fileName.append(format());
60QString ScreenshotDirectory::format()
const
63 return QStringLiteral(
"png");