diff --git a/src/LyXRC.cpp b/src/LyXRC.cpp index 79465326a0..c8cf673b3b 100644 --- a/src/LyXRC.cpp +++ b/src/LyXRC.cpp @@ -165,6 +165,7 @@ keyword_item lyxrcTags[] = { { "\\use_input_encoding", LyXRC::RC_USE_INP_ENC }, { "\\use_lastfilepos", LyXRC::RC_USELASTFILEPOS }, { "\\use_personal_dictionary", LyXRC::RC_USE_PERS_DICT }, + { "\\use_pixmap_cache", LyXRC::RC_USE_PIXMAP_CACHE }, // compatibility with versions older than 1.4.0 only { "\\use_pspell", LyXRC::RC_USE_SPELL_LIB }, { "\\use_spell_lib", LyXRC::RC_USE_SPELL_LIB }, @@ -280,6 +281,7 @@ void LyXRC::setDefaults() { preview_hashed_labels = false; preview_scale_factor = "0.9"; use_converter_cache = true; + use_pixmap_cache = false; converter_cache_maxage = 6 * 30 * 24 * 3600; // 6 months user_name = to_utf8(support::user_name()); @@ -901,6 +903,11 @@ int LyXRC::read(Lexer & lexrc) isp_use_pers_dict = lexrc.getBool(); } break; + case RC_USE_PIXMAP_CACHE: + if (lexrc.next()) { + use_pixmap_cache = lexrc.getBool(); + } + break; case RC_USE_ESC_CHARS: if (lexrc.next()) { isp_use_esc_chars = lexrc.getBool(); @@ -2064,6 +2071,13 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c } if (tag != RC_LAST) break; + case RC_USE_PIXMAP_CACHE: + if (ignore_system_lyxrc || + use_pixmap_cache != system_lyxrc.use_pixmap_cache) { + os << "\\use_pixmap_cache " + << convert<string>(use_pixmap_cache) + << '\n'; + } case RC_PERS_DICT: if (isp_pers_dict != system_lyxrc.isp_pers_dict) { string const path = os::external_path(isp_pers_dict); @@ -2498,6 +2512,10 @@ string const LyXRC::getDescription(LyXRCTags tag) str = _("Specify an alternate personal dictionary file. E.g. \".ispell_english\"."); break; + case RC_USE_PIXMAP_CACHE: + str = _("Enable the pixmap cache that might improve performance on Mac and Windows."); + break; + case RC_PREVIEW: str = _("Shows a typeset preview of things such as math"); break; diff --git a/src/LyXRC.h b/src/LyXRC.h index 20eedd914d..e5c5958c1b 100644 --- a/src/LyXRC.h +++ b/src/LyXRC.h @@ -138,6 +138,7 @@ public: RC_USE_ESC_CHARS, RC_USE_INP_ENC, RC_USE_PERS_DICT, + RC_USE_PIXMAP_CACHE, RC_USE_SPELL_LIB, RC_VIEWDVI_PAPEROPTION, RC_VIEWER, @@ -291,6 +292,8 @@ public: bool isp_use_alt_lang; /// Use personal dictionary? bool isp_use_pers_dict; + /// Use pixmap cache? + bool use_pixmap_cache; /// Use escape chars? bool isp_use_esc_chars; /// Alternate language for ispell diff --git a/src/frontends/qt4/GuiPainter.cpp b/src/frontends/qt4/GuiPainter.cpp index 16631003c0..57a5bd766e 100644 --- a/src/frontends/qt4/GuiPainter.cpp +++ b/src/frontends/qt4/GuiPainter.cpp @@ -22,6 +22,7 @@ #include "debug.h" #include "Language.h" +#include "LyXRC.h" #include "support/unicode.h" @@ -44,12 +45,12 @@ namespace frontend { namespace { -bool const usePixmapCache = USE_PIXMAP_CACHE; } // anon namespace GuiPainter::GuiPainter(QPaintDevice * device) - : QPainter(device), Painter() + : QPainter(device), Painter(), + use_pixmap_cache_(lyxrc.use_pixmap_cache && USE_PIXMAP_CACHE) { // new QPainter has default QPen: current_color_ = guiApp->colorCache().get(Color_black); @@ -359,7 +360,7 @@ int GuiPainter::text(int x, int y, docstring const & s, return textwidth; } - if (!usePixmapCache) { + if (!use_pixmap_cache_) { // don't use the pixmap cache, // draw directly onto the painting device setQPainterPen(computeColor(f.realColor())); diff --git a/src/frontends/qt4/GuiPainter.h b/src/frontends/qt4/GuiPainter.h index aa4bfcacf9..06a8112898 100644 --- a/src/frontends/qt4/GuiPainter.h +++ b/src/frontends/qt4/GuiPainter.h @@ -117,6 +117,8 @@ private: Painter::line_style current_ls_; Painter::line_width current_lw_; /// + bool const use_pixmap_cache_; + /// std::stack<QColor> monochrome_min_; /// std::stack<QColor> monochrome_max_; diff --git a/src/frontends/qt4/GuiPrefs.cpp b/src/frontends/qt4/GuiPrefs.cpp index 5074605bf7..7ebc2b381a 100644 --- a/src/frontends/qt4/GuiPrefs.cpp +++ b/src/frontends/qt4/GuiPrefs.cpp @@ -1625,6 +1625,8 @@ PrefUserInterface::PrefUserInterface(GuiPreferences * form, QWidget * parent) this, SIGNAL(changed())); connect(lastfilesSB, SIGNAL(valueChanged(int)), this, SIGNAL(changed())); + connect(pixmapCacheCB, SIGNAL(toggled(bool)), + this, SIGNAL(changed())); lastfilesSB->setMaximum(maxlastfiles); } @@ -1646,6 +1648,7 @@ void PrefUserInterface::apply(LyXRC & rc) const rc.autosave = autoSaveSB->value() * 60; rc.make_backup = autoSaveCB->isChecked(); rc.num_lastfiles = lastfilesSB->value(); + rc.use_pixmap_cache = pixmapCacheCB->isChecked(); } @@ -1669,6 +1672,10 @@ void PrefUserInterface::update(LyXRC const & rc) autoSaveSB->setValue(mins); autoSaveCB->setChecked(rc.make_backup); lastfilesSB->setValue(rc.num_lastfiles); + pixmapCacheCB->setChecked(rc.use_pixmap_cache); +#if (QT_VERSION < 0x040200) || defined(Q_WS_X11) + pixmapCacheGB->setEnabled(false); +#endif } diff --git a/src/frontends/qt4/ui/PrefUi.ui b/src/frontends/qt4/ui/PrefUi.ui index 4edfe17e82..a2522e0e01 100644 --- a/src/frontends/qt4/ui/PrefUi.ui +++ b/src/frontends/qt4/ui/PrefUi.ui @@ -6,13 +6,11 @@ <x>0</x> <y>0</y> <width>398</width> - <height>418</height> + <height>565</height> </rect> </property> <property name="sizePolicy" > - <sizepolicy> - <hsizetype>1</hsizetype> - <vsizetype>1</vsizetype> + <sizepolicy vsizetype="Minimum" hsizetype="Minimum" > <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> @@ -21,148 +19,6 @@ <string/> </property> <layout class="QGridLayout" > - <property name="margin" > - <number>9</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item row="5" column="1" > - <spacer> - <property name="orientation" > - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" > - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - <item row="4" column="0" colspan="3" > - <widget class="QGroupBox" name="scrollGB" > - <property name="title" > - <string>Scrolling</string> - </property> - <property name="alignment" > - <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> - </property> - <property name="flat" > - <bool>true</bool> - </property> - <layout class="QGridLayout" > - <property name="margin" > - <number>9</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item row="0" column="0" > - <widget class="QCheckBox" name="cursorFollowsCB" > - <property name="text" > - <string>Cursor follows &scrollbar</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item row="3" column="0" colspan="3" > - <widget class="QGroupBox" name="documentsGB" > - <property name="title" > - <string>Documents</string> - </property> - <property name="flat" > - <bool>true</bool> - </property> - <layout class="QGridLayout" > - <property name="margin" > - <number>9</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item row="0" column="1" > - <widget class="QSpinBox" name="autoSaveSB" > - <property name="maximum" > - <number>300</number> - </property> - <property name="minimum" > - <number>1</number> - </property> - </widget> - </item> - <item row="0" column="0" > - <widget class="QCheckBox" name="autoSaveCB" > - <property name="text" > - <string>B&ackup documents, every</string> - </property> - </widget> - </item> - <item row="0" column="2" > - <widget class="QLabel" name="TextLabel1" > - <property name="text" > - <string>minutes</string> - </property> - </widget> - </item> - <item row="0" column="3" > - <spacer> - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" > - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item row="1" column="0" colspan="4" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="lastfilesLA" > - <property name="text" > - <string>&Maximum last files:</string> - </property> - <property name="buddy" > - <cstring>lastfilesSB</cstring> - </property> - </widget> - </item> - <item> - <widget class="QSpinBox" name="lastfilesSB" > - <property name="maximum" > - <number>9</number> - </property> - </widget> - </item> - <item> - <spacer> - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" > - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - </layout> - </widget> - </item> <item row="0" column="0" > <widget class="QLabel" name="uiFileLA" > <property name="text" > @@ -183,12 +39,10 @@ </property> </widget> </item> - <item row="2" column="0" colspan="3" > + <item row="1" column="0" colspan="3" > <widget class="QGroupBox" name="GeometryGB" > <property name="sizePolicy" > - <sizepolicy> - <hsizetype>5</hsizetype> - <vsizetype>5</vsizetype> + <sizepolicy vsizetype="Preferred" hsizetype="Preferred" > <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> @@ -200,10 +54,22 @@ <bool>true</bool> </property> <layout class="QGridLayout" > - <property name="margin" > + <property name="leftMargin" > <number>9</number> </property> - <property name="spacing" > + <property name="topMargin" > + <number>9</number> + </property> + <property name="rightMargin" > + <number>9</number> + </property> + <property name="bottomMargin" > + <number>9</number> + </property> + <property name="horizontalSpacing" > + <number>6</number> + </property> + <property name="verticalSpacing" > <number>6</number> </property> <item row="0" column="0" colspan="2" > @@ -258,12 +124,21 @@ </item> <item row="1" column="0" > <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> <property name="spacing" > <number>6</number> </property> + <property name="leftMargin" > + <number>0</number> + </property> + <property name="topMargin" > + <number>0</number> + </property> + <property name="rightMargin" > + <number>0</number> + </property> + <property name="bottomMargin" > + <number>0</number> + </property> <item> <spacer> <property name="orientation" > @@ -295,12 +170,12 @@ <property name="enabled" > <bool>false</bool> </property> - <property name="maximum" > - <number>9999</number> - </property> <property name="minimum" > <number>200</number> </property> + <property name="maximum" > + <number>9999</number> + </property> <property name="singleStep" > <number>10</number> </property> @@ -321,12 +196,12 @@ <property name="enabled" > <bool>false</bool> </property> - <property name="maximum" > - <number>9999</number> - </property> <property name="minimum" > <number>200</number> </property> + <property name="maximum" > + <number>9999</number> + </property> <property name="singleStep" > <number>10</number> </property> @@ -353,6 +228,221 @@ </layout> </widget> </item> + <item row="2" column="0" colspan="3" > + <widget class="QGroupBox" name="documentsGB" > + <property name="title" > + <string>Documents</string> + </property> + <property name="flat" > + <bool>true</bool> + </property> + <layout class="QGridLayout" > + <property name="leftMargin" > + <number>9</number> + </property> + <property name="topMargin" > + <number>9</number> + </property> + <property name="rightMargin" > + <number>9</number> + </property> + <property name="bottomMargin" > + <number>9</number> + </property> + <property name="horizontalSpacing" > + <number>6</number> + </property> + <property name="verticalSpacing" > + <number>6</number> + </property> + <item row="0" column="1" > + <widget class="QSpinBox" name="autoSaveSB" > + <property name="minimum" > + <number>1</number> + </property> + <property name="maximum" > + <number>300</number> + </property> + </widget> + </item> + <item row="0" column="0" > + <widget class="QCheckBox" name="autoSaveCB" > + <property name="text" > + <string>B&ackup documents, every</string> + </property> + </widget> + </item> + <item row="0" column="2" > + <widget class="QLabel" name="TextLabel1" > + <property name="text" > + <string>minutes</string> + </property> + </widget> + </item> + <item row="0" column="3" > + <spacer> + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" > + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item row="1" column="0" colspan="4" > + <layout class="QHBoxLayout" > + <property name="spacing" > + <number>6</number> + </property> + <property name="leftMargin" > + <number>0</number> + </property> + <property name="topMargin" > + <number>0</number> + </property> + <property name="rightMargin" > + <number>0</number> + </property> + <property name="bottomMargin" > + <number>0</number> + </property> + <item> + <widget class="QLabel" name="lastfilesLA" > + <property name="text" > + <string>&Maximum last files:</string> + </property> + <property name="buddy" > + <cstring>lastfilesSB</cstring> + </property> + </widget> + </item> + <item> + <widget class="QSpinBox" name="lastfilesSB" > + <property name="maximum" > + <number>9</number> + </property> + </widget> + </item> + <item> + <spacer> + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" > + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + </layout> + </widget> + </item> + <item row="3" column="0" colspan="3" > + <widget class="QGroupBox" name="scrollGB" > + <property name="title" > + <string>Scrolling</string> + </property> + <property name="alignment" > + <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> + </property> + <property name="flat" > + <bool>true</bool> + </property> + <layout class="QGridLayout" > + <property name="leftMargin" > + <number>9</number> + </property> + <property name="topMargin" > + <number>9</number> + </property> + <property name="rightMargin" > + <number>9</number> + </property> + <property name="bottomMargin" > + <number>9</number> + </property> + <property name="horizontalSpacing" > + <number>6</number> + </property> + <property name="verticalSpacing" > + <number>6</number> + </property> + <item row="0" column="0" > + <widget class="QCheckBox" name="cursorFollowsCB" > + <property name="text" > + <string>Cursor follows &scrollbar</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item row="4" column="0" colspan="3" > + <widget class="QGroupBox" name="pixmapCacheGB" > + <property name="title" > + <string>Pixmap Cache</string> + </property> + <property name="alignment" > + <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> + </property> + <property name="flat" > + <bool>true</bool> + </property> + <layout class="QGridLayout" > + <property name="leftMargin" > + <number>9</number> + </property> + <property name="topMargin" > + <number>9</number> + </property> + <property name="rightMargin" > + <number>9</number> + </property> + <property name="bottomMargin" > + <number>9</number> + </property> + <property name="horizontalSpacing" > + <number>6</number> + </property> + <property name="verticalSpacing" > + <number>6</number> + </property> + <item row="0" column="0" > + <widget class="QCheckBox" name="pixmapCacheCB" > + <property name="toolTip" > + <string><html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Checking this improves performance, but might decrease the on-screen quality of fonts.</p></body></html></string> + </property> + <property name="text" > + <string>Enable Pi&xmap Cache</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item row="5" column="1" > + <spacer> + <property name="orientation" > + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" > + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> </layout> </widget> <tabstops>