#include "BufferView.h"
#include "Color.h"
#include "ColorCache.h"
+#include "Converter.h"
#include "Cursor.h"
#include "Encoding.h"
#include "FloatPlacement.h"
{
// 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);
void PreambleModule::apply(BufferParams & params)
{
- params.preamble = fromqstr(preambleTE->document()->toPlainText());
+ params.preamble = qstring_to_ucs4(preambleTE->document()->toPlainText());
}
void LocalLayout::apply(BufferParams & params)
{
- string const layout = fromqstr(locallayoutTE->document()->toPlainText());
+ 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();
+}
+
+
void LocalLayout::textChanged()
{
static const QString message =
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();
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 FontModule;
connect(fontModule->osFontsCB, SIGNAL(clicked()),
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"));
docPS->addPanel(listingsModule, N_("Listings[[inset]]"));
docPS->addPanel(bulletsModule, N_("Bullets"));
docPS->addPanel(branchesModule, N_("Branches"));
- docPS->addPanel(outputModule, N_("Output"));
+ 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
}
+void GuiDocument::onBufferViewChanged()
+{
+ if (isVisibleView())
+ initialiseParams("");
+}
+
+
void GuiDocument::saveDefaultClicked()
{
saveDocDefault();
QString GuiDocument::validateListingsParameters()
{
- // use a cache here to avoid repeated validation
- // of the same parameters
- // FIXME THREAD
- 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::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()) {
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_.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 langname = langModule->languageCO->itemData(
langModule->languageCO->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_.html_math_img_scale = outputModule->mathimgSB->value();
bp_.display_pixel_ratio = theGuiApp()->pixelRatio();
+ bp_.save_transient_properties =
+ outputModule->saveTransientPropertiesCB->isChecked();
+
// fonts
bp_.fonts_roman[nontexfonts] =
fromqstr(fontModule->fontsRomanCO->
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") {
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");