From: Scott Kostyshak Date: Sun, 22 Nov 2015 16:39:15 +0000 (-0500) Subject: Update previews when turned on in prefs (#9507) X-Git-Tag: 2.2.0beta1~512 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=d887b2a5dcef98947f7560d98ff35606e53875d9;p=features.git Update previews when turned on in prefs (#9507) 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. --- diff --git a/src/BufferList.cpp b/src/BufferList.cpp index c253282b79..68a1e808cb 100644 --- a/src/BufferList.cpp +++ b/src/BufferList.cpp @@ -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()); diff --git a/src/BufferList.h b/src/BufferList.h index 4f9cb95c05..242eff03be 100644 --- a/src/BufferList.h +++ b/src/BufferList.h @@ -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 diff --git a/src/frontends/qt4/GuiPrefs.cpp b/src/frontends/qt4/GuiPrefs.cpp index ef6f263ff3..c9ca024cc1 100644 --- a/src/frontends/qt4/GuiPrefs.cpp +++ b/src/frontends/qt4/GuiPrefs.cpp @@ -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"), diff --git a/src/frontends/qt4/GuiPrefs.h b/src/frontends/qt4/GuiPrefs.h index e57d1dd9d7..4094d0137e 100644 --- a/src/frontends/qt4/GuiPrefs.h +++ b/src/frontends/qt4/GuiPrefs.h @@ -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 colors_; bool update_screen_font_; + bool update_previews_; };