]> git.lyx.org Git - lyx.git/commitdiff
Use the OK/Apply paradigm for all document settings
authorEnrico Forestieri <forenr@lyx.org>
Wed, 9 Aug 2017 23:32:23 +0000 (01:32 +0200)
committerEnrico Forestieri <forenr@lyx.org>
Wed, 9 Aug 2017 23:32:23 +0000 (01:32 +0200)
Due to its peculiarity of not being saved in the document, the
shell escape setting was applied immediately without the need
for hitting the Apply or OK buttons. However, for uniformity
sake, it is better to adhere to the established paragdim of
confirming any changes before applying them.

src/frontends/qt4/GuiDocument.cpp
src/frontends/qt4/GuiDocument.h
src/frontends/qt4/ui/OutputUi.ui

index 8889fdf677a127ef6f81d10a51aa14804e2d438f..e980921f62868e728a9241435838aac16df9ad02 100644 (file)
@@ -664,7 +664,8 @@ void LocalLayout::validatePressed() {
 
 GuiDocument::GuiDocument(GuiView & lv)
        : GuiDialog(lv, "document", qt_("Document Settings")),
-         biblioChanged_(false), nonModuleChanged_(false)
+         biblioChanged_(false), nonModuleChanged_(false),
+         modulesChanged_(false), shellescapeChanged_(false)
 {
        setupUi(this);
 
@@ -1542,18 +1543,30 @@ void GuiDocument::change_adaptor()
 
 void GuiDocument::shellescapeChanged()
 {
-       // This is treated specially as the change is automatically applied
-       // and the document isn't marked as dirty. Visual feedback is given
-       // by the appearance/disappearance of a red icon in the status bar.
-       bp_.shell_escape = outputModule->shellescapeCB->isChecked();
-       if (!bp_.shell_escape)
-           theSession().shellescapeFiles().remove(buffer().absFileName());
-       else if (!theSession().shellescapeFiles().find(buffer().absFileName()))
-           theSession().shellescapeFiles().insert(buffer().absFileName());
-       Buffer & buf = const_cast<Buffer &>(buffer());
-       buf.params().shell_escape = bp_.shell_escape;
-       BufferView * bv = const_cast<BufferView *>(bufferview());
-       bv->processUpdateFlags(Update::Force);
+       shellescapeChanged_ = true;
+       changed();
+}
+
+
+void GuiDocument::slotApply()
+{
+       bool only_shellescape_changed = !nonModuleChanged_ && !modulesChanged_;
+       bool wasclean = buffer().isClean();
+       GuiDialog::slotApply();
+       if (wasclean && only_shellescape_changed)
+               buffer().markClean();
+       modulesChanged_ = false;
+}
+
+
+void GuiDocument::slotOK()
+{
+       bool only_shellescape_changed = !nonModuleChanged_ && !modulesChanged_;
+       bool wasclean = buffer().isClean();
+       GuiDialog::slotOK();
+       if (wasclean && only_shellescape_changed)
+               buffer().markClean();
+       modulesChanged_ = false;
 }
 
 
@@ -2662,7 +2675,7 @@ void GuiDocument::modulesChanged()
 {
        modulesToParams(bp_);
 
-       if (applyPB->isEnabled() && nonModuleChanged_) {
+       if (applyPB->isEnabled() && (nonModuleChanged_ || shellescapeChanged_)) {
                int const ret = Alert::prompt(_("Unapplied changes"),
                                _("Some changes in the dialog were not yet applied.\n"
                                "If you do not apply now, they will be lost after this action."),
@@ -2671,6 +2684,7 @@ void GuiDocument::modulesChanged()
                        applyView();
        }
 
+       modulesChanged_ = true;
        bp_.makeDocumentClass();
        paramsToDialog();
        changed();
@@ -3136,6 +3150,12 @@ void GuiDocument::applyView()
        bp_.useNonTeXFonts = nontexfonts;
 
        bp_.shell_escape = outputModule->shellescapeCB->isChecked();
+       if (!bp_.shell_escape)
+           theSession().shellescapeFiles().remove(buffer().absFileName());
+       else if (!theSession().shellescapeFiles().find(buffer().absFileName()))
+           theSession().shellescapeFiles().insert(buffer().absFileName());
+       Buffer & buf = const_cast<Buffer &>(buffer());
+       buf.params().shell_escape = bp_.shell_escape;
 
        bp_.output_sync = outputModule->outputsyncCB->isChecked();
 
@@ -3274,8 +3294,9 @@ void GuiDocument::applyView()
        pdf.quoted_options = pdf.quoted_options_check(
                                fromqstr(pdfSupportModule->optionsLE->text()));
 
-       // reset tracker
+       // reset trackers
        nonModuleChanged_ = false;
+       shellescapeChanged_ = false;
 }
 
 
@@ -3863,8 +3884,9 @@ void GuiDocument::paramsToDialog()
        // clear changed branches cache
        changedBranches_.clear();
 
-       // reset tracker
+       // reset trackers
        nonModuleChanged_ = false;
+       shellescapeChanged_ = false;
 }
 
 
index 5efde8eee3e289b37cec36f8ef031aa20be151c9..be1b7e489f5f9eb392f0f889803940bc53fc265a 100644 (file)
@@ -86,6 +86,10 @@ public:
 
 public Q_SLOTS:
        void onBufferViewChanged();//override
+       // OK button clicked
+       void slotOK();
+       // Apply button clicked
+       void slotApply();
 
 private Q_SLOTS:
        void updateNumbering();
@@ -303,6 +307,10 @@ private:
        bool biblioChanged_;
        /// Track if a non-module document param changed
        bool nonModuleChanged_;
+       /// Track if used modules changed
+       bool modulesChanged_;
+       /// Track if the shellescape param changed
+       bool shellescapeChanged_;
 };
 
 
index e3e36dab0e7c2348bd7687620d6e60ece32a0371..b309bbb1d4e2849ac6889d3f62be71507ca9f15c 100644 (file)
    <item row="1" column="0">
     <widget class="QCheckBox" name="shellescapeCB">
      <property name="toolTip">
-      <string>Runs the LaTeX backend with the -shell-escape option (this setting is always applied immediately)</string>
+      <string>Runs the LaTeX backend with the -shell-escape option (Warning: use only when really necessary)</string>
      </property>
      <property name="text">
       <string>&amp;Allow running external programs</string>