mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-26 03:11:59 +00:00
Use the OK/Apply paradigm for all document settings
Due to its peculiarity of not being saved in the document, the shell escape setting was applied immediately without the need for hitting the Apply or OK buttons. However, for uniformity sake, it is better to adhere to the established paragdim of confirming any changes before applying them.
This commit is contained in:
parent
094341fa5a
commit
40e9dea551
@ -664,7 +664,8 @@ void LocalLayout::validatePressed() {
|
||||
|
||||
GuiDocument::GuiDocument(GuiView & lv)
|
||||
: GuiDialog(lv, "document", qt_("Document Settings")),
|
||||
biblioChanged_(false), nonModuleChanged_(false)
|
||||
biblioChanged_(false), nonModuleChanged_(false),
|
||||
modulesChanged_(false), shellescapeChanged_(false)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
@ -1542,18 +1543,30 @@ void GuiDocument::change_adaptor()
|
||||
|
||||
void GuiDocument::shellescapeChanged()
|
||||
{
|
||||
// This is treated specially as the change is automatically applied
|
||||
// and the document isn't marked as dirty. Visual feedback is given
|
||||
// by the appearance/disappearance of a red icon in the status bar.
|
||||
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;
|
||||
BufferView * bv = const_cast<BufferView *>(bufferview());
|
||||
bv->processUpdateFlags(Update::Force);
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@ -2662,7 +2675,7 @@ void GuiDocument::modulesChanged()
|
||||
{
|
||||
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."),
|
||||
@ -2671,6 +2684,7 @@ void GuiDocument::modulesChanged()
|
||||
applyView();
|
||||
}
|
||||
|
||||
modulesChanged_ = true;
|
||||
bp_.makeDocumentClass();
|
||||
paramsToDialog();
|
||||
changed();
|
||||
@ -3136,6 +3150,12 @@ void GuiDocument::applyView()
|
||||
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();
|
||||
|
||||
@ -3274,8 +3294,9 @@ void GuiDocument::applyView()
|
||||
pdf.quoted_options = pdf.quoted_options_check(
|
||||
fromqstr(pdfSupportModule->optionsLE->text()));
|
||||
|
||||
// reset tracker
|
||||
// reset trackers
|
||||
nonModuleChanged_ = false;
|
||||
shellescapeChanged_ = false;
|
||||
}
|
||||
|
||||
|
||||
@ -3863,8 +3884,9 @@ void GuiDocument::paramsToDialog()
|
||||
// clear changed branches cache
|
||||
changedBranches_.clear();
|
||||
|
||||
// reset tracker
|
||||
// reset trackers
|
||||
nonModuleChanged_ = false;
|
||||
shellescapeChanged_ = false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -86,6 +86,10 @@ public:
|
||||
|
||||
public Q_SLOTS:
|
||||
void onBufferViewChanged();//override
|
||||
// OK button clicked
|
||||
void slotOK();
|
||||
// Apply button clicked
|
||||
void slotApply();
|
||||
|
||||
private Q_SLOTS:
|
||||
void updateNumbering();
|
||||
@ -303,6 +307,10 @@ private:
|
||||
bool biblioChanged_;
|
||||
/// Track if a non-module document param changed
|
||||
bool nonModuleChanged_;
|
||||
/// Track if used modules changed
|
||||
bool modulesChanged_;
|
||||
/// Track if the shellescape param changed
|
||||
bool shellescapeChanged_;
|
||||
};
|
||||
|
||||
|
||||
|
@ -108,7 +108,7 @@
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="shellescapeCB">
|
||||
<property name="toolTip">
|
||||
<string>Runs the LaTeX backend with the -shell-escape option (this setting is always applied immediately)</string>
|
||||
<string>Runs the LaTeX backend with the -shell-escape option (Warning: use only when really necessary)</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Allow running external programs</string>
|
||||
|
Loading…
Reference in New Issue
Block a user