]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiParagraph.cpp
Speed up exit time
[lyx.git] / src / frontends / qt4 / GuiParagraph.cpp
index 1bc22488a9a112c8f1192b3c9096f06f283bcbce..15958d721be2a1bf577aa59bfdeaee66b3aa1de4 100644 (file)
@@ -167,9 +167,13 @@ void GuiParagraph::on_synchronizedViewCB_toggled()
 void GuiParagraph::changed()
 {
        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()
-           && !linespacingValue->text().endsWith(loc.decimalPoint())
-           && linespacingValue->hasAcceptableInput())
+           && (linespacing->currentIndex() != 4
+               || (!linespacingValue->text().endsWith(loc.decimalPoint())
+                   && linespacingValue->hasAcceptableInput())))
                on_applyPB_clicked();
 }
 
@@ -266,26 +270,37 @@ void GuiParagraph::updateView()
 
        // 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 {
@@ -369,10 +384,9 @@ bool GuiParagraph::hasLabelwidth() const
 }
 
 
-void GuiParagraph::saveSession() const
+void GuiParagraph::saveSession(QSettings & settings) const
 {
-       Dialog::saveSession();
-       QSettings settings;
+       Dialog::saveSession(settings);
        settings.setValue(sessionKey() + "/autoapply", synchronizedViewCB->isChecked());
 }