#include "GuiApplication.h"
#include "GuiBranches.h"
#include "GuiIndices.h"
+#include "GuiView.h"
#include "GuiSelectionManager.h"
-#include "LaTeXHighlighter.h"
#include "Validator.h"
#include "LayoutFile.h"
#include <QAbstractItemModel>
#include <QButtonGroup>
#include <QColor>
-#include <QColorDialog>
#include <QCloseEvent>
#include <QDirIterator>
#include <QFontDatabase>
#include <vector>
-// a style sheet for buttons
-// this is for example used for the background color setting button
-static inline QString colorButtonStyleSheet(QColor const & bgColor)
+// a style sheet for color frame widgets
+static inline QString colorFrameStyleSheet(QColor const & bgColor)
{
if (bgColor.isValid()) {
QString rc = QLatin1String("background-color:");
}
QModelIndex const & idx = availableLV->selectionModel()->currentIndex();
+
+ if (!idx.isValid())
+ return;
if (getAvailableModel()->itemFromIndex(idx)->hasChildren()) {
// This is a category header
/////////////////////////////////////////////////////////////////////
PreambleModule::PreambleModule(QWidget * parent)
- : UiWidget<Ui::PreambleUi>(parent), current_id_(nullptr)
+ : UiWidget<Ui::PreambleUi>(parent), current_id_(nullptr),
+ highlighter_(new LaTeXHighlighter(preambleTE->document(), true))
{
// This is not a memory leak. The object will be destroyed
// with this.
// @ is letter in the LyX user preamble
- (void) new LaTeXHighlighter(preambleTE->document(), true);
preambleTE->setFont(guiApp->typewriterSystemFont());
preambleTE->setWordWrapMode(QTextOption::NoWrap);
setFocusProxy(preambleTE);
+ // Install event filter on find line edit to capture return/enter key
+ findLE->installEventFilter(this);
connect(preambleTE, SIGNAL(textChanged()), this, SIGNAL(changed()));
connect(findLE, SIGNAL(textEdited(const QString &)), this, SLOT(checkFindButton()));
connect(findButtonPB, SIGNAL(clicked()), this, SLOT(findText()));
}
+bool PreambleModule::eventFilter(QObject * sender, QEvent * event)
+{
+ if (sender == findLE) {
+ if (event->type() == QEvent::KeyPress) {
+ QKeyEvent * key = static_cast<QKeyEvent *>(event);
+ if ((key->key() == Qt::Key_Enter) || (key->key() == Qt::Key_Return)) {
+ findText();
+ // Return true to filter out the event
+ return true;
+ }
+ }
+ }
+ if (event->type() == QEvent::ApplicationPaletteChange) {
+ // mode switch: colors need to be updated
+ // and the highlighting redone
+ if (highlighter_) {
+ highlighter_->setupColors();
+ highlighter_->rehighlight();
+ }
+ }
+ return QWidget::eventFilter(sender, event);
+}
+
+
+
void PreambleModule::checkFindButton()
{
findButtonPB->setEnabled(!findLE->text().isEmpty());
docstring const s = tempfilename.fileContents("UTF-8");
preambleTE->document()->setPlainText(toqstr(s));
tempfile_.reset();
- editPB->setText(qt_("&Edit"));
+ editPB->setText(qt_("&Edit Externally"));
+ editPB->setIcon(QIcon());
changed();
return;
}
preambleTE->setReadOnly(true);
theFormats().edit(*current_id_, tempfilename, format);
editPB->setText(qt_("&End Edit"));
+ QIcon warn(guiApp ? guiApp->getScaledPixmap("images/", "emblem-shellescape-user")
+ : getPixmap("images/", "emblem-shellescape", "svgz,png"));
+ editPB->setIcon(warn);
changed();
}
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"));
+ editPB->setIcon(QIcon());
changed();
return;
}
locallayoutTE->setReadOnly(true);
theFormats().edit(*current_id_, tempfilename, format);
editPB->setText(qt_("&End Edit"));
+ QIcon warn(guiApp ? guiApp->getScaledPixmap("images/", "emblem-shellescape-user")
+ : getPixmap("images/", "emblem-shellescape", "svgz,png"));
+ editPB->setIcon(warn);
validatePB->setEnabled(false);
hideConvert();
changed();
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->lspacingLE->setValidator(new QDoubleValidator(
textLayoutModule->lspacingLE));
textLayoutModule->indentLE->setValidator(new LengthValidator(
- textLayoutModule->indentLE));
+ textLayoutModule->indentLE, false));
textLayoutModule->skipLE->setValidator(new LengthValidator(
- textLayoutModule->skipLE));
+ textLayoutModule->skipLE, false));
textLayoutModule->indentCO->addItem(qt_("Default"), toqstr("default"));
textLayoutModule->indentCO->addItem(qt_("Custom"), toqstr("custom"));
textLayoutModule->lspacingCO->insertItem(
Spacing::Other, qt_("Custom"));
// initialize the length validator
- bc().addCheckedLineEdit(textLayoutModule->indentLE);
- bc().addCheckedLineEdit(textLayoutModule->skipLE);
+ bc().addCheckedLineEdit(textLayoutModule->indentLE, textLayoutModule->indentRB);
+ bc().addCheckedLineEditPanel(textLayoutModule->indentLE, docPS, N_("Text Layout"));
+ bc().addCheckedLineEdit(textLayoutModule->skipLE, textLayoutModule->skipRB);
+ bc().addCheckedLineEditPanel(textLayoutModule->skipLE, docPS, N_("Text Layout"));
textLayoutModule->tableStyleCO->addItem(qt_("Default"), toqstr("default"));
getTableStyles();
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);
outputModule->synccustomCB->addItem("\\synctex=-1");
outputModule->synccustomCB->addItem("\\usepackage[active]{srcltx}");
- outputModule->synccustomCB->setValidator(new NoNewLineValidator(
+ outputModule->synccustomCB->lineEdit()->setValidator(new NoNewLineValidator(
outputModule->synccustomCB));
connect(outputModule->saveTransientPropertiesCB, SIGNAL(clicked()),
pageLayoutModule->pagestyleCO->addItem(qt_("fancy"));
bc().addCheckedLineEdit(pageLayoutModule->paperheightLE,
pageLayoutModule->paperheightL);
+ bc().addCheckedLineEditPanel(pageLayoutModule->paperheightLE, docPS, N_("Page Layout"));
bc().addCheckedLineEdit(pageLayoutModule->paperwidthLE,
pageLayoutModule->paperwidthL);
+ bc().addCheckedLineEditPanel(pageLayoutModule->paperwidthLE, docPS, N_("Page Layout"));
QComboBox * cb = pageLayoutModule->papersizeCO;
cb->addItem(qt_("Default"));
// margins
marginsModule = new UiWidget<Ui::MarginsUi>(this);
- connect(marginsModule->marginCB, SIGNAL(toggled(bool)),
+ connect(marginsModule->marginCB, SIGNAL(clicked(bool)),
this, SLOT(setCustomMargins(bool)));
connect(marginsModule->marginCB, SIGNAL(clicked()),
this, SLOT(change_adaptor()));
bc().addCheckedLineEdit(marginsModule->topLE,
marginsModule->topL);
+ bc().addCheckedLineEditPanel(marginsModule->topLE,
+ docPS, N_("Page Margins"));
bc().addCheckedLineEdit(marginsModule->bottomLE,
marginsModule->bottomL);
+ bc().addCheckedLineEditPanel(marginsModule->bottomLE,
+ docPS, N_("Page Margins"));
bc().addCheckedLineEdit(marginsModule->innerLE,
marginsModule->innerL);
+ bc().addCheckedLineEditPanel(marginsModule->innerLE,
+ docPS, N_("Page Margins"));
bc().addCheckedLineEdit(marginsModule->outerLE,
marginsModule->outerL);
+ bc().addCheckedLineEditPanel(marginsModule->outerLE,
+ docPS, N_("Page Margins"));
bc().addCheckedLineEdit(marginsModule->headsepLE,
marginsModule->headsepL);
+ bc().addCheckedLineEditPanel(marginsModule->headsepLE,
+ docPS, N_("Page Margins"));
bc().addCheckedLineEdit(marginsModule->headheightLE,
marginsModule->headheightL);
+ bc().addCheckedLineEditPanel(marginsModule->headheightLE,
+ docPS, N_("Page Margins"));
bc().addCheckedLineEdit(marginsModule->footskipLE,
marginsModule->footskipL);
+ bc().addCheckedLineEditPanel(marginsModule->footskipLE,
+ docPS, N_("Page Margins"));
bc().addCheckedLineEdit(marginsModule->columnsepLE,
marginsModule->columnsepL);
+ bc().addCheckedLineEditPanel(marginsModule->columnsepLE,
+ docPS, N_("Page Margins"));
// color
this, SLOT(outputChangesToggled(bool)));
connect(changesModule->changeBarsCB, SIGNAL(clicked()),
this, SLOT(change_adaptor()));
+ connect(&lv, SIGNAL(changeTrackingToggled(bool)),
+ this, SLOT(changeTrackingChanged(bool)));
// numbering
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;
connect(mathsModule->MathNumberingPosCO, SIGNAL(activated(int)),
this, SLOT(change_adaptor()));
- connect(mathsModule->MathIndentCB, SIGNAL(toggled(bool)),
- this, SLOT(change_adaptor()));
connect(mathsModule->MathIndentCB, SIGNAL(toggled(bool)),
this, SLOT(allowMathIndent()));
- connect(mathsModule->MathIndentCO, SIGNAL(activated(int)),
+ connect(mathsModule->MathIndentCB, SIGNAL(toggled(bool)),
this, SLOT(change_adaptor()));
connect(mathsModule->MathIndentCO, SIGNAL(activated(int)),
this, SLOT(enableMathIndent(int)));
+ connect(mathsModule->MathIndentCO, SIGNAL(activated(int)),
+ this, SLOT(change_adaptor()));
connect(mathsModule->MathIndentLE, SIGNAL(textChanged(const QString &)),
this, SLOT(change_adaptor()));
connect(mathsModule->MathIndentLengthCO, SIGNAL(activated(int)),
mathsModule->MathIndentCO->addItem(qt_("Default"), toqstr("default"));
mathsModule->MathIndentCO->addItem(qt_("Custom"), toqstr("custom"));
mathsModule->MathIndentLE->setValidator(new LengthValidator(
- mathsModule->MathIndentLE));
+ mathsModule->MathIndentLE, false));
// initialize the length validator
- bc().addCheckedLineEdit(mathsModule->MathIndentLE);
+ bc().addCheckedLineEdit(mathsModule->MathIndentLE, mathsModule->MathIndentCB);
+ bc().addCheckedLineEditPanel(mathsModule->MathIndentLE, docPS, N_("Math Options"));
mathsModule->MathNumberingPosCO->addItem(qt_("Left"));
mathsModule->MathNumberingPosCO->addItem(qt_("Default"));
mathsModule->MathNumberingPosCO->addItem(qt_("Right"));
this, SLOT(change_adaptor()));
connect(latexModule->refstyleCB, SIGNAL(clicked()),
this, SLOT(change_adaptor()));
+ connect(latexModule->refFormattedCB, SIGNAL(clicked()),
+ this, SLOT(change_adaptor()));
latexModule->optionsLE->setValidator(new NoNewLineValidator(
latexModule->optionsLE));
// 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
pdfSupportModule->subjectLE));
pdfSupportModule->keywordsLE->setValidator(new NoNewLineValidator(
pdfSupportModule->keywordsLE));
- (void) new LaTeXHighlighter(pdfSupportModule->optionsTE->document(), true, true);
- (void) new LaTeXHighlighter(pdfSupportModule->metadataTE->document(), true, true);
+
+ pdf_options_highlighter_ = new LaTeXHighlighter(
+ pdfSupportModule->optionsTE->document(), true, true);
+ pdf_metadata_highlighter_ = new LaTeXHighlighter(
+ pdfSupportModule->metadataTE->document(), true, true);
for (int i = 0; backref_opts[i][0]; ++i)
pdfSupportModule->backrefCO->addItem(qt_(backref_opts_gui[i]));
docPS->addPanel(listingsModule, N_("Listings[[inset]]"));
docPS->addPanel(bulletsModule, N_("Bullets"));
docPS->addPanel(branchesModule, N_("Branches"));
- docPS->addPanel(outputModule, N_("Formats[[output]]"));
+ 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
- docPS->updateGeometry();
-#endif
+
+ // Filter out (dark/light) mode changes
+ installEventFilter(this);
}
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::changeTrackingChanged(bool state)
+{
+ // This is triggered if the CT state is toggled outside
+ // the document dialog (e.g., menu).
+ changesModule->trackChangesCB->setChecked(state);
+}
+
+
void GuiDocument::slotApply()
{
bool only_shellescape_changed = !nonModuleChanged_ && !modulesChanged_;
if (wasclean && only_shellescape_changed)
buffer().markClean();
modulesChanged_ = false;
+ isValid();
}
return 0 < b.name.localeAwareCompare(a.name);
});
- QIcon user_icon(getPixmap("images/", "lyxfiles-user", "svgz,png"));
- QIcon system_icon(getPixmap("images/", "lyxfiles-system", "svgz,png"));
+ QIcon user_icon(guiApp ? guiApp->getScaledPixmap("images/", "lyxfiles-user")
+ : getPixmap("images/", "lyxfiles-user", "svgz,png"));
+ QIcon system_icon(guiApp ? guiApp->getScaledPixmap("images/", "lyxfiles-system")
+ : getPixmap("images/", "lyxfiles-system", "svgz,png"));
int i = 0;
for (modInfoStruct const & m : modInfoList) {
return;
string child = fromqstr(item->text(0));
+
if (child.empty())
return;
- if (std::find(includeonlys_.begin(),
- includeonlys_.end(), child) != includeonlys_.end())
+ if (isChildIncluded(child))
includeonlys_.remove(child);
else
includeonlys_.push_back(child);
- updateIncludeonlys();
+ updateIncludeonlys(false);
change_adaptor();
}
static bool isOK = true;
QString msg = validateListingsParameters();
if (msg.isEmpty()) {
+ listingsModule->listingsTB->setTextColor(QColor());
if (isOK)
return;
isOK = true;
- // listingsModule->listingsTB->setTextColor("black");
listingsModule->listingsTB->setPlainText(
qt_("Input listings parameters below. "
"Enter ? for a list of parameters."));
} else {
isOK = false;
- // listingsModule->listingsTB->setTextColor("red");
+ listingsModule->listingsTB->setTextColor(QColor(255, 0, 0));
listingsModule->listingsTB->setPlainText(msg);
}
}
textLayoutModule->indentLengthCO->setEnabled(enable);
textLayoutModule->skipLE->setEnabled(false);
textLayoutModule->skipLengthCO->setEnabled(false);
+ // needed to catch empty custom case
+ bc().refresh();
isValid();
}
bool const enable = (kind == VSpace::LENGTH);
textLayoutModule->skipLE->setEnabled(enable);
textLayoutModule->skipLengthCO->setEnabled(enable);
+ // needed to catch empty custom case
+ bc().refresh();
isValid();
}
bool const enable = (item == 1);
mathsModule->MathIndentLE->setEnabled(enable);
mathsModule->MathIndentLengthCO->setEnabled(enable);
+ // needed to catch empty custom case
+ bc().refresh();
isValid();
}
marginsModule->marginCB->setChecked(!bp_.use_geometry);
setCustomMargins(!bp_.use_geometry);
}
-
- // set some placeholder text that hint on defaults
- QString const placeholder = marginsModule->marginCB->isChecked() ?
- qt_("Class defaults") : qt_("Package defaults");
- // set tooltip depending on gemoetry state
- QString const tooltip = marginsModule->marginCB->isChecked() ?
- qt_("If no value is given, the defaults as set by the class are used.")
- : qt_("If no value is given, the defaults as set by the geometry package or a package/class overriding geometry's defaults are used.");
- marginsModule->topLE->setPlaceholderText(placeholder);
- marginsModule->bottomLE->setPlaceholderText(placeholder);
- marginsModule->innerLE->setPlaceholderText(placeholder);
- marginsModule->outerLE->setPlaceholderText(placeholder);
- marginsModule->headheightLE->setPlaceholderText(placeholder);
- marginsModule->headsepLE->setPlaceholderText(placeholder);
- marginsModule->footskipLE->setPlaceholderText(placeholder);
- marginsModule->columnsepLE->setPlaceholderText(placeholder);
- marginsModule->topLE->setToolTip(tooltip);
- marginsModule->bottomLE->setToolTip(tooltip);
- marginsModule->innerLE->setToolTip(tooltip);
- marginsModule->outerLE->setToolTip(tooltip);
- marginsModule->headheightLE->setToolTip(tooltip);
- marginsModule->headsepLE->setToolTip(tooltip);
- marginsModule->footskipLE->setToolTip(tooltip);
- marginsModule->columnsepLE->setToolTip(tooltip);
}
}
-void GuiDocument::setCustomMargins(bool custom)
-{
- marginsModule->topL->setEnabled(!custom);
- marginsModule->topLE->setEnabled(!custom);
- marginsModule->topUnit->setEnabled(!custom);
+void GuiDocument::setCustomMargins(bool cb_checked)
+{
+ bool const custom_margins = !cb_checked;
+ if (custom_margins) {
+ Length::UNIT const default_unit = Length::defaultUnit();
+ // fill with chached values
+ lengthToWidgets(marginsModule->topLE,
+ marginsModule->topUnit,
+ tmp_topmargin_, default_unit);
+ lengthToWidgets(marginsModule->bottomLE,
+ marginsModule->bottomUnit,
+ tmp_bottommargin_, default_unit);
+ lengthToWidgets(marginsModule->innerLE,
+ marginsModule->innerUnit,
+ tmp_leftmargin_, default_unit);
+ lengthToWidgets(marginsModule->outerLE,
+ marginsModule->outerUnit,
+ tmp_rightmargin_, default_unit);
+ lengthToWidgets(marginsModule->headheightLE,
+ marginsModule->headheightUnit,
+ tmp_headheight_, default_unit);
+ lengthToWidgets(marginsModule->headsepLE,
+ marginsModule->headsepUnit,
+ tmp_headsep_, default_unit);
+ lengthToWidgets(marginsModule->footskipLE,
+ marginsModule->footskipUnit,
+ tmp_footskip_, default_unit);
+ lengthToWidgets(marginsModule->columnsepLE,
+ marginsModule->columnsepUnit,
+ tmp_columnsep_, default_unit);
+ } else { // default margins
+ // Cache current values
+ tmp_leftmargin_ = widgetsToLength(marginsModule->innerLE,
+ marginsModule->innerUnit);
+ tmp_topmargin_ = widgetsToLength(marginsModule->topLE,
+ marginsModule->topUnit);
+ tmp_rightmargin_ = widgetsToLength(marginsModule->outerLE,
+ marginsModule->outerUnit);
+ tmp_bottommargin_ = widgetsToLength(marginsModule->bottomLE,
+ marginsModule->bottomUnit);
+ tmp_headheight_ = widgetsToLength(marginsModule->headheightLE,
+ marginsModule->headheightUnit);
+ tmp_headsep_ = widgetsToLength(marginsModule->headsepLE,
+ marginsModule->headsepUnit);
+ tmp_footskip_ = widgetsToLength(marginsModule->footskipLE,
+ marginsModule->footskipUnit);
+ tmp_columnsep_ = widgetsToLength(marginsModule->columnsepLE,
+ marginsModule->columnsepUnit);
+ // clear widgets
+ marginsModule->topLE->clear();
+ marginsModule->bottomLE->clear();
+ marginsModule->innerLE->clear();
+ marginsModule->outerLE->clear();
+ marginsModule->headheightLE->clear();
+ marginsModule->headsepLE->clear();
+ marginsModule->footskipLE->clear();
+ marginsModule->columnsepLE->clear();
+ }
+
+ marginsModule->topL->setEnabled(custom_margins);
+ marginsModule->topLE->setEnabled(custom_margins);
+ marginsModule->topUnit->setEnabled(custom_margins);
- marginsModule->bottomL->setEnabled(!custom);
- marginsModule->bottomLE->setEnabled(!custom);
- marginsModule->bottomUnit->setEnabled(!custom);
+ marginsModule->bottomL->setEnabled(custom_margins);
+ marginsModule->bottomLE->setEnabled(custom_margins);
+ marginsModule->bottomUnit->setEnabled(custom_margins);
- marginsModule->innerL->setEnabled(!custom);
- marginsModule->innerLE->setEnabled(!custom);
- marginsModule->innerUnit->setEnabled(!custom);
+ marginsModule->innerL->setEnabled(custom_margins);
+ marginsModule->innerLE->setEnabled(custom_margins);
+ marginsModule->innerUnit->setEnabled(custom_margins);
- marginsModule->outerL->setEnabled(!custom);
- marginsModule->outerLE->setEnabled(!custom);
- marginsModule->outerUnit->setEnabled(!custom);
+ marginsModule->outerL->setEnabled(custom_margins);
+ marginsModule->outerLE->setEnabled(custom_margins);
+ marginsModule->outerUnit->setEnabled(custom_margins);
- marginsModule->headheightL->setEnabled(!custom);
- marginsModule->headheightLE->setEnabled(!custom);
- marginsModule->headheightUnit->setEnabled(!custom);
+ marginsModule->headheightL->setEnabled(custom_margins);
+ marginsModule->headheightLE->setEnabled(custom_margins);
+ marginsModule->headheightUnit->setEnabled(custom_margins);
- marginsModule->headsepL->setEnabled(!custom);
- marginsModule->headsepLE->setEnabled(!custom);
- marginsModule->headsepUnit->setEnabled(!custom);
+ marginsModule->headsepL->setEnabled(custom_margins);
+ marginsModule->headsepLE->setEnabled(custom_margins);
+ marginsModule->headsepUnit->setEnabled(custom_margins);
- marginsModule->footskipL->setEnabled(!custom);
- marginsModule->footskipLE->setEnabled(!custom);
- marginsModule->footskipUnit->setEnabled(!custom);
+ marginsModule->footskipL->setEnabled(custom_margins);
+ marginsModule->footskipLE->setEnabled(custom_margins);
+ marginsModule->footskipUnit->setEnabled(custom_margins);
- bool const enableColSep = !custom &&
- textLayoutModule->twoColumnCB->checkState() == Qt::Checked;
+ bool const enableColSep = custom_margins &&
+ textLayoutModule->twoColumnCB->isChecked();
marginsModule->columnsepL->setEnabled(enableColSep);
marginsModule->columnsepLE->setEnabled(enableColSep);
marginsModule->columnsepUnit->setEnabled(enableColSep);
// set some placeholder text that hint on defaults
QString const placeholder = marginsModule->marginCB->isChecked() ?
- qt_("Class defaults") : qt_("Package defaults");
+ qt_("Default margins") : qt_("Package defaults");
// set tooltip depending on gemoetry state
QString const tooltip = marginsModule->marginCB->isChecked() ?
- qt_("If no value is given, the defaults as set by the class are used.")
+ qt_("If no value is given, the defaults as set by the class, a package or the preamble are used.")
: qt_("If no value is given, the defaults as set by the geometry package or a package/class overriding geometry's defaults are used.");
marginsModule->topLE->setPlaceholderText(placeholder);
marginsModule->bottomLE->setPlaceholderText(placeholder);
marginsModule->headsepLE->setToolTip(tooltip);
marginsModule->footskipLE->setToolTip(tooltip);
marginsModule->columnsepLE->setToolTip(tooltip);
-
}
void GuiDocument::changeBackgroundColor()
{
- QColor const & newColor = QColorDialog::getColor(
- rgb2qcolor(set_backgroundcolor), asQWidget());
+ QColor const & newColor = getColor(rgb2qcolor(set_backgroundcolor));
if (!newColor.isValid())
return;
- // set the button color and text
- colorModule->backgroundPB->setStyleSheet(
- colorButtonStyleSheet(newColor));
- colorModule->backgroundPB->setText(qt_("&Change..."));
+ // set the color
+ colorModule->pageBackgroundCF->setVisible(true);
+ colorModule->pageBackgroundCF->setStyleSheet(
+ colorFrameStyleSheet(newColor));
// save color
set_backgroundcolor = rgbFromHexName(fromqstr(newColor.name()));
is_backgroundcolor = true;
void GuiDocument::deleteBackgroundColor()
{
- // set the button color back to default by setting an empty StyleSheet
- colorModule->backgroundPB->setStyleSheet(QLatin1String(""));
- // change button text
- colorModule->backgroundPB->setText(qt_("&Default..."));
+ // set the color back to default by setting an empty StyleSheet
+ colorModule->pageBackgroundCF->setStyleSheet(QLatin1String(""));
+ colorModule->pageBackgroundCF->setVisible(false);
// save default color (white)
set_backgroundcolor = rgbFromHexName("#ffffff");
is_backgroundcolor = false;
void GuiDocument::changeFontColor()
{
- QColor const & newColor = QColorDialog::getColor(
- rgb2qcolor(set_fontcolor), asQWidget());
+ QColor const & newColor = getColor(rgb2qcolor(set_fontcolor));
if (!newColor.isValid())
return;
- // set the button color and text
- colorModule->fontColorPB->setStyleSheet(
- colorButtonStyleSheet(newColor));
- colorModule->fontColorPB->setText(qt_("&Change..."));
+ // set the color
+ colorModule->mainTextCF->setVisible(true);
+ colorModule->mainTextCF->setStyleSheet(
+ colorFrameStyleSheet(newColor));
// save color
set_fontcolor = rgbFromHexName(fromqstr(newColor.name()));
is_fontcolor = true;
void GuiDocument::deleteFontColor()
{
// set the button color back to default by setting an empty StyleSheet
- colorModule->fontColorPB->setStyleSheet(QLatin1String(""));
- // change button text
- colorModule->fontColorPB->setText(qt_("&Default..."));
+ colorModule->mainTextCF->setStyleSheet(QLatin1String(""));
+ colorModule->mainTextCF->setVisible(false);
// save default color (black)
set_fontcolor = rgbFromHexName("#000000");
is_fontcolor = false;
void GuiDocument::changeNoteFontColor()
{
- QColor const & newColor = QColorDialog::getColor(
- rgb2qcolor(set_notefontcolor), asQWidget());
+ QColor const & newColor = getColor(rgb2qcolor(set_notefontcolor));
if (!newColor.isValid())
return;
- // set the button color
- colorModule->noteFontColorPB->setStyleSheet(
- colorButtonStyleSheet(newColor));
+ // set the color
+ colorModule->noteFontCF->setStyleSheet(
+ colorFrameStyleSheet(newColor));
// save color
set_notefontcolor = rgbFromHexName(fromqstr(newColor.name()));
is_notefontcolor = true;
void GuiDocument::deleteNoteFontColor()
{
- // set the button color back to pref
+ // set the color back to pref
theApp()->getRgbColor(Color_greyedouttext, set_notefontcolor);
- colorModule->noteFontColorPB->setStyleSheet(
- colorButtonStyleSheet(rgb2qcolor(set_notefontcolor)));
+ colorModule->noteFontCF->setStyleSheet(
+ colorFrameStyleSheet(rgb2qcolor(set_notefontcolor)));
is_notefontcolor = false;
change_adaptor();
}
void GuiDocument::changeBoxBackgroundColor()
{
- QColor const & newColor = QColorDialog::getColor(
- rgb2qcolor(set_boxbgcolor), asQWidget());
+ QColor const & newColor = getColor(rgb2qcolor(set_boxbgcolor));
if (!newColor.isValid())
return;
- // set the button color
- colorModule->boxBackgroundPB->setStyleSheet(
- colorButtonStyleSheet(newColor));
+ // set the color
+ colorModule->boxBackgroundCF->setStyleSheet(
+ colorFrameStyleSheet(newColor));
// save color
set_boxbgcolor = rgbFromHexName(fromqstr(newColor.name()));
is_boxbgcolor = true;
void GuiDocument::deleteBoxBackgroundColor()
{
- // set the button color back to pref
+ // set the color back to pref
theApp()->getRgbColor(Color_shadedbg, set_boxbgcolor);
- colorModule->boxBackgroundPB->setStyleSheet(
- colorButtonStyleSheet(rgb2qcolor(set_boxbgcolor)));
+ colorModule->boxBackgroundCF->setStyleSheet(
+ colorFrameStyleSheet(rgb2qcolor(set_boxbgcolor)));
is_boxbgcolor = false;
change_adaptor();
}
langModule->quoteStyleCO->addItem(
toqstr(quoteparams.getGuiLabel(qs, langdef)), static_cast<int>(qs));
}
+ // Use document serif font to assure quotation marks are distinguishable
+ QFont comboFont(toqstr(lyxrc.roman_font_name),
+ langModule->quoteStyleCO->fontInfo().pointSize() * 1.4, -1, false);
+ QFontMetrics fm(comboFont);
+ // calculate width of the widest item in the set font
+ int qswidth = 0;
+ for (int i = 0; i < langModule->quoteStyleCO->count(); ++i) {
+ langModule->quoteStyleCO->setItemData(i, QVariant(comboFont), Qt::FontRole);
+ QString str = langModule->quoteStyleCO->itemText(i);
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
+ qswidth = max(qswidth, fm.horizontalAdvance(str));
+#else
+ qswidth = max(qswidth, fm.width(str));
+#endif
+ }
+ // add scrollbar width and margin to width
+ qswidth += langModule->quoteStyleCO->style()->pixelMetric(QStyle::PM_ScrollBarExtent);
+ qswidth += langModule->quoteStyleCO->view()->autoScrollMargin();
+ langModule->quoteStyleCO->view()->setMinimumWidth(qswidth);
if (set && has_default)
// (re)set to the default style
langModule->quoteStyleCO->setCurrentIndex(0);
{
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_roman = fontModule->fontsRomanCO->getData(
+ fontModule->fontsRomanCO->currentIndex());
+ QString const font_sans = fontModule->fontsSansCO->getData(
+ fontModule->fontsSansCO->currentIndex());
+ QString const font_typewriter = fontModule->fontsTypewriterCO->getData(
+ fontModule->fontsTypewriterCO->currentIndex());
QString const font_math = fontModule->fontsMathCO->itemData(
fontModule->fontsMathCO->currentIndex()).toString();
int const font_sf_scale = fontModule->scaleSansSB->value();
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);
+ if (!fontModule->font_roman.isEmpty())
+ fontModule->fontsRomanCO->set(fontModule->font_roman);
+ if (!fontModule->font_sans.isEmpty())
+ fontModule->fontsSansCO->set(fontModule->font_sans);
+ if (!fontModule->font_typewriter.isEmpty())
+ fontModule->fontsTypewriterCO->set(fontModule->font_typewriter);
index = fontModule->fontsMathCO->findData(fontModule->font_math);
if (index != -1)
fontModule->fontsMathCO->setCurrentIndex(index);
langModule->encodingCO->setEnabled(tex_fonts);
inputencodingToDialog();
- fontModule->fontsDefaultCO->setEnabled(tex_fonts);
- fontModule->fontsDefaultLA->setEnabled(tex_fonts);
fontModule->cjkFontLE->setEnabled(tex_fonts);
fontModule->cjkFontLA->setEnabled(tex_fonts);
langModule->unicodeEncodingCO->setVisible(i == EncodingSets::unicode);
langModule->autoEncodingCO->setVisible(i == EncodingSets::legacy);
langModule->customEncodingCO->setVisible(i == EncodingSets::custom);
+ switch (i) {
+ case EncodingSets::unicode:
+ langModule->encodingVariantLA->setBuddy(langModule->unicodeEncodingCO);
+ break;
+ case EncodingSets::legacy:
+ langModule->encodingVariantLA->setBuddy(langModule->autoEncodingCO);
+ break;
+ case EncodingSets::custom:
+ langModule->encodingVariantLA->setBuddy(langModule->customEncodingCO);
+ break;
+ }
+
if (tex_fonts)
langModule->unicodeEncodingCO->setItemText(1, qt_("Direct (No inputenc)"));
else
{
if (fontModule->osFontsCB->isChecked())
return;
- QString font = fontModule->fontsRomanCO->itemData(
- fontModule->fontsRomanCO->currentIndex()).toString();
+ QString font = fontModule->fontsRomanCO->getData(
+ fontModule->fontsRomanCO->currentIndex());
if (hasMonolithicExpertSet(font))
fontModule->fontScCB->setChecked(state);
}
{
if (fontModule->osFontsCB->isChecked())
return;
- QString font = fontModule->fontsRomanCO->itemData(
- fontModule->fontsRomanCO->currentIndex()).toString();
+ QString font = fontModule->fontsRomanCO->getData(
+ fontModule->fontsRomanCO->currentIndex());
if (hasMonolithicExpertSet(font))
fontModule->fontOsfCB->setChecked(state);
}
void GuiDocument::updateExtraOpts()
{
- bool const tex_fonts = !fontModule->osFontsCB->isChecked();
- QString font;
- if (tex_fonts)
- font = fontModule->fontsRomanCO->itemData(
- fontModule->fontsRomanCO->currentIndex()).toString();
+ QString font = fontModule->fontsRomanCO->getData(
+ fontModule->fontsRomanCO->currentIndex());
bool const rm_opts = providesExtraOpts(font);
- if (tex_fonts)
- font = fontModule->fontsSansCO->itemData(
- fontModule->fontsSansCO->currentIndex()).toString();
+ font = fontModule->fontsSansCO->getData(
+ fontModule->fontsSansCO->currentIndex());
bool const sf_opts = providesExtraOpts(font);
- if (tex_fonts)
- font = fontModule->fontsTypewriterCO->itemData(
- fontModule->fontsTypewriterCO->currentIndex()).toString();
+ font = fontModule->fontsTypewriterCO->getData(
+ fontModule->fontsTypewriterCO->currentIndex());
bool const tt_opts = providesExtraOpts(font);
- fontModule->fontspecRomanLA->setEnabled(!tex_fonts || rm_opts);
- fontModule->fontspecRomanLE->setEnabled(!tex_fonts || rm_opts);
- fontModule->fontspecSansLA->setEnabled(!tex_fonts || sf_opts);
- fontModule->fontspecSansLE->setEnabled(!tex_fonts || sf_opts);
- fontModule->fontspecTypewriterLA->setEnabled(!tex_fonts || tt_opts);
- fontModule->fontspecTypewriterLE->setEnabled(!tex_fonts || tt_opts);
+ fontModule->fontspecRomanLA->setEnabled(rm_opts);
+ fontModule->fontspecRomanLE->setEnabled(rm_opts);
+ fontModule->fontspecSansLA->setEnabled(sf_opts);
+ fontModule->fontspecSansLE->setEnabled(sf_opts);
+ fontModule->fontspecTypewriterLA->setEnabled(tt_opts);
+ fontModule->fontspecTypewriterLE->setEnabled(tt_opts);
}
void GuiDocument::updateFontOptions()
{
- bool const tex_fonts = !fontModule->osFontsCB->isChecked();
- QString font;
- if (tex_fonts)
- font = fontModule->fontsSansCO->itemData(
- fontModule->fontsSansCO->currentIndex()).toString();
+ QString font = fontModule->fontsSansCO->getData(
+ fontModule->fontsSansCO->currentIndex());
bool scalable = providesScale(font);
fontModule->scaleSansSB->setEnabled(scalable);
fontModule->scaleSansLA->setEnabled(scalable);
fontModule->fontSansOsfCB->setEnabled(providesOSF(font));
- if (tex_fonts)
- font = fontModule->fontsTypewriterCO->itemData(
- fontModule->fontsTypewriterCO->currentIndex()).toString();
+ font = fontModule->fontsTypewriterCO->getData(
+ fontModule->fontsTypewriterCO->currentIndex());
scalable = providesScale(font);
fontModule->scaleTypewriterSB->setEnabled(scalable);
fontModule->scaleTypewriterLA->setEnabled(scalable);
fontModule->fontTypewriterOsfCB->setEnabled(providesOSF(font));
- if (tex_fonts)
- font = fontModule->fontsRomanCO->itemData(
- fontModule->fontsRomanCO->currentIndex()).toString();
+ font = fontModule->fontsRomanCO->getData(
+ fontModule->fontsRomanCO->currentIndex());
fontModule->fontScCB->setEnabled(providesSC(font));
fontModule->fontOsfCB->setEnabled(providesOSF(font));
updateExtraOpts();
bool GuiDocument::completeFontset() const
{
- return (fontModule->fontsSansCO->itemData(
- fontModule->fontsSansCO->currentIndex()).toString() == "default"
- && fontModule->fontsSansCO->itemData(
- fontModule->fontsTypewriterCO->currentIndex()).toString() == "default");
+ return (fontModule->fontsSansCO->getData(
+ fontModule->fontsSansCO->currentIndex()) == "default"
+ && fontModule->fontsSansCO->getData(
+ fontModule->fontsTypewriterCO->currentIndex()) == "default");
}
// 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"));
+ fontModule->fontsRomanCO->addItemSort(QString("default"), qt_("Default"),
+ QString(), qt_("Default font (as set by class)"),
+ false, false, false, true, true);
+ fontModule->fontsSansCO->addItemSort(QString("default"), qt_("Default"),
+ QString(), qt_("Default font (as set by class)"),
+ false, false, false, true, true);
+ fontModule->fontsTypewriterCO->addItemSort(QString("default"), qt_("Default"),
+ QString(), qt_("Default font (as set by class)"),
+ false, false, false, true, true);
QString unimath = qt_("Non-TeX Fonts Default");
if (!LaTeXFeatures::isAvailable("unicode-math"))
unimath += qt_(" (not available)");
const QStringList families(fontdb.families());
#endif
for (auto const & family : families) {
- fontModule->fontsRomanCO->addItem(family, family);
- fontModule->fontsSansCO->addItem(family, family);
- fontModule->fontsTypewriterCO->addItem(family, family);
+ fontModule->fontsRomanCO->addItemSort(family, family,
+ QString(), QString(),
+ false, false, false, true, true);
+ fontModule->fontsSansCO->addItemSort(family, family,
+ QString(), QString(),
+ false, false, false, true, true);
+ fontModule->fontsTypewriterCO->addItemSort(family, family,
+ QString(), QString(),
+ false, false, false, true, true);
}
return;
}
if (rmfonts_.empty())
updateTexFonts();
- fontModule->fontsRomanCO->addItem(qt_("Default"), QString("default"));
+ fontModule->fontsRomanCO->addItemSort(QString("default"), qt_("Default"),
+ QString(), qt_("Default font (as set by class)"),
+ false, false, false, true, true);
QMap<QString, QString>::const_iterator rmi = rmfonts_.constBegin();
while (rmi != rmfonts_.constEnd()) {
- fontModule->fontsRomanCO->addItem(rmi.key(), rmi.value());
+ fontModule->fontsRomanCO->addItemSort(rmi.value(), rmi.key(),
+ QString(), QString(),
+ false, false, false, true, true);
++rmi;
}
- fontModule->fontsSansCO->addItem(qt_("Default"), QString("default"));
+ fontModule->fontsSansCO->addItemSort(QString("default"), qt_("Default"),
+ QString(), qt_("Default font (as set by class)"),
+ false, false, false, true, true);
QMap<QString, QString>::const_iterator sfi = sffonts_.constBegin();
while (sfi != sffonts_.constEnd()) {
- fontModule->fontsSansCO->addItem(sfi.key(), sfi.value());
+ fontModule->fontsSansCO->addItemSort(sfi.value(), sfi.key(),
+ QString(), QString(),
+ false, false, false, true, true);
++sfi;
}
- fontModule->fontsTypewriterCO->addItem(qt_("Default"), QString("default"));
+ fontModule->fontsTypewriterCO->addItemSort(QString("default"), qt_("Default"),
+ QString(), qt_("Default font (as set by class)"),
+ false, false, false, true, true);
QMap<QString, QString>::const_iterator tti = ttfonts_.constBegin();
while (tti != ttfonts_.constEnd()) {
- fontModule->fontsTypewriterCO->addItem(tti.key(), tti.value());
+ fontModule->fontsTypewriterCO->addItemSort(tti.value(), tti.key(),
+ QString(), QString(),
+ false, false, false, true, true);
++tti;
}
void GuiDocument::romanChanged(int item)
{
+ QString const font = fontModule->fontsRomanCO->getData(item);
+ fontModule->fontOsfCB->setEnabled(providesOSF(font));
+ updateExtraOpts();
if (fontModule->osFontsCB->isChecked())
return;
- QString const font =
- fontModule->fontsRomanCO->itemData(item).toString();
fontModule->fontScCB->setEnabled(providesSC(font));
- fontModule->fontOsfCB->setEnabled(providesOSF(font));
- updateExtraOpts();
updateMathFonts(font);
}
void GuiDocument::sansChanged(int item)
{
- if (fontModule->osFontsCB->isChecked())
- return;
- QString const font =
- fontModule->fontsSansCO->itemData(item).toString();
+ QString const font = fontModule->fontsSansCO->getData(item);
bool const scalable = providesScale(font);
fontModule->scaleSansSB->setEnabled(scalable);
fontModule->scaleSansLA->setEnabled(scalable);
void GuiDocument::ttChanged(int item)
{
- if (fontModule->osFontsCB->isChecked())
- return;
- QString const font =
- fontModule->fontsTypewriterCO->itemData(item).toString();
+ QString const font = fontModule->fontsTypewriterCO->getData(item);
bool scalable = providesScale(font);
fontModule->scaleTypewriterSB->setEnabled(scalable);
fontModule->scaleTypewriterLA->setEnabled(scalable);
}
QModelIndex const & idx = lv->selectionModel()->currentIndex();
+ if (!idx.isValid())
+ return;
+
if (!focus_on_selected
&& modules_av_model_.itemFromIndex(idx)->hasChildren()) {
// This is a category header
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_);
// date
bp_.suppress_date = latexModule->suppressDateCB->isChecked();
bp_.use_refstyle = latexModule->refstyleCB->isChecked();
+ bp_.use_formatted_ref = latexModule->refFormattedCB->isChecked();
// biblio
string const engine =
// Master/Child
bp_.clearIncludedChildren();
+ updateIncludeonlys();
if (masterChildModule->includeonlyRB->isChecked()) {
list<string>::const_iterator it = includeonlys_.begin();
for (; it != includeonlys_.end() ; ++it) {
// fonts
bp_.fonts_roman[nontexfonts] =
fromqstr(fontModule->fontsRomanCO->
- itemData(fontModule->fontsRomanCO->currentIndex()).toString());
+ getData(fontModule->fontsRomanCO->currentIndex()));
bp_.fonts_roman[!nontexfonts] = fromqstr(fontModule->font_roman);
bp_.font_roman_opts = fromqstr(fontModule->fontspecRomanLE->text());
bp_.fonts_sans[nontexfonts] =
fromqstr(fontModule->fontsSansCO->
- itemData(fontModule->fontsSansCO->currentIndex()).toString());
+ getData(fontModule->fontsSansCO->currentIndex()));
bp_.fonts_sans[!nontexfonts] = fromqstr(fontModule->font_sans);
bp_.font_sans_opts = fromqstr(fontModule->fontspecSansLE->text());
bp_.fonts_typewriter[nontexfonts] =
fromqstr(fontModule->fontsTypewriterCO->
- itemData(fontModule->fontsTypewriterCO->currentIndex()).toString());
+ getData(fontModule->fontsTypewriterCO->currentIndex()));
bp_.fonts_typewriter[!nontexfonts] = fromqstr(fontModule->font_typewriter);
bp_.font_typewriter_opts = fromqstr(fontModule->fontspecTypewriterLE->text());
bp_.fonts_sans_osf = fontModule->fontSansOsfCB->isChecked();
bp_.fonts_typewriter_osf = fontModule->fontTypewriterOsfCB->isChecked();
- if (nontexfonts)
- bp_.fonts_default_family = "default";
- else
- bp_.fonts_default_family = GuiDocument::fontfamilies[
- fontModule->fontsDefaultCO->currentIndex()];
+ bp_.fonts_default_family = GuiDocument::fontfamilies[
+ fontModule->fontsDefaultCO->currentIndex()];
if (fontModule->fontsizeCO->currentIndex() == 0)
bp_.fontsize = "default";
Ui::MarginsUi const * m = marginsModule;
- bp_.leftmargin = widgetsToLength(m->innerLE, m->innerUnit);
- bp_.topmargin = widgetsToLength(m->topLE, m->topUnit);
- bp_.rightmargin = widgetsToLength(m->outerLE, m->outerUnit);
- bp_.bottommargin = widgetsToLength(m->bottomLE, m->bottomUnit);
- bp_.headheight = widgetsToLength(m->headheightLE, m->headheightUnit);
- bp_.headsep = widgetsToLength(m->headsepLE, m->headsepUnit);
- bp_.footskip = widgetsToLength(m->footskipLE, m->footskipUnit);
- bp_.columnsep = widgetsToLength(m->columnsepLE, m->columnsepUnit);
+ if (bp_.use_geometry) {
+ bp_.leftmargin = widgetsToLength(m->innerLE, m->innerUnit);
+ bp_.topmargin = widgetsToLength(m->topLE, m->topUnit);
+ bp_.rightmargin = widgetsToLength(m->outerLE, m->outerUnit);
+ bp_.bottommargin = widgetsToLength(m->bottomLE, m->bottomUnit);
+ bp_.headheight = widgetsToLength(m->headheightLE, m->headheightUnit);
+ bp_.headsep = widgetsToLength(m->headsepLE, m->headsepUnit);
+ bp_.footskip = widgetsToLength(m->footskipLE, m->footskipUnit);
+ bp_.columnsep = widgetsToLength(m->columnsepLE, m->columnsepUnit);
+ }
// branches
branchesModule->apply(bp_);
pdf.pagemode.clear();
pdf.quoted_options = pdf.quoted_options_check(
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();
// date
latexModule->suppressDateCB->setChecked(bp_.suppress_date);
latexModule->refstyleCB->setChecked(bp_.use_refstyle);
+ latexModule->refFormattedCB->setChecked(bp_.use_formatted_ref);
// biblio
string const cite_engine = bp_.citeEngine();
//color
if (bp_.isfontcolor) {
- colorModule->fontColorPB->setStyleSheet(
- colorButtonStyleSheet(rgb2qcolor(bp_.fontcolor)));
- }
+ colorModule->mainTextCF->setStyleSheet(
+ colorFrameStyleSheet(rgb2qcolor(bp_.fontcolor)));
+ colorModule->mainTextCF->setVisible(true);
+ } else
+ colorModule->mainTextCF->setVisible(false);
set_fontcolor = bp_.fontcolor;
is_fontcolor = bp_.isfontcolor;
- colorModule->noteFontColorPB->setStyleSheet(
- colorButtonStyleSheet(rgb2qcolor(bp_.notefontcolor)));
+ colorModule->noteFontCF->setStyleSheet(
+ colorFrameStyleSheet(rgb2qcolor(bp_.notefontcolor)));
set_notefontcolor = bp_.notefontcolor;
is_notefontcolor = bp_.isnotefontcolor;
if (bp_.isbackgroundcolor) {
- colorModule->backgroundPB->setStyleSheet(
- colorButtonStyleSheet(rgb2qcolor(bp_.backgroundcolor)));
- }
+ colorModule->pageBackgroundCF->setStyleSheet(
+ colorFrameStyleSheet(rgb2qcolor(bp_.backgroundcolor)));
+ colorModule->pageBackgroundCF->setVisible(true);
+ } else
+ colorModule->pageBackgroundCF->setVisible(false);
set_backgroundcolor = bp_.backgroundcolor;
is_backgroundcolor = bp_.isbackgroundcolor;
- colorModule->boxBackgroundPB->setStyleSheet(
- colorButtonStyleSheet(rgb2qcolor(bp_.boxbgcolor)));
+ colorModule->boxBackgroundCF->setStyleSheet(
+ colorFrameStyleSheet(rgb2qcolor(bp_.boxbgcolor)));
set_boxbgcolor = bp_.boxbgcolor;
is_boxbgcolor = bp_.isboxbgcolor;
bp_.fontsize);
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);
+ bool foundfont = fontModule->fontsRomanCO->set(font, false);
+ if (!foundfont) {
+ fontModule->fontsRomanCO->addItemSort(font, font + qt_(" (not installed)"),
+ qt_("Uninstalled used fonts"),
+ qt_("This font is not installed and won't be used in output"),
+ false, false, false, true);
+ fontModule->fontsRomanCO->set(font);
}
- fontModule->fontsRomanCO->setCurrentIndex(rpos);
fontModule->font_roman = toqstr(bp_.fonts_roman[!bp_.useNonTeXFonts]);
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);
+ foundfont = fontModule->fontsSansCO->set(font, false);
+ if (!foundfont) {
+ fontModule->fontsSansCO->addItemSort(font, font + qt_(" (not installed)"),
+ qt_("Uninstalled used fonts"),
+ qt_("This font is not installed and won't be used in output"),
+ false, false, false, true);
+ fontModule->fontsSansCO->set(font);
}
- fontModule->fontsSansCO->setCurrentIndex(spos);
fontModule->font_sans = toqstr(bp_.fonts_sans[!bp_.useNonTeXFonts]);
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);
+ foundfont = fontModule->fontsTypewriterCO->set(font, false);
+ if (!foundfont) {
+ fontModule->fontsTypewriterCO->addItemSort(font, font + qt_(" (not installed)"),
+ qt_("Uninstalled used fonts"),
+ qt_("This font is not installed and won't be used in output"),
+ false, false, false, true);
+ fontModule->fontsTypewriterCO->set(font);
}
- fontModule->fontsTypewriterCO->setCurrentIndex(tpos);
fontModule->font_typewriter = toqstr(bp_.fonts_typewriter[!bp_.useNonTeXFonts]);
font = toqstr(bp_.fontsMath());
fontModule->fontencLA->setEnabled(true);
fontModule->fontencCO->setEnabled(true);
fontModule->fontencLE->setEnabled(true);
- romanChanged(rpos);
- sansChanged(spos);
- ttChanged(tpos);
+ romanChanged(fontModule->fontsRomanCO->currentIndex());
+ sansChanged(fontModule->fontsSansCO->currentIndex());
+ ttChanged(fontModule->fontsTypewriterCO->currentIndex());
}
+ // Handle options enabling
+ updateFontOptions();
if (!bp_.fonts_cjk.empty())
fontModule->cjkFontLE->setText(
// margins
Ui::MarginsUi * m = marginsModule;
- setMargins();
+ tmp_leftmargin_ = bp_.leftmargin;
+ tmp_topmargin_ = bp_.topmargin;
+ tmp_rightmargin_ = bp_.rightmargin;
+ tmp_bottommargin_ = bp_.bottommargin;
+ tmp_headheight_ = bp_.headheight;
+ tmp_headsep_ = bp_.headsep;
+ tmp_footskip_ = bp_.footskip;
+ tmp_columnsep_ = bp_.columnsep;
lengthToWidgets(m->topLE, m->topUnit,
bp_.topmargin, default_unit);
-
lengthToWidgets(m->bottomLE, m->bottomUnit,
bp_.bottommargin, default_unit);
-
lengthToWidgets(m->innerLE, m->innerUnit,
bp_.leftmargin, default_unit);
-
lengthToWidgets(m->outerLE, m->outerUnit,
bp_.rightmargin, default_unit);
-
lengthToWidgets(m->headheightLE, m->headheightUnit,
bp_.headheight, default_unit);
-
lengthToWidgets(m->headsepLE, m->headsepUnit,
bp_.headsep, default_unit);
-
lengthToWidgets(m->footskipLE, m->footskipUnit,
bp_.footskip, default_unit);
-
lengthToWidgets(m->columnsepLE, m->columnsepUnit,
bp_.columnsep, default_unit);
+ setMargins();
+
// branches
updateUnknownBranches();
branchesModule->update(bp_);
toqstr(pdf.quoted_options));
pdfSupportModule->metadataTE->setPlainText(
- toqstr(bp_.document_metadata));
+ toqstr(rtrim(bp_.document_metadata, "\n")));
// change tracking
changesModule->trackChangesCB->setChecked(bp_.track_changes);
modInfoList.sort([](modInfoStruct const & a, modInfoStruct const & b) {
return 0 < b.name.localeAwareCompare(a.name);
});
- QIcon user_icon(getPixmap("images/", "lyxfiles-user", "svgz,png"));
- QIcon system_icon(getPixmap("images/", "lyxfiles-system", "svgz,png"));
+ QIcon user_icon(guiApp ? guiApp->getScaledPixmap("images/", "lyxfiles-user")
+ : getPixmap("images/", "lyxfiles-user", "svgz,png"));
+ QIcon system_icon(guiApp ? guiApp->getScaledPixmap("images/", "lyxfiles-system")
+ : getPixmap("images/", "lyxfiles-system", "svgz,png"));
int i = 0;
QFont catfont;
catfont.setBold(true);
}
-void GuiDocument::updateIncludeonlys()
+void GuiDocument::updateIncludeonlys(bool const cleanup)
{
masterChildModule->childrenTW->clear();
QString const no = qt_("No");
}
// Both if all children are included and if none is included
// is equal to "include all" (i.e., omit \includeonly).
- if (!has_unincluded || all_unincluded)
+ if (cleanup && (!has_unincluded || all_unincluded))
includeonlys_.clear();
}
bool GuiDocument::isValid()
{
- 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
- 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->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->itemData(
- mathsModule->MathIndentCO->currentIndex()) != "custom") ||
- // or else a length has been given
- !mathsModule->MathIndentLE->text().isEmpty()
- );
+ bool const listings_valid = validateListingsParameters().isEmpty();
+ bool const local_layout_valid = !localLayout->editing();
+ bool const preamble_valid = !preambleModule->editing();
+
+ docPS->markPanelValid(N_("Listings[[inset]]"), listings_valid);
+ docPS->markPanelValid(N_("Local Layout"), local_layout_valid && localLayout->isValid());
+ docPS->markPanelValid(N_("LaTeX Preamble"), preamble_valid);
+
+ return listings_valid && local_layout_valid && preamble_valid;
}
paramsToDialog();
return true;
}
+ prev_buffer_filename_ = view->buffer().absFileName();
bp_ = view->buffer().params();
loadModuleInfo();
updateAvailableModules();
if (fontModule->osFontsCB->isChecked())
// FIXME: we should check if the fonts really
// have OSF support. But how?
- return true;
+ return font != "default";
return theLaTeXFonts().getLaTeXFont(
qstring_to_ucs4(font)).providesOSF(ot1(),
completeFontset(),
bool GuiDocument::providesScale(QString const & font) const
{
if (fontModule->osFontsCB->isChecked())
- return true;
+ return font != "default";
return theLaTeXFonts().getLaTeXFont(
qstring_to_ucs4(font)).providesScale(ot1(),
completeFontset(),
bool GuiDocument::providesExtraOpts(QString const & font) const
{
if (fontModule->osFontsCB->isChecked())
- return true;
+ return font != "default";
return theLaTeXFonts().getLaTeXFont(
qstring_to_ucs4(font)).providesMoreOptions(ot1(),
completeFontset(),
}
+bool GuiDocument::eventFilter(QObject * sender, QEvent * event)
+{
+ if (event->type() == QEvent::ApplicationPaletteChange) {
+ // mode switch: colors need to be updated
+ // and the highlighting redone
+ if (pdf_options_highlighter_) {
+ pdf_options_highlighter_->setupColors();
+ pdf_options_highlighter_->rehighlight();
+ }
+ if (pdf_metadata_highlighter_) {
+ pdf_metadata_highlighter_->setupColors();
+ pdf_metadata_highlighter_->rehighlight();
+ }
+ }
+ return QWidget::eventFilter(sender, event);
+}
+
+
} // namespace frontend
} // namespace lyx