Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explain why saving a screenshot might fail #2012

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions src/utils/screenshotsaver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ bool ScreenshotSaver::saveToFilesystem(const QPixmap& capture,
{
QString completePath = FileNameHandler().properScreenshotPath(
path, ConfigHandler().setSaveAsFileExtension());
bool ok = capture.save(completePath);
QFile file{ completePath };
file.open(QIODevice::WriteOnly);
bool ok = capture.save(&file);
QString saveMessage = messagePrefix;
QString notificationPath = completePath;
if (!saveMessage.isEmpty()) {
Expand All @@ -103,6 +105,9 @@ bool ScreenshotSaver::saveToFilesystem(const QPixmap& capture,
m_id, QFileInfo(completePath).canonicalFilePath());
} else {
saveMessage += QObject::tr("Error trying to save as ") + completePath;
if (file.error() != QFile::NoError) {
saveMessage += ": " + file.errorString();
}
notificationPath = "";
}

Expand Down Expand Up @@ -171,7 +176,10 @@ bool ScreenshotSaver::saveToFilesystemGUI(const QPixmap& capture)
return ok;
}

ok = capture.save(savePath);
QFile file{ savePath };
file.open(QIODevice::WriteOnly);

ok = capture.save(&file);

if (ok) {
QString pathNoFile =
Expand All @@ -198,6 +206,11 @@ bool ScreenshotSaver::saveToFilesystemGUI(const QPixmap& capture)

} else {
QString msg = QObject::tr("Error trying to save as ") + savePath;

if (file.error() != QFile::NoError) {
msg += ": " + file.errorString();
}

QMessageBox saveErrBox(
QMessageBox::Warning, QObject::tr("Save Error"), msg);
saveErrBox.setWindowIcon(QIcon(":img/app/flameshot.svg"));
Expand Down