mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 05:25:26 +00:00
Partially fix bug #10827. Patch from Daniel, slightly modified by me.
This commit is contained in:
parent
be224a1a8f
commit
233ce1ec12
@ -27,7 +27,7 @@ namespace frontend {
|
|||||||
|
|
||||||
GuiDialog::GuiDialog(GuiView & lv, QString const & name, QString const & title)
|
GuiDialog::GuiDialog(GuiView & lv, QString const & name, QString const & title)
|
||||||
: QDialog(&lv), Dialog(lv, name, title), updating_(false),
|
: QDialog(&lv), Dialog(lv, name, title), updating_(false),
|
||||||
is_closing_(false)
|
is_closing_(false), apply_stopped_(false)
|
||||||
{
|
{
|
||||||
connect(&lv, SIGNAL(bufferViewChanged()),
|
connect(&lv, SIGNAL(bufferViewChanged()),
|
||||||
this, SLOT(onBufferViewChanged()));
|
this, SLOT(onBufferViewChanged()));
|
||||||
@ -52,7 +52,10 @@ void GuiDialog::setButtonsValid(bool valid)
|
|||||||
|
|
||||||
void GuiDialog::slotApply()
|
void GuiDialog::slotApply()
|
||||||
{
|
{
|
||||||
|
setApplyStopped(false);
|
||||||
apply();
|
apply();
|
||||||
|
if (applyStopped())
|
||||||
|
return;
|
||||||
bc().apply();
|
bc().apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,7 +70,10 @@ void GuiDialog::slotAutoApply()
|
|||||||
void GuiDialog::slotOK()
|
void GuiDialog::slotOK()
|
||||||
{
|
{
|
||||||
is_closing_ = true;
|
is_closing_ = true;
|
||||||
|
setApplyStopped(false);
|
||||||
apply();
|
apply();
|
||||||
|
if (applyStopped())
|
||||||
|
return;
|
||||||
is_closing_ = false;
|
is_closing_ = false;
|
||||||
hideView();
|
hideView();
|
||||||
bc().ok();
|
bc().ok();
|
||||||
|
@ -74,6 +74,9 @@ public:
|
|||||||
*/
|
*/
|
||||||
void setButtonsValid(bool valid);
|
void setButtonsValid(bool valid);
|
||||||
|
|
||||||
|
// Set whether to stop the apply process
|
||||||
|
void setApplyStopped(bool stop) { apply_stopped_ = stop; };
|
||||||
|
|
||||||
/** \name Dialog Components
|
/** \name Dialog Components
|
||||||
* Methods to access the various components making up a dialog.
|
* Methods to access the various components making up a dialog.
|
||||||
*/
|
*/
|
||||||
@ -115,6 +118,10 @@ private:
|
|||||||
bool updating_;
|
bool updating_;
|
||||||
|
|
||||||
bool is_closing_;
|
bool is_closing_;
|
||||||
|
|
||||||
|
/// stop the apply process?
|
||||||
|
bool applyStopped() { return apply_stopped_; };
|
||||||
|
bool apply_stopped_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -657,23 +657,18 @@ void LocalLayout::hideConvert()
|
|||||||
|
|
||||||
void LocalLayout::textChanged()
|
void LocalLayout::textChanged()
|
||||||
{
|
{
|
||||||
// Flashy red bold text
|
validLB->setText("");
|
||||||
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!"));
|
|
||||||
string const layout =
|
string const layout =
|
||||||
fromqstr(locallayoutTE->document()->toPlainText().trimmed());
|
fromqstr(locallayoutTE->document()->toPlainText().trimmed());
|
||||||
|
|
||||||
if (layout.empty()) {
|
if (layout.empty()) {
|
||||||
validated_ = true;
|
validated_ = true;
|
||||||
validatePB->setEnabled(false);
|
validatePB->setEnabled(false);
|
||||||
validLB->setText("");
|
|
||||||
hideConvert();
|
hideConvert();
|
||||||
changed();
|
changed();
|
||||||
} else if (!validatePB->isEnabled()) {
|
} else if (!validatePB->isEnabled()) {
|
||||||
// if that's already enabled, we shouldn't need to do anything.
|
// if that's already enabled, we shouldn't need to do anything.
|
||||||
validated_ = false;
|
validated_ = false;
|
||||||
validLB->setText(message);
|
|
||||||
validatePB->setEnabled(true);
|
validatePB->setEnabled(true);
|
||||||
hideConvert();
|
hideConvert();
|
||||||
changed();
|
changed();
|
||||||
@ -3418,6 +3413,16 @@ bool GuiDocument::isChildIncluded(string const & child)
|
|||||||
|
|
||||||
void GuiDocument::applyView()
|
void GuiDocument::applyView()
|
||||||
{
|
{
|
||||||
|
// auto-validate local layout
|
||||||
|
if (!localLayout->isValid()) {
|
||||||
|
localLayout->validate();
|
||||||
|
if (!localLayout->isValid()) {
|
||||||
|
setApplyStopped(true);
|
||||||
|
docPS->setCurrentPanel(N_("Local Layout"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// preamble
|
// preamble
|
||||||
preambleModule->apply(bp_);
|
preambleModule->apply(bp_);
|
||||||
localLayout->apply(bp_);
|
localLayout->apply(bp_);
|
||||||
@ -4849,7 +4854,6 @@ bool GuiDocument::isValid()
|
|||||||
{
|
{
|
||||||
return
|
return
|
||||||
validateListingsParameters().isEmpty() &&
|
validateListingsParameters().isEmpty() &&
|
||||||
localLayout->isValid() &&
|
|
||||||
!localLayout->editing() &&
|
!localLayout->editing() &&
|
||||||
!preambleModule->editing() &&
|
!preambleModule->editing() &&
|
||||||
(
|
(
|
||||||
|
@ -388,6 +388,7 @@ public:
|
|||||||
LocalLayout(QWidget * parent);
|
LocalLayout(QWidget * parent);
|
||||||
void update(BufferParams const & params, BufferId id);
|
void update(BufferParams const & params, BufferId id);
|
||||||
void apply(BufferParams & params);
|
void apply(BufferParams & params);
|
||||||
|
void validate();
|
||||||
bool isValid() const { return validated_; }
|
bool isValid() const { return validated_; }
|
||||||
bool editing() const { return (bool)tempfile_; }
|
bool editing() const { return (bool)tempfile_; }
|
||||||
|
|
||||||
@ -396,7 +397,6 @@ Q_SIGNALS:
|
|||||||
void changed();
|
void changed();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void validate();
|
|
||||||
void convert();
|
void convert();
|
||||||
void hideConvert();
|
void hideConvert();
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
|
Loading…
Reference in New Issue
Block a user