public:
///
ModuleSelectionManager(QObject * parent,
- QTreeView * availableLVarg,
- QTreeView * selectedLVarg,
- QPushButton * addPBarg,
- QPushButton * delPBarg,
- QPushButton * upPBarg,
- QPushButton * downPBarg,
- QStandardItemModel * availableModelarg,
- GuiIdListModel * selectedModelarg,
- GuiDocument const * container)
+ QTreeView * availableLVarg,
+ QTreeView * selectedLVarg,
+ QPushButton * addPBarg,
+ QPushButton * delPBarg,
+ QPushButton * upPBarg,
+ QPushButton * downPBarg,
+ QStandardItemModel * availableModelarg,
+ GuiIdListModel * selectedModelarg,
+ GuiDocument const * container)
: GuiSelectionManager(parent, availableLVarg, selectedLVarg, addPBarg, delPBarg,
upPBarg, downPBarg, availableModelarg, selectedModelarg),
container_(container)
connect(editPB, SIGNAL(clicked()), this, SLOT(editExternal()));
connect(findLE, SIGNAL(returnPressed()), this, SLOT(findText()));
checkFindButton();
- // https://stackoverflow.com/questions/13027091/how-to-override-tab-width-in-qt
- const int tabStop = 4;
+ int const tabStop = 4;
QFontMetrics metrics(preambleTE->currentFont());
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
// horizontalAdvance() is available starting in 5.11.0
docstring const s = tempfilename.fileContents("UTF-8");
preambleTE->document()->setPlainText(toqstr(s));
tempfile_.reset();
- editPB->setText(qt_("&Edit"));
+ editPB->setText(qt_("&Edit Externally"));
changed();
return;
}
connect(validatePB, SIGNAL(clicked()), this, SLOT(validatePressed()));
connect(convertPB, SIGNAL(clicked()), this, SLOT(convertPressed()));
connect(editPB, SIGNAL(clicked()), this, SLOT(editExternal()));
+ int const tabStop = 4;
+ QFontMetrics metrics(locallayoutTE->currentFont());
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
+ // horizontalAdvance() is available starting in 5.11.0
+ // setTabStopDistance() is available starting in 5.10.0
+ locallayoutTE->setTabStopDistance(tabStop * metrics.horizontalAdvance(' '));
+#else
+ locallayoutTE->setTabStopWidth(tabStop * metrics.width(' '));
+#endif
}
void LocalLayout::textChanged()
{
- // Flashy red bold text
- static const QString ivpar("<p style=\"color: #c00000; font-weight: bold; text-align:left\">"
- "%1</p>");
- static const QString message = ivpar.arg(qt_("Validation required!"));
+ validLB->setText("");
string const layout =
fromqstr(locallayoutTE->document()->toPlainText().trimmed());
if (layout.empty()) {
validated_ = true;
validatePB->setEnabled(false);
- validLB->setText("");
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);
hideConvert();
changed();
docstring const s = tempfilename.fileContents("UTF-8");
locallayoutTE->document()->setPlainText(toqstr(s));
tempfile_.reset();
- editPB->setText(qt_("&Edit"));
+ editPB->setText(qt_("&Edit Externally"));
changed();
return;
}
GuiDocument::GuiDocument(GuiView & lv)
: GuiDialog(lv, "document", qt_("Document Settings")),
biblioChanged_(false), nonModuleChanged_(false),
- modulesChanged_(false), shellescapeChanged_(false)
+ modulesChanged_(false), shellescapeChanged_(false),
+ switchback_(false), prompted_(false)
{
setupUi(this);
textLayoutModule->skipLE->setValidator(new LengthValidator(
textLayoutModule->skipLE));
- textLayoutModule->indentCO->addItem(qt_("Default"));
- textLayoutModule->indentCO->addItem(qt_("Custom"));
+ textLayoutModule->indentCO->addItem(qt_("Default"), toqstr("default"));
+ textLayoutModule->indentCO->addItem(qt_("Custom"), toqstr("custom"));
textLayoutModule->skipCO->addItem(qt_("Half line height"), VSpace::HALFLINE);
textLayoutModule->skipCO->addItem(qt_("Line height"), VSpace::FULLLINE);
- textLayoutModule->skipCO->addItem(qt_("SmallSkip"), VSpace::SMALLSKIP);
- textLayoutModule->skipCO->addItem(qt_("MedSkip"), VSpace::MEDSKIP);
- textLayoutModule->skipCO->addItem(qt_("BigSkip"), VSpace::BIGSKIP);
+ textLayoutModule->skipCO->addItem(qt_("Small Skip"), VSpace::SMALLSKIP);
+ textLayoutModule->skipCO->addItem(qt_("Medium Skip"), VSpace::MEDSKIP);
+ textLayoutModule->skipCO->addItem(qt_("Big Skip"), VSpace::BIGSKIP);
textLayoutModule->skipCO->addItem(qt_("Custom"), VSpace::LENGTH);
textLayoutModule->lspacingCO->insertItem(
Spacing::Single, qt_("Single"));
masterChildModule->childrenTW->setColumnCount(2);
masterChildModule->childrenTW->headerItem()->setText(0, qt_("Child Document"));
masterChildModule->childrenTW->headerItem()->setText(1, qt_("Include to Output"));
-#if (QT_VERSION > 0x050000)
- masterChildModule->childrenTW->header()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
- masterChildModule->childrenTW->header()->setSectionResizeMode(1, QHeaderView::ResizeToContents);
-#else
- masterChildModule->childrenTW->header()->setResizeMode(0, QHeaderView::ResizeToContents);
- masterChildModule->childrenTW->header()->setResizeMode(1, QHeaderView::ResizeToContents);
-#endif
+ masterChildModule->childrenTW->header()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
+ masterChildModule->childrenTW->header()->setSectionResizeMode(1, QHeaderView::ResizeToContents);
// Formats
outputModule = new UiWidget<Ui::OutputUi>(this);
connect(outputModule->tableoutCB, SIGNAL(currentIndexChanged(int)),
this, SLOT(change_adaptor()));
connect(outputModule->mathmlprefixCB, SIGNAL(currentIndexChanged(int)),
- this, SLOT(change_adaptor()));
+ this, SLOT(change_adaptor()));
- connect(outputModule->shellescapeCB, SIGNAL(stateChanged(int)),
+ connect(outputModule->shellescapeCB, SIGNAL(stateChanged(int)),
this, SLOT(shellescapeChanged()));
connect(outputModule->outputsyncCB, SIGNAL(toggled(bool)),
this, SLOT(setOutputSync(bool)));
connect(colorModule->delBoxBackgroundTB, SIGNAL(clicked()),
this, SLOT(deleteBoxBackgroundColor()));
+
// change tracking
changesModule = new UiWidget<Ui::ChangeTrackingUi>(this);
connect(changesModule->trackChangesCB, SIGNAL(clicked()),
connect(changesModule->changeBarsCB, SIGNAL(clicked()),
this, SLOT(change_adaptor()));
+
// numbering
numberingModule = new UiWidget<Ui::NumberingUi>(this);
connect(numberingModule->depthSL, SIGNAL(valueChanged(int)),
numberingModule->tocTW->headerItem()->setText(0, qt_("Example"));
numberingModule->tocTW->headerItem()->setText(1, qt_("Numbered"));
numberingModule->tocTW->headerItem()->setText(2, qt_("Appears in TOC"));
- setSectionResizeMode(numberingModule->tocTW->header(), QHeaderView::ResizeToContents);
+ numberingModule->tocTW->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
connect(numberingModule->linenoCB, SIGNAL(toggled(bool)),
this, SLOT(linenoToggled(bool)));
connect(numberingModule->linenoCB, SIGNAL(clicked()),
headers << qt_("Package") << qt_("Load automatically")
<< qt_("Load always") << qt_("Do not load");
mathsModule->packagesTW->setHorizontalHeaderLabels(headers);
- setSectionResizeMode(mathsModule->packagesTW->horizontalHeader(), QHeaderView::Stretch);
+ mathsModule->packagesTW->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
map<string, string> const & packages = BufferParams::auto_packages();
mathsModule->packagesTW->setRowCount(packages.size());
int packnum = 0;
this, SLOT(change_adaptor()));
- mathsModule->MathIndentCO->addItem(qt_("Default"));
- mathsModule->MathIndentCO->addItem(qt_("Custom"));
+ mathsModule->MathIndentCO->addItem(qt_("Default"), toqstr("default"));
+ mathsModule->MathIndentCO->addItem(qt_("Custom"), toqstr("custom"));
mathsModule->MathIndentLE->setValidator(new LengthValidator(
mathsModule->MathIndentLE));
// initialize the length validator
// Modules
modulesModule = new UiWidget<Ui::ModulesUi>(this);
modulesModule->availableLV->header()->setVisible(false);
- setSectionResizeMode(modulesModule->availableLV->header(), QHeaderView::ResizeToContents);
+ modulesModule->availableLV->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
modulesModule->availableLV->header()->setStretchLastSection(false);
modulesModule->selectedLV->header()->setVisible(false);
- setSectionResizeMode(modulesModule->selectedLV->header(), QHeaderView::ResizeToContents);
+ modulesModule->selectedLV->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
modulesModule->selectedLV->header()->setStretchLastSection(false);
selectionManager =
new ModuleSelectionManager(this, modulesModule->availableLV,
this, SLOT(moduleFilterChanged(QString)));
connect(filter_, SIGNAL(returnPressed()),
this, SLOT(moduleFilterPressed()));
-#if (QT_VERSION < 0x050000)
- connect(filter_, SIGNAL(downPressed()),
- modulesModule->availableLV, SLOT(setFocus()));
-#else
connect(filter_, &FancyLineEdit::downPressed,
modulesModule->availableLV, [this](){ focusAndHighlight(modulesModule->availableLV); });
-#endif
// PDF support
this, SLOT(change_adaptor()));
connect(pdfSupportModule->fullscreenCB, SIGNAL(toggled(bool)),
this, SLOT(change_adaptor()));
- connect(pdfSupportModule->optionsLE, SIGNAL(textChanged(QString)),
+ connect(pdfSupportModule->optionsTE, SIGNAL(textChanged()),
+ this, SLOT(change_adaptor()));
+ connect(pdfSupportModule->metadataTE, SIGNAL(textChanged()),
this, SLOT(change_adaptor()));
pdfSupportModule->titleLE->setValidator(new NoNewLineValidator(
pdfSupportModule->subjectLE));
pdfSupportModule->keywordsLE->setValidator(new NoNewLineValidator(
pdfSupportModule->keywordsLE));
- pdfSupportModule->optionsLE->setValidator(new NoNewLineValidator(
- pdfSupportModule->optionsLE));
+ (void) new LaTeXHighlighter(pdfSupportModule->optionsTE->document(), true, true);
+ (void) new LaTeXHighlighter(pdfSupportModule->metadataTE->document(), true, true);
for (int i = 0; backref_opts[i][0]; ++i)
pdfSupportModule->backrefCO->addItem(qt_(backref_opts_gui[i]));
qt_("Input listings parameters below. Enter ? for a list of parameters."));
for (int i = 0; lst_packages[i][0]; ++i)
- listingsModule->packageCO->addItem(lst_packages[i]);
+ listingsModule->packageCO->addItem(lst_packages[i]);
// add the panels
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
- docPS->updateGeometry();
-#endif
}
void GuiDocument::onBufferViewChanged()
{
+ if (switchback_) {
+ // We are just switching back. Nothing to do.
+ switchback_ = false;
+ return;
+ }
+ BufferView const * view = bufferview();
+ string const new_filename = view ? view->buffer().absFileName() : string();
+ // If we switched buffer really and the previous file name is different to
+ // the current one, we ask on unapplied changes (#9369)
+ // FIXME: This is more complicated than it should be. Why do we need these to cycles?
+ // And ideally, we should propose to apply without having to switch back
+ // (e.g., via a LFUN_BUFFER_PARAMS_APPLY_OTHER)
+ if (!prev_buffer_filename_.empty() && prev_buffer_filename_ != new_filename
+ && buttonBox->button(QDialogButtonBox::Apply)->isEnabled()) {
+ // Only ask if we haven't yet in this cycle
+ int const ret = prompted_ ? 3 : Alert::prompt(_("Unapplied changes"),
+ _("Some changes in the previous document were not yet applied.\n"
+ "Do you want to switch back and apply them?"),
+ 1, 1, _("Yes, &Switch Back"), _("No, &Dismiss Changes"));
+ if (ret == 0) {
+ // Switch to previous buffer view and apply
+ switchback_ = true;
+ // Record that we have asked.
+ prompted_ = true;
+ lyx::dispatch(FuncRequest(LFUN_BUFFER_SWITCH, prev_buffer_filename_));
+ return;
+ } else if (ret == 3) {
+ // We are in the second cycle. Set back.
+ prompted_ = false;
+ return;
+ }
+ }
+
if (isVisibleView())
initialiseParams("");
}
void GuiDocument::setIndent(int item)
{
- bool const enable = (item == 1);
+ bool const enable = (textLayoutModule->indentCO->itemData(item) == "custom");
textLayoutModule->indentLE->setEnabled(enable);
textLayoutModule->indentLengthCO->setEnabled(enable);
textLayoutModule->skipLE->setEnabled(false);
mathsModule->MathIndentLengthCO->setEnabled(false);
}
if (mathsModule->MathIndentCB->isChecked()
- && mathsModule->MathIndentCO->currentIndex() == 1) {
+ && mathsModule->MathIndentCO->itemData(mathsModule->MathIndentCO->currentIndex()) == "custom") {
mathsModule->MathIndentLE->setEnabled(true);
mathsModule->MathIndentLengthCO->setEnabled(true);
}
fontModule->fontsMathCO->addItem(qt_("Class Default (TeX Fonts)"), QString("auto"));
fontModule->fontsMathCO->addItem(unimath, QString("default"));
+#if QT_VERSION >= 0x060000
+ const QStringList families(QFontDatabase::families());
+#else
QFontDatabase fontdb;
- QStringList families(fontdb.families());
+ const QStringList families(fontdb.families());
+#endif
for (auto const & family : families) {
fontModule->fontsRomanCO->addItem(family, family);
fontModule->fontsSansCO->addItem(family, family);
void GuiDocument::applyView()
{
+ // auto-validate local layout
+ if (!localLayout->isValid()) {
+ localLayout->validate();
+ if (!localLayout->isValid()) {
+ setApplyStopped(true);
+ docPS->setCurrentPanel(N_("Local Layout"));
+ return;
+ }
+ }
+
// preamble
preambleModule->apply(bp_);
localLayout->apply(bp_);
bp_.is_math_indent = mathsModule->MathIndentCB->isChecked();
if (bp_.is_math_indent) {
// if formulas are indented
- switch (mathsModule->MathIndentCO->currentIndex()) {
- case 0:
- bp_.setMathIndent(Length());
- break;
- case 1: {
+ if (mathsModule->MathIndentCO->itemData(mathsModule->MathIndentCO->currentIndex()) == "custom") {
Length mathindent(widgetsToLength(mathsModule->MathIndentLE,
mathsModule->MathIndentLengthCO));
bp_.setMathIndent(mathindent);
- break;
- }
- default:
- // this should never happen
+ } else
+ // default
bp_.setMathIndent(Length());
- break;
- }
}
switch (mathsModule->MathNumberingPosCO->currentIndex()) {
case 0:
if (textLayoutModule->indentRB->isChecked()) {
// if paragraphs are separated by an indentation
bp_.paragraph_separation = BufferParams::ParagraphIndentSeparation;
- switch (textLayoutModule->indentCO->currentIndex()) {
- case 0:
- bp_.setParIndent(Length());
- break;
- case 1: {
+ if (textLayoutModule->indentCO->itemData(textLayoutModule->indentCO->currentIndex()) == "custom") {
Length parindent(widgetsToLength(textLayoutModule->indentLE,
textLayoutModule->indentLengthCO));
bp_.setParIndent(parindent);
- break;
- }
- default:
- // this should never happen
+ } else
+ // default
bp_.setParIndent(Length());
- break;
- }
} else {
// if paragraphs are separated by a skip
bp_.paragraph_separation = BufferParams::ParagraphSkipSeparation;
else
pdf.pagemode.clear();
pdf.quoted_options = pdf.quoted_options_check(
- fromqstr(pdfSupportModule->optionsLE->text()));
+ fromqstr(pdfSupportModule->optionsTE->toPlainText()));
+#if QT_VERSION < 0x060000
+ bp_.document_metadata = qstring_to_ucs4(pdfSupportModule->metadataTE->toPlainText()
+ .trimmed().replace(QRegExp("\n+"), "\n"));
+#else
+ bp_.document_metadata = qstring_to_ucs4(pdfSupportModule->metadataTE->toPlainText()
+ .trimmed().replace(QRegularExpression("\n+"), "\n"));
+#endif
// change tracking
bp_.track_changes = changesModule->trackChangesCB->isChecked();
if (bp_.paragraph_separation == BufferParams::ParagraphIndentSeparation) {
textLayoutModule->indentRB->setChecked(true);
string parindent = bp_.getParIndent().asString();
- int indent = 0;
+ QString indent = toqstr("default");
if (!parindent.empty()) {
lengthToWidgets(textLayoutModule->indentLE,
textLayoutModule->indentLengthCO,
parindent, default_unit);
- indent = 1;
+ indent = toqstr("custom");
}
- textLayoutModule->indentCO->setCurrentIndex(indent);
- setIndent(indent);
+ textLayoutModule->indentCO->setCurrentIndex(textLayoutModule->indentCO->findData(indent));
+ setIndent(textLayoutModule->indentCO->currentIndex());
} else {
textLayoutModule->skipRB->setChecked(true);
VSpace::VSpaceKind skip = bp_.getDefSkip().kind();
pdfSupportModule->fullscreenCB->setChecked
(pdf.pagemode == pdf.pagemode_fullscreen);
- pdfSupportModule->optionsLE->setText(
+ pdfSupportModule->optionsTE->setPlainText(
toqstr(pdf.quoted_options));
+ pdfSupportModule->metadataTE->setPlainText(
+ toqstr(bp_.document_metadata));
+
// change tracking
changesModule->trackChangesCB->setChecked(bp_.track_changes);
changesModule->outputChangesCB->setChecked(bp_.output_changes);
{
return
validateListingsParameters().isEmpty() &&
- localLayout->isValid() &&
!localLayout->editing() &&
!preambleModule->editing() &&
(
// if we're asking for skips between paragraphs
!textLayoutModule->skipRB->isChecked() ||
// then either we haven't chosen custom
- textLayoutModule->skipCO->currentIndex() != 3 ||
+ VSpace::VSpaceKind(
+ textLayoutModule->skipCO->itemData(
+ textLayoutModule->skipCO->currentIndex()).toInt())
+ != VSpace::LENGTH ||
// or else a length has been given
!textLayoutModule->skipLE->text().isEmpty()
) &&
// if we're asking for indentation
!textLayoutModule->indentRB->isChecked() ||
// then either we haven't chosen custom
- textLayoutModule->indentCO->currentIndex() != 1 ||
+ (textLayoutModule->indentCO->itemData(
+ textLayoutModule->indentCO->currentIndex()) != "custom") ||
// or else a length has been given
!textLayoutModule->indentLE->text().isEmpty()
) &&
// if we're asking for math indentation
!mathsModule->MathIndentCB->isChecked() ||
// then either we haven't chosen custom
- mathsModule->MathIndentCO->currentIndex() != 1 ||
+ (mathsModule->MathIndentCO->itemData(
+ mathsModule->MathIndentCO->currentIndex()) != "custom") ||
// or else a length has been given
!mathsModule->MathIndentLE->text().isEmpty()
);
paramsToDialog();
return true;
}
+ prev_buffer_filename_ = view->buffer().absFileName();
bp_ = view->buffer().params();
loadModuleInfo();
updateAvailableModules();