removed loop that occured when screenshot failed to save.

This commit is contained in:
Jeremy Borgman
2021-02-25 10:32:15 -06:00
parent d9b9049736
commit acb9a08e2c
2 changed files with 49 additions and 54 deletions

2
.gitignore vendored
View File

@@ -1,7 +1,7 @@
# common # common
.idea .idea
.cache
# C++ objects and libs # C++ objects and libs
*.slo *.slo

View File

@@ -104,14 +104,13 @@ bool ScreenshotSaver::saveToFilesystem(const QPixmap& capture,
bool ScreenshotSaver::saveToFilesystemGUI(const QPixmap& capture) bool ScreenshotSaver::saveToFilesystemGUI(const QPixmap& capture)
{ {
bool ok = false; bool ok = false;
while (!ok) {
ConfigHandler config; ConfigHandler config;
QString savePath = FileNameHandler().absoluteSavePath(); QString savePath = FileNameHandler().absoluteSavePath();
#if defined(Q_OS_MACOS) #if defined(Q_OS_MACOS)
for (QWidget* widget : qApp->topLevelWidgets()) { for (QWidget* widget : qApp->topLevelWidgets()) {
QString className(widget->metaObject()->className()); QString className(widget->metaObject()->className());
if (0 == className.compare( if (0 ==
CaptureWidget::staticMetaObject.className())) { className.compare(CaptureWidget::staticMetaObject.className())) {
widget->showNormal(); widget->showNormal();
widget->hide(); widget->hide();
break; break;
@@ -127,10 +126,6 @@ bool ScreenshotSaver::saveToFilesystemGUI(const QPixmap& capture)
"file (*.bmp);;JPEG file (*.jpg)")); "file (*.bmp);;JPEG file (*.jpg)"));
} }
if (savePath.isNull()) {
break;
}
if (!savePath.endsWith(QLatin1String(".png"), Qt::CaseInsensitive) && if (!savePath.endsWith(QLatin1String(".png"), Qt::CaseInsensitive) &&
!savePath.endsWith(QLatin1String(".bmp"), Qt::CaseInsensitive) && !savePath.endsWith(QLatin1String(".bmp"), Qt::CaseInsensitive) &&
!savePath.endsWith(QLatin1String(".jpg"), Qt::CaseInsensitive)) { !savePath.endsWith(QLatin1String(".jpg"), Qt::CaseInsensitive)) {
@@ -146,8 +141,8 @@ bool ScreenshotSaver::saveToFilesystemGUI(const QPixmap& capture)
QString msg = QObject::tr("Capture saved as ") + savePath; QString msg = QObject::tr("Capture saved as ") + savePath;
if (config.copyPathAfterSaveEnabled()) { if (config.copyPathAfterSaveEnabled()) {
QApplication::clipboard()->setText(savePath); QApplication::clipboard()->setText(savePath);
msg = QObject::tr( msg =
"Capture is saved and copied to the clipboard as ") + QObject::tr("Capture is saved and copied to the clipboard as ") +
savePath; savePath;
} }
SystemNotification().sendMessage(msg, savePath); SystemNotification().sendMessage(msg, savePath);
@@ -160,6 +155,6 @@ bool ScreenshotSaver::saveToFilesystemGUI(const QPixmap& capture)
saveErrBox.setWindowIcon(QIcon(":img/app/flameshot.svg")); saveErrBox.setWindowIcon(QIcon(":img/app/flameshot.svg"));
saveErrBox.exec(); saveErrBox.exec();
} }
}
return ok; return ok;
} }