2002-11-13 02:22:48 +00:00
|
|
|
/**
|
|
|
|
* \file QPrefs.C
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author John Levon
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2002-11-13 02:22:48 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2004-05-20 09:36:28 +00:00
|
|
|
#include "QPrefs.h"
|
2002-11-13 02:22:48 +00:00
|
|
|
#include "QPrefsDialog.h"
|
2004-05-20 09:36:28 +00:00
|
|
|
|
|
|
|
#include "lcolorcache.h"
|
|
|
|
#include "Qt2BC.h"
|
|
|
|
#include "qt_helpers.h"
|
|
|
|
|
2002-11-15 06:32:13 +00:00
|
|
|
#include "ui/QPrefAsciiModule.h"
|
|
|
|
#include "ui/QPrefDateModule.h"
|
|
|
|
#include "ui/QPrefKeyboardModule.h"
|
|
|
|
#include "ui/QPrefLatexModule.h"
|
|
|
|
#include "ui/QPrefScreenFontsModule.h"
|
|
|
|
#include "ui/QPrefColorsModule.h"
|
|
|
|
#include "ui/QPrefDisplayModule.h"
|
|
|
|
#include "ui/QPrefPathsModule.h"
|
|
|
|
#include "ui/QPrefSpellcheckerModule.h"
|
|
|
|
#include "ui/QPrefLanguageModule.h"
|
|
|
|
#include "ui/QPrefPrinterModule.h"
|
|
|
|
#include "ui/QPrefUIModule.h"
|
2003-02-09 00:11:51 +00:00
|
|
|
#include "ui/QPrefIdentityModule.h"
|
2004-05-20 09:36:28 +00:00
|
|
|
|
|
|
|
#include "debug.h"
|
|
|
|
#include "LColor.h"
|
2003-07-26 23:04:39 +00:00
|
|
|
#include "lyxfont.h"
|
2002-11-13 02:22:48 +00:00
|
|
|
|
2004-05-20 09:36:28 +00:00
|
|
|
#include "support/lstrings.h"
|
|
|
|
#include "support/tostr.h"
|
|
|
|
|
|
|
|
#include "controllers/ControlPrefs.h"
|
|
|
|
#include "controllers/frnt_lang.h"
|
|
|
|
#include "controllers/helper_funcs.h"
|
|
|
|
|
|
|
|
#include "frontends/lyx_gui.h"
|
2002-11-27 21:49:50 +00:00
|
|
|
|
2002-11-15 06:32:13 +00:00
|
|
|
#include <qcheckbox.h>
|
2004-05-20 09:36:28 +00:00
|
|
|
#include "qcoloritem.h"
|
2002-11-27 10:30:28 +00:00
|
|
|
#include <qcombobox.h>
|
2002-11-25 03:18:27 +00:00
|
|
|
#include <qlabel.h>
|
2004-05-20 09:36:28 +00:00
|
|
|
#include <qlineedit.h>
|
|
|
|
#include <qpushbutton.h>
|
|
|
|
#include <qspinbox.h>
|
2002-11-27 10:30:28 +00:00
|
|
|
|
2004-05-20 09:36:28 +00:00
|
|
|
#include <boost/tuple/tuple.hpp>
|
|
|
|
|
|
|
|
#include <iomanip>
|
2004-07-24 10:55:30 +00:00
|
|
|
#include <sstream>
|
2003-09-16 09:01:15 +00:00
|
|
|
|
2003-09-09 22:13:45 +00:00
|
|
|
using lyx::support::compare_no_case;
|
|
|
|
using lyx::support::strToDbl;
|
2003-06-30 23:56:22 +00:00
|
|
|
|
2004-01-28 16:21:29 +00:00
|
|
|
using std::distance;
|
2003-09-08 00:33:41 +00:00
|
|
|
using std::endl;
|
2002-11-17 09:42:25 +00:00
|
|
|
using std::setfill;
|
|
|
|
using std::setw;
|
2003-10-06 15:43:21 +00:00
|
|
|
using std::string;
|
2003-09-08 00:33:41 +00:00
|
|
|
using std::ostringstream;
|
|
|
|
using std::pair;
|
|
|
|
using std::vector;
|
2002-11-27 10:30:28 +00:00
|
|
|
|
2004-05-19 15:11:37 +00:00
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
2003-07-04 08:23:23 +00:00
|
|
|
|
2004-03-31 18:51:11 +00:00
|
|
|
typedef QController<ControlPrefs, QView<QPrefsDialog> > base_class;
|
2002-11-13 02:22:48 +00:00
|
|
|
|
2004-03-31 18:51:11 +00:00
|
|
|
QPrefs::QPrefs(Dialog & parent)
|
|
|
|
: base_class(parent, _("LyX: Preferences"))
|
2002-11-13 02:22:48 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-03-31 16:50:59 +00:00
|
|
|
Converters & QPrefs::converters()
|
|
|
|
{
|
|
|
|
return controller().converters();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Formats & QPrefs::formats()
|
|
|
|
{
|
|
|
|
return controller().formats();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-11-13 02:22:48 +00:00
|
|
|
void QPrefs::build_dialog()
|
|
|
|
{
|
|
|
|
dialog_.reset(new QPrefsDialog(this));
|
|
|
|
|
2003-03-10 03:13:28 +00:00
|
|
|
bcview().setOK(dialog_->savePB);
|
|
|
|
bcview().setApply(dialog_->applyPB);
|
|
|
|
bcview().setCancel(dialog_->closePB);
|
|
|
|
bcview().setRestore(dialog_->restorePB);
|
2002-11-27 10:30:28 +00:00
|
|
|
|
2002-11-17 05:37:27 +00:00
|
|
|
QPrefLanguageModule * langmod(dialog_->languageModule);
|
2002-11-27 10:30:28 +00:00
|
|
|
|
2002-11-17 05:37:27 +00:00
|
|
|
langmod->defaultLanguageCO->clear();
|
|
|
|
// store the lang identifiers for later
|
2004-05-19 15:11:37 +00:00
|
|
|
using lyx::frontend::LanguagePair;
|
|
|
|
vector<LanguagePair> const langs =
|
|
|
|
lyx::frontend::getLanguageData(false);
|
2002-11-17 05:37:27 +00:00
|
|
|
lang_ = getSecond(langs);
|
|
|
|
|
2004-05-19 15:11:37 +00:00
|
|
|
vector<LanguagePair>::const_iterator lit = langs.begin();
|
|
|
|
vector<LanguagePair>::const_iterator lend = langs.end();
|
2002-11-17 05:37:27 +00:00
|
|
|
for (; lit != lend; ++lit) {
|
2002-12-17 20:37:13 +00:00
|
|
|
langmod->defaultLanguageCO->insertItem(toqstr(lit->first));
|
2002-11-17 05:37:27 +00:00
|
|
|
}
|
2003-03-28 20:50:04 +00:00
|
|
|
|
|
|
|
QPrefSpellcheckerModule * spellmod(dialog_->spellcheckerModule);
|
|
|
|
spellmod->spellCommandCO->insertItem(qt_("ispell"));
|
|
|
|
spellmod->spellCommandCO->insertItem(qt_("aspell"));
|
|
|
|
spellmod->spellCommandCO->insertItem(qt_("hspell"));
|
|
|
|
#ifdef USE_PSPELL
|
|
|
|
spellmod->spellCommandCO->insertItem(qt_("pspell (library)"));
|
|
|
|
#else
|
|
|
|
#ifdef USE_ASPELL
|
|
|
|
spellmod->spellCommandCO->insertItem(qt_("aspell (library)"));
|
|
|
|
#endif
|
|
|
|
#endif
|
2002-11-13 02:22:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QPrefs::apply()
|
|
|
|
{
|
|
|
|
LyXRC & rc(controller().rc());
|
|
|
|
|
2002-11-17 05:37:27 +00:00
|
|
|
QPrefLanguageModule * langmod(dialog_->languageModule);
|
2002-11-27 10:30:28 +00:00
|
|
|
|
2002-11-17 05:37:27 +00:00
|
|
|
// FIXME: remove rtl_support bool
|
|
|
|
rc.rtl_support = langmod->rtlCB->isChecked();
|
2002-11-27 10:30:28 +00:00
|
|
|
rc.mark_foreign_language = langmod->markForeignCB->isChecked();
|
|
|
|
rc.language_auto_begin = langmod->autoBeginCB->isChecked();
|
|
|
|
rc.language_auto_end = langmod->autoEndCB->isChecked();
|
2002-11-17 05:37:27 +00:00
|
|
|
rc.language_use_babel = langmod->useBabelCB->isChecked();
|
|
|
|
rc.language_global_options = langmod->globalCB->isChecked();
|
2002-12-17 20:37:13 +00:00
|
|
|
rc.language_package = fromqstr(langmod->languagePackageED->text());
|
|
|
|
rc.language_command_begin = fromqstr(langmod->startCommandED->text());
|
|
|
|
rc.language_command_end = fromqstr(langmod->endCommandED->text());
|
2002-11-27 10:30:28 +00:00
|
|
|
rc.default_language = lang_[langmod->defaultLanguageCO->currentItem()];
|
2002-11-17 05:37:27 +00:00
|
|
|
|
2002-11-27 10:30:28 +00:00
|
|
|
QPrefUIModule * uimod(dialog_->uiModule);
|
2002-11-15 06:02:43 +00:00
|
|
|
|
2002-12-17 20:37:13 +00:00
|
|
|
rc.ui_file = fromqstr(uimod->uiFileED->text());
|
|
|
|
rc.bind_file = fromqstr(uimod->bindFileED->text());
|
2002-11-27 10:30:28 +00:00
|
|
|
rc.cursor_follows_scrollbar = uimod->cursorFollowsCB->isChecked();
|
2002-11-17 05:37:27 +00:00
|
|
|
rc.wheel_jump = uimod->wheelMouseSB->value();
|
|
|
|
rc.autosave = uimod->autoSaveSB->value() * 60;
|
|
|
|
rc.make_backup = uimod->autoSaveCB->isChecked();
|
|
|
|
rc.num_lastfiles = uimod->lastfilesSB->value();
|
2002-11-27 10:30:28 +00:00
|
|
|
|
|
|
|
|
2002-11-17 05:37:27 +00:00
|
|
|
QPrefKeyboardModule * keymod(dialog_->keyboardModule);
|
2002-11-15 06:02:43 +00:00
|
|
|
|
2002-11-27 10:30:28 +00:00
|
|
|
// FIXME: can derive CB from the two EDs
|
2002-11-17 05:37:27 +00:00
|
|
|
rc.use_kbmap = keymod->keymapCB->isChecked();
|
2002-12-17 20:37:13 +00:00
|
|
|
rc.primary_kbmap = fromqstr(keymod->firstKeymapED->text());
|
|
|
|
rc.secondary_kbmap = fromqstr(keymod->secondKeymapED->text());
|
2002-11-27 10:30:28 +00:00
|
|
|
|
2002-11-15 06:02:43 +00:00
|
|
|
|
2002-11-17 05:37:27 +00:00
|
|
|
QPrefAsciiModule * ascmod(dialog_->asciiModule);
|
2002-11-15 06:02:43 +00:00
|
|
|
|
2002-11-17 05:37:27 +00:00
|
|
|
rc.ascii_linelen = ascmod->asciiLinelengthSB->value();
|
2002-12-17 20:37:13 +00:00
|
|
|
rc.ascii_roff_command = fromqstr(ascmod->asciiRoffED->text());
|
2002-11-15 06:02:43 +00:00
|
|
|
|
|
|
|
|
2002-11-17 05:37:27 +00:00
|
|
|
QPrefDateModule * datemod(dialog_->dateModule);
|
|
|
|
|
2002-12-17 20:37:13 +00:00
|
|
|
rc.date_insert_format = fromqstr(datemod->DateED->text());
|
2002-11-15 06:02:43 +00:00
|
|
|
|
|
|
|
|
2002-11-17 05:37:27 +00:00
|
|
|
QPrefLatexModule * latexmod(dialog_->latexModule);
|
2002-11-15 06:02:43 +00:00
|
|
|
|
2002-12-17 20:37:13 +00:00
|
|
|
rc.fontenc = fromqstr(latexmod->latexEncodingED->text());
|
|
|
|
rc.chktex_command = fromqstr(latexmod->latexChecktexED->text());
|
2004-03-29 12:11:53 +00:00
|
|
|
rc.bibtex_command = fromqstr(latexmod->latexBibtexED->text());
|
2002-11-17 05:37:27 +00:00
|
|
|
rc.auto_reset_options = latexmod->latexAutoresetCB->isChecked();
|
2002-12-17 20:37:13 +00:00
|
|
|
rc.view_dvi_paper_option = fromqstr(latexmod->latexDviPaperED->text());
|
2002-11-17 05:37:27 +00:00
|
|
|
rc.default_papersize =
|
2003-07-26 23:04:39 +00:00
|
|
|
static_cast<PAPER_SIZE>(latexmod->latexPaperSizeCO->currentItem());
|
2002-11-17 05:37:27 +00:00
|
|
|
|
|
|
|
QPrefDisplayModule * displaymod(dialog_->displayModule);
|
|
|
|
|
2004-04-19 13:31:17 +00:00
|
|
|
switch (displaymod->instantPreviewCO->currentItem()) {
|
|
|
|
case 0:
|
|
|
|
rc.preview = LyXRC::PREVIEW_OFF;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
rc.preview = LyXRC::PREVIEW_NO_MATH;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
rc.preview = LyXRC::PREVIEW_ON;
|
|
|
|
break;
|
|
|
|
}
|
2004-04-20 08:51:15 +00:00
|
|
|
|
2003-07-21 21:30:57 +00:00
|
|
|
lyx::graphics::DisplayType dtype(lyx::graphics::ColorDisplay);
|
2002-11-27 10:30:28 +00:00
|
|
|
|
2002-11-17 05:37:27 +00:00
|
|
|
switch (displaymod->displayGraphicsCO->currentItem()) {
|
2004-04-19 13:31:17 +00:00
|
|
|
case 3: dtype = lyx::graphics::NoDisplay; break;
|
|
|
|
case 2: dtype = lyx::graphics::ColorDisplay; break;
|
|
|
|
case 1: dtype = lyx::graphics::GrayscaleDisplay; break;
|
|
|
|
case 0: dtype = lyx::graphics::MonochromeDisplay; break;
|
2002-11-15 06:02:43 +00:00
|
|
|
}
|
2002-11-17 05:37:27 +00:00
|
|
|
rc.display_graphics = dtype;
|
2002-11-27 10:30:28 +00:00
|
|
|
|
2002-11-15 06:02:43 +00:00
|
|
|
#ifdef WITH_WARNINGS
|
|
|
|
#warning FIXME!! The graphics cache no longer has a changeDisplay method.
|
|
|
|
#endif
|
|
|
|
#if 0
|
|
|
|
if (old_value != rc.display_graphics) {
|
2003-07-21 21:30:57 +00:00
|
|
|
lyx::graphics::GCache & gc = lyx::graphics::GCache::get();
|
2002-11-15 06:02:43 +00:00
|
|
|
gc.changeDisplay();
|
|
|
|
}
|
|
|
|
#endif
|
2002-11-27 10:30:28 +00:00
|
|
|
|
2002-11-17 05:37:27 +00:00
|
|
|
QPrefPathsModule * pathsmod(dialog_->pathsModule);
|
2002-11-27 10:30:28 +00:00
|
|
|
|
2002-12-17 20:37:13 +00:00
|
|
|
rc.document_path = fromqstr(pathsmod->workingDirED->text());
|
|
|
|
rc.template_path = fromqstr(pathsmod->templateDirED->text());
|
|
|
|
rc.backupdir_path = fromqstr(pathsmod->backupDirED->text());
|
|
|
|
rc.tempdir_path = fromqstr(pathsmod->tempDirED->text());
|
2002-11-17 05:37:27 +00:00
|
|
|
// FIXME: should be a checkbox only
|
2002-12-17 20:37:13 +00:00
|
|
|
rc.lyxpipes = fromqstr(pathsmod->lyxserverDirED->text());
|
2002-11-15 06:02:43 +00:00
|
|
|
|
|
|
|
|
2002-11-17 05:37:27 +00:00
|
|
|
QPrefSpellcheckerModule * spellmod(dialog_->spellcheckerModule);
|
2002-11-15 06:02:43 +00:00
|
|
|
|
2003-03-28 20:50:04 +00:00
|
|
|
switch (spellmod->spellCommandCO->currentItem()) {
|
|
|
|
case 0:
|
|
|
|
case 1:
|
|
|
|
case 2:
|
|
|
|
rc.use_spell_lib = false;
|
|
|
|
rc.isp_command = fromqstr(spellmod->spellCommandCO->currentText());
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
rc.use_spell_lib = true;
|
|
|
|
break;
|
|
|
|
}
|
2002-11-27 10:30:28 +00:00
|
|
|
|
2002-11-17 05:37:27 +00:00
|
|
|
// FIXME: remove isp_use_alt_lang
|
2002-12-17 20:37:13 +00:00
|
|
|
rc.isp_alt_lang = fromqstr(spellmod->altLanguageED->text());
|
2002-11-27 10:30:28 +00:00
|
|
|
rc.isp_use_alt_lang = !rc.isp_alt_lang.empty();
|
|
|
|
// FIXME: remove isp_use_esc_chars
|
2002-12-17 20:37:13 +00:00
|
|
|
rc.isp_esc_chars = fromqstr(spellmod->escapeCharactersED->text());
|
2002-11-17 05:37:27 +00:00
|
|
|
rc.isp_use_esc_chars = !rc.isp_esc_chars.empty();
|
2002-11-27 10:30:28 +00:00
|
|
|
// FIXME: remove isp_use_pers_dict
|
2002-12-17 20:37:13 +00:00
|
|
|
rc.isp_pers_dict = fromqstr(spellmod->persDictionaryED->text());
|
2002-11-17 05:37:27 +00:00
|
|
|
rc.isp_use_pers_dict = !rc.isp_pers_dict.empty();
|
|
|
|
rc.isp_accept_compound = spellmod->compoundWordCB->isChecked();
|
|
|
|
rc.isp_use_input_encoding = spellmod->inputEncodingCB->isChecked();
|
|
|
|
|
|
|
|
|
|
|
|
QPrefPrinterModule * printmod(dialog_->printerModule);
|
|
|
|
|
|
|
|
rc.print_adapt_output = printmod->printerAdaptCB->isChecked();
|
2002-12-17 20:37:13 +00:00
|
|
|
rc.print_command = fromqstr(printmod->printerCommandED->text());
|
|
|
|
rc.printer = fromqstr(printmod->printerNameED->text());
|
|
|
|
|
|
|
|
rc.print_pagerange_flag = fromqstr(printmod->printerPageRangeED->text());
|
|
|
|
rc.print_copies_flag = fromqstr(printmod->printerCopiesED->text());
|
|
|
|
rc.print_reverse_flag = fromqstr(printmod->printerReverseED->text());
|
|
|
|
rc.print_to_printer = fromqstr(printmod->printerToPrinterED->text());
|
|
|
|
rc.print_file_extension = fromqstr(printmod->printerExtensionED->text());
|
2003-02-15 19:52:37 +00:00
|
|
|
rc.print_spool_command = fromqstr(printmod->printerSpoolCommandED->text());
|
2002-12-17 20:37:13 +00:00
|
|
|
rc.print_paper_flag = fromqstr(printmod->printerPaperTypeED->text());
|
|
|
|
rc.print_evenpage_flag = fromqstr(printmod->printerEvenED->text());
|
|
|
|
rc.print_oddpage_flag = fromqstr(printmod->printerOddED->text());
|
|
|
|
rc.print_collcopies_flag = fromqstr(printmod->printerCollatedED->text());
|
|
|
|
rc.print_landscape_flag = fromqstr(printmod->printerLandscapeED->text());
|
|
|
|
rc.print_to_file = fromqstr(printmod->printerToFileED->text());
|
|
|
|
rc.print_extra_options = fromqstr(printmod->printerExtraED->text());
|
|
|
|
rc.print_spool_printerprefix = fromqstr(printmod->printerSpoolPrefixED->text());
|
|
|
|
rc.print_paper_dimension_flag = fromqstr(printmod->printerPaperSizeED->text());
|
2002-11-17 05:37:27 +00:00
|
|
|
|
|
|
|
|
2003-02-09 00:11:51 +00:00
|
|
|
QPrefIdentityModule * idmod(dialog_->identityModule);
|
|
|
|
rc.user_name = fromqstr(idmod->nameED->text());
|
|
|
|
rc.user_email = fromqstr(idmod->emailED->text());
|
|
|
|
|
2002-11-17 05:37:27 +00:00
|
|
|
QPrefScreenFontsModule * fontmod(dialog_->screenfontsModule);
|
|
|
|
|
|
|
|
LyXRC const oldrc(rc);
|
2002-12-01 22:59:25 +00:00
|
|
|
|
2002-11-27 21:49:50 +00:00
|
|
|
boost::tie(rc.roman_font_name, rc.roman_font_foundry)
|
2002-12-17 20:37:13 +00:00
|
|
|
= parseFontName(fromqstr(fontmod->screenRomanCO->currentText()));
|
2002-12-01 22:59:25 +00:00
|
|
|
boost::tie(rc.sans_font_name, rc.sans_font_foundry) =
|
2002-12-17 20:37:13 +00:00
|
|
|
parseFontName(fromqstr(fontmod->screenSansCO->currentText()));
|
2002-11-27 21:49:50 +00:00
|
|
|
boost::tie(rc.typewriter_font_name, rc.typewriter_font_foundry) =
|
2002-12-17 20:37:13 +00:00
|
|
|
parseFontName(fromqstr(fontmod->screenTypewriterCO->currentText()));
|
2002-11-27 10:30:28 +00:00
|
|
|
|
2002-11-17 05:37:27 +00:00
|
|
|
rc.zoom = fontmod->screenZoomSB->value();
|
|
|
|
rc.dpi = fontmod->screenDpiSB->value();
|
2002-12-17 20:37:13 +00:00
|
|
|
rc.font_sizes[LyXFont::SIZE_TINY] = strToDbl(fromqstr(fontmod->screenTinyED->text()));
|
|
|
|
rc.font_sizes[LyXFont::SIZE_SCRIPT] = strToDbl(fromqstr(fontmod->screenSmallestED->text()));
|
|
|
|
rc.font_sizes[LyXFont::SIZE_FOOTNOTE] = strToDbl(fromqstr(fontmod->screenSmallerED->text()));
|
|
|
|
rc.font_sizes[LyXFont::SIZE_SMALL] = strToDbl(fromqstr(fontmod->screenSmallED->text()));
|
|
|
|
rc.font_sizes[LyXFont::SIZE_NORMAL] = strToDbl(fromqstr(fontmod->screenNormalED->text()));
|
|
|
|
rc.font_sizes[LyXFont::SIZE_LARGE] = strToDbl(fromqstr(fontmod->screenLargeED->text()));
|
|
|
|
rc.font_sizes[LyXFont::SIZE_LARGER] = strToDbl(fromqstr(fontmod->screenLargerED->text()));
|
|
|
|
rc.font_sizes[LyXFont::SIZE_LARGEST] = strToDbl(fromqstr(fontmod->screenLargestED->text()));
|
|
|
|
rc.font_sizes[LyXFont::SIZE_HUGE] = strToDbl(fromqstr(fontmod->screenHugeED->text()));
|
|
|
|
rc.font_sizes[LyXFont::SIZE_HUGER] = strToDbl(fromqstr(fontmod->screenHugerED->text()));
|
2002-11-17 05:37:27 +00:00
|
|
|
|
|
|
|
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.zoom != oldrc.zoom || rc.dpi != oldrc.dpi) {
|
|
|
|
controller().updateScreenFonts();
|
2002-11-15 06:02:43 +00:00
|
|
|
}
|
2002-11-27 10:30:28 +00:00
|
|
|
|
2002-11-17 09:42:25 +00:00
|
|
|
QPrefColorsModule * colmod(dialog_->colorsModule);
|
2002-11-27 10:30:28 +00:00
|
|
|
|
2002-11-17 09:42:25 +00:00
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
for (i = 0; i < colmod->lyxObjectsLB->count(); ++i) {
|
|
|
|
QListBoxItem * ib(colmod->lyxObjectsLB->item(i));
|
|
|
|
QColorItem * ci(static_cast<QColorItem*>(ib));
|
|
|
|
|
2003-04-30 15:11:25 +00:00
|
|
|
LColor::color const col(dialog_->colors_[i]);
|
2003-05-24 15:19:05 +00:00
|
|
|
QColor const & qcol(lcolorcache.get(col));
|
2002-11-17 09:42:25 +00:00
|
|
|
|
|
|
|
// FIXME: dubious, but it's what xforms does
|
2003-04-30 15:11:25 +00:00
|
|
|
if (qcol != ci->color()) {
|
|
|
|
ostringstream ostr;
|
2003-06-30 23:56:22 +00:00
|
|
|
|
2003-04-30 15:11:25 +00:00
|
|
|
ostr << '#' << std::setbase(16) << setfill('0')
|
|
|
|
<< setw(2) << ci->color().red()
|
|
|
|
<< setw(2) << ci->color().green()
|
|
|
|
<< setw(2) << ci->color().blue();
|
|
|
|
|
2003-09-15 12:00:03 +00:00
|
|
|
string newhex(ostr.str());
|
2002-11-17 09:42:25 +00:00
|
|
|
controller().setColor(col, newhex);
|
|
|
|
}
|
|
|
|
}
|
2002-11-17 05:37:27 +00:00
|
|
|
}
|
2002-11-15 06:02:43 +00:00
|
|
|
|
2002-11-17 05:37:27 +00:00
|
|
|
|
2002-11-27 10:30:28 +00:00
|
|
|
// FIXME: move to helper_funcs.h
|
2002-11-17 05:37:27 +00:00
|
|
|
namespace {
|
2002-11-27 10:30:28 +00:00
|
|
|
|
2002-11-17 05:37:27 +00:00
|
|
|
template<class A>
|
|
|
|
typename std::vector<A>::size_type
|
|
|
|
findPos(std::vector<A> const & vec, A const & val)
|
|
|
|
{
|
2004-01-28 16:21:29 +00:00
|
|
|
typedef typename std::vector<A>::const_iterator Cit;
|
|
|
|
|
|
|
|
Cit it = std::find(vec.begin(), vec.end(), val);
|
2002-11-17 05:37:27 +00:00
|
|
|
if (it == vec.end())
|
|
|
|
return 0;
|
2004-01-28 16:21:29 +00:00
|
|
|
return distance(vec.begin(), it);
|
2002-11-13 02:22:48 +00:00
|
|
|
}
|
|
|
|
|
2003-04-14 19:12:25 +00:00
|
|
|
void setComboxFont(QComboBox * cb, string const & family, string const & foundry)
|
2002-11-27 21:49:50 +00:00
|
|
|
{
|
|
|
|
string const name = makeFontName(family, foundry);
|
|
|
|
for (int i = 0; i < cb->count(); ++i) {
|
2002-12-17 20:37:13 +00:00
|
|
|
if (fromqstr(cb->text(i)) == name) {
|
2002-11-27 21:49:50 +00:00
|
|
|
cb->setCurrentItem(i);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-07-23 23:13:53 +00:00
|
|
|
// Try matching without foundry name
|
2002-12-19 03:22:33 +00:00
|
|
|
|
|
|
|
// We count in reverse in order to prefer the Xft foundry
|
2002-11-27 21:49:50 +00:00
|
|
|
for (int i = cb->count() - 1; i >= 0; --i) {
|
2002-12-17 20:37:13 +00:00
|
|
|
pair<string, string> tmp = parseFontName(fromqstr(cb->text(i)));
|
2002-11-27 21:49:50 +00:00
|
|
|
if (compare_no_case(tmp.first, family) == 0) {
|
|
|
|
cb->setCurrentItem(i);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-07-23 23:13:53 +00:00
|
|
|
// family alone can contain e.g. "Helvetica [Adobe]"
|
|
|
|
pair<string, string> tmpfam = parseFontName(family);
|
|
|
|
|
|
|
|
// We count in reverse in order to prefer the Xft foundry
|
|
|
|
for (int i = cb->count() - 1; i >= 0; --i) {
|
|
|
|
pair<string, string> tmp = parseFontName(fromqstr(cb->text(i)));
|
|
|
|
if (compare_no_case(tmp.first, tmpfam.first) == 0) {
|
|
|
|
cb->setCurrentItem(i);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-04-22 23:25:27 +00:00
|
|
|
// Bleh, default fonts, and the names couldn't be found. Hack
|
|
|
|
// for bug 1063. Qt makes baby Jesus cry.
|
2003-06-30 23:56:22 +00:00
|
|
|
|
2003-04-22 23:25:27 +00:00
|
|
|
QFont font;
|
|
|
|
|
|
|
|
if (family == lyx_gui::roman_font_name()) {
|
|
|
|
font.setStyleHint(QFont::Serif);
|
|
|
|
font.setFamily(lyx_gui::roman_font_name().c_str());
|
|
|
|
} else if (family == lyx_gui::sans_font_name()) {
|
|
|
|
font.setStyleHint(QFont::SansSerif);
|
|
|
|
font.setFamily(lyx_gui::sans_font_name().c_str());
|
|
|
|
} else if (family == lyx_gui::typewriter_font_name()) {
|
|
|
|
font.setStyleHint(QFont::TypeWriter);
|
|
|
|
font.setFamily(lyx_gui::typewriter_font_name().c_str());
|
|
|
|
} else {
|
|
|
|
lyxerr << "FAILED to find the default font !"
|
|
|
|
<< foundry << ", " << family << endl;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
QFontInfo info(font);
|
|
|
|
lyxerr << "Apparent font is " << info.family() << endl;
|
|
|
|
|
|
|
|
for (int i = 0; i < cb->count(); ++i) {
|
|
|
|
lyxerr << "Looking at " << fromqstr(cb->text(i)) << endl;
|
|
|
|
if (compare_no_case(cb->text(i).latin1(), info.family().latin1()) == 0) {
|
|
|
|
cb->setCurrentItem(i);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
lyxerr << "FAILED to find the font !"
|
|
|
|
<< foundry << ", " << family << endl;
|
2002-11-17 05:37:27 +00:00
|
|
|
}
|
2002-11-13 02:22:48 +00:00
|
|
|
|
2003-04-22 23:25:27 +00:00
|
|
|
} // end namespace anon
|
|
|
|
|
|
|
|
|
2002-11-13 02:22:48 +00:00
|
|
|
void QPrefs::update_contents()
|
|
|
|
{
|
|
|
|
LyXRC const & rc(controller().rc());
|
|
|
|
|
2002-11-15 06:32:13 +00:00
|
|
|
QPrefLanguageModule * langmod(dialog_->languageModule);
|
2002-11-27 10:30:28 +00:00
|
|
|
|
2002-11-15 06:32:13 +00:00
|
|
|
// FIXME: remove rtl_support bool
|
|
|
|
langmod->rtlCB->setChecked(rc.rtl_support);
|
2002-11-27 10:30:28 +00:00
|
|
|
langmod->markForeignCB->setChecked(rc.mark_foreign_language);
|
|
|
|
langmod->autoBeginCB->setChecked(rc.language_auto_begin);
|
|
|
|
langmod->autoEndCB->setChecked(rc.language_auto_end);
|
2002-11-15 06:32:13 +00:00
|
|
|
langmod->useBabelCB->setChecked(rc.language_use_babel);
|
|
|
|
langmod->globalCB->setChecked(rc.language_global_options);
|
2002-12-17 20:37:13 +00:00
|
|
|
langmod->languagePackageED->setText(toqstr(rc.language_package));
|
|
|
|
langmod->startCommandED->setText(toqstr(rc.language_command_begin));
|
|
|
|
langmod->endCommandED->setText(toqstr(rc.language_command_end));
|
2002-11-15 06:32:13 +00:00
|
|
|
|
2002-11-17 05:37:27 +00:00
|
|
|
int const pos = int(findPos(lang_, rc.default_language));
|
|
|
|
langmod->defaultLanguageCO->setCurrentItem(pos);
|
2002-11-15 06:32:13 +00:00
|
|
|
|
2002-11-27 10:30:28 +00:00
|
|
|
QPrefUIModule * uimod(dialog_->uiModule);
|
2002-11-15 06:32:13 +00:00
|
|
|
|
2002-12-17 20:37:13 +00:00
|
|
|
uimod->uiFileED->setText(toqstr(rc.ui_file));
|
|
|
|
uimod->bindFileED->setText(toqstr(rc.bind_file));
|
2002-11-27 10:30:28 +00:00
|
|
|
uimod->cursorFollowsCB->setChecked(rc.cursor_follows_scrollbar);
|
2002-11-15 06:32:13 +00:00
|
|
|
uimod->wheelMouseSB->setValue(rc.wheel_jump);
|
|
|
|
// convert to minutes
|
2002-11-15 06:39:14 +00:00
|
|
|
int mins(rc.autosave / 60);
|
|
|
|
if (rc.autosave && !mins)
|
2002-11-15 06:32:13 +00:00
|
|
|
mins = 1;
|
|
|
|
uimod->autoSaveSB->setValue(mins);
|
2002-11-17 03:35:02 +00:00
|
|
|
uimod->autoSaveCB->setChecked(rc.make_backup);
|
2002-11-17 05:37:27 +00:00
|
|
|
uimod->lastfilesSB->setValue(rc.num_lastfiles);
|
2002-11-27 10:30:28 +00:00
|
|
|
|
|
|
|
|
2003-02-09 00:11:51 +00:00
|
|
|
QPrefIdentityModule * idmod(dialog_->identityModule);
|
|
|
|
idmod->nameED->setText(toqstr(rc.user_name));
|
|
|
|
idmod->emailED->setText(toqstr(rc.user_email));
|
2003-02-25 13:35:26 +00:00
|
|
|
|
2003-02-09 00:11:51 +00:00
|
|
|
|
2002-11-15 06:32:13 +00:00
|
|
|
QPrefKeyboardModule * keymod(dialog_->keyboardModule);
|
|
|
|
|
2002-11-27 10:30:28 +00:00
|
|
|
// FIXME: can derive CB from the two EDs
|
2002-11-15 06:32:13 +00:00
|
|
|
keymod->keymapCB->setChecked(rc.use_kbmap);
|
2002-11-25 03:18:27 +00:00
|
|
|
// no idea why we need these. Fscking Qt.
|
|
|
|
keymod->firstKeymapED->setEnabled(rc.use_kbmap);
|
|
|
|
keymod->firstKeymapPB->setEnabled(rc.use_kbmap);
|
|
|
|
keymod->firstKeymapLA->setEnabled(rc.use_kbmap);
|
|
|
|
keymod->secondKeymapED->setEnabled(rc.use_kbmap);
|
|
|
|
keymod->secondKeymapPB->setEnabled(rc.use_kbmap);
|
|
|
|
keymod->secondKeymapLA->setEnabled(rc.use_kbmap);
|
2002-12-17 20:37:13 +00:00
|
|
|
keymod->firstKeymapED->setText(toqstr(rc.primary_kbmap));
|
|
|
|
keymod->secondKeymapED->setText(toqstr(rc.secondary_kbmap));
|
2002-11-27 10:30:28 +00:00
|
|
|
|
2002-11-15 06:32:13 +00:00
|
|
|
|
|
|
|
QPrefAsciiModule * ascmod(dialog_->asciiModule);
|
|
|
|
|
|
|
|
ascmod->asciiLinelengthSB->setValue(rc.ascii_linelen);
|
2002-12-17 20:37:13 +00:00
|
|
|
ascmod->asciiRoffED->setText(toqstr(rc.ascii_roff_command));
|
2002-11-15 06:32:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
QPrefDateModule * datemod(dialog_->dateModule);
|
|
|
|
|
2002-12-17 20:37:13 +00:00
|
|
|
datemod->DateED->setText(toqstr(rc.date_insert_format));
|
2002-11-15 06:32:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
QPrefLatexModule * latexmod(dialog_->latexModule);
|
|
|
|
|
2002-12-17 20:37:13 +00:00
|
|
|
latexmod->latexEncodingED->setText(toqstr(rc.fontenc));
|
|
|
|
latexmod->latexChecktexED->setText(toqstr(rc.chktex_command));
|
2004-03-29 12:11:53 +00:00
|
|
|
latexmod->latexBibtexED->setText(toqstr(rc.bibtex_command));
|
2002-11-15 06:32:13 +00:00
|
|
|
latexmod->latexAutoresetCB->setChecked(rc.auto_reset_options);
|
2002-12-17 20:37:13 +00:00
|
|
|
latexmod->latexDviPaperED->setText(toqstr(rc.view_dvi_paper_option));
|
2002-11-17 05:37:27 +00:00
|
|
|
latexmod->latexPaperSizeCO->setCurrentItem(rc.default_papersize);
|
2002-11-15 06:32:13 +00:00
|
|
|
|
2002-11-17 03:35:02 +00:00
|
|
|
|
|
|
|
QPrefDisplayModule * displaymod(dialog_->displayModule);
|
|
|
|
|
2004-04-19 13:31:17 +00:00
|
|
|
switch (rc.preview) {
|
|
|
|
case LyXRC::PREVIEW_OFF:
|
|
|
|
displaymod->instantPreviewCO->setCurrentItem(0);
|
|
|
|
break;
|
|
|
|
case LyXRC::PREVIEW_NO_MATH :
|
|
|
|
displaymod->instantPreviewCO->setCurrentItem(1);
|
|
|
|
break;
|
|
|
|
case LyXRC::PREVIEW_ON :
|
|
|
|
displaymod->instantPreviewCO->setCurrentItem(2);
|
|
|
|
break;
|
|
|
|
}
|
2004-04-20 08:51:15 +00:00
|
|
|
|
2002-11-17 03:35:02 +00:00
|
|
|
int item = 2;
|
2002-11-27 10:30:28 +00:00
|
|
|
|
2002-11-17 03:35:02 +00:00
|
|
|
switch (rc.display_graphics) {
|
2003-07-21 21:30:57 +00:00
|
|
|
case lyx::graphics::NoDisplay: item = 3; break;
|
|
|
|
case lyx::graphics::ColorDisplay: item = 2; break;
|
|
|
|
case lyx::graphics::GrayscaleDisplay: item = 1; break;
|
|
|
|
case lyx::graphics::MonochromeDisplay: item = 0; break;
|
2002-12-19 03:22:33 +00:00
|
|
|
default: break;
|
2002-11-17 03:35:02 +00:00
|
|
|
}
|
|
|
|
displaymod->displayGraphicsCO->setCurrentItem(item);
|
2002-11-27 10:30:28 +00:00
|
|
|
|
2002-11-17 03:35:02 +00:00
|
|
|
|
|
|
|
QPrefPathsModule * pathsmod(dialog_->pathsModule);
|
2002-11-27 10:30:28 +00:00
|
|
|
|
2002-12-17 20:37:13 +00:00
|
|
|
pathsmod->workingDirED->setText(toqstr(rc.document_path));
|
|
|
|
pathsmod->templateDirED->setText(toqstr(rc.template_path));
|
|
|
|
pathsmod->backupDirED->setText(toqstr(rc.backupdir_path));
|
|
|
|
pathsmod->tempDirED->setText(toqstr(rc.tempdir_path));
|
2002-11-17 03:35:02 +00:00
|
|
|
// FIXME: should be a checkbox only
|
2002-12-17 20:37:13 +00:00
|
|
|
pathsmod->lyxserverDirED->setText(toqstr(rc.lyxpipes));
|
2002-11-17 03:35:02 +00:00
|
|
|
|
2002-11-15 06:02:43 +00:00
|
|
|
|
2002-11-17 05:37:27 +00:00
|
|
|
QPrefSpellcheckerModule * spellmod(dialog_->spellcheckerModule);
|
|
|
|
|
2003-03-28 20:50:04 +00:00
|
|
|
spellmod->spellCommandCO->setCurrentItem(0);
|
|
|
|
|
|
|
|
if (rc.isp_command == "ispell") {
|
|
|
|
spellmod->spellCommandCO->setCurrentItem(0);
|
|
|
|
} else if (rc.isp_command == "aspell") {
|
|
|
|
spellmod->spellCommandCO->setCurrentItem(1);
|
|
|
|
} else if (rc.isp_command == "hspell") {
|
|
|
|
spellmod->spellCommandCO->setCurrentItem(2);
|
2003-03-07 18:06:56 +00:00
|
|
|
}
|
2003-06-30 23:56:22 +00:00
|
|
|
|
2003-03-28 20:50:04 +00:00
|
|
|
if (rc.use_spell_lib) {
|
|
|
|
#if defined(USE_ASPELL) || defined(USE_PSPELL)
|
|
|
|
spellmod->spellCommandCO->setCurrentItem(3);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2002-11-17 05:37:27 +00:00
|
|
|
// FIXME: remove isp_use_alt_lang
|
2002-12-17 20:37:13 +00:00
|
|
|
spellmod->altLanguageED->setText(toqstr(rc.isp_alt_lang));
|
2002-11-27 10:30:28 +00:00
|
|
|
// FIXME: remove isp_use_esc_chars
|
2002-12-17 20:37:13 +00:00
|
|
|
spellmod->escapeCharactersED->setText(toqstr(rc.isp_esc_chars));
|
2002-11-27 10:30:28 +00:00
|
|
|
// FIXME: remove isp_use_pers_dict
|
2002-12-17 20:37:13 +00:00
|
|
|
spellmod->persDictionaryED->setText(toqstr(rc.isp_pers_dict));
|
2002-11-17 05:37:27 +00:00
|
|
|
spellmod->compoundWordCB->setChecked(rc.isp_accept_compound);
|
|
|
|
spellmod->inputEncodingCB->setChecked(rc.isp_use_input_encoding);
|
|
|
|
|
|
|
|
|
|
|
|
QPrefPrinterModule * printmod(dialog_->printerModule);
|
|
|
|
|
|
|
|
printmod->printerAdaptCB->setChecked(rc.print_adapt_output);
|
2002-12-17 20:37:13 +00:00
|
|
|
printmod->printerCommandED->setText(toqstr(rc.print_command));
|
|
|
|
printmod->printerNameED->setText(toqstr(rc.printer));
|
|
|
|
|
|
|
|
printmod->printerPageRangeED->setText(toqstr(rc.print_pagerange_flag));
|
|
|
|
printmod->printerCopiesED->setText(toqstr(rc.print_copies_flag));
|
|
|
|
printmod->printerReverseED->setText(toqstr(rc.print_reverse_flag));
|
|
|
|
printmod->printerToPrinterED->setText(toqstr(rc.print_to_printer));
|
|
|
|
printmod->printerExtensionED->setText(toqstr(rc.print_file_extension));
|
2003-02-15 19:52:37 +00:00
|
|
|
printmod->printerSpoolCommandED->setText(toqstr(rc.print_spool_command));
|
2002-12-17 20:37:13 +00:00
|
|
|
printmod->printerPaperTypeED->setText(toqstr(rc.print_paper_flag));
|
|
|
|
printmod->printerEvenED->setText(toqstr(rc.print_evenpage_flag));
|
|
|
|
printmod->printerOddED->setText(toqstr(rc.print_oddpage_flag));
|
|
|
|
printmod->printerCollatedED->setText(toqstr(rc.print_collcopies_flag));
|
|
|
|
printmod->printerLandscapeED->setText(toqstr(rc.print_landscape_flag));
|
|
|
|
printmod->printerToFileED->setText(toqstr(rc.print_to_file));
|
|
|
|
printmod->printerExtraED->setText(toqstr(rc.print_extra_options));
|
|
|
|
printmod->printerSpoolPrefixED->setText(toqstr(rc.print_spool_printerprefix));
|
|
|
|
printmod->printerPaperSizeED->setText(toqstr(rc.print_paper_dimension_flag));
|
2002-11-17 05:37:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
QPrefScreenFontsModule * fontmod(dialog_->screenfontsModule);
|
|
|
|
|
2002-12-19 03:22:33 +00:00
|
|
|
setComboxFont(fontmod->screenRomanCO, rc.roman_font_name,
|
2003-04-14 19:12:25 +00:00
|
|
|
rc.roman_font_foundry);
|
2002-12-19 03:22:33 +00:00
|
|
|
setComboxFont(fontmod->screenSansCO, rc.sans_font_name,
|
2003-04-14 19:12:25 +00:00
|
|
|
rc.sans_font_foundry);
|
2002-12-19 03:22:33 +00:00
|
|
|
setComboxFont(fontmod->screenTypewriterCO, rc.typewriter_font_name,
|
2003-04-14 19:12:25 +00:00
|
|
|
rc.typewriter_font_foundry);
|
2002-11-27 21:49:50 +00:00
|
|
|
|
|
|
|
dialog_->select_roman(fontmod->screenRomanCO->currentText());
|
|
|
|
dialog_->select_sans(fontmod->screenSansCO->currentText());
|
|
|
|
dialog_->select_typewriter(fontmod->screenTypewriterCO->currentText());
|
2002-12-01 22:59:25 +00:00
|
|
|
|
2002-11-17 05:37:27 +00:00
|
|
|
fontmod->screenZoomSB->setValue(rc.zoom);
|
|
|
|
fontmod->screenDpiSB->setValue(int(rc.dpi));
|
2002-12-17 20:37:13 +00:00
|
|
|
fontmod->screenTinyED->setText(toqstr(tostr(rc.font_sizes[LyXFont::SIZE_TINY])));
|
|
|
|
fontmod->screenSmallestED->setText(toqstr(tostr(rc.font_sizes[LyXFont::SIZE_SCRIPT])));
|
|
|
|
fontmod->screenSmallerED->setText(toqstr(tostr(rc.font_sizes[LyXFont::SIZE_FOOTNOTE])));
|
|
|
|
fontmod->screenSmallED->setText(toqstr(tostr(rc.font_sizes[LyXFont::SIZE_SMALL])));
|
|
|
|
fontmod->screenNormalED->setText(toqstr(tostr(rc.font_sizes[LyXFont::SIZE_NORMAL])));
|
|
|
|
fontmod->screenLargeED->setText(toqstr(tostr(rc.font_sizes[LyXFont::SIZE_LARGE])));
|
|
|
|
fontmod->screenLargerED->setText(toqstr(tostr(rc.font_sizes[LyXFont::SIZE_LARGER])));
|
|
|
|
fontmod->screenLargestED->setText(toqstr(tostr(rc.font_sizes[LyXFont::SIZE_LARGEST])));
|
|
|
|
fontmod->screenHugeED->setText(toqstr(tostr(rc.font_sizes[LyXFont::SIZE_HUGE])));
|
|
|
|
fontmod->screenHugerED->setText(toqstr(tostr(rc.font_sizes[LyXFont::SIZE_HUGER])));
|
2002-11-17 05:37:27 +00:00
|
|
|
|
2002-11-17 07:11:02 +00:00
|
|
|
dialog_->updateFormats();
|
2002-11-27 10:30:28 +00:00
|
|
|
|
2002-11-17 07:11:02 +00:00
|
|
|
dialog_->updateConverters();
|
2002-11-13 02:22:48 +00:00
|
|
|
}
|
2004-05-19 15:11:37 +00:00
|
|
|
|
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|