On Tue, Aug 08, 2017 at 04:01:40PM +0200, Jürgen Spitzmüller wrote:
> Am Dienstag, den 25.07.2017, 21:19 +0200 schrieb Enrico Forestieri:
> > On Tue, Jul 25, 2017 at 11:11:36AM +0200, Pavel Sanda wrote:
> > 
> > > Scott Kostyshak wrote:
> > > > It did feel strange that the "OK" and "Apply" buttons were not
> > > > enabled
> > > > when checking the "Allow running external programs" checkbox, but
> > > > I got
> > > > used to it quickly.
> > > 
> > > Likely not feature but just forgotten connect with signal of box
> > > being checked.
> > 
> > No, this was done by design. The status of this checkbox is not saved
> > in
> > the document, so the document should not be marked as dirty.
> 
> I find it irritating as well. Since this dialog in general follows an
> OK/Apply paradigm, I think this should be done for this checkbox as
> well, even if the change does not survive sessions (and at the cost of
> a dirty buffer).

Please, can you check if the attached patch addresses your concern?

-- 
Enrico
diff --git a/src/frontends/qt4/GuiDocument.cpp 
b/src/frontends/qt4/GuiDocument.cpp
index 8889fdf677..04e78d1ae6 100644
--- a/src/frontends/qt4/GuiDocument.cpp
+++ b/src/frontends/qt4/GuiDocument.cpp
@@ -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,9 +1543,16 @@ 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.
+       shellescapeChanged_ = true;
+       changed();
+}
+
+
+void GuiDocument::updateShellEscape()
+{
+       if (!shellescapeChanged_)
+               return;
+
        bp_.shell_escape = outputModule->shellescapeCB->isChecked();
        if (!bp_.shell_escape)
            theSession().shellescapeFiles().remove(buffer().absFileName());
@@ -1552,8 +1560,28 @@ void GuiDocument::shellescapeChanged()
            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);
+}
+
+
+void GuiDocument::slotApply()
+{
+       updateShellEscape();
+       bool wasclean = !nonModuleChanged_ && buffer().isClean();
+       GuiDialog::slotApply();
+       if (wasclean && !modulesChanged_)
+               buffer().markClean();
+       modulesChanged_ = false;
+}
+
+
+void GuiDocument::slotOK()
+{
+       updateShellEscape();
+       bool wasclean = !nonModuleChanged_ && buffer().isClean();
+       GuiDialog::slotOK();
+       if (wasclean && !modulesChanged_)
+               buffer().markClean();
+       modulesChanged_ = false;
 }
 
 
@@ -2662,7 +2690,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 +2699,7 @@ void GuiDocument::modulesChanged()
                        applyView();
        }
 
+       modulesChanged_ = true;
        bp_.makeDocumentClass();
        paramsToDialog();
        changed();
@@ -3276,6 +3305,7 @@ void GuiDocument::applyView()
 
        // reset tracker
        nonModuleChanged_ = false;
+       shellescapeChanged_ = false;
 }
 
 
@@ -3865,6 +3895,7 @@ void GuiDocument::paramsToDialog()
 
        // reset tracker
        nonModuleChanged_ = false;
+       shellescapeChanged_ = false;
 }
 
 
diff --git a/src/frontends/qt4/GuiDocument.h b/src/frontends/qt4/GuiDocument.h
index 5efde8eee3..37cecbfe60 100644
--- a/src/frontends/qt4/GuiDocument.h
+++ b/src/frontends/qt4/GuiDocument.h
@@ -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();
@@ -274,6 +278,8 @@ private:
        ///
        void loadModuleInfo();
        ///
+       void updateShellEscape();
+       ///
        void updateUnknownBranches();
        ///
        void updateTexFonts();
@@ -303,6 +309,10 @@ private:
        bool biblioChanged_;
        /// Track if a non-module document param changed
        bool nonModuleChanged_;
+       /// Track if a modules document param changed
+       bool modulesChanged_;
+       /// Track if the shellescape param changed
+       bool shellescapeChanged_;
 };
 
 
diff --git a/src/frontends/qt4/ui/OutputUi.ui b/src/frontends/qt4/ui/OutputUi.ui
index e3e36dab0e..b309bbb1d4 100644
--- a/src/frontends/qt4/ui/OutputUi.ui
+++ b/src/frontends/qt4/ui/OutputUi.ui
@@ -108,7 +108,7 @@
    <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>

Reply via email to