]> git.lyx.org Git - features.git/commitdiff
Simplify and polish
authorRichard Kimberly Heck <rikiheck@lyx.org>
Wed, 13 Jan 2021 19:42:26 +0000 (14:42 -0500)
committerRichard Kimberly Heck <rikiheck@lyx.org>
Wed, 13 Jan 2021 19:42:26 +0000 (14:42 -0500)
src/frontends/qt/GuiView.cpp
src/frontends/qt/GuiView.h

index 07e08e086ecbe7429b6f75b14879a98df03bbe8d..bdd7f1d2b9a0dea2cc6a928492b57b992a541a56 100644 (file)
@@ -2716,11 +2716,11 @@ void GuiView::newDocument(string const & filename, string templatefile,
 }
 
 
-void GuiView::insertLyXFile(docstring const & fname, bool ignorelang)
+bool GuiView::insertLyXFile(docstring const & fname, bool ignorelang)
 {
        BufferView * bv = documentBufferView();
        if (!bv)
-               return;
+               return false;
 
        // FIXME UNICODE
        FileName filename(to_utf8(fname));
@@ -2742,7 +2742,7 @@ void GuiView::insertLyXFile(docstring const & fname, bool ignorelang)
                                         QStringList(qt_("LyX Documents (*.lyx)")));
 
                if (result.first == FileDialog::Later)
-                       return;
+                       return false;
 
                // FIXME UNICODE
                filename.set(fromqstr(result.second));
@@ -2751,12 +2751,13 @@ void GuiView::insertLyXFile(docstring const & fname, bool ignorelang)
                if (filename.empty()) {
                        // emit message signal.
                        message(_("Canceled."));
-                       return;
+                       return false;
                }
        }
 
        bv->insertLyXFile(filename, ignorelang);
        bv->buffer().errors("Parse");
+       return true;
 }
 
 
@@ -4158,12 +4159,11 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                        break;
 
                case LFUN_FILE_INSERT: {
-                       if (cmd.getArg(1) == "ignorelang")
-                               insertLyXFile(from_utf8(cmd.getArg(0)), true);
-                       else
-                               insertLyXFile(cmd.argument());
-                       dr.forceBufferUpdate();
-                       dr.screenUpdate(Update::Force);
+                       bool const ignore_lang = cmd.getArg(1) == "ignorelang";
+                       if (insertLyXFile(from_utf8(cmd.getArg(0)), ignore_lang)) {
+                               dr.forceBufferUpdate();
+                               dr.screenUpdate(Update::Force);
+                       }
                        break;
                }
 
index 9c2481111c5ee2f8f599d079e4885974b768589c..4c610e0ef930fc393cc50702e5f726132c04dbff 100644 (file)
@@ -376,8 +376,8 @@ private:
        bool lfunUiToggle(std::string const & ui_component);
        ///
        void toggleFullScreen();
-       ///
-       void insertLyXFile(docstring const & fname, bool ignorelang = false);
+        /// \return whether we did anything
+        bool insertLyXFile(docstring const & fname, bool ignorelang = false);
        ///
        /// Open Export As ... dialog. \p iformat is the format the
        /// filter is initially set to.