]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiView.cpp
New LFUN buffer-external-modification-clear
[lyx.git] / src / frontends / qt4 / GuiView.cpp
index 2c481245680727876bc3d2c5f4171cec0a3608fb..e2e6555ca61b3669daac8d754941489aca52eed5 100644 (file)
@@ -227,7 +227,7 @@ private:
        /// Current ratio between physical pixels and device-independent pixels
        double pixelRatio() const {
 #if QT_VERSION >= 0x050000
-               return devicePixelRatio();
+               return qt_scale_factor * devicePixelRatio();
 #else
                return 1.0;
 #endif
@@ -1121,6 +1121,12 @@ void GuiView::updateWindowTitle(GuiWorkArea * wa)
        Buffer const & buf = wa->bufferView().buffer();
        // Set the windows title
        docstring title = buf.fileName().displayName(130) + from_ascii("[*]");
+       if (buf.notifiesExternalModification()) {
+               title = bformat(_("%1$s (modified externally)"), title);
+               // If the external modification status has changed, then maybe the status of
+               // buffer-save has changed too.
+               updateToolbars();
+       }
 #ifndef Q_WS_MAC
        title += from_ascii(" - LyX");
 #endif
@@ -1341,7 +1347,7 @@ void GuiView::resetCommandExecute()
 double GuiView::pixelRatio() const
 {
 #if QT_VERSION >= 0x050000
-       return devicePixelRatio();
+       return qt_scale_factor * devicePixelRatio();
 #else
        return 1.0;
 #endif
@@ -1812,9 +1818,7 @@ bool GuiView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
 
        case LFUN_BUFFER_RELOAD:
                enable = doc_buffer && !doc_buffer->isUnnamed()
-                       && doc_buffer->fileName().exists()
-                       && (!doc_buffer->isClean()
-                          || doc_buffer->isExternallyModified(Buffer::timestamp_method));
+                       && doc_buffer->fileName().exists() && !doc_buffer->isClean();
                break;
 
        case LFUN_BUFFER_CHILD_OPEN:
@@ -1844,6 +1848,10 @@ bool GuiView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
                break;
        }
 
+       case LFUN_BUFFER_EXTERNAL_MODIFICATION_CLEAR:
+               enable = doc_buffer && doc_buffer->notifiesExternalModification();
+               break;
+
        case LFUN_BUFFER_WRITE_AS:
        case LFUN_BUFFER_EXPORT_AS:
                enable = doc_buffer != 0;
@@ -3070,8 +3078,7 @@ void GuiView::checkExternallyModifiedBuffers()
        BufferList::iterator const bend = theBufferList().end();
        for (; bit != bend; ++bit) {
                Buffer * buf = *bit;
-               if (buf->fileName().exists()
-                       && buf->isExternallyModified(Buffer::checksum_method)) {
+               if (buf->fileName().exists() && buf->isChecksumModified()) {
                        docstring text = bformat(_("Document \n%1$s\n has been externally modified."
                                        " Reload now? Any local changes will be lost."),
                                        from_utf8(buf->absFileName()));
@@ -3548,14 +3555,17 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                        else
                                target_dir = doc_buffer->fileName().onlyPath();
 
+                       string const format = (argument.empty() || argument == "default") ?
+                               doc_buffer->params().getDefaultOutputFormat() : argument;
+
                        if ((dest.empty() && doc_buffer->isUnnamed())
                            || !target_dir.isDirWritable()) {
-                               exportBufferAs(*doc_buffer, cmd.argument());
+                               exportBufferAs(*doc_buffer, from_utf8(format));
                                break;
                        }
                        /* TODO/Review: Is it a problem to also export the children?
                                        See the update_unincluded flag */
-                       d.asyncBufferProcessing(argument,
+                       d.asyncBufferProcessing(format,
                                                doc_buffer,
                                                _("Exporting ..."),
                                                &GuiViewPrivate::exportAndDestroy,
@@ -3767,6 +3777,11 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                        break;
                }
 
+               case LFUN_BUFFER_EXTERNAL_MODIFICATION_CLEAR:
+                       LASSERT(doc_buffer, break);
+                       doc_buffer->clearExternalModification();
+                       break;
+
                case LFUN_BUFFER_CLOSE:
                        closeBuffer();
                        break;