]> git.lyx.org Git - lyx.git/commitdiff
Update screen as needed when preferences are changed
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Tue, 26 Feb 2019 15:37:41 +0000 (16:37 +0100)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 27 Feb 2019 11:04:09 +0000 (12:04 +0100)
This commit removes the adhoc code in GuiPrefs and moves it to LyXRC,
so that it triggers in every preference change.

The code has also been updated to trigger on more variables, e.g.
font_*_foundry.

Note that the actual function that are called have not been changed
(addPreviews and LFUN_SCREEN_FONT_UPDATE), although there are doubts
that they behave as needed (see FIXMEs).

Fixes bug #11498.

(cherry picked from commit 954531f247adee029c12713634a81717f87a2bcf)

src/LyXRC.cpp
src/frontends/qt4/GuiApplication.cpp
src/frontends/qt4/GuiPrefs.cpp
src/frontends/qt4/GuiPrefs.h
status.23x

index 71f184d69d0bd9730218a0fbc4353bc30100e136..67530bd3e349eff5129081b89de1e0739d8a8673 100644 (file)
@@ -23,6 +23,8 @@
 #include "Converter.h"
 #include "FontEnums.h"
 #include "Format.h"
+#include "FuncCode.h"
+#include "FuncRequest.h"
 #include "Lexer.h"
 #include "LyX.h"
 #include "Mover.h"
@@ -3003,6 +3005,14 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new)
                }
                // fall through
        case LyXRC::RC_PREVIEW:
+               if (lyxrc_orig.preview != lyxrc_new.preview) {
+                       // Update all previews of all documents.
+                       /* FIXME: this can be very expensive. It would be cheaper
+                        * to kill all existing previews and update visible
+                        * previews.*/
+                       theBufferList().updatePreviews();
+               }
+               // fall through
        case LyXRC::RC_PREVIEW_HASHED_LABELS:
        case LyXRC::RC_PREVIEW_SCALE_FACTOR:
        case LyXRC::RC_PRINTLANDSCAPEFLAG:
@@ -3011,6 +3021,7 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new)
        case LyXRC::RC_SAVE_COMPRESSED:
        case LyXRC::RC_SAVE_ORIGIN:
        case LyXRC::RC_SCREEN_DPI:
+
        case LyXRC::RC_SCREEN_FONT_ROMAN:
        case LyXRC::RC_SCREEN_FONT_ROMAN_FOUNDRY:
        case LyXRC::RC_SCREEN_FONT_SANS:
@@ -3019,8 +3030,20 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new)
        case LyXRC::RC_SCREEN_FONT_SIZES:
        case LyXRC::RC_SCREEN_FONT_TYPEWRITER:
        case LyXRC::RC_SCREEN_FONT_TYPEWRITER_FOUNDRY:
-       case LyXRC::RC_GEOMETRY_SESSION:
        case LyXRC::RC_SCREEN_ZOOM:
+               if (lyxrc_orig.roman_font_name != lyxrc_new.roman_font_name
+               || lyxrc_orig.sans_font_name != lyxrc_new.sans_font_name
+               || lyxrc_orig.typewriter_font_name != lyxrc_new.typewriter_font_name
+               || lyxrc_orig.roman_font_foundry != lyxrc_new.roman_font_foundry
+               || lyxrc_orig.sans_font_foundry != lyxrc_new.sans_font_foundry
+               || lyxrc_orig.use_scalable_fonts != lyxrc_new.use_scalable_fonts
+               || lyxrc_orig.font_sizes != lyxrc_new.font_sizes
+               || lyxrc_orig.typewriter_font_foundry != lyxrc_new.typewriter_font_foundry
+               || lyxrc_orig.defaultZoom != lyxrc_new.defaultZoom) {
+               dispatch(FuncRequest(LFUN_SCREEN_FONT_UPDATE));
+       }
+
+       case LyXRC::RC_GEOMETRY_SESSION:
        case LyXRC::RC_SERVERPIPE:
        case LyXRC::RC_SET_COLOR:
        case LyXRC::RC_SHOW_BANNER:
index 3c6e137e46776f93cc98933560161c255c2c199b..3d88764c732fbd2243102a40c7e0c9aef806d818 100644 (file)
@@ -1632,6 +1632,9 @@ void GuiApplication::dispatch(FuncRequest const & cmd, DispatchResult & dr)
 
        case LFUN_SCREEN_FONT_UPDATE: {
                // handle the screen font changes.
+               /* FIXME: this only updates the current document, whereas all
+                * documents should see their metrics updated.
+                */
                d->font_loader_.update();
                dr.screenUpdate(Update::Force | Update::FitCursor);
                break;
index 58810dfb85e13c13ab5e720b8d81357034e05372..ae0986ecc0e3d0386fadd5cddf486f221f15d905 100644 (file)
@@ -1101,19 +1101,6 @@ void PrefScreenFonts::applyRC(LyXRC & rc) const
        rc.font_sizes[FONT_SIZE_HUGE] = widgetToDoubleStr(screenHugeED);
        rc.font_sizes[FONT_SIZE_HUGER] = widgetToDoubleStr(screenHugerED);
        rc.use_pixmap_cache = pixmapCacheCB->isChecked();
-
-       if (rc.font_sizes != oldrc.font_sizes
-               || rc.roman_font_name != oldrc.roman_font_name
-               || rc.sans_font_name != oldrc.sans_font_name
-               || rc.typewriter_font_name != oldrc.typewriter_font_name
-               || rc.defaultZoom != oldrc.defaultZoom) {
-               // The global QPixmapCache is used in GuiPainter to cache text
-               // painting so we must reset it in case any of the above
-               // parameter is changed.
-               QPixmapCache::clear();
-               guiApp->fontLoader().update();
-               form_->updateScreenFonts();
-       }
 }
 
 
