reformatted to Mozilla code style

This commit is contained in:
Jeremy Borgman
2020-09-04 20:16:33 -05:00
committed by borgmanJeremy
parent c0e2e48db4
commit c8d15205be
176 changed files with 12695 additions and 11269 deletions

View File

@@ -16,82 +16,84 @@
// along with Flameshot. If not, see <http://www.gnu.org/licenses/>.
#include "screenshotsaver.h"
#include "src/utils/systemnotification.h"
#include "src/utils/filenamehandler.h"
#include "src/utils/confighandler.h"
#include <QClipboard>
#include "src/utils/filenamehandler.h"
#include "src/utils/systemnotification.h"
#include <QApplication>
#include <QMessageBox>
#include <QClipboard>
#include <QFileDialog>
#include <QImageWriter>
#include <QMessageBox>
ScreenshotSaver::ScreenshotSaver() {
}
ScreenshotSaver::ScreenshotSaver() {}
void ScreenshotSaver::saveToClipboard(const QPixmap &capture) {
SystemNotification().sendMessage(
QObject::tr("Capture saved to clipboard"));
QApplication::clipboard()->setPixmap(capture);
}
bool ScreenshotSaver::saveToFilesystem(const QPixmap &capture,
const QString &path)
void
ScreenshotSaver::saveToClipboard(const QPixmap& capture)
{
QString completePath = FileNameHandler().generateAbsolutePath(path);
completePath += QLatin1String(".png");
bool ok = capture.save(completePath);
QString saveMessage;
QString notificationPath = completePath;
SystemNotification().sendMessage(QObject::tr("Capture saved to clipboard"));
QApplication::clipboard()->setPixmap(capture);
}
bool
ScreenshotSaver::saveToFilesystem(const QPixmap& capture, const QString& path)
{
QString completePath = FileNameHandler().generateAbsolutePath(path);
completePath += QLatin1String(".png");
bool ok = capture.save(completePath);
QString saveMessage;
QString notificationPath = completePath;
if (ok) {
ConfigHandler().setSavePath(path);
saveMessage = QObject::tr("Capture saved as ") + completePath;
} else {
saveMessage = QObject::tr("Error trying to save as ") + completePath;
notificationPath = "";
}
SystemNotification().sendMessage(saveMessage, notificationPath);
return ok;
}
bool
ScreenshotSaver::saveToFilesystemGUI(const QPixmap& capture)
{
bool ok = false;
while (!ok) {
QString savePath = QFileDialog::getSaveFileName(
nullptr,
QString(),
FileNameHandler().absoluteSavePath() + ".png",
QLatin1String("Portable Network Graphic file (PNG) (*.png);;BMP file "
"(*.bmp);;JPEG file (*.jpg)"));
if (savePath.isNull()) {
break;
}
if (!savePath.endsWith(QLatin1String(".png"), Qt::CaseInsensitive) &&
!savePath.endsWith(QLatin1String(".bmp"), Qt::CaseInsensitive) &&
!savePath.endsWith(QLatin1String(".jpg"), Qt::CaseInsensitive)) {
savePath += QLatin1String(".png");
}
ok = capture.save(savePath);
if (ok) {
ConfigHandler().setSavePath(path);
saveMessage = QObject::tr("Capture saved as ") + completePath;
QString pathNoFile =
savePath.left(savePath.lastIndexOf(QLatin1String("/")));
ConfigHandler().setSavePath(pathNoFile);
QString msg = QObject::tr("Capture saved as ") + savePath;
SystemNotification().sendMessage(msg, savePath);
} else {
saveMessage = QObject::tr("Error trying to save as ") + completePath;
notificationPath = "";
QString msg = QObject::tr("Error trying to save as ") + savePath;
QMessageBox saveErrBox(
QMessageBox::Warning, QObject::tr("Save Error"), msg);
saveErrBox.setWindowIcon(QIcon(":img/app/flameshot.svg"));
saveErrBox.exec();
}
SystemNotification().sendMessage(saveMessage, notificationPath);
return ok;
}
bool ScreenshotSaver::saveToFilesystemGUI(const QPixmap &capture) {
bool ok = false;
while (!ok) {
QString savePath = QFileDialog::getSaveFileName(
nullptr,
QString(),
FileNameHandler().absoluteSavePath() + ".png",
QLatin1String("Portable Network Graphic file (PNG) (*.png);;BMP file (*.bmp);;JPEG file (*.jpg)"));
if (savePath.isNull()) {
break;
}
if (!savePath.endsWith(QLatin1String(".png"), Qt::CaseInsensitive) &&
!savePath.endsWith(QLatin1String(".bmp"), Qt::CaseInsensitive) &&
!savePath.endsWith(QLatin1String(".jpg"), Qt::CaseInsensitive)) {
savePath += QLatin1String(".png");
}
ok = capture.save(savePath);
if (ok) {
QString pathNoFile = savePath.left(savePath.lastIndexOf(QLatin1String("/")));
ConfigHandler().setSavePath(pathNoFile);
QString msg = QObject::tr("Capture saved as ") + savePath;
SystemNotification().sendMessage(msg, savePath);
} else {
QString msg = QObject::tr("Error trying to save as ") + savePath;
QMessageBox saveErrBox(
QMessageBox::Warning,
QObject::tr("Save Error"),
msg);
saveErrBox.setWindowIcon(QIcon(":img/app/flameshot.svg"));
saveErrBox.exec();
}
}
return ok;
}
return ok;
}