mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
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 at390ae054
which was reverted at358745d0
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.
This commit is contained in:
parent
19c6a015fb
commit
d887b2a5dc
@ -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());
|
||||
|
@ -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
|
||||
|
@ -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"),
|
||||
|
@ -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_;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user