connect(labelWidth, SIGNAL(textChanged(QString)),
this, SLOT(changed()));
-#ifdef Q_WS_MACX
+#ifdef Q_OS_MAC
// On Mac it's common to have tool windows which are always in the
// foreground and are hidden when the main window is not focused.
setWindowFlags(Qt::Tool);
#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;
+ // We apply immediately, except if we have custom line spacing
+ // with an intermediate result (trailing decimal separator) or
+ // an invalid value (which might as well be intermediate)
+ if (synchronizedViewCB->isChecked()
+ && (linespacing->currentIndex() != 4
+ || (!linespacingValue->text().endsWith(loc.decimalPoint())
+ && linespacingValue->hasAcceptableInput())))
on_applyPB_clicked();
}
// linespacing
int ls;
+ bool pending_input = false;
Spacing const & space = pp.spacing();
- switch (space.getSpace()) {
- case Spacing::Single:
- ls = 1;
- break;
- case Spacing::Onehalf:
- ls = 2;
- break;
- case Spacing::Double:
- ls = 3;
- break;
- case Spacing::Other:
+ if (synchronizedViewCB->isChecked() && linespacingValue->hasFocus()) {
+ // The user is about to enter custom spacing.
+ // We thus stay in Custom mode.
+ // This prevents the combo from e.g. immediately
+ // switching to single if a user enters "1" in the
+ // linespacingValue widget while aiming at e.g. "1.3"
ls = 4;
- break;
- default:
- ls = 0;
- break;
+ pending_input = true;
+ } else {
+ switch (space.getSpace()) {
+ case Spacing::Single:
+ ls = 1;
+ break;
+ case Spacing::Onehalf:
+ ls = 2;
+ break;
+ case Spacing::Double:
+ ls = 3;
+ break;
+ case Spacing::Other:
+ ls = 4;
+ break;
+ default:
+ ls = 0;
+ break;
+ }
}
linespacing->setCurrentIndex(ls);
- if (space.getSpace() == Spacing::Other) {
+ if (space.getSpace() == Spacing::Other || pending_input) {
doubleToWidget(linespacingValue, space.getValue());
linespacingValue->setEnabled(true);
} else {