#include "Buffer.h"
#include "BufferParams.h"
#include "BufferView.h"
+#include "CiteEnginesList.h"
#include "Color.h"
#include "ColorCache.h"
+#include "Converter.h"
+#include "Cursor.h"
#include "Encoding.h"
#include "FloatPlacement.h"
#include "Format.h"
#include "qt_helpers.h"
#include "Spacing.h"
#include "TextClass.h"
+#include "Undo.h"
+#include "VSpace.h"
#include "insets/InsetListingsParams.h"
#include <QCloseEvent>
#include <QFontDatabase>
#include <QScrollBar>
+#include <QTextBoundaryFinder>
#include <QTextCursor>
#include <sstream>
bool is_fontcolor;
RGBColor set_notefontcolor;
RGBColor set_boxbgcolor;
+bool forced_fontspec_activation;
namespace {
// used when sorting the textclass list.
{
// This is not a memory leak. The object will be destroyed
// with this.
- (void) new LaTeXHighlighter(preambleTE->document());
+ // @ is letter in the LyX user preamble
+ (void) new LaTeXHighlighter(preambleTE->document(), true);
+ preambleTE->setFont(guiApp->typewriterSystemFont());
+ preambleTE->setWordWrapMode(QTextOption::NoWrap);
setFocusProxy(preambleTE);
connect(preambleTE, SIGNAL(textChanged()), this, SIGNAL(changed()));
}
void PreambleModule::apply(BufferParams & params)
{
- params.preamble = fromqstr(preambleTE->document()->toPlainText());
+ params.preamble = qstring_to_ucs4(preambleTE->document()->toPlainText());
}
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;
+ docstring const layout =
+ qstring_to_ucs4(locallayoutTE->document()->toPlainText());
+ params.setLocalLayout(layout, false);
+}
+
+
+void LocalLayout::hideConvert()
+{
+ convertPB->setEnabled(false);
+ convertLB->setText("");
+ convertPB->hide();
+ convertLB->hide();
}
validated_ = true;
validatePB->setEnabled(false);
validLB->setText("");
- convertPB->hide();
- convertLB->hide();
+ hideConvert();
changed();
} else if (!validatePB->isEnabled()) {
// if that's already enabled, we shouldn't need to do anything.
validated_ = false;
validLB->setText(message);
validatePB->setEnabled(true);
- convertPB->setEnabled(false);
+ hideConvert();
changed();
}
}
string const layout =
fromqstr(locallayoutTE->document()->toPlainText().trimmed());
string const newlayout = TextClass::convert(layout);
- LYXERR0(newlayout);
- if (newlayout.empty()) {
- Alert::error(_("Conversion Failed!"),
- _("Failed to convert local layout to current format."));
- } else {
+ if (!newlayout.empty())
locallayoutTE->setPlainText(toqstr(newlayout));
- }
validate();
}
void LocalLayout::convertPressed() {
convert();
+ hideConvert();
changed();
}
void LocalLayout::validate() {
- static const QString valid = qt_("Layout is valid!");
- static const QString vtext =
- toqstr("<p style=\"font-weight: bold; \">")
- + valid + toqstr("</p>");
- static const QString invalid = qt_("Layout is invalid!");
- static const QString ivtext =
- toqstr("<p style=\"color: #c00000; font-weight: bold; \">")
- + invalid + toqstr("</p>");
-
+ // Bold text
+ static const QString vpar("<p style=\"font-weight: bold;\">%1</p>");
+ // Flashy red bold text
+ static const QString ivpar("<p style=\"color: #c00000; font-weight: bold; \">"
+ "%1</p>");
string const layout =
fromqstr(locallayoutTE->document()->toPlainText().trimmed());
if (!layout.empty()) {
TextClass::ReturnValues const ret = TextClass::validate(layout);
validated_ = (ret == TextClass::OK) || (ret == TextClass::OK_OLDFORMAT);
validatePB->setEnabled(false);
- validLB->setText(validated_ ? vtext : ivtext);
+ validLB->setText(validated_ ? vpar.arg(qt_("Layout is valid!"))
+ : ivpar.arg(qt_("Layout is invalid!")));
if (ret == TextClass::OK_OLDFORMAT) {
convertPB->show();
- convertPB->setEnabled(true);
- convertLB->setText(qt_("Convert to current format"));
+ // Testing conversion to LYXFILE_LAYOUT_FORMAT at this point
+ // already.
+ if (TextClass::convert(layout).empty()) {
+ // Conversion failed. If LAYOUT_FORMAT > LYXFILE_LAYOUT_FORMAT,
+ // then maybe the layout is still valid, but its format is more
+ // recent than LYXFILE_LAYOUT_FORMAT. However, if LAYOUT_FORMAT
+ // == LYXFILE_LAYOUT_FORMAT then something is definitely wrong.
+ convertPB->setEnabled(false);
+ const QString text = (LAYOUT_FORMAT == LYXFILE_LAYOUT_FORMAT)
+ ? ivpar.arg(qt_("Conversion to current format impossible!"))
+ : vpar.arg(qt_("Conversion to current stable format "
+ "impossible."));
+ convertLB->setText(text);
+ } else {
+ convertPB->setEnabled(true);
+ convertLB->setText(qt_("Convert to current format"));
+ }
convertLB->show();
} else {
convertPB->hide();
GuiDocument::GuiDocument(GuiView & lv)
- : GuiDialog(lv, "document", qt_("Document Settings"))
+ : GuiDialog(lv, "document", qt_("Document Settings")),
+ biblioChanged_(false), nonModuleChanged_(false)
{
setupUi(this);
textLayoutModule->lspacingLE->setValidator(new QDoubleValidator(
textLayoutModule->lspacingLE));
- textLayoutModule->indentLE->setValidator(unsignedLengthValidator(
+ textLayoutModule->indentLE->setValidator(new LengthValidator(
textLayoutModule->indentLE));
- textLayoutModule->skipLE->setValidator(unsignedGlueLengthValidator(
+ textLayoutModule->skipLE->setValidator(new LengthValidator(
textLayoutModule->skipLE));
textLayoutModule->indentCO->addItem(qt_("Default"));
masterChildModule->childrenTW->resizeColumnToContents(2);
- // output
+ // Formats
outputModule = new UiWidget<Ui::OutputUi>;
connect(outputModule->defaultFormatCO, SIGNAL(activated(int)),
outputModule->synccustomCB->setValidator(new NoNewLineValidator(
outputModule->synccustomCB));
+ connect(outputModule->saveTransientPropertiesCB, SIGNAL(clicked()),
+ this, SLOT(change_adaptor()));
+
// fonts
- fontModule = new UiWidget<Ui::FontUi>;
+ fontModule = new FontModule;
connect(fontModule->osFontsCB, SIGNAL(clicked()),
this, SLOT(change_adaptor()));
connect(fontModule->osFontsCB, SIGNAL(toggled(bool)),
this, SLOT(change_adaptor()));
connect(fontModule->cjkFontLE, SIGNAL(textChanged(const QString &)),
this, SLOT(change_adaptor()));
+ connect(fontModule->microtypeCB, SIGNAL(clicked()),
+ this, SLOT(change_adaptor()));
connect(fontModule->scaleSansSB, SIGNAL(valueChanged(int)),
this, SLOT(change_adaptor()));
connect(fontModule->scaleTypewriterSB, SIGNAL(valueChanged(int)),
this, SLOT(change_adaptor()));
connect(marginsModule->columnsepUnit, SIGNAL(activated(int)),
this, SLOT(change_adaptor()));
- marginsModule->topLE->setValidator(unsignedLengthValidator(
+ marginsModule->topLE->setValidator(new LengthValidator(
marginsModule->topLE));
- marginsModule->bottomLE->setValidator(unsignedLengthValidator(
+ marginsModule->bottomLE->setValidator(new LengthValidator(
marginsModule->bottomLE));
- marginsModule->innerLE->setValidator(unsignedLengthValidator(
+ marginsModule->innerLE->setValidator(new LengthValidator(
marginsModule->innerLE));
- marginsModule->outerLE->setValidator(unsignedLengthValidator(
+ marginsModule->outerLE->setValidator(new LengthValidator(
marginsModule->outerLE));
- marginsModule->headsepLE->setValidator(unsignedLengthValidator(
+ marginsModule->headsepLE->setValidator(new LengthValidator(
marginsModule->headsepLE));
- marginsModule->headheightLE->setValidator(unsignedLengthValidator(
+ marginsModule->headheightLE->setValidator(new LengthValidator(
marginsModule->headheightLE));
- marginsModule->footskipLE->setValidator(unsignedLengthValidator(
+ marginsModule->footskipLE->setValidator(new LengthValidator(
marginsModule->footskipLE));
- marginsModule->columnsepLE->setValidator(unsignedLengthValidator(
+ marginsModule->columnsepLE->setValidator(new LengthValidator(
marginsModule->columnsepLE));
bc().addCheckedLineEdit(marginsModule->topLE,
this, SLOT(change_adaptor()));
connect(langModule->languagePackageCO, SIGNAL(currentIndexChanged(int)),
this, SLOT(languagePackageChanged(int)));
+ connect(langModule->dynamicQuotesCB, SIGNAL(clicked()),
+ this, SLOT(change_adaptor()));
langModule->languagePackageLE->setValidator(new NoNewLineValidator(
langModule->languagePackageLE));
encodinglist.sort();
langModule->encodingCO->addItems(encodinglist);
- 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);
+ for (int i = 0; i < quoteparams.stylescount(); ++i) {
+ InsetQuotesParams::QuoteStyle qs = InsetQuotesParams::QuoteStyle(i);
+ if (qs == InsetQuotesParams::DynamicQuotes)
+ continue;
+ langModule->quoteStyleCO->addItem(toqstr(quoteparams.getGuiLabel(qs)), qs);
+ }
langModule->languagePackageCO->addItem(
qt_("Default"), toqstr("default"));
// biblio
biblioModule = new UiWidget<Ui::BiblioUi>;
- connect(biblioModule->citeDefaultRB, SIGNAL(toggled(bool)),
- this, SLOT(setNumerical(bool)));
- connect(biblioModule->citeJurabibRB, SIGNAL(toggled(bool)),
- this, SLOT(setAuthorYear(bool)));
- connect(biblioModule->citeNatbibRB, SIGNAL(toggled(bool)),
- biblioModule->citationStyleL, SLOT(setEnabled(bool)));
- connect(biblioModule->citeNatbibRB, SIGNAL(toggled(bool)),
- biblioModule->citeStyleCO, SLOT(setEnabled(bool)));
- connect(biblioModule->citeDefaultRB, SIGNAL(clicked()),
- this, SLOT(biblioChanged()));
- connect(biblioModule->citeNatbibRB, SIGNAL(clicked()),
- this, SLOT(biblioChanged()));
+ connect(biblioModule->citeEngineCO, SIGNAL(activated(int)),
+ this, SLOT(citeEngineChanged(int)));
connect(biblioModule->citeStyleCO, SIGNAL(activated(int)),
this, SLOT(biblioChanged()));
- connect(biblioModule->citeJurabibRB, SIGNAL(clicked()),
- this, SLOT(biblioChanged()));
connect(biblioModule->bibtopicCB, SIGNAL(clicked()),
this, SLOT(biblioChanged()));
connect(biblioModule->bibtexCO, SIGNAL(activated(int)),
connect(biblioModule->bibtexStyleLE, SIGNAL(textChanged(QString)),
this, SLOT(biblioChanged()));
+ biblioModule->citeEngineCO->clear();
+ for (LyXCiteEngine const & cet : theCiteEnginesList) {
+ biblioModule->citeEngineCO->addItem(qt_(cet.getName()), toqstr(cet.getID()));
+ int const i = biblioModule->citeEngineCO->findData(toqstr(cet.getID()));
+ biblioModule->citeEngineCO->setItemData(i, qt_(cet.getDescription()),
+ Qt::ToolTipRole);
+ }
+
biblioModule->bibtexOptionsLE->setValidator(new NoNewLineValidator(
biblioModule->bibtexOptionsLE));
biblioModule->bibtexStyleLE->setValidator(new NoNewLineValidator(
biblioModule->bibtexStyleLE));
- biblioModule->citeStyleCO->addItem(qt_("Author-year"));
- biblioModule->citeStyleCO->addItem(qt_("Numerical"));
- biblioModule->citeStyleCO->setCurrentIndex(0);
-
// NOTE: we do not provide "custom" here for security reasons!
biblioModule->bibtexCO->clear();
biblioModule->bibtexCO->addItem(qt_("Default"), QString("default"));
headers << qt_("Package") << qt_("Load automatically")
<< qt_("Load always") << qt_("Do not load");
mathsModule->packagesTW->setHorizontalHeaderLabels(headers);
- setSectionResizeMode(mathsModule->packagesTW->horizontalHeader(), QHeaderView::Stretch);
+ setSectionResizeMode(mathsModule->packagesTW->horizontalHeader(), QHeaderView::Stretch);
map<string, string> const & packages = BufferParams::auto_packages();
mathsModule->packagesTW->setRowCount(packages.size());
int i = 0;
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()),
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. "
+ tooltip += '\n' + toqstr(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(", ")))));
+ output_type, from_utf8(tc.prerequisites(", "))));
}
latexModule->classCO->addItemSort(toqstr(tc.name()),
toqstr(guiname),
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_("Formats[[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::onBufferViewChanged()
+{
+ if (isVisibleView())
+ initialiseParams("");
+}
+
+
void GuiDocument::saveDefaultClicked()
{
saveDocDefault();
void GuiDocument::change_adaptor()
{
+ nonModuleChanged_ = true;
changed();
}
includeonlys_.push_back(child);
updateIncludeonlys();
- changed();
+ change_adaptor();
}
QString GuiDocument::validateListingsParameters()
{
- // use a cache here to avoid repeated validation
- // of the same parameters
- static string param_cache;
- static QString msg_cache;
-
if (listingsModule->bypassCB->isChecked())
return QString();
-
string params = fromqstr(listingsModule->listingsED->toPlainText());
- if (params != param_cache) {
- param_cache = params;
- msg_cache = toqstr(InsetListingsParams(params).validate());
- }
- return msg_cache;
+ return toqstr(InsetListingsParams(params).validate());
}
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
+ // some languages only work with polyglossia
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()) {
void GuiDocument::osFontsChanged(bool nontexfonts)
{
bool const tex_fonts = !nontexfonts;
+ // store current fonts
+ QString const font_roman = fontModule->fontsRomanCO->itemData(
+ fontModule->fontsRomanCO->currentIndex()).toString();
+ QString const font_sans = fontModule->fontsSansCO->itemData(
+ fontModule->fontsSansCO->currentIndex()).toString();
+ QString const font_typewriter = fontModule->fontsTypewriterCO->itemData(
+ fontModule->fontsTypewriterCO->currentIndex()).toString();
+ QString const font_math = fontModule->fontsMathCO->itemData(
+ fontModule->fontsMathCO->currentIndex()).toString();
+ int const font_sf_scale = fontModule->scaleSansSB->value();
+ int const font_tt_scale = fontModule->scaleTypewriterSB->value();
+
updateFontlist();
// store default format
QString const dformat = outputModule->defaultFormatCO->itemData(
if (index == -1)
index = 0;
outputModule->defaultFormatCO->setCurrentIndex(index);
+
+ // try to restore fonts which were selected two toggles ago
+ index = fontModule->fontsRomanCO->findData(fontModule->font_roman);
+ if (index != -1)
+ fontModule->fontsRomanCO->setCurrentIndex(index);
+ index = fontModule->fontsSansCO->findData(fontModule->font_sans);
+ if (index != -1)
+ fontModule->fontsSansCO->setCurrentIndex(index);
+ index = fontModule->fontsTypewriterCO->findData(fontModule->font_typewriter);
+ if (index != -1)
+ fontModule->fontsTypewriterCO->setCurrentIndex(index);
+ index = fontModule->fontsMathCO->findData(fontModule->font_math);
+ if (index != -1)
+ fontModule->fontsMathCO->setCurrentIndex(index);
+ // save fonts for next next toggle
+ fontModule->font_roman = font_roman;
+ fontModule->font_sans = font_sans;
+ fontModule->font_typewriter = font_typewriter;
+ fontModule->font_math = font_math;
+ fontModule->font_sf_scale = font_sf_scale;
+ fontModule->font_tt_scale = font_tt_scale;
+
langModule->encodingCO->setEnabled(tex_fonts &&
!langModule->defaultencodingRB->isChecked());
langModule->defaultencodingRB->setEnabled(tex_fonts);
if (!tex_fonts)
fontModule->fontencLE->setEnabled(false);
else
- fontencChanged(fontModule->fontencCO->currentIndex());
+ fontencChanged(fontModule->fontencCO->currentIndex());
}
return (fontModule->fontsSansCO->itemData(
fontModule->fontsSansCO->currentIndex()).toString() == "default"
&& fontModule->fontsSansCO->itemData(
- fontModule->fontsSansCO->currentIndex()).toString() == "default");
+ fontModule->fontsTypewriterCO->currentIndex()).toString() == "default");
}
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->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;
}
-
+
fontModule->fontsTypewriterCO->addItem(qt_("Default"), QString("default"));
QMap<QString, QString>::const_iterator tti = ttfonts_.constBegin();
while (tti != ttfonts_.constEnd()) {
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;
}
+void GuiDocument::classChanged_adaptor()
+{
+ const_cast<Buffer &>(buffer()).setLayoutPos(string());
+ classChanged();
+}
+
+
void GuiDocument::classChanged()
{
int idx = latexModule->classCO->currentIndex();
return;
string const classname = fromqstr(latexModule->classCO->getData(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;
- }
- }
-
- 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();
+}
+
+
+void GuiDocument::citeEngineChanged(int n)
+{
+ QString const engine = biblioModule->citeEngineCO->itemData(n).toString();
+
+ vector<string> const engs =
+ theCiteEnginesList[fromqstr(engine)]->getEngineType();
+
+ updateCiteStyles(engs);
+
+ biblioChanged();
}
void GuiDocument::setAuthorYear(bool authoryear)
{
if (authoryear)
- biblioModule->citeStyleCO->setCurrentIndex(0);
+ biblioModule->citeStyleCO->setCurrentIndex(
+ biblioModule->citeStyleCO->findData(ENGINE_TYPE_AUTHORYEAR));
biblioChanged();
}
void GuiDocument::setNumerical(bool numerical)
{
if (numerical)
- biblioModule->citeStyleCO->setCurrentIndex(1);
+ biblioModule->citeStyleCO->setCurrentIndex(
+ biblioModule->citeStyleCO->findData(ENGINE_TYPE_NUMERICAL));
biblioChanged();
}
+void GuiDocument::updateCiteStyles(vector<string> const & engs, CiteEngineType const & sel)
+{
+ biblioModule->citeStyleCO->clear();
+
+ vector<string>::const_iterator it = engs.begin();
+ vector<string>::const_iterator end = engs.end();
+ for (; it != end; ++it) {
+ if (*it == "default")
+ biblioModule->citeStyleCO->addItem(qt_("Basic numerical"),
+ ENGINE_TYPE_DEFAULT);
+ else if (*it == "authoryear")
+ biblioModule->citeStyleCO->addItem(qt_("Author-year"),
+ ENGINE_TYPE_AUTHORYEAR);
+ else if (*it == "numerical")
+ biblioModule->citeStyleCO->addItem(qt_("Author-number"),
+ ENGINE_TYPE_NUMERICAL);
+ }
+ int i = biblioModule->citeStyleCO->findData(sel);
+ if (biblioModule->citeStyleCO->findData(sel) == -1)
+ i = 0;
+ biblioModule->citeStyleCO->setCurrentIndex(i);
+
+ biblioModule->citationStyleL->setEnabled(engs.size() > 1);
+ biblioModule->citeStyleCO->setEnabled(engs.size() > 1);
+}
+
+
void GuiDocument::updateEngineType(string const & items, CiteEngineType const & sel)
{
engine_types_.clear();
engine_types_.push_back(style);
}
- switch (sel) {
- case ENGINE_TYPE_AUTHORYEAR:
- biblioModule->citeStyleCO->setCurrentIndex(0);
- break;
- case ENGINE_TYPE_NUMERICAL:
- biblioModule->citeStyleCO->setCurrentIndex(1);
- break;
- }
-
- biblioModule->citationStyleL->setEnabled(nn > 1);
- biblioModule->citeStyleCO->setEnabled(nn > 1);
-
- if (nn != 1)
- return;
-
- // If the textclass allows only one of authoryear or numerical,
- // we have no choice but to force that engine type.
- if (engine_types_[0] == "authoryear")
- biblioModule->citeStyleCO->setCurrentIndex(0);
- else
- biblioModule->citeStyleCO->setCurrentIndex(1);
+ updateCiteStyles(engine_types_, sel);
}
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();
}
if (idx >= 0) {
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();
outputModule->defaultFormatCO->addItem(qt_("Default"),
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)
- outputModule->defaultFormatCO->addItem(qt_((*cit)->prettyname()),
- QVariant(toqstr((*cit)->name())));
+ FormatList const & formats =
+ param_copy.exportableFormats(true);
+ for (Format const * f : formats)
+ outputModule->defaultFormatCO->addItem
+ (toqstr(translateIfPossible(f->prettyname())),
+ QVariant(toqstr(f->name())));
outputModule->defaultFormatCO->blockSignals(false);
}
bp_.use_refstyle = latexModule->refstyleCB->isChecked();
// biblio
- if (biblioModule->citeNatbibRB->isChecked())
- bp_.setCiteEngine("natbib");
- else if (biblioModule->citeJurabibRB->isChecked())
- bp_.setCiteEngine("jurabib");
+ string const engine =
+ fromqstr(biblioModule->citeEngineCO->itemData(
+ biblioModule->citeEngineCO->currentIndex()).toString());
+ bp_.setCiteEngine(engine);
+
+ CiteEngineType const style = CiteEngineType(biblioModule->citeStyleCO->itemData(
+ biblioModule->citeStyleCO->currentIndex()).toInt());
+ if (theCiteEnginesList[engine]->hasEngineType(style))
+ bp_.setCiteEngineType(style);
else
- bp_.setCiteEngine("basic");
-
- if (biblioModule->citeStyleCO->currentIndex())
- bp_.setCiteEngineType(ENGINE_TYPE_NUMERICAL);
- else
- bp_.setCiteEngineType(ENGINE_TYPE_AUTHORYEAR);
+ bp_.setCiteEngineType(ENGINE_TYPE_DEFAULT);
bp_.use_bibtopic =
biblioModule->bibtopicCB->isChecked();
}
}
- bp_.quotes_language = (InsetQuotes::QuoteLanguage) langModule->quoteStyleCO->itemData(
+ bp_.quotes_style = (InsetQuotesParams::QuoteStyle) langModule->quoteStyleCO->itemData(
langModule->quoteStyleCO->currentIndex()).toInt();
+ bp_.dynamic_quotes = langModule->dynamicQuotesCB->isChecked();
- 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();
bp_.listings_params =
InsetListingsParams(fromqstr(listingsModule->listingsED->toPlainText())).params();
- // output
+ // Formats
bp_.default_output_format = fromqstr(outputModule->defaultFormatCO->itemData(
outputModule->defaultFormatCO->currentIndex()).toString());
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();
+
+ bp_.save_transient_properties =
+ outputModule->saveTransientPropertiesCB->isChecked();
// fonts
- bp_.fonts_roman =
+ bp_.fonts_roman[nontexfonts] =
fromqstr(fontModule->fontsRomanCO->
itemData(fontModule->fontsRomanCO->currentIndex()).toString());
+ bp_.fonts_roman[!nontexfonts] = fromqstr(fontModule->font_roman);
- bp_.fonts_sans =
+ bp_.fonts_sans[nontexfonts] =
fromqstr(fontModule->fontsSansCO->
itemData(fontModule->fontsSansCO->currentIndex()).toString());
+ bp_.fonts_sans[!nontexfonts] = fromqstr(fontModule->font_sans);
- bp_.fonts_typewriter =
+ bp_.fonts_typewriter[nontexfonts] =
fromqstr(fontModule->fontsTypewriterCO->
itemData(fontModule->fontsTypewriterCO->currentIndex()).toString());
+ bp_.fonts_typewriter[!nontexfonts] = fromqstr(fontModule->font_typewriter);
- bp_.fonts_math =
+ bp_.fonts_math[nontexfonts] =
fromqstr(fontModule->fontsMathCO->
itemData(fontModule->fontsMathCO->currentIndex()).toString());
+ bp_.fonts_math[!nontexfonts] = fromqstr(fontModule->font_math);
QString const fontenc =
fontModule->fontencCO->itemData(fontModule->fontencCO->currentIndex()).toString();
bp_.fonts_cjk =
fromqstr(fontModule->cjkFontLE->text());
- bp_.fonts_sans_scale = fontModule->scaleSansSB->value();
+ bp_.use_microtype = fontModule->microtypeCB->isChecked();
+
+ bp_.fonts_sans_scale[nontexfonts] = fontModule->scaleSansSB->value();
+ bp_.fonts_sans_scale[!nontexfonts] = fontModule->font_sf_scale;
- bp_.fonts_typewriter_scale = fontModule->scaleTypewriterSB->value();
+ bp_.fonts_typewriter_scale[nontexfonts] = fontModule->scaleTypewriterSB->value();
+ bp_.fonts_typewriter_scale[!nontexfonts] = fontModule->font_tt_scale;
bp_.fonts_expert_sc = fontModule->fontScCB->isChecked();
pdf.pagemode.clear();
pdf.quoted_options = pdf.quoted_options_check(
fromqstr(pdfSupportModule->optionsLE->text()));
+
+ // reset tracker
+ nonModuleChanged_ = false;
}
// biblio
string const cite_engine = bp_.citeEngine().list().front();
- biblioModule->citeDefaultRB->setChecked(
- cite_engine == "basic");
-
- biblioModule->citeJurabibRB->setChecked(
- cite_engine == "jurabib");
-
- biblioModule->citeNatbibRB->setChecked(
- cite_engine == "natbib");
-
- biblioModule->citeStyleCO->setCurrentIndex(
- bp_.citeEngineType() == ENGINE_TYPE_NUMERICAL);
+ biblioModule->citeEngineCO->setCurrentIndex(
+ biblioModule->citeEngineCO->findData(toqstr(cite_engine)));
updateEngineType(documentClass().opt_enginetype(),
bp_.citeEngineType());
+ biblioModule->citeStyleCO->setCurrentIndex(
+ biblioModule->citeStyleCO->findData(bp_.citeEngineType()));
+
biblioModule->bibtopicCB->setChecked(
bp_.use_bibtopic);
biblioChanged_ = false;
// indices
- indicesModule->update(bp_);
+ // We may be called when there is no Buffer, e.g., when
+ // the last view has just been closed.
+ bool const isReadOnly = isBufferAvailable() ? buffer().isReadonly() : false;
+ indicesModule->update(bp_, isReadOnly);
// language & quotes
int const pos = langModule->languageCO->findData(toqstr(
langModule->languageCO->setCurrentIndex(pos);
langModule->quoteStyleCO->setCurrentIndex(
- bp_.quotes_language);
+ bp_.quotes_style);
+ langModule->dynamicQuotesCB->setChecked(bp_.dynamic_quotes);
bool default_enc = true;
if (bp_.inputenc != "auto") {
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);
- QString font = toqstr(bp_.fonts_roman);
+ QString font = toqstr(bp_.fontsRoman());
int rpos = fontModule->fontsRomanCO->findData(font);
if (rpos == -1) {
rpos = fontModule->fontsRomanCO->count();
fontModule->fontsRomanCO->addItem(font + qt_(" (not installed)"), font);
}
fontModule->fontsRomanCO->setCurrentIndex(rpos);
+ fontModule->font_roman = toqstr(bp_.fonts_roman[!bp_.useNonTeXFonts]);
- font = toqstr(bp_.fonts_sans);
+ font = toqstr(bp_.fontsSans());
int spos = fontModule->fontsSansCO->findData(font);
if (spos == -1) {
spos = fontModule->fontsSansCO->count();
fontModule->fontsSansCO->addItem(font + qt_(" (not installed)"), font);
}
fontModule->fontsSansCO->setCurrentIndex(spos);
+ fontModule->font_sans = toqstr(bp_.fonts_sans[!bp_.useNonTeXFonts]);
- font = toqstr(bp_.fonts_typewriter);
+ font = toqstr(bp_.fontsTypewriter());
int tpos = fontModule->fontsTypewriterCO->findData(font);
if (tpos == -1) {
tpos = fontModule->fontsTypewriterCO->count();
fontModule->fontsTypewriterCO->addItem(font + qt_(" (not installed)"), font);
}
fontModule->fontsTypewriterCO->setCurrentIndex(tpos);
+ fontModule->font_typewriter = toqstr(bp_.fonts_typewriter[!bp_.useNonTeXFonts]);
- font = toqstr(bp_.fonts_math);
+ font = toqstr(bp_.fontsMath());
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);
+ fontModule->font_math = toqstr(bp_.fonts_math[!bp_.useNonTeXFonts]);
if (bp_.useNonTeXFonts && os_fonts_available) {
fontModule->fontencLA->setEnabled(false);
toqstr(bp_.fonts_cjk));
else
fontModule->cjkFontLE->setText(QString());
+
+ fontModule->microtypeCB->setChecked(bp_.use_microtype);
fontModule->fontScCB->setChecked(bp_.fonts_expert_sc);
fontModule->fontOsfCB->setChecked(bp_.fonts_old_figures);
- fontModule->scaleSansSB->setValue(bp_.fonts_sans_scale);
- fontModule->scaleTypewriterSB->setValue(bp_.fonts_typewriter_scale);
+ fontModule->scaleSansSB->setValue(bp_.fontsSansScale());
+ fontModule->font_sf_scale = bp_.fonts_sans_scale[!bp_.useNonTeXFonts];
+ fontModule->scaleTypewriterSB->setValue(bp_.fontsTypewriterScale());
+ fontModule->font_tt_scale = bp_.fonts_typewriter_scale[!bp_.useNonTeXFonts];
int nn = findToken(GuiDocument::fontfamilies, bp_.fonts_default_family);
if (nn >= 0)
fontModule->fontencLE->setText(toqstr(bp_.fontenc));
}
- // Output
+ // Formats
// This must be set _after_ fonts since updateDefaultFormat()
// checks osFontsCB settings.
// update combobox with formats
outputModule->strictCB->setChecked(bp_.html_be_strict);
outputModule->cssCB->setChecked(bp_.html_css_as_file);
+ outputModule->saveTransientPropertiesCB
+ ->setChecked(bp_.save_transient_properties);
+
// paper
bool const extern_geometry =
documentClass().provides("geometry");
// clear changed branches cache
changedBranches_.clear();
+
+ // reset tracker
+ nonModuleChanged_ = false;
}
void GuiDocument::updateAvailableModules()
{
modules_av_model_.clear();
- list<modInfoStruct> const & modInfoList = getModuleInfo();
- list<modInfoStruct>::const_iterator mit = modInfoList.begin();
- list<modInfoStruct>::const_iterator men = modInfoList.end();
- for (int i = 0; mit != men; ++mit, ++i)
- modules_av_model_.insertRow(i, mit->name, mit->id,
- mit->description);
+ list<modInfoStruct> modInfoList = getModuleInfo();
+ // Sort names according to the locale
+ modInfoList.sort([](modInfoStruct const & a, modInfoStruct const & b) {
+ return 0 < b.name.localeAwareCompare(a.name);
+ });
+ int i = 0;
+ for (modInfoStruct const & m : modInfoList) {
+ modules_av_model_.insertRow(i, m.name, m.id, m.description);
+ ++i;
+ }
}
{
modules_sel_model_.clear();
list<modInfoStruct> const selModList = getSelectedModules();
- list<modInfoStruct>::const_iterator mit = selModList.begin();
- list<modInfoStruct>::const_iterator men = selModList.end();
- for (int i = 0; mit != men; ++mit, ++i)
- modules_sel_model_.insertRow(i, mit->name, mit->id,
- mit->description);
+ int i = 0;
+ for (modInfoStruct const & m : selModList) {
+ modules_sel_model_.insertRow(i, m.name, m.id, m.description);
+ ++i;
+ }
}
masterChildModule->childrenTW->setEnabled(true);
masterChildModule->maintainAuxCB->setEnabled(true);
}
- QTreeWidgetItem * item = 0;
ListOfBuffers children = buffer().getChildren();
ListOfBuffers::const_iterator it = children.begin();
ListOfBuffers::const_iterator end = children.end();
bool has_unincluded = false;
bool all_unincluded = true;
for (; it != end; ++it) {
- item = new QTreeWidgetItem(masterChildModule->childrenTW);
+ QTreeWidgetItem * item = new QTreeWidgetItem(masterChildModule->childrenTW);
// FIXME Unicode
string const name =
to_utf8(makeRelPath(from_utf8((*it)->fileName().absFileName()),
list<GuiDocument::modInfoStruct> const
- GuiDocument::makeModuleInfo(LayoutModuleList const & mods)
+GuiDocument::makeModuleInfo(LayoutModuleList const & mods)
{
- LayoutModuleList::const_iterator it = mods.begin();
- LayoutModuleList::const_iterator end = mods.end();
list<modInfoStruct> mInfo;
- for (; it != end; ++it) {
+ for (string const & name : mods) {
modInfoStruct m;
- m.id = *it;
- LyXModule const * const mod = theModuleList[*it];
+ LyXModule const * const mod = theModuleList[name];
if (mod)
- // FIXME Unicode
- m.name = toqstr(translateIfPossible(from_utf8(mod->getName())));
- else
- m.name = toqstr(*it) + toqstr(" (") + qt_("Not Found") + toqstr(")");
+ m = modInfo(*mod);
+ else {
+ m.id = name;
+ m.name = toqstr(name + " (") + qt_("Not Found") + toqstr(")");
+ }
mInfo.push_back(m);
}
return mInfo;
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());
}
}
+//static
+GuiDocument::modInfoStruct GuiDocument::modInfo(LyXModule const & mod)
+{
+ // FIXME Unicode: docstrings would be better for these parameters but this
+ // change requires a lot of others
+ modInfoStruct m;
+ m.id = mod.getID();
+ m.name = toqstr(translateIfPossible(from_utf8(mod.getName())));
+ QString desc = toqstr(translateIfPossible(from_utf8(mod.getDescription())));
+ // Find the first sentence of the description
+ QTextBoundaryFinder bf(QTextBoundaryFinder::Sentence, desc);
+ int pos = bf.toNextBoundary();
+ if (pos > 0)
+ desc.truncate(pos);
+ QString modulename = QString(qt_("(Module name: %1)")).arg(toqstr(m.id));
+ // Tooltip is the desc followed by the module name
+ m.description = QString("%1<i>%2</i>")
+ .arg(desc.isEmpty() ? QString() : QString("<p>%1</p>").arg(desc),
+ modulename);
+ return m;
+}
+
+
void GuiDocument::loadModuleInfo()
{
moduleNames_.clear();
- LyXModuleList::const_iterator it = theModuleList.begin();
- LyXModuleList::const_iterator end = theModuleList.end();
- for (; it != end; ++it) {
- modInfoStruct m;
- m.id = it->getID();
- // FIXME Unicode
- m.name = toqstr(translateIfPossible(from_utf8(it->getName())));
- // this is supposed to give us the first sentence of the description
- // FIXME Unicode
- QString desc =
- toqstr(translateIfPossible(from_utf8(it->getDescription())));
- int const pos = desc.indexOf(".");
- if (pos > 0)
- desc.truncate(pos + 1);
- m.description = desc;
- if (it->category().substr(0, 8) != "Citation")
- moduleNames_.push_back(m);
- }
+ for (LyXModule const & mod : theModuleList)
+ if (mod.category().substr(0, 8) != "Citation")
+ moduleNames_.push_back(modInfo(mod));
}