GuiDialog::GuiDialog(GuiView & lv, QString const & name, QString const & title)
: QDialog(&lv), Dialog(lv, name, title), updating_(false),
- is_closing_(false)
+ is_closing_(false), apply_stopped_(false)
{
connect(&lv, SIGNAL(bufferViewChanged()),
this, SLOT(onBufferViewChanged()));
void GuiDialog::slotApply()
{
+ setApplyStopped(false);
apply();
+ if (applyStopped())
+ return;
bc().apply();
}
void GuiDialog::slotOK()
{
is_closing_ = true;
+ setApplyStopped(false);
apply();
+ if (applyStopped())
+ return;
is_closing_ = false;
hideView();
bc().ok();
*/
void setButtonsValid(bool valid);
+ // Set whether to stop the apply process
+ void setApplyStopped(bool stop) { apply_stopped_ = stop; };
+
/** \name Dialog Components
* Methods to access the various components making up a dialog.
*/
bool updating_;
bool is_closing_;
+
+ /// stop the apply process?
+ bool applyStopped() { return apply_stopped_; };
+ bool apply_stopped_;
};
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();
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_);
{
return
validateListingsParameters().isEmpty() &&
- localLayout->isValid() &&
!localLayout->editing() &&
!preambleModule->editing() &&
(
LocalLayout(QWidget * parent);
void update(BufferParams const & params, BufferId id);
void apply(BufferParams & params);
+ void validate();
bool isValid() const { return validated_; }
bool editing() const { return (bool)tempfile_; }
void changed();
private:
- void validate();
void convert();
void hideConvert();
private Q_SLOTS: