mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
Optimize a bit the handling of local layout validation. This handles
empty cases better than what was before. Patch from Scott Kostyshak.
This commit is contained in:
parent
0dde9cc163
commit
afee2488cb
@ -606,13 +606,26 @@ void LocalLayout::apply(BufferParams & params)
|
||||
|
||||
void LocalLayout::textChanged()
|
||||
{
|
||||
static const QString unknown = qt_("Press button to check validity...");
|
||||
static const QString message =
|
||||
qt_("Press button to check validity...");
|
||||
string const layout =
|
||||
fromqstr(locallayoutTE->document()->toPlainText().trimmed());
|
||||
|
||||
is_valid_ = false;
|
||||
validLB->setText(unknown);
|
||||
validatePB->setEnabled(true);
|
||||
convertPB->setEnabled(false);
|
||||
changed();
|
||||
if (layout.empty()) {
|
||||
is_valid_ = true;
|
||||
validatePB->setEnabled(false);
|
||||
validLB->setText("");
|
||||
convertPB->hide();
|
||||
convertLB->hide();
|
||||
changed();
|
||||
} else if (!validatePB->isEnabled()) {
|
||||
// if that's already enabled, we shouldn't need to do anything.
|
||||
is_valid_ = false;
|
||||
validLB->setText(message);
|
||||
validatePB->setEnabled(true);
|
||||
convertPB->setEnabled(false);
|
||||
changed();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -649,13 +662,7 @@ void LocalLayout::validate() {
|
||||
|
||||
string const layout =
|
||||
fromqstr(locallayoutTE->document()->toPlainText().trimmed());
|
||||
if (layout.empty()) {
|
||||
is_valid_ = true;
|
||||
validatePB->setEnabled(false);
|
||||
validLB->setText("");
|
||||
convertPB->hide();
|
||||
convertLB->hide();
|
||||
} else {
|
||||
if (!layout.empty()) {
|
||||
TextClass::ReturnValues const ret = TextClass::validate(layout);
|
||||
is_valid_ = (ret == TextClass::OK) || (ret == TextClass::OK_OLDFORMAT);
|
||||
validatePB->setEnabled(false);
|
||||
|
Loading…
Reference in New Issue
Block a user