]> 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 a23bbddf4540822f6815e5b471ddf917b8f7a1a0..b84c6f310e760e7c6531528a0744d91372d95acd 100644 (file)
@@ -444,11 +444,18 @@ GuiView::GuiView(int id)
        setAttribute(Qt::WA_DeleteOnClose, true);
 
 #if (!defined(Q_WS_WIN) && !defined(Q_WS_MACX))
+       // QIcon::fromTheme was introduced in Qt 4.6
+#if (QT_VERSION >= 0x040600)
        // assign an icon to main form. We do not do it under Qt/Win or Qt/Mac,
-       // since the icon is provided in the application bundle.
+       // since the icon is provided in the application bundle. We use a themed
+       // version when available and use the bundled one as fallback.
+       setWindowIcon(QIcon::fromTheme("lyx", getPixmap("images/", "lyx", "png")));
+#else
        setWindowIcon(getPixmap("images/", "lyx", "png"));
 #endif
 
+#endif
+
 #if (QT_VERSION >= 0x040300)
        // use tabbed dock area for multiple docks
        // (such as "source" and "messages")
@@ -1868,13 +1875,9 @@ bool GuiView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
                break;
 
        case LFUN_FILE_INSERT_PLAINTEXT:
-       case LFUN_FILE_INSERT_PLAINTEXT_PARA: {
-               if (BufferView const * bv = documentBufferView())
-                       enable = bv->cursor().inTexted();
-               else
-                       enable = false;
+       case LFUN_FILE_INSERT_PLAINTEXT_PARA:
+               enable = documentBufferView() && documentBufferView()->cursor().inTexted();
                break;
-       }
 
        default:
                return false;
@@ -2277,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);