#include "OutputParams.h"
#include "PDFOptions.h"
#include "qt_helpers.h"
+#include "Session.h"
#include "Spacing.h"
#include "TextClass.h"
#include "Undo.h"
#include "frontends/alert.h"
#include <QAbstractItemModel>
-#include <QHeaderView>
+#include <QButtonGroup>
#include <QColor>
#include <QColorDialog>
#include <QCloseEvent>
#include <QFontDatabase>
+#include <QHeaderView>
#include <QScrollBar>
#include <QTextBoundaryFinder>
#include <QTextCursor>
}
};
-}
+} // namespace
namespace frontend {
namespace {
preambleTE->setWordWrapMode(QTextOption::NoWrap);
setFocusProxy(preambleTE);
connect(preambleTE, SIGNAL(textChanged()), this, SIGNAL(changed()));
+ connect(findLE, SIGNAL(textEdited(const QString &)), this, SLOT(checkFindButton()));
+ connect(findButtonPB, SIGNAL(clicked()), this, SLOT(findText()));
+ connect(findLE, SIGNAL(returnPressed()), this, SLOT(findText()));
+ checkFindButton();
+ // https://stackoverflow.com/questions/13027091/how-to-override-tab-width-in-qt
+ const int tabStop = 4;
+ QFontMetrics metrics(preambleTE->currentFont());
+ preambleTE->setTabStopWidth(tabStop * metrics.width(' '));
+}
+
+
+void PreambleModule::checkFindButton()
+{
+ findButtonPB->setEnabled(!findLE->text().isEmpty());
+}
+
+
+void PreambleModule::findText()
+{
+ bool const found = preambleTE->find(findLE->text());
+ if (!found) {
+ // wrap
+ QTextCursor qtcur = preambleTE->textCursor();
+ qtcur.movePosition(QTextCursor::Start);
+ preambleTE->setTextCursor(qtcur);
+ preambleTE->find(findLE->text());
+ }
}
LocalLayout::LocalLayout(QWidget * parent)
: UiWidget<Ui::LocalLayoutUi>(parent), current_id_(0), validated_(false)
{
+ locallayoutTE->setFont(guiApp->typewriterSystemFont());
+ locallayoutTE->setWordWrapMode(QTextOption::NoWrap);
connect(locallayoutTE, SIGNAL(textChanged()), this, SLOT(textChanged()));
connect(validatePB, SIGNAL(clicked()), this, SLOT(validatePressed()));
connect(convertPB, SIGNAL(clicked()), this, SLOT(convertPressed()));
GuiDocument::GuiDocument(GuiView & lv)
: GuiDialog(lv, "document", qt_("Document Settings")),
- biblioChanged_(false), nonModuleChanged_(false)
+ biblioChanged_(false), nonModuleChanged_(false),
+ modulesChanged_(false), shellescapeChanged_(false)
{
setupUi(this);
connect(outputModule->mathoutCB, SIGNAL(currentIndexChanged(int)),
this, SLOT(change_adaptor()));
+ connect(outputModule->shellescapeCB, SIGNAL(stateChanged(int)),
+ this, SLOT(shellescapeChanged()));
connect(outputModule->outputsyncCB, SIGNAL(clicked()),
this, SLOT(change_adaptor()));
connect(outputModule->synccustomCB, SIGNAL(editTextChanged(QString)),
// Always put the default encoding in the first position.
langModule->encodingCO->addItem(qt_("Language Default (no inputenc)"));
QStringList encodinglist;
- Encodings::const_iterator it = encodings.begin();
- Encodings::const_iterator const end = encodings.end();
- for (; it != end; ++it)
- if (!it->unsafe())
- encodinglist.append(qt_(it->guiName()));
+ for (auto const & encvar : encodings) {
+ if (!encvar.unsafe() && !encvar.guiName().empty())
+ encodinglist.append(qt_(encvar.guiName()));
+ }
encodinglist.sort();
langModule->encodingCO->addItems(encodinglist);
this, SLOT(updateResetDefaultBiblio()));
connect(biblioModule->biblatexBbxCO, SIGNAL(activated(int)),
this, SLOT(biblioChanged()));
+ connect(biblioModule->biblatexBbxCO, SIGNAL(editTextChanged(QString)),
+ this, SLOT(biblioChanged()));
connect(biblioModule->biblatexBbxCO, SIGNAL(editTextChanged(QString)),
this, SLOT(updateResetDefaultBiblio()));
connect(biblioModule->biblatexCbxCO, SIGNAL(activated(int)),
this, SLOT(biblioChanged()));
+ connect(biblioModule->biblatexCbxCO, SIGNAL(editTextChanged(QString)),
+ this, SLOT(biblioChanged()));
connect(biblioModule->biblatexCbxCO, SIGNAL(editTextChanged(QString)),
this, SLOT(updateResetDefaultBiblio()));
connect(biblioModule->rescanBibliosPB, SIGNAL(clicked()),
biblioModule->bibtexOptionsLE));
biblioModule->defaultBiblioCO->lineEdit()->setValidator(new NoNewLineValidator(
biblioModule->defaultBiblioCO->lineEdit()));
+ biblioModule->citePackageOptionsLE->setValidator(new NoNewLineValidator(
+ biblioModule->citePackageOptionsLE));
// NOTE: we do not provide "custom" here for security reasons!
biblioModule->bibtexCO->clear();
setSectionResizeMode(mathsModule->packagesTW->horizontalHeader(), QHeaderView::Stretch);
map<string, string> const & packages = BufferParams::auto_packages();
mathsModule->packagesTW->setRowCount(packages.size());
- int i = 0;
+ int packnum = 0;
for (map<string, string>::const_iterator it = packages.begin();
it != packages.end(); ++it) {
docstring const package = from_ascii(it->first);
autoRB->setToolTip(autoTooltip);
alwaysRB->setToolTip(alwaysTooltip);
neverRB->setToolTip(neverTooltip);
+
+ // Pack the buttons in a layout in order to get proper alignment
+ QWidget * autoRBWidget = new QWidget();
+ QHBoxLayout * autoRBLayout = new QHBoxLayout(autoRBWidget);
+ autoRBLayout->addWidget(autoRB);
+ autoRBLayout->setAlignment(Qt::AlignCenter);
+ autoRBLayout->setContentsMargins(0, 0, 0, 0);
+ autoRBWidget->setLayout(autoRBLayout);
+
+ QWidget * alwaysRBWidget = new QWidget();
+ QHBoxLayout * alwaysRBLayout = new QHBoxLayout(alwaysRBWidget);
+ alwaysRBLayout->addWidget(alwaysRB);
+ alwaysRBLayout->setAlignment(Qt::AlignCenter);
+ alwaysRBLayout->setContentsMargins(0, 0, 0, 0);
+ alwaysRBWidget->setLayout(alwaysRBLayout);
+
+ QWidget * neverRBWidget = new QWidget();
+ QHBoxLayout * neverRBLayout = new QHBoxLayout(neverRBWidget);
+ neverRBLayout->addWidget(neverRB);
+ neverRBLayout->setAlignment(Qt::AlignCenter);
+ neverRBLayout->setContentsMargins(0, 0, 0, 0);
+ neverRBWidget->setLayout(neverRBLayout);
+
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);
+
+ mathsModule->packagesTW->setItem(packnum, 0, pack);
+ mathsModule->packagesTW->setCellWidget(packnum, 1, autoRBWidget);
+ mathsModule->packagesTW->setCellWidget(packnum, 2, alwaysRBWidget);
+ mathsModule->packagesTW->setCellWidget(packnum, 3, neverRBWidget);
connect(autoRB, SIGNAL(clicked()),
this, SLOT(change_adaptor()));
this, SLOT(change_adaptor()));
connect(neverRB, SIGNAL(clicked()),
this, SLOT(change_adaptor()));
- ++i;
+ ++packnum;
}
connect(mathsModule->allPackagesAutoPB, SIGNAL(clicked()),
this, SLOT(allPackagesAuto()));
connect(mathsModule->MathIndentLengthCO, SIGNAL(activated(int)),
this, SLOT(change_adaptor()));
-
+
mathsModule->MathIndentCO->addItem(qt_("Default"));
mathsModule->MathIndentCO->addItem(qt_("Custom"));
mathsModule->MathIndentLE->setValidator(new LengthValidator(
mathsModule->MathNumberingPosCO->addItem(qt_("Default"));
mathsModule->MathNumberingPosCO->addItem(qt_("Right"));
mathsModule->MathNumberingPosCO->setCurrentIndex(1);
-
+
// latex class
latexModule = new UiWidget<Ui::LaTeXUi>(this);
this, SLOT(setListingsMessage()));
connect(listingsModule->packageCO, SIGNAL(activated(int)),
this, SLOT(change_adaptor()));
- connect(listingsModule->packageCO, SIGNAL(currentIndexChanged(int)),
+ connect(listingsModule->packageCO, SIGNAL(activated(int)),
this, SLOT(listingsPackageChanged(int)));
connect(listingsModule->listingsED, SIGNAL(textChanged()),
this, SLOT(setListingsMessage()));
}
+void GuiDocument::shellescapeChanged()
+{
+ shellescapeChanged_ = true;
+ changed();
+}
+
+
+void GuiDocument::slotApply()
+{
+ bool only_shellescape_changed = !nonModuleChanged_ && !modulesChanged_;
+ bool wasclean = buffer().isClean();
+ GuiDialog::slotApply();
+ if (wasclean && only_shellescape_changed)
+ buffer().markClean();
+ modulesChanged_ = false;
+}
+
+
+void GuiDocument::slotOK()
+{
+ bool only_shellescape_changed = !nonModuleChanged_ && !modulesChanged_;
+ bool wasclean = buffer().isClean();
+ GuiDialog::slotOK();
+ if (wasclean && only_shellescape_changed)
+ buffer().markClean();
+ modulesChanged_ = false;
+}
+
+
void GuiDocument::includeonlyClicked(QTreeWidgetItem * item, int)
{
if (item == 0)
fontModule->fontsRomanCO->currentIndex()).toString();
fontModule->fontScCB->setEnabled(providesSC(font));
fontModule->fontOsfCB->setEnabled(providesOSF(font));
- fontModule->dashesCB->setEnabled(tex_fonts);
updateMathFonts(font);
}
}
+void GuiDocument::checkPossibleCiteEngines()
+{
+ // Check if the class provides a specific engine,
+ // and if so, enforce this.
+ string force_engine;
+ if (documentClass().provides("natbib")
+ || documentClass().provides("natbib-internal"))
+ force_engine = "natbib";
+ else if (documentClass().provides("jurabib"))
+ force_engine = "jurabib";
+ else if (documentClass().provides("biblatex"))
+ force_engine = "biblatex";
+ else if (documentClass().provides("biblatex-natbib"))
+ force_engine = "biblatex-natbib";
+
+ if (!force_engine.empty())
+ biblioModule->citeEngineCO->setCurrentIndex(
+ biblioModule->citeEngineCO->findData(toqstr(force_engine)));
+ biblioModule->citeEngineCO->setEnabled(force_engine.empty());
+}
+
+
void GuiDocument::rescanBibFiles()
{
if (isBiblatex())
{
modulesToParams(bp_);
- if (applyPB->isEnabled() && nonModuleChanged_) {
+ if (applyPB->isEnabled() && (nonModuleChanged_ || shellescapeChanged_)) {
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."),
applyView();
}
+ modulesChanged_ = true;
bp_.makeDocumentClass();
paramsToDialog();
changed();
if (!item)
continue;
int row = mathsModule->packagesTW->row(item);
- QRadioButton * rb = (QRadioButton*)mathsModule->packagesTW->cellWidget(row, 1);
+
+ QRadioButton * rb =
+ (QRadioButton*)mathsModule->packagesTW->cellWidget(row, 1)->layout()->itemAt(0)->widget();
if (rb->isChecked()) {
bp_.use_package(it->first, BufferParams::package_auto);
continue;
}
- rb = (QRadioButton*)mathsModule->packagesTW->cellWidget(row, 2);
+ rb = (QRadioButton*)mathsModule->packagesTW->cellWidget(row, 2)->layout()->itemAt(0)->widget();
if (rb->isChecked()) {
bp_.use_package(it->first, BufferParams::package_on);
continue;
}
- rb = (QRadioButton*)mathsModule->packagesTW->cellWidget(row, 3);
+ rb = (QRadioButton*)mathsModule->packagesTW->cellWidget(row, 3)->layout()->itemAt(0)->widget();
if (rb->isChecked())
bp_.use_package(it->first, BufferParams::package_off);
}
bool const nontexfonts = fontModule->osFontsCB->isChecked();
bp_.useNonTeXFonts = nontexfonts;
+ bp_.shell_escape = outputModule->shellescapeCB->isChecked();
+ if (!bp_.shell_escape)
+ theSession().shellescapeFiles().remove(buffer().absFileName());
+ else if (!theSession().shellescapeFiles().find(buffer().absFileName()))
+ theSession().shellescapeFiles().insert(buffer().absFileName());
+ Buffer & buf = const_cast<Buffer &>(buffer());
+ buf.params().shell_escape = bp_.shell_escape;
+
bp_.output_sync = outputModule->outputsyncCB->isChecked();
bp_.output_sync_macro = fromqstr(outputModule->synccustomCB->currentText());
fromqstr(fontModule->cjkFontLE->text());
bp_.use_microtype = fontModule->microtypeCB->isChecked();
- bp_.use_dash_ligatures = fontModule->dashesCB->isChecked();
+ bp_.use_dash_ligatures = !fontModule->dashesCB->isChecked();
bp_.fonts_sans_scale[nontexfonts] = fontModule->scaleSansSB->value();
bp_.fonts_sans_scale[!nontexfonts] = fontModule->font_sf_scale;
pdf.quoted_options = pdf.quoted_options_check(
fromqstr(pdfSupportModule->optionsLE->text()));
- // reset tracker
+ // reset trackers
nonModuleChanged_ = false;
+ shellescapeChanged_ = false;
}
updateEngineType(documentClass().opt_enginetype(),
bp_.citeEngineType());
+ checkPossibleCiteEngines();
+
biblioModule->citeStyleCO->setCurrentIndex(
biblioModule->citeStyleCO->findData(bp_.citeEngineType()));
biblioChanged_ = false;
// indices
- // We may be called when there is no Buffer, e.g., when
+ // 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);
int row = mathsModule->packagesTW->row(item);
switch (bp_.use_package(it->first)) {
case BufferParams::package_off: {
- QRadioButton * rb = (QRadioButton*)mathsModule->packagesTW->cellWidget(row, 3);
+ QRadioButton * rb =
+ (QRadioButton*)mathsModule->packagesTW->cellWidget(row, 3)->layout()->itemAt(0)->widget();
rb->setChecked(true);
break;
}
case BufferParams::package_on: {
- QRadioButton * rb = (QRadioButton*)mathsModule->packagesTW->cellWidget(row, 2);
+ QRadioButton * rb =
+ (QRadioButton*)mathsModule->packagesTW->cellWidget(row, 2)->layout()->itemAt(0)->widget();
rb->setChecked(true);
break;
}
case BufferParams::package_auto: {
- QRadioButton * rb = (QRadioButton*)mathsModule->packagesTW->cellWidget(row, 1);
+ QRadioButton * rb =
+ (QRadioButton*)mathsModule->packagesTW->cellWidget(row, 1)->layout()->itemAt(0)->widget();
rb->setChecked(true);
break;
}
toqstr(bp_.fonts_cjk));
else
fontModule->cjkFontLE->setText(QString());
-
+
fontModule->microtypeCB->setChecked(bp_.use_microtype);
- fontModule->dashesCB->setChecked(bp_.use_dash_ligatures);
+ fontModule->dashesCB->setChecked(!bp_.use_dash_ligatures);
fontModule->fontScCB->setChecked(bp_.fonts_expert_sc);
fontModule->fontOsfCB->setChecked(bp_.fonts_old_figures);
index = 0;
outputModule->defaultFormatCO->setCurrentIndex(index);
+ outputModule->shellescapeCB->setChecked(bp_.shell_escape);
outputModule->outputsyncCB->setChecked(bp_.output_sync);
outputModule->synccustomCB->setEditText(toqstr(bp_.output_sync_macro));
// clear changed branches cache
changedBranches_.clear();
- // reset tracker
+ // reset trackers
nonModuleChanged_ = false;
+ shellescapeChanged_ = false;
}
all_unincluded = false;
}
// Both if all childs are included and if none is included
- // is equal to "include all" (i.e., ommit \includeonly).
+ // is equal to "include all" (i.e., omit \includeonly).
// Thus, reset the GUI.
if (!has_unincluded || all_unincluded) {
masterChildModule->includeallRB->setChecked(true);
biblioModule->citeEngineCO->itemData(
biblioModule->citeEngineCO->currentIndex()).toString();
+ // this can happen if the cite engine is unknown, which can happen
+ // if one is using a file that came from someone else, etc. in that
+ // case, we crash if we proceed.
+ if (engine.isEmpty())
+ return false;
+
return theCiteEnginesList[fromqstr(engine)]->getCiteFramework() == "biblatex";
}
}
bp_.useClassDefaults();
paramsToDialog();
+ changed();
}
// 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 handles undo groups automagically
+ UndoGroupHelper ugh(&buf);
// This must come first so that a language change is correctly noticed
setLanguage();
// 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::allPackages(int col)
{
for (int row = 0; row < mathsModule->packagesTW->rowCount(); ++row) {
- QRadioButton * rb = (QRadioButton*)mathsModule->packagesTW->cellWidget(row, col);
+ QRadioButton * rb =
+ (QRadioButton*)mathsModule->packagesTW->cellWidget(row, col)->layout()->itemAt(0)->widget();
rb->setChecked(true);
}
}