@@ -1,5 +1,5 @@
2− * Copyright (C) 2014 Canonical, Ltd.
2+ * Copyright (C) 2014-2015 Canonical, Ltd.
4 * This program is free software; you can redistribute it and/or modify
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
5 * it under the terms of the GNU General Public License as published by
@@ -28,18 +28,17 @@
29#include <QDebug>
29#include <QDebug>
31−void saveScreenshot(QImage screenshot, QString filename, QString format, int quality)
31+void saveScreenshot(QImage screenshot, const QString &filename, const QString &format, int quality)
33 if (!screenshot.save(filename, format.toLatin1().data(), quality))
33 if (!screenshot.save(filename, format.toLatin1().data(), quality))
34 qWarning() << "ScreenShotter: failed to save snapshot!";
34 qWarning() << "ScreenShotter: failed to save snapshot!";
37ScreenGrabber::ScreenGrabber(QObject *parent)
37ScreenGrabber::ScreenGrabber(QObject *parent)
38− : QObject(parent),
38+ : QObject(parent)
41− QDir screenshotsDir(QStandardPaths::displayName(QStandardPaths::PicturesLocation));
40+ QDir screenshotsDir(QStandardPaths::writableLocation(QStandardPaths::PicturesLocation));
42− screenshotsDir.mkdir("Screenshots");
41+ screenshotsDir.mkpath("Screenshots");
43 screenshotsDir.cd("Screenshots");
42 screenshotsDir.cd("Screenshots");
44 if (screenshotsDir.exists())
43 if (screenshotsDir.exists())
@@ -78,7 +77,7 @@ void ScreenGrabber::captureAndSave()
78 QtConcurrent::run(saveScreenshot, screenshot, makeFileName(), getFormat(), screenshotQuality);
77 QtConcurrent::run(saveScreenshot, screenshot, makeFileName(), getFormat(), screenshotQuality);
81−QString ScreenGrabber::makeFileName()
80+QString ScreenGrabber::makeFileName() const
83 QString fileName(fileNamePrefix);
82 QString fileName(fileNamePrefix);
84 fileName.append(QDateTime::currentDateTime().toString("yyyyMMdd_hhmmsszzz"));
83 fileName.append(QDateTime::currentDateTime().toString("yyyyMMdd_hhmmsszzz"));
@@ -87,7 +86,7 @@ QString ScreenGrabber::makeFileName()
87 return fileName;
86 return fileName;
90−QString ScreenGrabber::getFormat()
89+QString ScreenGrabber::getFormat() const
92 //TODO: This should be configurable (perhaps through gsettings?)
91 //TODO: This should be configurable (perhaps through gsettings?)
93 return "png";
92 return "png";