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
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
|
2002-11-15 06:32:13 +00:00
|
|
|
#include "support/lstrings.h"
|
2002-11-17 09:42:25 +00:00
|
|
|
#include "Lsstream.h"
|
|
|
|
#include <iomanip>
|
2002-11-27 10:30:28 +00:00
|
|
|
|
2002-11-13 02:22:48 +00:00
|
|
|
#include "ControlPrefs.h"
|
|
|
|
#include "QPrefsDialog.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/QPrefConvertersModule.h"
|
|
|
|
#include "ui/QPrefFileformatsModule.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"
|
2002-11-13 02:22:48 +00:00
|
|
|
#include "QPrefs.h"
|
|
|
|
#include "Qt2BC.h"
|
|
|
|
#include "lyxrc.h"
|
2002-11-17 05:37:27 +00:00
|
|
|
#include "frnt_lang.h"
|
|
|
|
#include "helper_funcs.h"
|
2002-11-27 21:49:50 +00:00
|
|
|
#include "qt_helpers.h"
|
2002-11-17 09:42:25 +00:00
|
|
|
#include "debug.h"
|
2002-11-13 02:22:48 +00:00
|
|
|
|
2002-11-27 21:49:50 +00:00
|
|
|
#include <boost/tuple/tuple.hpp>
|
|
|
|
|
2002-11-13 02:22:48 +00:00
|
|
|
#include <qpushbutton.h>
|
2002-11-15 06:32:13 +00:00
|
|
|
#include <qcheckbox.h>
|
|
|
|
#include <qlineedit.h>
|
|
|
|
#include <qspinbox.h>
|
2002-11-27 10:30:28 +00:00
|
|
|
#include <qcombobox.h>
|
2002-11-17 07:11:02 +00:00
|
|
|
#include <qlistbox.h>
|
2002-11-25 03:18:27 +00:00
|
|
|
#include <qlabel.h>
|
2002-11-17 09:42:25 +00:00
|
|
|
#include "qcoloritem.h"
|
2002-11-27 10:30:28 +00:00
|
|
|
|
2002-11-17 08:40:04 +00:00
|
|
|
using std::vector;
|
2002-11-27 21:49:50 +00:00
|
|
|
using std::pair;
|
2002-11-17 09:42:25 +00:00
|
|
|
using std::ostringstream;
|
|
|
|
using std::setfill;
|
|
|
|
using std::setw;
|
|
|
|
using std::endl;
|
2002-11-27 10:30:28 +00:00
|
|
|
|
2002-11-13 02:22:48 +00:00
|
|
|
typedef Qt2CB<ControlPrefs, Qt2DB<QPrefsDialog> > base_class;
|
|
|
|
|
|
|
|
|
|
|
|
QPrefs::QPrefs()
|
2002-12-17 20:37:13 +00:00
|
|
|
: base_class(qt_("LyX: Preferences"))
|
2002-11-13 02:22:48 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QPrefs::build_dialog()
|
|
|
|
{
|
|
|
|
dialog_.reset(new QPrefsDialog(this));
|
|
|
|
|
|
|
|
bc().setOK(dialog_->savePB);
|
|
|
|
bc().setApply(dialog_->applyPB);
|
|
|
|
bc().setCancel(dialog_->closePB);
|
|
|
|
bc().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
|
|
|
|
vector<frnt::LanguagePair> const langs = frnt::getLanguageData(false);
|
|
|
|
lang_ = getSecond(langs);
|
|
|
|
|
|
|
|
vector<frnt::LanguagePair>::const_iterator lit = langs.begin();
|
|
|
|
vector<frnt::LanguagePair>::const_iterator lend = langs.end();
|
|
|
|
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
|
|
|
}
|
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());
|
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 =
|
|
|
|
static_cast<BufferParams::PAPER_SIZE>(latexmod->latexPaperSizeCO->currentItem());
|
2002-11-15 06:02:43 +00:00
|
|
|
|
2002-11-17 05:37:27 +00:00
|
|
|
|
|
|
|
QPrefDisplayModule * displaymod(dialog_->displayModule);
|
|
|
|
|
|
|
|
rc.preview = displaymod->previewCB->isChecked();
|
2002-11-27 10:30:28 +00:00
|
|
|
|
2002-11-17 05:37:27 +00:00
|
|
|
grfx::DisplayType dtype(grfx::ColorDisplay);
|
2002-11-27 10:30:28 +00:00
|
|
|
|
2002-11-17 05:37:27 +00:00
|
|
|
switch (displaymod->displayGraphicsCO->currentItem()) {
|
|
|
|
case 3: dtype = grfx::NoDisplay; break;
|
|
|
|
case 2: dtype = grfx::ColorDisplay; break;
|
|
|
|
case 1: dtype = grfx::GrayscaleDisplay; break;
|
|
|
|
case 0: dtype = grfx::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) {
|
|
|
|
grfx::GCache & gc = grfx::GCache::get();
|
|
|
|
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());
|
2002-11-17 05:37:27 +00:00
|
|
|
rc.use_tempdir = pathsmod->tempDirCB->isChecked();
|
2002-12-17 20:37:13 +00:00
|
|
|
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-07 18:06:56 +00:00
|
|
|
rc.isp_command = fromqstr(spellmod->spellCommandCO->currentText());
|
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
|
|
|
|
|
|
|
controller().setFormats(formats_);
|
2003-02-02 02:11:28 +00:00
|
|
|
controller().setConverters(converters_);
|
2002-11-15 06:02:43 +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));
|
|
|
|
|
|
|
|
ostringstream ostr;
|
2002-11-27 10:30:28 +00:00
|
|
|
|
|
|
|
ostr << '#' << std::setbase(16) << setfill('0')
|
2002-11-17 09:42:25 +00:00
|
|
|
<< setw(2) << ci->color().red()
|
|
|
|
<< setw(2) << ci->color().green()
|
|
|
|
<< setw(2) << ci->color().blue();
|
2002-11-27 10:30:28 +00:00
|
|
|
|
2002-11-17 09:42:25 +00:00
|
|
|
string newhex(STRCONV(ostr.str()));
|
|
|
|
|
|
|
|
LColor::color col(dialog_->colors_[i]);
|
|
|
|
|
|
|
|
// FIXME: dubious, but it's what xforms does
|
|
|
|
if (lcolor.getX11Name(col) != newhex) {
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
typename std::vector<A>::const_iterator it =
|
|
|
|
std::find(vec.begin(), vec.end(), val);
|
|
|
|
if (it == vec.end())
|
|
|
|
return 0;
|
|
|
|
return std::distance(vec.begin(), it);
|
2002-11-13 02:22:48 +00:00
|
|
|
}
|
|
|
|
|
2002-12-19 03:22:33 +00:00
|
|
|
void setComboxFont(QComboBox * cb, string const & family,
|
|
|
|
string const & foundry, QFont::StyleHint hint)
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Try matching without foundary 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;
|
|
|
|
}
|
|
|
|
}
|
2002-12-19 03:22:33 +00:00
|
|
|
|
|
|
|
// Try the hint
|
|
|
|
QFont font;
|
|
|
|
font.setStyleHint(hint);
|
|
|
|
QFontInfo fi(font);
|
|
|
|
|
|
|
|
for (int i = cb->count() - 1; i >= 0; --i) {
|
|
|
|
if (cb->text(i) == fi.family()) {
|
|
|
|
cb->setCurrentItem(i);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2002-11-27 21:49:50 +00:00
|
|
|
}
|
|
|
|
|
2002-11-17 05:37:27 +00:00
|
|
|
}
|
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));
|
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);
|
|
|
|
|
|
|
|
displaymod->previewCB->setChecked(rc.preview);
|
2002-11-27 10:30:28 +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) {
|
|
|
|
case grfx::NoDisplay: item = 3; break;
|
|
|
|
case grfx::ColorDisplay: item = 2; break;
|
|
|
|
case grfx::GrayscaleDisplay: item = 1; break;
|
|
|
|
case grfx::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));
|
2002-11-17 03:35:02 +00:00
|
|
|
pathsmod->tempDirCB->setChecked(rc.use_tempdir);
|
2002-12-17 20:37:13 +00:00
|
|
|
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-07 18:06:56 +00:00
|
|
|
QString const tmp = qt_(rc.isp_command);
|
|
|
|
for (int i = 0; i < spellmod->spellCommandCO->count(); ++i) {
|
|
|
|
if (spellmod->spellCommandCO->text(i) == tmp) {
|
|
|
|
spellmod->spellCommandCO->setCurrentItem(i);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
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,
|
|
|
|
rc.roman_font_foundry, QFont::Serif);
|
|
|
|
setComboxFont(fontmod->screenSansCO, rc.sans_font_name,
|
|
|
|
rc.sans_font_foundry, QFont::SansSerif);
|
|
|
|
setComboxFont(fontmod->screenTypewriterCO, rc.typewriter_font_name,
|
|
|
|
rc.typewriter_font_foundry, QFont::TypeWriter);
|
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
|
|
|
|
|
|
|
formats_ = formats;
|
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
|
|
|
converters_ = converters;
|
2002-11-15 06:02:43 +00:00
|
|
|
|
2002-11-17 07:11:02 +00:00
|
|
|
dialog_->updateConverters();
|
2002-11-13 02:22:48 +00:00
|
|
|
}
|