hrev50892 adds 1 changeset to branch 'master'
old head: a7359754615a412d841c9d34ea6974f7aae342fb
new head: b285b436e71b5146061140ad99034f32a4c1ab96
overview:
http://cgit.haiku-os.org/haiku/log/?qt=range&q=b285b436e71b+%5Ea7359754615a
----------------------------------------------------------------------------
b285b436e71b: Screenshot: better error handling on save
Show error messages when saving fails, to enmake sure the user is not
confused by thinking the file saved when the window doesn't close.
Signed-off-by: Adrien Destugues <pulkomandy@xxxxxxxxxxxxx>
Fixes #12945
[ Gabriel Maia <gbl08ma@xxxxxxxxx> ]
----------------------------------------------------------------------------
Revision: hrev50892
Commit: b285b436e71b5146061140ad99034f32a4c1ab96
URL: http://cgit.haiku-os.org/haiku/commit/?id=b285b436e71b
Author: Gabriel Maia <gbl08ma@xxxxxxxxx>
Date: Sun Jan 22 00:32:52 2017 UTC
Committer: Adrien Destugues <pulkomandy@xxxxxxxxxxxxx>
Commit-Date: Sun Jan 22 08:29:18 2017 UTC
Ticket: https://dev.haiku-os.org/ticket/12945
----------------------------------------------------------------------------
2 files changed, 33 insertions(+), 4 deletions(-)
src/apps/screenshot/ScreenshotWindow.cpp | 36 ++++++++++++++++++++++++----
src/apps/screenshot/ScreenshotWindow.h | 1 +
----------------------------------------------------------------------------
diff --git a/src/apps/screenshot/ScreenshotWindow.cpp
b/src/apps/screenshot/ScreenshotWindow.cpp
index 58a6df3..ecfcd4b 100644
--- a/src/apps/screenshot/ScreenshotWindow.cpp
+++ b/src/apps/screenshot/ScreenshotWindow.cpp
@@ -608,6 +608,21 @@ ScreenshotWindow::_SetupTranslatorMenu()
}
+void
+ScreenshotWindow::_DisplaySaveError(BString _message) {
+ BString alertText;
+ alertText.SetToFormat(B_TRANSLATE("Error saving \"%s\":\n\t%s"),
+ fNameControl->Text(), _message.String());
+
+ BAlert* alert = new BAlert(B_TRANSLATE("Failed to save screenshot"),
+ alertText.String(), B_TRANSLATE("OK"),
+ NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT);
+
+ alert->SetShortcut(0, B_ESCAPE);
+ alert->Go();
+}
+
+
status_t
ScreenshotWindow::_SaveScreenshot()
{
@@ -626,13 +641,19 @@ ScreenshotWindow::_SaveScreenshot()
// necessary, for example, when the user selects the Artwork folder from
// the list of predefined folders.
if (!directoryEntry.Exists()) {
- if (create_directory(path.Path(), 0755) != B_OK) {
- return B_ERROR;
+ status_t directoryCreateStatus = create_directory(path.Path(),
0755);
+ if (directoryCreateStatus != B_OK) {
+ _DisplaySaveError(strerror(directoryCreateStatus));
+
+ return directoryCreateStatus;
}
} else if (!directoryEntry.IsDirectory()) {
// the entry exists but is not a directory.
// not much we can do
- return B_ERROR;
+ _DisplaySaveError(
+ B_TRANSLATE("The destination path exists but is not a
folder."));
+
+ return B_NOT_A_DIRECTORY;
}
path.Append(fNameControl->Text());
@@ -655,7 +676,14 @@ ScreenshotWindow::_SaveScreenshot()
return B_CANCELED;
}
- return fUtility.Save(fScreenshot, path.Path(), fImageFileType);
+ status_t saveStatus = fUtility.Save(fScreenshot,
+ path.Path(), fImageFileType);
+
+ if (saveStatus != B_OK) {
+ _DisplaySaveError(strerror(saveStatus));
+ return saveStatus;
+ }
+ return B_OK;
}
diff --git a/src/apps/screenshot/ScreenshotWindow.h
b/src/apps/screenshot/ScreenshotWindow.h
index cdb0148..0db27ff 100644
--- a/src/apps/screenshot/ScreenshotWindow.h
+++ b/src/apps/screenshot/ScreenshotWindow.h
@@ -50,6 +50,7 @@ private:
uint32
shortcutKey = 0);
void _UpdateFilenameSelection();
void _SetupTranslatorMenu();
+ void _DisplaySaveError(BString
_message);
status_t _SaveScreenshot();
void _ShowSettings(bool activate);
BString _FindValidFileName(const char*
name);