commit 40cfede2bff5854254e7067155e053cd88231cdb
Author: Guillaume MM <g...@lyx.org>
Date:   Sun Jun 11 06:01:04 2017 +0200

    Clearer message when about to discard an unsaved document entirely.
---
 src/frontends/qt4/GuiView.cpp |   27 ++++++++++++++++++++-------
 1 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp
index d02b9be..f859338 100644
--- a/src/frontends/qt4/GuiView.cpp
+++ b/src/frontends/qt4/GuiView.cpp
@@ -2979,11 +2979,17 @@ bool GuiView::saveBufferIfNeeded(Buffer & buf, bool 
hiding)
        setBuffer(&buf);
 
        docstring file;
+       bool exists;
        // FIXME: Unicode?
-       if (buf.isUnnamed())
+       if (buf.isUnnamed()) {
                file = from_utf8(buf.fileName().onlyFileName());
-       else
-               file = buf.fileName().displayName(30);
+               exists = false;
+       } else {
+               FileName filename = buf.fileName();
+               filename.refresh();
+               file = filename.displayName(30);
+               exists = filename.exists();
+       }
 
        // Bring this window to top before asking questions.
        raise();
@@ -2999,10 +3005,17 @@ bool GuiView::saveBufferIfNeeded(Buffer & buf, bool 
hiding)
                if (ret == 1)
                        ++ret;
        } else {
-               docstring const text = bformat(_("The document %1$s has unsaved 
changes."
-                       "\n\nDo you want to save the document or discard the 
changes?"), file);
-               ret = Alert::prompt(_("Save changed document?"),
-                       text, 0, 2, _("&Save"), _("&Discard"), _("&Cancel"));
+               docstring const text = exists ?
+                       bformat(_("The document %1$s has unsaved changes."
+                                 "\n\nDo you want to save the document or "
+                                 "discard the changes?"), file) :
+                       bformat(_("The document %1$s has not been saved yet."
+                                 "\n\nDo you want to save the document or "
+                                 "discard it entirely?"), file);
+               docstring const title = exists ?
+                       _("Save changed document?") : _("Save document?");
+               ret = Alert::prompt(title, text, 0, 2,
+                                   _("&Save"), _("&Discard"), _("&Cancel"));
        }
 
        switch (ret) {

Reply via email to