#include "GuiDocument.h"
+#include "CategorizedCombo.h"
#include "GuiApplication.h"
#include "GuiBranches.h"
#include "GuiIndices.h"
#include "BufferView.h"
#include "Color.h"
#include "ColorCache.h"
+#include "Cursor.h"
#include "Encoding.h"
#include "FloatPlacement.h"
#include "Format.h"
#include "IndicesList.h"
#include "Language.h"
#include "LaTeXFeatures.h"
+#include "LaTeXFonts.h"
#include "Layout.h"
+#include "LayoutEnums.h"
#include "LayoutModuleList.h"
#include "LyXRC.h"
#include "ModuleList.h"
#include "qt_helpers.h"
#include "Spacing.h"
#include "TextClass.h"
+#include "Undo.h"
+#include "VSpace.h"
#include "insets/InsetListingsParams.h"
};
-char const * const tex_fonts_roman[] =
-{
- "default", "cmr", "lmodern", "ae", "times", "palatino",
- "charter", "newcent", "bookman", "utopia", "beraserif",
- "ccfonts", "chancery", ""
-};
-
-
-char const * tex_fonts_roman_gui[] =
-{
- N_("Default"), N_("Computer Modern Roman"), N_("Latin Modern Roman"),
- N_("AE (Almost European)"), N_("Times Roman"), N_("Palatino"),
- N_("Bitstream Charter"), N_("New Century Schoolbook"), N_("Bookman"),
- N_("Utopia"), N_("Bera Serif"), N_("Concrete Roman"), N_("Zapf Chancery"),
- ""
-};
-
-
-char const * const tex_fonts_sans[] =
-{
- "default", "cmss", "lmss", "helvet", "avant", "berasans", "cmbr", ""
-};
-
-
-char const * tex_fonts_sans_gui[] =
-{
- N_("Default"), N_("Computer Modern Sans"), N_("Latin Modern Sans"),
- N_("Helvetica"), N_("Avant Garde"), N_("Bera Sans"), N_("CM Bright"), ""
-};
-
-
-char const * const tex_fonts_monospaced[] =
-{
- "default", "cmtt", "lmtt", "courier", "beramono", "luximono", "cmtl", ""
-};
-
-
-char const * tex_fonts_monospaced_gui[] =
-{
- N_("Default"), N_("Computer Modern Typewriter"),
- N_("Latin Modern Typewriter"), N_("Courier"), N_("Bera Mono"),
- N_("LuxiMono"), N_("CM Typewriter Light"), ""
-};
-
-
char const * backref_opts[] =
{
"false", "section", "slide", "page", ""
};
-char const * packages_gui[][4] =
-{
- {"amsmath",
- N_("&Use amsmath package automatically"),
- N_("Use ams&math package"),
- N_("The LaTeX package amsmath is only used if AMS formula types or symbols from the AMS math toolbars are inserted into formulas")},
- {"amssymb",
- N_("&Use amssymb package automatically"),
- N_("Use amssymb package"),
- N_("The LaTeX package amssymb is only used if symbols from the AMS math toolbars are inserted into formulas")},
- {"esint",
- N_("Use esint package &automatically"),
- N_("Use &esint package"),
- N_("The LaTeX package esint is only used if special integral symbols are inserted into formulas")},
- {"mathdots",
- N_("Use math&dots package automatically"),
- N_("Use mathdo&ts package"),
- N_("The LaTeX package mathdots is only used if the command \\iddots is inserted into formulas")},
- {"mathtools",
- N_("Use mathtools package automatically"),
- N_("Use mathtools package"),
- N_("The LaTeX package mathtools is only used if some mathematical relations are inserted into formulas")},
- {"mhchem",
- N_("Use mhchem &package automatically"),
- N_("Use mh&chem package"),
- N_("The LaTeX package mhchem is only used if either the command \\ce or \\cf is inserted into formulas")},
- {"undertilde",
- N_("Use u&ndertilde package automatically"),
- N_("Use undertilde pac&kage"),
- N_("The LaTeX package undertilde is only used if you use the math frame decoration 'utilde'")},
- {"", "", "", ""}
-};
-
-
vector<string> engine_types_;
vector<pair<string, QString> > pagestyles;
+QMap<QString, QString> rmfonts_;
+QMap<QString, QString> sffonts_;
+QMap<QString, QString> ttfonts_;
+QMap<QString, QString> mathfonts_;
+
} // anonymous namespace
bool is_fontcolor;
RGBColor set_notefontcolor;
RGBColor set_boxbgcolor;
+bool forced_fontspec_activation;
namespace {
// used when sorting the textclass list.
string const modname = getAvailableModel()->getIDString(idx.row());
bool const enable =
- container_->params().moduleCanBeAdded(modname);
+ container_->params().layoutModuleCanBeAdded(modname);
addPB->setEnabled(enable);
}
void LocalLayout::update(BufferParams const & params, BufferId id)
{
- QString layout = toqstr(params.local_layout);
+ QString layout = toqstr(params.getLocalLayout(false));
// Nothing to do if the params and preamble are unchanged.
if (id == current_id_
&& layout == locallayoutTE->document()->toPlainText())
void LocalLayout::apply(BufferParams & params)
{
string const layout = fromqstr(locallayoutTE->document()->toPlainText());
- params.local_layout = layout;
+ params.setLocalLayout(layout, false);
}
GuiDocument::GuiDocument(GuiView & lv)
- : GuiDialog(lv, "document", qt_("Document Settings"))
+ : GuiDialog(lv, "document", qt_("Document Settings")),
+ nonModuleChanged_(false)
{
setupUi(this);
this, SLOT(change_adaptor()));
connect(fontModule->fontsTypewriterCO, SIGNAL(activated(int)),
this, SLOT(ttChanged(int)));
+ connect(fontModule->fontsMathCO, SIGNAL(activated(int)),
+ this, SLOT(change_adaptor()));
+ connect(fontModule->fontsMathCO, SIGNAL(activated(int)),
+ this, SLOT(mathFontChanged(int)));
connect(fontModule->fontsDefaultCO, SIGNAL(activated(int)),
this, SLOT(change_adaptor()));
connect(fontModule->fontencCO, SIGNAL(activated(int)),
this, SLOT(change_adaptor()));
connect(fontModule->fontScCB, SIGNAL(clicked()),
this, SLOT(change_adaptor()));
+ connect(fontModule->fontScCB, SIGNAL(toggled(bool)),
+ this, SLOT(fontScToggled(bool)));
connect(fontModule->fontOsfCB, SIGNAL(clicked()),
this, SLOT(change_adaptor()));
+ connect(fontModule->fontOsfCB, SIGNAL(toggled(bool)),
+ this, SLOT(fontOsfToggled(bool)));
fontModule->fontencLE->setValidator(new NoNewLineValidator(
fontModule->fontencLE));
fontModule->fontsizeCO->addItem(qt_("11"));
fontModule->fontsizeCO->addItem(qt_("12"));
- fontModule->fontencCO->addItem(qt_("Default"));
- fontModule->fontencCO->addItem(qt_("Custom"));
- fontModule->fontencCO->addItem(qt_("None (no fontenc)"));
+ fontModule->fontencCO->addItem(qt_("Default"), QString("global"));
+ fontModule->fontencCO->addItem(qt_("Custom"), QString("custom"));
+ fontModule->fontencCO->addItem(qt_("None (no fontenc)"), QString("default"));
for (int n = 0; GuiDocument::fontfamilies_gui[n][0]; ++n)
fontModule->fontsDefaultCO->addItem(
// language & quote
langModule = new UiWidget<Ui::LanguageUi>;
+ connect(langModule->languageCO, SIGNAL(activated(int)),
+ this, SLOT(change_adaptor()));
connect(langModule->languageCO, SIGNAL(activated(int)),
this, SLOT(languageChanged(int)));
connect(langModule->defaultencodingRB, SIGNAL(clicked()),
Encodings::const_iterator it = encodings.begin();
Encodings::const_iterator const end = encodings.end();
for (; it != end; ++it)
- encodinglist.append(qt_(it->guiName()));
+ if (!it->unsafe())
+ encodinglist.append(qt_(it->guiName()));
encodinglist.sort();
langModule->encodingCO->addItems(encodinglist);
- langModule->quoteStyleCO->addItem(qt_("``text''"));
- langModule->quoteStyleCO->addItem(qt_("''text''"));
- langModule->quoteStyleCO->addItem(qt_(",,text``"));
- langModule->quoteStyleCO->addItem(qt_(",,text''"));
- langModule->quoteStyleCO->addItem(qt_("<<text>>"));
- langModule->quoteStyleCO->addItem(qt_(">>text<<"));
+ langModule->quoteStyleCO->addItem(
+ qt_("``text''"),InsetQuotes::EnglishQuotes);
+ langModule->quoteStyleCO->addItem(
+ qt_("''text''"), InsetQuotes::SwedishQuotes);
+ langModule->quoteStyleCO->addItem
+ (qt_(",,text``"), InsetQuotes::GermanQuotes);
+ langModule->quoteStyleCO->addItem(
+ qt_(",,text''"), InsetQuotes::PolishQuotes);
+ langModule->quoteStyleCO->addItem(
+ qt_("<<text>>"), InsetQuotes::FrenchQuotes);
+ langModule->quoteStyleCO->addItem(
+ qt_(">>text<<"), InsetQuotes::DanishQuotes);
langModule->languagePackageCO->addItem(
qt_("Default"), toqstr("default"));
numberingModule->tocTW->headerItem()->setText(0, qt_("Example"));
numberingModule->tocTW->headerItem()->setText(1, qt_("Numbered"));
numberingModule->tocTW->headerItem()->setText(2, qt_("Appears in TOC"));
- numberingModule->tocTW->header()->setResizeMode(QHeaderView::ResizeToContents);
-
+ setSectionResizeMode(numberingModule->tocTW->header(), QHeaderView::ResizeToContents);
// biblio
biblioModule = new UiWidget<Ui::BiblioUi>;
// maths
- // FIXME This UI has problems:
- // 1) It is not generic, packages_gui needs to be changed for each new package
- // 2) Two checkboxes have 4 states, but one is invalid (both pressed)
- // 3) The auto cb is not disabled if the use cb is checked
mathsModule = new UiWidget<Ui::MathsUi>;
- vector<string> const & packages = BufferParams::auto_packages();
- for (size_t i = 0; i < packages.size(); ++i) {
- // Use the order of BufferParams::auto_packages() for easier
- // access in applyView() and paramsToDialog()
- int n = 0;
- for (n = 0; packages_gui[n][0][0]; n++)
- if (packages_gui[n][0] == packages[i])
- break;
- // If this fires somebody changed
- // BufferParams::auto_packages() without adjusting packages_gui
- LASSERT(packages_gui[n][0][0], /**/);
- QString autoText = qt_(packages_gui[n][1]);
- QString alwaysText = qt_(packages_gui[n][2]);
- QString autoTooltip = qt_(packages_gui[n][3]);
+ QStringList headers;
+ headers << qt_("Package") << qt_("Load automatically")
+ << qt_("Load always") << qt_("Do not load");
+ mathsModule->packagesTW->setHorizontalHeaderLabels(headers);
+ setSectionResizeMode(mathsModule->packagesTW->horizontalHeader(), QHeaderView::Stretch);
+ map<string, string> const & packages = BufferParams::auto_packages();
+ mathsModule->packagesTW->setRowCount(packages.size());
+ int i = 0;
+ for (map<string, string>::const_iterator it = packages.begin();
+ it != packages.end(); ++it) {
+ docstring const package = from_ascii(it->first);
+ QString autoTooltip = qt_(it->second);
QString alwaysTooltip;
- if (packages[i] == "amsmath")
+ if (package == "amsmath")
alwaysTooltip =
qt_("The AMS LaTeX packages are always used");
else
alwaysTooltip = toqstr(bformat(
_("The LaTeX package %1$s is always used"),
- from_ascii(packages[i])));
- QCheckBox * autoCB = new QCheckBox(autoText, mathsModule);
- QCheckBox * alwaysCB = new QCheckBox(alwaysText, mathsModule);
- mathsModule->gridLayout->addWidget(autoCB, 2 * i, 0);
- mathsModule->gridLayout->addWidget(alwaysCB, 2 * i + 1, 0);
- autoCB->setToolTip(autoTooltip);
- alwaysCB->setToolTip(alwaysTooltip);
- connect(autoCB, SIGNAL(toggled(bool)),
- alwaysCB, SLOT(setDisabled(bool)));
- connect(autoCB, SIGNAL(clicked()),
+ package));
+ QString neverTooltip;
+ if (package == "amsmath")
+ neverTooltip =
+ qt_("The AMS LaTeX packages are never used");
+ else
+ neverTooltip = toqstr(bformat(
+ _("The LaTeX package %1$s is never used"),
+ package));
+ QRadioButton * autoRB = new QRadioButton(mathsModule);
+ QRadioButton * alwaysRB = new QRadioButton(mathsModule);
+ QRadioButton * neverRB = new QRadioButton(mathsModule);
+ QButtonGroup * packageGroup = new QButtonGroup(mathsModule);
+ packageGroup->addButton(autoRB);
+ packageGroup->addButton(alwaysRB);
+ packageGroup->addButton(neverRB);
+ autoRB->setToolTip(autoTooltip);
+ alwaysRB->setToolTip(alwaysTooltip);
+ neverRB->setToolTip(neverTooltip);
+ QTableWidgetItem * pack = new QTableWidgetItem(toqstr(package));
+ mathsModule->packagesTW->setItem(i, 0, pack);
+ mathsModule->packagesTW->setCellWidget(i, 1, autoRB);
+ mathsModule->packagesTW->setCellWidget(i, 2, alwaysRB);
+ mathsModule->packagesTW->setCellWidget(i, 3, neverRB);
+
+ connect(autoRB, SIGNAL(clicked()),
+ this, SLOT(change_adaptor()));
+ connect(alwaysRB, SIGNAL(clicked()),
this, SLOT(change_adaptor()));
- connect(alwaysCB, SIGNAL(clicked()),
+ connect(neverRB, SIGNAL(clicked()),
this, SLOT(change_adaptor()));
+ ++i;
}
- QSpacerItem * spacer = new QSpacerItem(20, 20, QSizePolicy::Minimum,
- QSizePolicy::Expanding);
- mathsModule->gridLayout->addItem(spacer, 2 * packages.size(), 0);
+ connect(mathsModule->allPackagesAutoPB, SIGNAL(clicked()),
+ this, SLOT(allPackagesAuto()));
+ connect(mathsModule->allPackagesAlwaysPB, SIGNAL(clicked()),
+ this, SLOT(allPackagesAlways()));
+ connect(mathsModule->allPackagesNotPB, SIGNAL(clicked()),
+ this, SLOT(allPackagesNot()));
+ connect(mathsModule->allPackagesAutoPB, SIGNAL(clicked()),
+ this, SLOT(change_adaptor()));
+ connect(mathsModule->allPackagesAlwaysPB, SIGNAL(clicked()),
+ this, SLOT(change_adaptor()));
+ connect(mathsModule->allPackagesNotPB, SIGNAL(clicked()),
+ this, SLOT(change_adaptor()));
// latex class
connect(latexModule->psdriverCO, SIGNAL(activated(int)),
this, SLOT(change_adaptor()));
connect(latexModule->classCO, SIGNAL(activated(int)),
- this, SLOT(classChanged()));
+ this, SLOT(classChanged_adaptor()));
connect(latexModule->classCO, SIGNAL(activated(int)),
this, SLOT(change_adaptor()));
connect(latexModule->layoutPB, SIGNAL(clicked()),
latexModule->psdriverCO->addItem(enc);
}
// latex classes
- latexModule->classCO->setModel(&classes_model_);
LayoutFileList const & bcl = LayoutFileList::get();
vector<LayoutFileIndex> classList = bcl.classList();
sort(classList.begin(), classList.end(), less_textclass_avail_desc());
vector<LayoutFileIndex>::const_iterator cen = classList.end();
for (int i = 0; cit != cen; ++cit, ++i) {
LayoutFile const & tc = bcl[*cit];
- docstring item = (tc.isTeXClassAvailable()) ?
- from_utf8(tc.description()) :
- bformat(_("Unavailable: %1$s"), from_utf8(tc.description()));
- classes_model_.insertRow(i, toqstr(item), *cit);
+ bool const available = tc.isTeXClassAvailable();
+ docstring const guiname = translateIfPossible(from_utf8(tc.description()));
+ // tooltip sensu "KOMA-Script Article [Class 'scrartcl']"
+ QString tooltip = toqstr(bformat(_("%1$s [Class '%2$s']"), guiname, from_utf8(tc.latexname())));
+ if (!available) {
+ docstring const output_type = (tc.outputType() == lyx::DOCBOOK) ? _("DocBook") : _("LaTeX");
+ tooltip += '\n' + toqstr(wrap(bformat(_("Class not found by LyX. "
+ "Please check if you have the matching %1$s class "
+ "and all required packages (%2$s) installed."),
+ output_type, from_utf8(tc.prerequisites(", ")))));
+ }
+ latexModule->classCO->addItemSort(toqstr(tc.name()),
+ toqstr(guiname),
+ toqstr(translateIfPossible(from_utf8(tc.category()))),
+ tooltip,
+ true, true, true, available);
}
// Modules
modulesModule = new UiWidget<Ui::ModulesUi>;
modulesModule->availableLV->header()->setVisible(false);
- modulesModule->availableLV->header()->setResizeMode(QHeaderView::ResizeToContents);
+ setSectionResizeMode(modulesModule->availableLV->header(), QHeaderView::ResizeToContents);
modulesModule->availableLV->header()->setStretchLastSection(false);
selectionManager =
new ModuleSelectionManager(modulesModule->availableLV,
availableModel(), selectedModel(), this);
connect(selectionManager, SIGNAL(updateHook()),
this, SLOT(updateModuleInfo()));
- connect(selectionManager, SIGNAL(updateHook()),
- this, SLOT(change_adaptor()));
connect(selectionManager, SIGNAL(selectionChanged()),
this, SLOT(modulesChanged()));
// add the panels
- docPS->addPanel(latexModule, qt_("Document Class"));
- docPS->addPanel(masterChildModule, qt_("Child Documents"));
- docPS->addPanel(modulesModule, qt_("Modules"));
- docPS->addPanel(localLayout, qt_("Local Layout"));
- docPS->addPanel(fontModule, qt_("Fonts"));
- docPS->addPanel(textLayoutModule, qt_("Text Layout"));
- docPS->addPanel(pageLayoutModule, qt_("Page Layout"));
- docPS->addPanel(marginsModule, qt_("Page Margins"));
- docPS->addPanel(langModule, qt_("Language"));
- docPS->addPanel(colorModule, qt_("Colors"));
- docPS->addPanel(numberingModule, qt_("Numbering & TOC"));
- docPS->addPanel(biblioModule, qt_("Bibliography"));
- docPS->addPanel(indicesModule, qt_("Indexes"));
- docPS->addPanel(pdfSupportModule, qt_("PDF Properties"));
- docPS->addPanel(mathsModule, qt_("Math Options"));
- docPS->addPanel(floatModule, qt_("Float Placement"));
- docPS->addPanel(listingsModule, qt_("Listings[[inset]]"));
- docPS->addPanel(bulletsModule, qt_("Bullets"));
- docPS->addPanel(branchesModule, qt_("Branches"));
- docPS->addPanel(outputModule, qt_("Output"));
- docPS->addPanel(preambleModule, qt_("LaTeX Preamble"));
- docPS->setCurrentPanel(qt_("Document Class"));
+ docPS->addPanel(latexModule, N_("Document Class"));
+ docPS->addPanel(masterChildModule, N_("Child Documents"));
+ docPS->addPanel(modulesModule, N_("Modules"));
+ docPS->addPanel(localLayout, N_("Local Layout"));
+ docPS->addPanel(fontModule, N_("Fonts"));
+ docPS->addPanel(textLayoutModule, N_("Text Layout"));
+ docPS->addPanel(pageLayoutModule, N_("Page Layout"));
+ docPS->addPanel(marginsModule, N_("Page Margins"));
+ docPS->addPanel(langModule, N_("Language"));
+ docPS->addPanel(colorModule, N_("Colors"));
+ docPS->addPanel(numberingModule, N_("Numbering & TOC"));
+ docPS->addPanel(biblioModule, N_("Bibliography"));
+ docPS->addPanel(indicesModule, N_("Indexes"));
+ docPS->addPanel(pdfSupportModule, N_("PDF Properties"));
+ docPS->addPanel(mathsModule, N_("Math Options"));
+ docPS->addPanel(floatModule, N_("Float Placement"));
+ docPS->addPanel(listingsModule, N_("Listings[[inset]]"));
+ docPS->addPanel(bulletsModule, N_("Bullets"));
+ docPS->addPanel(branchesModule, N_("Branches"));
+ docPS->addPanel(outputModule, N_("Output"));
+ docPS->addPanel(preambleModule, N_("LaTeX Preamble"));
+ docPS->setCurrentPanel("Document Class");
// FIXME: hack to work around resizing bug in Qt >= 4.2
// bug verified with Qt 4.2.{0-3} (JSpitzm)
#if QT_VERSION >= 0x040200
void GuiDocument::change_adaptor()
{
+ nonModuleChanged_ = true;
changed();
}
includeonlys_.push_back(child);
updateIncludeonlys();
- changed();
+ change_adaptor();
}
{
// use a cache here to avoid repeated validation
// of the same parameters
+ // FIXME THREAD
static string param_cache;
static QString msg_cache;
void GuiDocument::setListingsMessage()
{
+ // FIXME THREAD
static bool isOK = true;
QString msg = validateListingsParameters();
if (msg.isEmpty()) {
// listingsTB->setTextColor("black");
listingsModule->listingsTB->setPlainText(
qt_("Input listings parameters below. "
- "Enter ? for a list of parameters."));
+ "Enter ? for a list of parameters."));
} else {
isOK = false;
// listingsTB->setTextColor("red");
// save color
set_backgroundcolor = rgbFromHexName(fromqstr(newColor.name()));
is_backgroundcolor = true;
- changed();
+ change_adaptor();
}
// save default color (white)
set_backgroundcolor = rgbFromHexName("#ffffff");
is_backgroundcolor = false;
- changed();
+ change_adaptor();
}
// save color
set_fontcolor = rgbFromHexName(fromqstr(newColor.name()));
is_fontcolor = true;
- changed();
+ change_adaptor();
}
// save default color (black)
set_fontcolor = rgbFromHexName("#000000");
is_fontcolor = false;
- changed();
+ change_adaptor();
}
colorButtonStyleSheet(newColor));
// save color
set_notefontcolor = rgbFromHexName(fromqstr(newColor.name()));
- changed();
+ change_adaptor();
}
theApp()->getRgbColor(Color_greyedouttext, set_notefontcolor);
colorModule->noteFontColorPB->setStyleSheet(
colorButtonStyleSheet(rgb2qcolor(set_notefontcolor)));
- changed();
+ change_adaptor();
}
colorButtonStyleSheet(newColor));
// save color
set_boxbgcolor = rgbFromHexName(fromqstr(newColor.name()));
- changed();
+ change_adaptor();
}
theApp()->getRgbColor(Color_shadedbg, set_boxbgcolor);
colorModule->boxBackgroundPB->setStyleSheet(
colorButtonStyleSheet(rgb2qcolor(set_boxbgcolor)));
- changed();
+ change_adaptor();
}
void GuiDocument::languageChanged(int i)
{
// some languages only work with polyglossia/XeTeX
- string current_language = lyx::languages.getLanguage(
- fromqstr(langModule->languageCO->itemData(i).toString()))->lang();
- if (current_language == "ancientgreek"
- || current_language == "coptic" || current_language == "divehi"
- || current_language == "hindi" || current_language == "kurmanji"
- || current_language == "lao" || current_language == "marathi"
- || current_language == "occitan" || current_language == "sanskrit"
- || current_language == "syriac" || current_language == "tamil"
- || current_language == "telugu" || current_language == "urdu") {
+ Language const * lang = lyx::languages.getLanguage(
+ fromqstr(langModule->languageCO->itemData(i).toString()));
+ if (lang->babel().empty() && !lang->polyglossia().empty()) {
+ // If we force to switch fontspec on, store
+ // current state (#8717)
+ if (fontModule->osFontsCB->isEnabled())
+ forced_fontspec_activation =
+ !fontModule->osFontsCB->isChecked();
fontModule->osFontsCB->setChecked(true);
fontModule->osFontsCB->setEnabled(false);
}
- else
+ else {
fontModule->osFontsCB->setEnabled(true);
+ // If we have forced to switch fontspec on,
+ // restore previous state (#8717)
+ if (forced_fontspec_activation)
+ fontModule->osFontsCB->setChecked(false);
+ forced_fontspec_activation = false;
+ }
+
+ // set appropriate quotation mark style
+ if (!lang->quoteStyle().empty()) {
+ langModule->quoteStyleCO->setCurrentIndex(
+ bp_.getQuoteStyle(lang->quoteStyle()));
+ }
}
fontModule->fontsDefaultLA->setEnabled(tex_fonts);
fontModule->cjkFontLE->setEnabled(tex_fonts);
fontModule->cjkFontLA->setEnabled(tex_fonts);
- string font;
+
+ updateFontOptions();
+
+ fontModule->fontencLA->setEnabled(tex_fonts);
+ fontModule->fontencCO->setEnabled(tex_fonts);
+ if (!tex_fonts)
+ fontModule->fontencLE->setEnabled(false);
+ else
+ fontencChanged(fontModule->fontencCO->currentIndex());
+}
+
+
+void GuiDocument::mathFontChanged(int)
+{
+ updateFontOptions();
+}
+
+
+void GuiDocument::fontOsfToggled(bool state)
+{
+ if (fontModule->osFontsCB->isChecked())
+ return;
+ QString font = fontModule->fontsRomanCO->itemData(
+ fontModule->fontsRomanCO->currentIndex()).toString();
+ if (hasMonolithicExpertSet(font))
+ fontModule->fontScCB->setChecked(state);
+}
+
+
+void GuiDocument::fontScToggled(bool state)
+{
+ if (fontModule->osFontsCB->isChecked())
+ return;
+ QString font = fontModule->fontsRomanCO->itemData(
+ fontModule->fontsRomanCO->currentIndex()).toString();
+ if (hasMonolithicExpertSet(font))
+ fontModule->fontOsfCB->setChecked(state);
+}
+
+
+void GuiDocument::updateFontOptions()
+{
+ bool const tex_fonts = !fontModule->osFontsCB->isChecked();
+ QString font;
if (tex_fonts)
- font = tex_fonts_sans[fontModule->fontsSansCO->currentIndex()];
+ font = fontModule->fontsSansCO->itemData(
+ fontModule->fontsSansCO->currentIndex()).toString();
bool scaleable = providesScale(font);
fontModule->scaleSansSB->setEnabled(scaleable);
fontModule->scaleSansLA->setEnabled(scaleable);
if (tex_fonts)
- font = tex_fonts_monospaced[fontModule->fontsTypewriterCO->currentIndex()];
+ font = fontModule->fontsTypewriterCO->itemData(
+ fontModule->fontsTypewriterCO->currentIndex()).toString();
scaleable = providesScale(font);
fontModule->scaleTypewriterSB->setEnabled(scaleable);
fontModule->scaleTypewriterLA->setEnabled(scaleable);
if (tex_fonts)
- font = tex_fonts_roman[fontModule->fontsRomanCO->currentIndex()];
+ font = fontModule->fontsRomanCO->itemData(
+ fontModule->fontsRomanCO->currentIndex()).toString();
fontModule->fontScCB->setEnabled(providesSC(font));
fontModule->fontOsfCB->setEnabled(providesOSF(font));
-
- fontModule->fontencLA->setEnabled(tex_fonts);
- fontModule->fontencCO->setEnabled(tex_fonts);
- if (!tex_fonts)
- fontModule->fontencLE->setEnabled(false);
- else
- fontencChanged(fontModule->fontencCO->currentIndex());
+ updateMathFonts(font);
}
}
+bool GuiDocument::ot1() const
+{
+ QString const fontenc =
+ fontModule->fontencCO->itemData(fontModule->fontencCO->currentIndex()).toString();
+ return (fontenc == "default"
+ || (fontenc == "global" && (lyxrc.fontenc == "default" || lyxrc.fontenc == "OT1"))
+ || (fontenc == "custom" && fontModule->fontencLE->text() == "OT1"));
+}
+
+
+bool GuiDocument::completeFontset() const
+{
+ return (fontModule->fontsSansCO->itemData(
+ fontModule->fontsSansCO->currentIndex()).toString() == "default"
+ && fontModule->fontsSansCO->itemData(
+ fontModule->fontsSansCO->currentIndex()).toString() == "default");
+}
+
+
+bool GuiDocument::noMathFont() const
+{
+ return (fontModule->fontsMathCO->itemData(
+ fontModule->fontsMathCO->currentIndex()).toString() == "default");
+}
+
+
+void GuiDocument::updateTexFonts()
+{
+ LaTeXFonts::TexFontMap texfontmap = theLaTeXFonts().getLaTeXFonts();
+
+ LaTeXFonts::TexFontMap::const_iterator it = texfontmap.begin();
+ LaTeXFonts::TexFontMap::const_iterator end = texfontmap.end();
+ for (; it != end; ++it) {
+ LaTeXFont lf = it->second;
+ if (lf.name().empty()) {
+ LYXERR0("Error: Unnamed font: " << it->first);
+ continue;
+ }
+ docstring const family = lf.family();
+ docstring guiname = translateIfPossible(lf.guiname());
+ if (!lf.available(ot1(), noMathFont()))
+ guiname += _(" (not installed)");
+ if (family == "rm")
+ rmfonts_.insert(toqstr(guiname), toqstr(it->first));
+ else if (family == "sf")
+ sffonts_.insert(toqstr(guiname), toqstr(it->first));
+ else if (family == "tt")
+ ttfonts_.insert(toqstr(guiname), toqstr(it->first));
+ else if (family == "math")
+ mathfonts_.insert(toqstr(guiname), toqstr(it->first));
+ }
+}
+
+
void GuiDocument::updateFontlist()
{
fontModule->fontsRomanCO->clear();
fontModule->fontsSansCO->clear();
fontModule->fontsTypewriterCO->clear();
+ fontModule->fontsMathCO->clear();
- // With XeTeX, we have access to all system fonts, but not the LaTeX fonts
+ // With fontspec (XeTeX, LuaTeX), we have access to all system fonts, but not the LaTeX fonts
if (fontModule->osFontsCB->isChecked()) {
fontModule->fontsRomanCO->addItem(qt_("Default"), QString("default"));
fontModule->fontsSansCO->addItem(qt_("Default"), QString("default"));
fontModule->fontsTypewriterCO->addItem(qt_("Default"), QString("default"));
+ QString unimath = qt_("Non-TeX Fonts Default");
+ if (!LaTeXFeatures::isAvailable("unicode-math"))
+ unimath += qt_(" (not available)");
+ fontModule->fontsMathCO->addItem(qt_("Class Default (TeX Fonts)"), QString("auto"));
+ fontModule->fontsMathCO->addItem(unimath, QString("default"));
QFontDatabase fontdb;
QStringList families(fontdb.families());
return;
}
- for (int n = 0; tex_fonts_roman[n][0]; ++n) {
- QString font = qt_(tex_fonts_roman_gui[n]);
- if (!isFontAvailable(tex_fonts_roman[n]))
- font += qt_(" (not installed)");
- fontModule->fontsRomanCO->addItem(font, qt_(tex_fonts_roman[n]));
+ if (rmfonts_.empty())
+ updateTexFonts();
+
+ fontModule->fontsRomanCO->addItem(qt_("Default"), QString("default"));
+ QMap<QString, QString>::const_iterator rmi = rmfonts_.constBegin();
+ while (rmi != rmfonts_.constEnd()) {
+ fontModule->fontsRomanCO->addItem(rmi.key(), rmi.value());
+ ++rmi;
+ }
+
+ fontModule->fontsSansCO->addItem(qt_("Default"), QString("default"));
+ QMap<QString, QString>::const_iterator sfi = sffonts_.constBegin();
+ while (sfi != sffonts_.constEnd()) {
+ fontModule->fontsSansCO->addItem(sfi.key(), sfi.value());
+ ++sfi;
}
- for (int n = 0; tex_fonts_sans[n][0]; ++n) {
- QString font = qt_(tex_fonts_sans_gui[n]);
- if (!isFontAvailable(tex_fonts_sans[n]))
- font += qt_(" (not installed)");
- fontModule->fontsSansCO->addItem(font, qt_(tex_fonts_sans[n]));
+
+ fontModule->fontsTypewriterCO->addItem(qt_("Default"), QString("default"));
+ QMap<QString, QString>::const_iterator tti = ttfonts_.constBegin();
+ while (tti != ttfonts_.constEnd()) {
+ fontModule->fontsTypewriterCO->addItem(tti.key(), tti.value());
+ ++tti;
}
- for (int n = 0; tex_fonts_monospaced[n][0]; ++n) {
- QString font = qt_(tex_fonts_monospaced_gui[n]);
- if (!isFontAvailable(tex_fonts_monospaced[n]))
- font += qt_(" (not installed)");
- fontModule->fontsTypewriterCO->addItem(font, qt_(tex_fonts_monospaced[n]));
+
+ fontModule->fontsMathCO->addItem(qt_("Automatic"), QString("auto"));
+ fontModule->fontsMathCO->addItem(qt_("Class Default"), QString("default"));
+ QMap<QString, QString>::const_iterator mmi = mathfonts_.constBegin();
+ while (mmi != mathfonts_.constEnd()) {
+ fontModule->fontsMathCO->addItem(mmi.key(), mmi.value());
+ ++mmi;
}
}
void GuiDocument::fontencChanged(int item)
{
- fontModule->fontencLE->setEnabled(item == 1);
+ fontModule->fontencLE->setEnabled(
+ fontModule->fontencCO->itemData(item).toString() == "custom");
+ // The availability of TeX fonts depends on the font encoding
+ updateTexFonts();
+ updateFontOptions();
+}
+
+
+void GuiDocument::updateMathFonts(QString const & rm)
+{
+ if (fontModule->osFontsCB->isChecked())
+ return;
+ QString const math =
+ fontModule->fontsMathCO->itemData(fontModule->fontsMathCO->currentIndex()).toString();
+ int const i = fontModule->fontsMathCO->findData("default");
+ if (providesNoMath(rm) && i == -1)
+ fontModule->fontsMathCO->insertItem(1, qt_("Class Default"), QString("default"));
+ else if (!providesNoMath(rm) && i != -1) {
+ int const c = fontModule->fontsMathCO->currentIndex();
+ fontModule->fontsMathCO->removeItem(i);
+ if (c == i)
+ fontModule->fontsMathCO->setCurrentIndex(0);
+ }
}
{
if (fontModule->osFontsCB->isChecked())
return;
- string const font = tex_fonts_roman[item];
+ QString const font =
+ fontModule->fontsRomanCO->itemData(item).toString();
fontModule->fontScCB->setEnabled(providesSC(font));
fontModule->fontOsfCB->setEnabled(providesOSF(font));
+ updateMathFonts(font);
}
{
if (fontModule->osFontsCB->isChecked())
return;
- string const font = tex_fonts_sans[item];
+ QString const font =
+ fontModule->fontsSansCO->itemData(item).toString();
bool scaleable = providesScale(font);
fontModule->scaleSansSB->setEnabled(scaleable);
fontModule->scaleSansLA->setEnabled(scaleable);
{
if (fontModule->osFontsCB->isChecked())
return;
- string const font = tex_fonts_monospaced[item];
+ QString const font =
+ fontModule->fontsTypewriterCO->itemData(item).toString();
bool scaleable = providesScale(font);
fontModule->scaleTypewriterSB->setEnabled(scaleable);
fontModule->scaleTypewriterLA->setEnabled(scaleable);
int const ret = Alert::prompt(_("Local layout file"),
_("The layout file you have selected is a local layout\n"
- "file, not one in the system or user directory. Your\n"
- "document may not work with this layout if you do not\n"
- "keep the layout file in the document directory."),
+ "file, not one in the system or user directory.\n"
+ "Your document will not work with this layout if you\n"
+ "move the layout file to a different directory."),
1, 1, _("&Set Layout"), _("&Cancel"));
if (ret == 1)
return;
LayoutFileList & bcl = LayoutFileList::get();
string classname = layoutFile.onlyFileName();
// this will update an existing layout if that layout has been loaded before.
- LayoutFileIndex name = bcl.addLocalLayout(
+ LayoutFileIndex name = support::onlyFileName(bcl.addLocalLayout(
classname.substr(0, classname.size() - 7),
- layoutFile.onlyPath().absFileName());
+ layoutFile.onlyPath().absFileName()));
if (name.empty()) {
Alert::error(_("Error"),
return;
}
+ const_cast<Buffer &>(buffer()).setLayoutPos(layoutFile.onlyPath().absFileName());
+
// do not trigger classChanged if there is no change.
if (latexModule->classCO->currentText() == toqstr(name))
return;
// add to combo box
- int idx = latexModule->classCO->findText(toqstr(name));
- if (idx == -1) {
- classes_model_.insertRow(0, toqstr(name), name);
- latexModule->classCO->setCurrentIndex(0);
- } else
- latexModule->classCO->setCurrentIndex(idx);
+ bool const avail = latexModule->classCO->set(toqstr(name));
+ if (!avail) {
+ LayoutFile const & tc = bcl[name];
+ docstring const guiname = translateIfPossible(from_utf8(tc.description()));
+ // tooltip sensu "KOMA-Script Article [Class 'scrartcl']"
+ QString tooltip = toqstr(bformat(_("%1$s [Class '%2$s']"), guiname, from_utf8(tc.latexname())));
+ tooltip += '\n' + qt_("This is a local layout file.");
+ latexModule->classCO->addItemSort(toqstr(tc.name()), toqstr(guiname),
+ toqstr(translateIfPossible(from_utf8(tc.category()))),
+ tooltip,
+ true, true, true, true);
+ latexModule->classCO->set(toqstr(name));
+ }
classChanged();
}
}
+void GuiDocument::classChanged_adaptor()
+{
+ const_cast<Buffer &>(buffer()).setLayoutPos(string());
+ classChanged();
+}
+
+
void GuiDocument::classChanged()
{
int idx = latexModule->classCO->currentIndex();
if (idx < 0)
return;
- string const classname = classes_model_.getIDString(idx);
-
- // check whether the selected modules have changed.
- bool modules_changed = false;
- unsigned int const srows = selectedModel()->rowCount();
- if (srows != bp_.getModules().size())
- modules_changed = true;
- else {
- list<string>::const_iterator mit = bp_.getModules().begin();
- list<string>::const_iterator men = bp_.getModules().end();
- for (unsigned int i = 0; i < srows && mit != men; ++i, ++mit)
- if (selectedModel()->getIDString(i) != *mit) {
- modules_changed = true;
- break;
- }
- }
+ string const classname = fromqstr(latexModule->classCO->getData(idx));
- if (modules_changed || lyxrc.auto_reset_options) {
- if (applyPB->isEnabled()) {
- int const ret = Alert::prompt(_("Unapplied changes"),
- _("Some changes in the dialog were not yet applied.\n"
- "If you do not apply now, they will be lost after this action."),
- 1, 1, _("&Apply"), _("&Dismiss"));
- if (ret == 0)
- applyView();
- }
+ if (applyPB->isEnabled()) {
+ int const ret = Alert::prompt(_("Unapplied changes"),
+ _("Some changes in the dialog were not yet applied.\n"
+ "If you do not apply now, they will be lost after this action."),
+ 1, 1, _("&Apply"), _("&Dismiss"));
+ if (ret == 0)
+ applyView();
}
// We load the TextClass as soon as it is selected. This is
void GuiDocument::biblioChanged()
{
biblioChanged_ = true;
- changed();
+ change_adaptor();
}
biblioModule->citeStyleCO->setCurrentIndex(0);
break;
case ENGINE_TYPE_NUMERICAL:
+ case ENGINE_TYPE_DEFAULT:
biblioModule->citeStyleCO->setCurrentIndex(1);
break;
}
void GuiDocument::modulesChanged()
{
modulesToParams(bp_);
+
+ if (applyPB->isEnabled() && nonModuleChanged_) {
+ int const ret = Alert::prompt(_("Unapplied changes"),
+ _("Some changes in the dialog were not yet applied.\n"
+ "If you do not apply now, they will be lost after this action."),
+ 1, 1, _("&Apply"), _("&Dismiss"));
+ if (ret == 0)
+ applyView();
+ }
+
bp_.makeDocumentClass();
paramsToDialog();
+ changed();
}
DocumentClass::const_iterator len = tclass.end();
for (; lit != len; ++lit) {
int const toclevel = lit->toclevel;
- if (toclevel != Layout::NOT_IN_TOC && lit->labeltype == LABEL_COUNTER) {
+ if (toclevel != Layout::NOT_IN_TOC && !lit->counter.empty()) {
item = new QTreeWidgetItem(numberingModule->tocTW);
item->setText(0, toqstr(translateIfPossible(lit->name())));
item->setText(1, (toclevel <= depth) ? yes : no);
param_copy.useNonTeXFonts = fontModule->osFontsCB->isChecked();
int const idx = latexModule->classCO->currentIndex();
if (idx >= 0) {
- string const classname = classes_model_.getIDString(idx);
+ string const classname = fromqstr(latexModule->classCO->getData(idx));
param_copy.setBaseClass(classname);
- param_copy.makeDocumentClass();
+ param_copy.makeDocumentClass(true);
}
outputModule->defaultFormatCO->blockSignals(true);
outputModule->defaultFormatCO->clear();
QVariant(QString("default")));
typedef vector<Format const *> Formats;
Formats formats = param_copy.exportableFormats(true);
+ sort(formats.begin(), formats.end(), Format::formatSorter);
Formats::const_iterator cit = formats.begin();
Formats::const_iterator end = formats.end();
for (; cit != end; ++cit)
bp_.setCiteEngine("natbib");
else if (biblioModule->citeJurabibRB->isChecked())
bp_.setCiteEngine("jurabib");
- else
+ if (biblioModule->citeDefaultRB->isChecked()) {
bp_.setCiteEngine("basic");
-
+ bp_.setCiteEngineType(ENGINE_TYPE_DEFAULT);
+ }
+ else
if (biblioModule->citeStyleCO->currentIndex())
bp_.setCiteEngineType(ENGINE_TYPE_NUMERICAL);
else
Encodings::const_iterator const end = encodings.end();
bool found = false;
for (; it != end; ++it) {
- if (qt_(it->guiName()) == enc_gui) {
- bp_.inputenc = it->latexName();
+ if (qt_(it->guiName()) == enc_gui &&
+ !it->unsafe()) {
+ bp_.inputenc = it->name();
found = true;
break;
}
}
}
- InsetQuotes::QuoteLanguage lga = InsetQuotes::EnglishQuotes;
- switch (langModule->quoteStyleCO->currentIndex()) {
- case 0:
- lga = InsetQuotes::EnglishQuotes;
- break;
- case 1:
- lga = InsetQuotes::SwedishQuotes;
- break;
- case 2:
- lga = InsetQuotes::GermanQuotes;
- break;
- case 3:
- lga = InsetQuotes::PolishQuotes;
- break;
- case 4:
- lga = InsetQuotes::FrenchQuotes;
- break;
- case 5:
- lga = InsetQuotes::DanishQuotes;
- break;
- }
- bp_.quotes_language = lga;
+ bp_.quotes_language = (InsetQuotes::QuoteLanguage) langModule->quoteStyleCO->itemData(
+ langModule->quoteStyleCO->currentIndex()).toInt();
- QString const lang = langModule->languageCO->itemData(
+ QString const langname = langModule->languageCO->itemData(
langModule->languageCO->currentIndex()).toString();
- bp_.language = lyx::languages.getLanguage(fromqstr(lang));
+ Language const * newlang = lyx::languages.getLanguage(fromqstr(langname));
+ Cursor & cur = const_cast<BufferView *>(bufferview())->cursor();
+ // If current cursor language was the document language, then update it too.
+ if (cur.current_font.language() == bp_.language) {
+ cur.current_font.setLanguage(newlang);
+ cur.real_current_font.setLanguage(newlang);
+ }
+ bp_.language = newlang;
QString const pack = langModule->languagePackageCO->itemData(
langModule->languagePackageCO->currentIndex()).toString();
// text layout
int idx = latexModule->classCO->currentIndex();
if (idx >= 0) {
- string const classname = classes_model_.getIDString(idx);
+ string const classname = fromqstr(latexModule->classCO->getData(idx));
bp_.setBaseClass(classname);
}
modulesToParams(bp_);
// Math
- vector<string> const & packages = BufferParams::auto_packages();
- for (size_t n = 0; n < packages.size(); ++n) {
- QCheckBox * autoCB = static_cast<QCheckBox *>(
- mathsModule->gridLayout->itemAtPosition(2 * n, 0)->widget());
- if (autoCB->isChecked())
- bp_.use_package(packages[n], BufferParams::package_auto);
- else {
- QCheckBox * alwaysCB = static_cast<QCheckBox *>(
- mathsModule->gridLayout->itemAtPosition(2 * n + 1, 0)->widget());
- if (alwaysCB->isChecked())
- bp_.use_package(packages[n], BufferParams::package_on);
- else
- bp_.use_package(packages[n], BufferParams::package_off);
+ map<string, string> const & packages = BufferParams::auto_packages();
+ for (map<string, string>::const_iterator it = packages.begin();
+ it != packages.end(); ++it) {
+ QTableWidgetItem * item = mathsModule->packagesTW->findItems(toqstr(it->first), Qt::MatchExactly)[0];
+ if (!item)
+ continue;
+ int row = mathsModule->packagesTW->row(item);
+ QRadioButton * rb = (QRadioButton*)mathsModule->packagesTW->cellWidget(row, 1);
+ if (rb->isChecked()) {
+ bp_.use_package(it->first, BufferParams::package_auto);
+ continue;
}
+ rb = (QRadioButton*)mathsModule->packagesTW->cellWidget(row, 2);
+ if (rb->isChecked()) {
+ bp_.use_package(it->first, BufferParams::package_on);
+ continue;
+ }
+ rb = (QRadioButton*)mathsModule->packagesTW->cellWidget(row, 3);
+ if (rb->isChecked())
+ bp_.use_package(it->first, BufferParams::package_off);
}
// Page Layout
bp_.useNonTeXFonts = nontexfonts;
bp_.output_sync = outputModule->outputsyncCB->isChecked();
-
+
bp_.output_sync_macro = fromqstr(outputModule->synccustomCB->currentText());
int mathfmt = outputModule->mathoutCB->currentIndex();
bp_.html_be_strict = outputModule->strictCB->isChecked();
bp_.html_css_as_file = outputModule->cssCB->isChecked();
bp_.html_math_img_scale = outputModule->mathimgSB->value();
+ bp_.display_pixel_ratio = theGuiApp()->pixelRatio();
// fonts
bp_.fonts_roman =
fromqstr(fontModule->fontsTypewriterCO->
itemData(fontModule->fontsTypewriterCO->currentIndex()).toString());
- if (fontModule->fontencCO->currentIndex() == 0)
- bp_.fontenc = "global";
- else if (fontModule->fontencCO->currentIndex() == 1)
+ bp_.fonts_math =
+ fromqstr(fontModule->fontsMathCO->
+ itemData(fontModule->fontsMathCO->currentIndex()).toString());
+
+ QString const fontenc =
+ fontModule->fontencCO->itemData(fontModule->fontencCO->currentIndex()).toString();
+ if (fontenc == "custom")
bp_.fontenc = fromqstr(fontModule->fontencLE->text());
- else if (fontModule->fontencCO->currentIndex() == 2)
- bp_.fontenc = "default";
+ else
+ bp_.fontenc = fromqstr(fontenc);
bp_.fonts_cjk =
fromqstr(fontModule->cjkFontLE->text());
pdf.pagemode.clear();
pdf.quoted_options = pdf.quoted_options_check(
fromqstr(pdfSupportModule->optionsLE->text()));
+
+ // reset tracker
+ nonModuleChanged_ = false;
}
cite_engine == "natbib");
biblioModule->citeStyleCO->setCurrentIndex(
- bp_.citeEngineType() == ENGINE_TYPE_NUMERICAL);
+ bp_.citeEngineType() & ENGINE_TYPE_NUMERICAL);
updateEngineType(documentClass().opt_enginetype(),
bp_.citeEngineType());
biblioChanged_ = false;
// indices
- indicesModule->update(bp_);
+ indicesModule->update(bp_, buffer().isReadonly());
// language & quotes
int const pos = langModule->languageCO->findData(toqstr(
Encodings::const_iterator it = encodings.begin();
Encodings::const_iterator const end = encodings.end();
for (; it != end; ++it) {
- if (it->latexName() == bp_.inputenc) {
+ if (it->name() == bp_.inputenc &&
+ !it->unsafe()) {
enc_gui = it->guiName();
break;
}
latexModule->psdriverCO->setCurrentIndex(nitem);
updateModuleInfo();
- vector<string> const & packages = BufferParams::auto_packages();
- for (size_t n = 0; n < packages.size(); ++n) {
- QCheckBox * alwaysCB = static_cast<QCheckBox *>(
- mathsModule->gridLayout->itemAtPosition(2 * n + 1, 0)->widget());
- alwaysCB->setChecked(bp_.use_package(packages[n]) == BufferParams::package_on);
- QCheckBox * autoCB = static_cast<QCheckBox *>(
- mathsModule->gridLayout->itemAtPosition(2 * n, 0)->widget());
- autoCB->setChecked(bp_.use_package(packages[n]) == BufferParams::package_auto);
+ map<string, string> const & packages = BufferParams::auto_packages();
+ for (map<string, string>::const_iterator it = packages.begin();
+ it != packages.end(); ++it) {
+ QTableWidgetItem * item = mathsModule->packagesTW->findItems(toqstr(it->first), Qt::MatchExactly)[0];
+ if (!item)
+ continue;
+ int row = mathsModule->packagesTW->row(item);
+ switch (bp_.use_package(it->first)) {
+ case BufferParams::package_off: {
+ QRadioButton * rb = (QRadioButton*)mathsModule->packagesTW->cellWidget(row, 3);
+ rb->setChecked(true);
+ break;
+ }
+ case BufferParams::package_on: {
+ QRadioButton * rb = (QRadioButton*)mathsModule->packagesTW->cellWidget(row, 2);
+ rb->setChecked(true);
+ break;
+ }
+ case BufferParams::package_auto: {
+ QRadioButton * rb = (QRadioButton*)mathsModule->packagesTW->cellWidget(row, 1);
+ rb->setChecked(true);
+ break;
+ }
+ }
}
switch (bp_.spacing().getSpace()) {
if (!bufferview() || !buffer().hasChildren()) {
masterChildModule->childrenTW->clear();
includeonlys_.clear();
- docPS->showPanel(qt_("Child Documents"), false);
- if (docPS->isCurrentPanel(qt_("Child Documents")))
- docPS->setCurrentPanel(qt_("Document Class"));
+ docPS->showPanel("Child Documents", false);
+ if (docPS->isCurrentPanel("Child Documents"))
+ docPS->setCurrentPanel("Document Class");
} else {
- docPS->showPanel(qt_("Child Documents"), true);
+ docPS->showPanel("Child Documents", true);
masterChildModule->setEnabled(true);
includeonlys_ = bp_.getIncludedChildren();
updateIncludeonlys();
listingsModule->listingsED->setPlainText(toqstr(lstparams));
// Fonts
+ // some languages only work with polyglossia/XeTeX
+ Language const * lang = lyx::languages.getLanguage(
+ fromqstr(langModule->languageCO->itemData(
+ langModule->languageCO->currentIndex()).toString()));
+ bool const need_fontspec =
+ lang->babel().empty() && !lang->polyglossia().empty();
bool const os_fonts_available =
bp_.baseClass()->outputType() == lyx::LATEX
&& LaTeXFeatures::isAvailable("fontspec");
- fontModule->osFontsCB->setEnabled(os_fonts_available);
+ fontModule->osFontsCB->setEnabled(os_fonts_available && !need_fontspec);
fontModule->osFontsCB->setChecked(
- os_fonts_available && bp_.useNonTeXFonts);
+ (os_fonts_available && bp_.useNonTeXFonts) || need_fontspec);
updateFontsize(documentClass().opt_fontsize(),
bp_.fontsize);
}
fontModule->fontsTypewriterCO->setCurrentIndex(tpos);
+ font = toqstr(bp_.fonts_math);
+ int mpos = fontModule->fontsMathCO->findData(font);
+ if (mpos == -1) {
+ mpos = fontModule->fontsMathCO->count();
+ fontModule->fontsMathCO->addItem(font + qt_(" (not installed)"), font);
+ }
+ fontModule->fontsMathCO->setCurrentIndex(mpos);
+
if (bp_.useNonTeXFonts && os_fonts_available) {
fontModule->fontencLA->setEnabled(false);
fontModule->fontencCO->setEnabled(false);
if (nn >= 0)
fontModule->fontsDefaultCO->setCurrentIndex(nn);
- if (bp_.fontenc == "global") {
- fontModule->fontencCO->setCurrentIndex(0);
- fontModule->fontencLE->setEnabled(false);
- } else if (bp_.fontenc == "default") {
- fontModule->fontencCO->setCurrentIndex(2);
+ if (bp_.fontenc == "global" || bp_.fontenc == "default") {
+ fontModule->fontencCO->setCurrentIndex(
+ fontModule->fontencCO->findData(toqstr(bp_.fontenc)));
fontModule->fontencLE->setEnabled(false);
} else {
fontModule->fontencCO->setCurrentIndex(1);
// clear changed branches cache
changedBranches_.clear();
+
+ // reset tracker
+ nonModuleChanged_ = false;
}
}
int idx = latexModule->classCO->currentIndex();
- string const classname = classes_model_.getIDString(idx);
+ string const classname = fromqstr(latexModule->classCO->getData(idx));
if (!bp_.setBaseClass(classname)) {
Alert::error(_("Error"), _("Unable to set document class."));
return;
void GuiDocument::setLayoutComboByIDString(string const & idString)
{
- int idx = classes_model_.findIDString(idString);
- if (idx < 0)
+ if (!latexModule->classCO->set(toqstr(idString)))
Alert::warning(_("Can't set layout!"),
bformat(_("Unable to set layout for ID: %1$s"), from_utf8(idString)));
- else
- latexModule->classCO->setCurrentIndex(idx);
}
static void dispatch_bufferparams(Dialog const & dialog,
- BufferParams const & bp, FuncCode lfun)
+ BufferParams const & bp, FuncCode lfun, Buffer const * buf)
{
ostringstream ss;
ss << "\\begin_header\n";
- bp.writeFile(ss);
+ bp.writeFile(ss, buf);
ss << "\\end_header\n";
dialog.dispatch(FuncRequest(lfun, ss.str()));
}
void GuiDocument::dispatchParams()
{
+ // We need a non-const buffer object.
+ Buffer & buf = const_cast<BufferView *>(bufferview())->buffer();
+ // There may be several undo records; group them (bug #8998)
+ buf.undo().beginUndoGroup();
+
// This must come first so that a language change is correctly noticed
setLanguage();
// Apply the BufferParams. Note that this will set the base class
// and then update the buffer's layout.
- dispatch_bufferparams(*this, params(), LFUN_BUFFER_PARAMS_APPLY);
+ dispatch_bufferparams(*this, params(), LFUN_BUFFER_PARAMS_APPLY, &buffer());
if (!params().master.empty()) {
FileName const master_file = support::makeAbsPath(params().master,
// If we used an LFUN, we would not need these two lines:
BufferView * bv = const_cast<BufferView *>(bufferview());
bv->processUpdateFlags(Update::Force | Update::FitCursor);
+
+ // Don't forget to close the group. Note that it is important
+ // to check that there is no early return in the method.
+ buf.undo().endUndoGroup();
}
void GuiDocument::saveAsDefault() const
{
- dispatch_bufferparams(*this, params(), LFUN_BUFFER_SAVE_AS_DEFAULT);
+ dispatch_bufferparams(*this, params(), LFUN_BUFFER_SAVE_AS_DEFAULT, &buffer());
}
-bool GuiDocument::isFontAvailable(string const & font) const
+bool GuiDocument::providesOSF(QString const & font) const
{
- if (font == "default" || font == "cmr"
- || font == "cmss" || font == "cmtt")
- // these are standard
+ if (fontModule->osFontsCB->isChecked())
+ // FIXME: we should check if the fonts really
+ // have OSF support. But how?
return true;
- if (font == "lmodern" || font == "lmss" || font == "lmtt")
- return LaTeXFeatures::isAvailable("lmodern");
- if (font == "times" || font == "palatino"
- || font == "helvet" || font == "courier")
- return LaTeXFeatures::isAvailable("psnfss");
- if (font == "cmbr" || font == "cmtl")
- return LaTeXFeatures::isAvailable("cmbright");
- if (font == "utopia")
- return LaTeXFeatures::isAvailable("utopia")
- || LaTeXFeatures::isAvailable("fourier");
- if (font == "beraserif" || font == "berasans"
- || font == "beramono")
- return LaTeXFeatures::isAvailable("bera");
- return LaTeXFeatures::isAvailable(font);
+ return theLaTeXFonts().getLaTeXFont(
+ qstring_to_ucs4(font)).providesOSF(ot1(),
+ completeFontset(),
+ noMathFont());
}
-bool GuiDocument::providesOSF(string const & font) const
+bool GuiDocument::providesSC(QString const & font) const
+{
+ if (fontModule->osFontsCB->isChecked())
+ return false;
+ return theLaTeXFonts().getLaTeXFont(
+ qstring_to_ucs4(font)).providesSC(ot1(),
+ completeFontset(),
+ noMathFont());
+}
+
+
+bool GuiDocument::providesScale(QString const & font) const
{
if (fontModule->osFontsCB->isChecked())
- // FIXME: we should check if the fonts really
- // have OSF support. But how?
return true;
- if (font == "cmr")
- return isFontAvailable("eco");
- if (font == "palatino")
- return isFontAvailable("mathpazo");
- return false;
+ return theLaTeXFonts().getLaTeXFont(
+ qstring_to_ucs4(font)).providesScale(ot1(),
+ completeFontset(),
+ noMathFont());
}
-bool GuiDocument::providesSC(string const & font) const
+bool GuiDocument::providesNoMath(QString const & font) const
{
if (fontModule->osFontsCB->isChecked())
return false;
- if (font == "palatino")
- return isFontAvailable("mathpazo");
- if (font == "utopia")
- return isFontAvailable("fourier");
- return false;
+ return theLaTeXFonts().getLaTeXFont(
+ qstring_to_ucs4(font)).providesNoMath(ot1(),
+ completeFontset());
}
-bool GuiDocument::providesScale(string const & font) const
+bool GuiDocument::hasMonolithicExpertSet(QString const & font) const
{
if (fontModule->osFontsCB->isChecked())
- return true;
- return font == "helvet" || font == "luximono"
- || font == "berasans" || font == "beramono";
+ return false;
+ return theLaTeXFonts().getLaTeXFont(
+ qstring_to_ucs4(font)).hasMonolithicExpertSet(ot1(),
+ completeFontset(),
+ noMathFont());
}
}
+void GuiDocument::allPackagesAuto()
+{
+ allPackages(1);
+}
+
+
+void GuiDocument::allPackagesAlways()
+{
+ allPackages(2);
+}
+
+
+void GuiDocument::allPackagesNot()
+{
+ allPackages(3);
+}
+
+
+void GuiDocument::allPackages(int col)
+{
+ for (int row = 0; row < mathsModule->packagesTW->rowCount(); ++row) {
+ QRadioButton * rb = (QRadioButton*)mathsModule->packagesTW->cellWidget(row, col);
+ rb->setChecked(true);
+ }
+}
+
+
Dialog * createGuiDocument(GuiView & lv) { return new GuiDocument(lv); }