@@ -1447,16 +1434,10 @@ void PrefDisplay::applyRC(LyXRC & rc) const
                        rc.preview = LyXRC::PREVIEW_OFF;
                        break;
                case 1:
-                       if (rc.preview != LyXRC::PREVIEW_NO_MATH) {
-                               rc.preview = LyXRC::PREVIEW_NO_MATH;
-                               form_->updatePreviews();
-                       }
+                       rc.preview = LyXRC::PREVIEW_NO_MATH;
                        break;
                case 2:
-                       if (rc.preview != LyXRC::PREVIEW_ON) {
-                               rc.preview = LyXRC::PREVIEW_ON;
-                               form_->updatePreviews();
-                       }
+                       rc.preview = LyXRC::PREVIEW_ON;
                        break;
        }
 
@@ -3537,8 +3518,7 @@ void PrefIdentity::updateRC(LyXRC const & rc)
 /////////////////////////////////////////////////////////////////////
 
 GuiPreferences::GuiPreferences(GuiView & lv)
-       : GuiDialog(lv, "prefs", qt_("Preferences")), update_screen_font_(false),
-         update_previews_(false)
+       : GuiDialog(lv, "prefs", qt_("Preferences"))
 {
        setupUi(this);
 
@@ -3647,8 +3627,6 @@ bool GuiPreferences::initialiseParams(string const &)
        converters_.update(formats_);
        movers_ = theMovers();
        colors_.clear();
-       update_screen_font_ = false;
-       update_previews_ = false;
 
        updateRC(rc_);
        // Make sure that the bc is in the INITIAL state
@@ -3682,24 +3660,10 @@ void GuiPreferences::dispatchParams()
 
        theMovers() = movers_;
 
-       vector<string>::const_iterator it = colors_.begin();
-       vector<string>::const_iterator const end = colors_.end();
-       for (; it != end; ++it)
-               dispatch(FuncRequest(LFUN_SET_COLOR, *it));
+       for (string const & color : colors_)
+               dispatch(FuncRequest(LFUN_SET_COLOR, color));
        colors_.clear();
 
-       if (update_screen_font_) {
-               dispatch(FuncRequest(LFUN_SCREEN_FONT_UPDATE));
-               // resets flag in case second apply in same dialog
-               update_screen_font_ = false;
-       }
-
-        if (update_previews_) {
-               // resets flag in case second apply in same dialog
-               theBufferList().updatePreviews();
-               update_previews_ = false;
-       }
-
        // Save permanently
        if (!tempSaveCB->isChecked())
                dispatch(FuncRequest(LFUN_PREFERENCES_SAVE));
@@ -3712,18 +3676,6 @@ void GuiPreferences::setColor(ColorCode col, QString const & hex)
 }
 
 
-void GuiPreferences::updateScreenFonts()
-{
-       update_screen_font_ = true;
-}
-
-
-void GuiPreferences::updatePreviews()
-{
-       update_previews_ = true;
-}
-
-
 QString GuiPreferences::browsebind(QString const & file) const
 {
        return browseLibFile("bind", file, "bind", qt_("Choose bind file"),
index b36f2e60c388aa111dff0a9a374a5a75eb1ee16e..4f877a1a0a9ef65c9e4c09209f7c13635fbc8c8d 100644 (file)
@@ -98,12 +98,6 @@ public:
        /// set a color
        void setColor(ColorCode col, QString const & hex);
 
-       /// 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_; }
@@ -124,9 +118,6 @@ private:
 
        /// A list of colors to be dispatched
        std::vector<std::string> colors_;
-
-       bool update_screen_font_;
-       bool update_previews_;
 };
 
 
index e21ebf9836174563ac09ade05348bdb91a4bdcec..5243604d9fe650579b0a56461af19844bedd9dbf 100644 (file)
@@ -116,10 +116,10 @@ What's new
 
 - Fix some display problems in the Text Properties dialog (bug 11385).
 
-- Accept/reject changes inside selection only if there are changes (bug 
+- Accept/reject changes inside selection only if there are changes (bug
   10338).
 
-- Fix missing TOC update (and related bugs) when setting default master (bug 
+- Fix missing TOC update (and related bugs) when setting default master (bug
   11422).
 
 - Properly update bibliography information (with bibliography environment)
@@ -154,6 +154,8 @@ What's new
 
 - Fix many drawing glitches in the IPA icons.
 
+- Fix crash when disabling math preview (bug 11498).
+
 
 
 * INTERNALS