]> git.lyx.org Git - features.git/commitdiff
Update previews when turned on in prefs (#9507)
authorScott Kostyshak <skostysh@lyx.org>
Sun, 22 Nov 2015 16:39:15 +0000 (11:39 -0500)
committerScott Kostyshak <skostysh@lyx.org>
Mon, 30 Nov 2015 23:51:05 +0000 (18:51 -0500)
Previews are now generated when previews are turned on in
preferences. This change ensures that when users activate previews
for the first time, they are not confused by no previews showing up
(a restart of LyX or a triggering of each individual preview would
be required).

There was a previously attempted fix for #9507 at 390ae054 which was
reverted at 358745d0 for performance reasons: it updated previews
after every preference change and updating previews is costly (even
if the cache signals there are no changes needed).

This implementation is consistent with what we do for updating the
system fonts in preferences.

src/BufferList.cpp
src/BufferList.h
src/frontends/qt4/GuiPrefs.cpp
src/frontends/qt4/GuiPrefs.h

index c253282b795c029ea244769362d4fee5d9e6ca5c..68a1e808cb07ab98672b4f5a49185e7dba0f4f05 100644 (file)
@@ -344,6 +344,15 @@ void BufferList::recordCurrentAuthor(Author const & author)
 }
 
 
+void BufferList::updatePreviews()
+{
+       BufferStorage::iterator it = bstore.begin();
+       BufferStorage::iterator end = bstore.end();
+       for (; it != end; ++it)
+               (*it)->updatePreviews();
+}
+
+
 int BufferList::bufferNum(FileName const & fname) const
 {
        FileNameList const buffers(fileNames());
index 4f9cb95c05cb6d177aa3637ed9a8a01bfebe5832..242eff03bea24d34d5750b670bd9511767055b64 100644 (file)
@@ -115,6 +115,8 @@ public:
        //@{
        /// reset current author for all buffers
        void recordCurrentAuthor(Author const & author);
+       /// update previews for all buffers, e.g. for Prefs update
+       void updatePreviews();
        /// Call changed() on all buffers, internal or not
        void changed(bool update_metrics) const;
        /// emergency save for all buffers
index ef6f263ff3f3da0c6c006d38ad010b8c60851ee0..c9ca024cc11b86ff5c5c1140761b4ca4f9a423ee 100644 (file)
@@ -1272,10 +1272,16 @@ void PrefDisplay::applyRC(LyXRC & rc) const
                        rc.preview = LyXRC::PREVIEW_OFF;
                        break;
                case 1:
-                       rc.preview = LyXRC::PREVIEW_NO_MATH;
+                       if (rc.preview != LyXRC::PREVIEW_NO_MATH) {
+                               rc.preview = LyXRC::PREVIEW_NO_MATH;
+                               form_->updatePreviews();
+                       }
                        break;
                case 2:
-                       rc.preview = LyXRC::PREVIEW_ON;
+                       if (rc.preview != LyXRC::PREVIEW_ON) {
+                               rc.preview = LyXRC::PREVIEW_ON;
+                               form_->updatePreviews();
+                       }
                        break;
        }
 
@@ -3205,7 +3211,8 @@ void PrefIdentity::updateRC(LyXRC const & rc)
 /////////////////////////////////////////////////////////////////////
 
 GuiPreferences::GuiPreferences(GuiView & lv)
-       : GuiDialog(lv, "prefs", qt_("Preferences")), update_screen_font_(false)
+       : GuiDialog(lv, "prefs", qt_("Preferences")), update_screen_font_(false),
+         update_previews_(false)
 {
        setupUi(this);
 
@@ -3315,6 +3322,7 @@ bool GuiPreferences::initialiseParams(string const &)
        movers_ = theMovers();
        colors_.clear();
        update_screen_font_ = false;
+       update_previews_ = false;
 
        updateRC(rc_);
        // Make sure that the bc is in the INITIAL state
@@ -3359,6 +3367,12 @@ void GuiPreferences::dispatchParams()
                update_screen_font_ = false;
        }
 
+        if (update_previews_) {
+               // resets flag in case second apply in same dialog
+               theBufferList().updatePreviews();
+               update_previews_ = false;
+       }
+
        // The Save button has been pressed
        if (isClosing())
                dispatch(FuncRequest(LFUN_PREFERENCES_SAVE));
@@ -3377,6 +3391,12 @@ void GuiPreferences::updateScreenFonts()
 }
 
 
+void GuiPreferences::updatePreviews()
+{
+       update_previews_ = true;
+}
+
+
 QString GuiPreferences::browsebind(QString const & file) const
 {
        return browseLibFile("bind", file, "bind", qt_("Choose bind file"),
index e57d1dd9d780642ba7c2e4adfc7d06601a4115fc..4094d0137ed02e7867017344223730a153b771e5 100644 (file)
@@ -101,6 +101,9 @@ public:
        /// update the screen fonts after change
        void updateScreenFonts();
 
+       /// update the previews after change
+       void updatePreviews();
+
        LyXRC & rc() { return rc_; }
        Converters & converters() { return converters_; }
        Formats & formats() { return formats_; }
@@ -123,6 +126,7 @@ private:
        std::vector<std::string> colors_;
 
        bool update_screen_font_;
+       bool update_previews_;
 };