#endif
on_synchronizedViewCB_toggled();
- linespacingValue->setValidator(new QDoubleValidator(linespacingValue));
+ QDoubleValidator * val = new QDoubleValidator(linespacingValue);
+ val->setNotation(QDoubleValidator::StandardNotation);
+ linespacingValue->setValidator(val);
labelWidth->setWhatsThis(qt_(
"As described in the User Guide, the width of"
void GuiParagraph::changed()
{
- if (synchronizedViewCB->isChecked())
+ QLocale loc;
+ if (synchronizedViewCB->isChecked()
+ && !linespacingValue->text().endsWith(loc.decimalPoint())
+ && linespacingValue->hasAcceptableInput())
on_applyPB_clicked();
}
// Set width and alignment
Length const tabwidth = tabular.tabularWidth();
- if (tabwidth.zero())
+ if (tabwidth.zero()
+ && !(tabularWidthED->hasFocus() && tabularWidthED->text() == "0"))
tabularWidthED->clear();
else
lengthToWidgets(tabularWidthED, tabularWidthUnitLC,
pwidth = getColumnPWidth(tabular, cell);
}
string colwidth;
- if (pwidth.zero())
+ if (pwidth.zero()
+ && !(columnWidthED->hasFocus() && columnWidthED->text() == "0"))
columnWidthED->clear();
else {
colwidth = pwidth.asString();
if (multirow)
mroffset = getMROffset(tabular, cell);
string offset;
- if (mroffset.zero())
+ if (mroffset.zero()
+ && !(multirowOffsetED->hasFocus() && multirowOffsetED->text() == "0"))
multirowOffsetED->clear();
else {
offset = mroffset.asString();
LengthValidator::LengthValidator(QWidget * parent)
: QValidator(parent),
- no_bottom_(true), glue_length_(false)
+ no_bottom_(true), glue_length_(false), unsigned_(false)
{}
{
QLocale loc;
bool ok;
- loc.toDouble(qtext.trimmed(), &ok);
+ double d = loc.toDouble(qtext.trimmed(), &ok);
+ // QLocale::toDouble accepts something like "1."
+ // We don't.
+ bool dp = qtext.endsWith(loc.decimalPoint());
if (!ok) {
// Fall back to C
QLocale c(QLocale::C);
- c.toDouble(qtext.trimmed(), &ok);
+ d = c.toDouble(qtext.trimmed(), &ok);
+ dp = qtext.endsWith(c.decimalPoint());
}
- if (qtext.isEmpty() || ok)
+ if (ok && unsigned_ && d < 0)
+ return QValidator::Invalid;
+
+ if (qtext.isEmpty() || (ok && !dp))
return QValidator::Acceptable;
string const text = fromqstr(qtext);
if (glue_length_) {
GlueLength gl;
+ if (unsigned_ && gl.len().value() < 0)
+ return QValidator::Invalid;
return (isValidGlueLength(text, &gl)) ?
QValidator::Acceptable : QValidator::Intermediate;
}
if (no_bottom_)
return QValidator::Acceptable;
+ if (unsigned_ && l.value() < 0)
+ return QValidator::Invalid;
+
return b_.inPixels(100) <= l.inPixels(100) ?
QValidator::Acceptable : QValidator::Intermediate;
}
{
LengthValidator * v = new LengthValidator(ed);
v->setBottom(Length());
+ v->setUnsigned(true);
return v;
}
{
LengthValidator * v = new LengthValidator(ed);
v->setBottom(GlueLength());
+ v->setUnsigned(true);
return v;
}
{
LengthAutoValidator * v = new LengthAutoValidator(ed, autotext);
v->setBottom(Length());
+ v->setUnsigned(true);
return v;
}