]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiWrap.cpp
GuiWrap.cpp: disconnect the widgets that are by default disabled from readonly
[lyx.git] / src / frontends / qt4 / GuiWrap.cpp
index ddbe458b1c48e420966401237618dad6c5d173ca..ac761d55f8f9dfb3cb133fd093248bae27164c59 100644 (file)
@@ -49,13 +49,20 @@ GuiWrapDialog::GuiWrapDialog(LyXView & lv)
                this, SLOT(change_adaptor()));
        connect(valignCO, SIGNAL(highlighted(const QString &)),
                this, SLOT(change_adaptor()));
+       connect(overhangCB, SIGNAL(stateChanged(int)),
+               this, SLOT(change_adaptor()));
        connect(overhangED, SIGNAL(textChanged(const QString &)),
                this, SLOT(change_adaptor()));
        connect(overhangUnitLC, SIGNAL(selectionChanged(lyx::Length::UNIT)),
                this, SLOT(change_adaptor()));
+       connect(linesCB, SIGNAL(stateChanged(int)),
+               this, SLOT(change_adaptor()));
        connect(linesSB, SIGNAL(valueChanged(int)),
                this, SLOT(change_adaptor()));
 
+       connect(overhangCB, SIGNAL(stateChanged(int)), this, SLOT(overhangChecked(int)));
+       connect(linesCB, SIGNAL(stateChanged(int)), this, SLOT(linesChecked(int)));
+
        widthED->setValidator(unsignedLengthValidator(widthED));
        // FIXME:
        // overhang can be negative, but the unsignedLengthValidator allows this
@@ -70,13 +77,12 @@ GuiWrapDialog::GuiWrapDialog(LyXView & lv)
        bc().addReadOnly(widthED);
        bc().addReadOnly(widthUnitLC);
        bc().addReadOnly(valignCO);
-       bc().addReadOnly(overhangED);
-       bc().addReadOnly(overhangUnitLC);
-       bc().addReadOnly(linesSB);
+       bc().addReadOnly(overhangCB);
+       bc().addReadOnly(linesCB);
 
        // initialize the length validator
        bc().addCheckedLineEdit(widthED, widthLA);
-       bc().addCheckedLineEdit(overhangED, overhangLA);
+       bc().addCheckedLineEdit(overhangED, overhangCB);
 }
 
 
@@ -99,6 +105,26 @@ void GuiWrapDialog::change_adaptor()
 }
 
 
+void GuiWrapDialog::overhangChecked(int checkState)
+{
+       if (checkState == Qt::Checked) {
+               overhangED->setEnabled(true);
+               overhangUnitLC->setEnabled(true);
+       } else { 
+               overhangED->setEnabled(false);
+               overhangUnitLC->setEnabled(false);
+       }
+}
+
+void GuiWrapDialog::linesChecked(int checkState)
+{
+       if (checkState == Qt::Checked)
+               linesSB->setEnabled(true);
+       else 
+               linesSB->setEnabled(false);
+}
+
+
 void GuiWrapDialog::applyView()
 {
        double const width_value = widthED->text().toDouble();
@@ -113,8 +139,20 @@ void GuiWrapDialog::applyView()
        InsetWrapParams & params = controller().params();
 
        params.width = Length(width_value, widthUnit);
-       params.overhang = Length(overhang_value, overhangUnit);
-       params.lines = linesSB->value();
+
+       if (overhangCB->checkState() == Qt::Checked)
+               params.overhang = Length(overhang_value, overhangUnit);
+       else
+               // when value is "0" the option is not set in the LaTeX-output
+               // in InsetWrap.cpp
+               params.overhang = Length("0in");
+
+       if (linesCB->checkState() == Qt::Checked)
+               params.lines = linesSB->value();
+       else
+               // when value is "0" the option is not set in the LaTeX-output
+               // in InsetWrap.cpp
+               params.lines = 0;
 
        switch (valignCO->currentIndex()) {
        case 0: