* src/LyXRC.{cpp,h}:

- new RC_USE_PIXMAP_CACHE
* src/frontends/qt4/GuiPainter.{cpp,h}:
	- use rc.use_pixmap_cache
* src/frontends/qt4/GuiPrefs.cpp:
* src/frontends/qt4/ui/QPref.ui:
	- implement rc.use_pixmap_cache

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21372 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Spitzmüller 2007-11-02 14:43:09 +00:00
parent 16441a6914
commit 33bb075fd8
6 changed files with 285 additions and 164 deletions

View File

@ -165,6 +165,7 @@ keyword_item lyxrcTags[] = {
{ "\\use_input_encoding", LyXRC::RC_USE_INP_ENC }, { "\\use_input_encoding", LyXRC::RC_USE_INP_ENC },
{ "\\use_lastfilepos", LyXRC::RC_USELASTFILEPOS }, { "\\use_lastfilepos", LyXRC::RC_USELASTFILEPOS },
{ "\\use_personal_dictionary", LyXRC::RC_USE_PERS_DICT }, { "\\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 // compatibility with versions older than 1.4.0 only
{ "\\use_pspell", LyXRC::RC_USE_SPELL_LIB }, { "\\use_pspell", LyXRC::RC_USE_SPELL_LIB },
{ "\\use_spell_lib", 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_hashed_labels = false;
preview_scale_factor = "0.9"; preview_scale_factor = "0.9";
use_converter_cache = true; use_converter_cache = true;
use_pixmap_cache = false;
converter_cache_maxage = 6 * 30 * 24 * 3600; // 6 months converter_cache_maxage = 6 * 30 * 24 * 3600; // 6 months
user_name = to_utf8(support::user_name()); user_name = to_utf8(support::user_name());
@ -901,6 +903,11 @@ int LyXRC::read(Lexer & lexrc)
isp_use_pers_dict = lexrc.getBool(); isp_use_pers_dict = lexrc.getBool();
} }
break; break;
case RC_USE_PIXMAP_CACHE:
if (lexrc.next()) {
use_pixmap_cache = lexrc.getBool();
}
break;
case RC_USE_ESC_CHARS: case RC_USE_ESC_CHARS:
if (lexrc.next()) { if (lexrc.next()) {
isp_use_esc_chars = lexrc.getBool(); 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) if (tag != RC_LAST)
break; 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: case RC_PERS_DICT:
if (isp_pers_dict != system_lyxrc.isp_pers_dict) { if (isp_pers_dict != system_lyxrc.isp_pers_dict) {
string const path = os::external_path(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\"."); str = _("Specify an alternate personal dictionary file. E.g. \".ispell_english\".");
break; break;
case RC_USE_PIXMAP_CACHE:
str = _("Enable the pixmap cache that might improve performance on Mac and Windows.");
break;
case RC_PREVIEW: case RC_PREVIEW:
str = _("Shows a typeset preview of things such as math"); str = _("Shows a typeset preview of things such as math");
break; break;

View File

@ -138,6 +138,7 @@ public:
RC_USE_ESC_CHARS, RC_USE_ESC_CHARS,
RC_USE_INP_ENC, RC_USE_INP_ENC,
RC_USE_PERS_DICT, RC_USE_PERS_DICT,
RC_USE_PIXMAP_CACHE,
RC_USE_SPELL_LIB, RC_USE_SPELL_LIB,
RC_VIEWDVI_PAPEROPTION, RC_VIEWDVI_PAPEROPTION,
RC_VIEWER, RC_VIEWER,
@ -291,6 +292,8 @@ public:
bool isp_use_alt_lang; bool isp_use_alt_lang;
/// Use personal dictionary? /// Use personal dictionary?
bool isp_use_pers_dict; bool isp_use_pers_dict;
/// Use pixmap cache?
bool use_pixmap_cache;
/// Use escape chars? /// Use escape chars?
bool isp_use_esc_chars; bool isp_use_esc_chars;
/// Alternate language for ispell /// Alternate language for ispell

View File

@ -22,6 +22,7 @@
#include "debug.h" #include "debug.h"
#include "Language.h" #include "Language.h"
#include "LyXRC.h"
#include "support/unicode.h" #include "support/unicode.h"
@ -44,12 +45,12 @@ namespace frontend {
namespace { namespace {
bool const usePixmapCache = USE_PIXMAP_CACHE;
} // anon namespace } // anon namespace
GuiPainter::GuiPainter(QPaintDevice * device) 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: // new QPainter has default QPen:
current_color_ = guiApp->colorCache().get(Color_black); current_color_ = guiApp->colorCache().get(Color_black);
@ -359,7 +360,7 @@ int GuiPainter::text(int x, int y, docstring const & s,
return textwidth; return textwidth;
} }
if (!usePixmapCache) { if (!use_pixmap_cache_) {
// don't use the pixmap cache, // don't use the pixmap cache,
// draw directly onto the painting device // draw directly onto the painting device
setQPainterPen(computeColor(f.realColor())); setQPainterPen(computeColor(f.realColor()));

View File

@ -117,6 +117,8 @@ private:
Painter::line_style current_ls_; Painter::line_style current_ls_;
Painter::line_width current_lw_; Painter::line_width current_lw_;
/// ///
bool const use_pixmap_cache_;
///
std::stack<QColor> monochrome_min_; std::stack<QColor> monochrome_min_;
/// ///
std::stack<QColor> monochrome_max_; std::stack<QColor> monochrome_max_;

View File

@ -1625,6 +1625,8 @@ PrefUserInterface::PrefUserInterface(GuiPreferences * form, QWidget * parent)
this, SIGNAL(changed())); this, SIGNAL(changed()));
connect(lastfilesSB, SIGNAL(valueChanged(int)), connect(lastfilesSB, SIGNAL(valueChanged(int)),
this, SIGNAL(changed())); this, SIGNAL(changed()));
connect(pixmapCacheCB, SIGNAL(toggled(bool)),
this, SIGNAL(changed()));
lastfilesSB->setMaximum(maxlastfiles); lastfilesSB->setMaximum(maxlastfiles);
} }
@ -1646,6 +1648,7 @@ void PrefUserInterface::apply(LyXRC & rc) const
rc.autosave = autoSaveSB->value() * 60; rc.autosave = autoSaveSB->value() * 60;
rc.make_backup = autoSaveCB->isChecked(); rc.make_backup = autoSaveCB->isChecked();
rc.num_lastfiles = lastfilesSB->value(); rc.num_lastfiles = lastfilesSB->value();
rc.use_pixmap_cache = pixmapCacheCB->isChecked();
} }
@ -1669,6 +1672,10 @@ void PrefUserInterface::update(LyXRC const & rc)
autoSaveSB->setValue(mins); autoSaveSB->setValue(mins);
autoSaveCB->setChecked(rc.make_backup); autoSaveCB->setChecked(rc.make_backup);
lastfilesSB->setValue(rc.num_lastfiles); lastfilesSB->setValue(rc.num_lastfiles);
pixmapCacheCB->setChecked(rc.use_pixmap_cache);
#if (QT_VERSION < 0x040200) || defined(Q_WS_X11)
pixmapCacheGB->setEnabled(false);
#endif
} }

View File

@ -6,13 +6,11 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>398</width> <width>398</width>
<height>418</height> <height>565</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy" > <property name="sizePolicy" >
<sizepolicy> <sizepolicy vsizetype="Minimum" hsizetype="Minimum" >
<hsizetype>1</hsizetype>
<vsizetype>1</vsizetype>
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
@ -21,148 +19,6 @@
<string/> <string/>
</property> </property>
<layout class="QGridLayout" > <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 &amp;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&amp;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>&amp;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" > <item row="0" column="0" >
<widget class="QLabel" name="uiFileLA" > <widget class="QLabel" name="uiFileLA" >
<property name="text" > <property name="text" >
@ -183,12 +39,10 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="0" colspan="3" > <item row="1" column="0" colspan="3" >
<widget class="QGroupBox" name="GeometryGB" > <widget class="QGroupBox" name="GeometryGB" >
<property name="sizePolicy" > <property name="sizePolicy" >
<sizepolicy> <sizepolicy vsizetype="Preferred" hsizetype="Preferred" >
<hsizetype>5</hsizetype>
<vsizetype>5</vsizetype>
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
@ -200,10 +54,22 @@
<bool>true</bool> <bool>true</bool>
</property> </property>
<layout class="QGridLayout" > <layout class="QGridLayout" >
<property name="margin" > <property name="leftMargin" >
<number>9</number> <number>9</number>
</property> </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> <number>6</number>
</property> </property>
<item row="0" column="0" colspan="2" > <item row="0" column="0" colspan="2" >
@ -258,12 +124,21 @@
</item> </item>
<item row="1" column="0" > <item row="1" column="0" >
<layout class="QHBoxLayout" > <layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </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> <item>
<spacer> <spacer>
<property name="orientation" > <property name="orientation" >
@ -295,12 +170,12 @@
<property name="enabled" > <property name="enabled" >
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="maximum" >
<number>9999</number>
</property>
<property name="minimum" > <property name="minimum" >
<number>200</number> <number>200</number>
</property> </property>
<property name="maximum" >
<number>9999</number>
</property>
<property name="singleStep" > <property name="singleStep" >
<number>10</number> <number>10</number>
</property> </property>
@ -321,12 +196,12 @@
<property name="enabled" > <property name="enabled" >
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="maximum" >
<number>9999</number>
</property>
<property name="minimum" > <property name="minimum" >
<number>200</number> <number>200</number>
</property> </property>
<property name="maximum" >
<number>9999</number>
</property>
<property name="singleStep" > <property name="singleStep" >
<number>10</number> <number>10</number>
</property> </property>
@ -353,6 +228,221 @@
</layout> </layout>
</widget> </widget>
</item> </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&amp;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>&amp;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 &amp;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>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">
p, li { white-space: pre-wrap; }
&lt;/style>&lt;/head>&lt;body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;">
&lt;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.&lt;/p>&lt;/body>&lt;/html></string>
</property>
<property name="text" >
<string>Enable Pi&amp;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> </layout>
</widget> </widget>
<tabstops> <tabstops>