]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiView.cpp
The View->Source pane resets the format every time you click into
[lyx.git] / src / frontends / qt4 / GuiView.cpp
index 4ac5d6b94a28bb412a2e48722279c5c3358d94e6..b84c6f310e760e7c6531528a0744d91372d95acd 100644 (file)
@@ -2280,9 +2280,27 @@ bool GuiView::renameBuffer(Buffer & b, docstring const & newname)
        }
 
        // fname is now the new Buffer location.
+
+       // if there is already a Buffer open with this name, we do not want
+       // to have another one.
+       if (theBufferList().exists(fname)) {
+               docstring const text = 
+                       bformat(_("The file\n%1$s\nis already open in your current session.\n"
+                           "Please close it before attempting to overwrite it.\n"
+                           "Do you want to choose a new filename?"),
+                               from_utf8(fname.absFileName()));
+               int const ret = Alert::prompt(_("Chosen File Already Open"),
+                       text, 0, 1, _("&Rename"), _("&Cancel"));
+               switch (ret) {
+               case 0: return renameBuffer(b, docstring());
+               case 1: return false;
+               }
+               //return false;
+       }
+       
        if (FileName(fname).exists()) {
                docstring const file = makeDisplayPath(fname.absFileName(), 30);
-               docstring text = bformat(_("The document %1$s already "
+               docstring const text = bformat(_("The document %1$s already "
                                           "exists.\n\nDo you want to "
                                           "overwrite that document?"),
                                         file);