commit 99f7b916e6b9c3eb3e9d69e7d996ed590248ee53
Author: Juergen Spitzmueller <[email protected]>
Date:   Mon Mar 30 14:44:11 2015 +0200

    Improve read-only mode of InsetParams derived dialogs
    
    * Disable "New Inset" button
    * Do not disable line edits, but use setReadOnly instead (this allows 
copying contents)
    
    Fixes: #9408
    
    Note that some dialogs still need some care.

diff --git a/src/frontends/qt4/GuiBibitem.cpp b/src/frontends/qt4/GuiBibitem.cpp
index 0b2da16..052be00 100644
--- a/src/frontends/qt4/GuiBibitem.cpp
+++ b/src/frontends/qt4/GuiBibitem.cpp
@@ -53,8 +53,10 @@ docstring GuiBibitem::dialogToParams() const
 }
 
 
-bool GuiBibitem::checkWidgets() const
+bool GuiBibitem::checkWidgets(bool readonly) const
 {
+       keyED->setReadOnly(readonly);
+       labelED->setReadOnly(readonly);
        if (!InsetParamsWidget::checkWidgets())
                return false;
        return !keyED->text().isEmpty();
diff --git a/src/frontends/qt4/GuiBibitem.h b/src/frontends/qt4/GuiBibitem.h
index a64ba72..70dcb2a 100644
--- a/src/frontends/qt4/GuiBibitem.h
+++ b/src/frontends/qt4/GuiBibitem.h
@@ -35,7 +35,7 @@ private:
        FuncCode creationCode() const { return LFUN_INSET_INSERT; }
        void paramsToDialog(Inset const *);
        docstring dialogToParams() const;
-       bool checkWidgets() const;
+       bool checkWidgets(bool readonly = false) const;
        //@}
 };
 
diff --git a/src/frontends/qt4/GuiHSpace.cpp b/src/frontends/qt4/GuiHSpace.cpp
index 57d4e98..a85037a 100644
--- a/src/frontends/qt4/GuiHSpace.cpp
+++ b/src/frontends/qt4/GuiHSpace.cpp
@@ -299,8 +299,13 @@ docstring GuiHSpace::dialogToParams() const
 }
 
 
-bool GuiHSpace::checkWidgets() const
+bool GuiHSpace::checkWidgets(bool readonly) const
 {
+       spacingCO->setEnabled(!readonly);
+       unitCO->setEnabled(!readonly);
+       fillPatternCO->setEnabled(!readonly);
+       keepCB->setEnabled(!readonly);
+       valueLE->setReadOnly(readonly);
        if (!InsetParamsWidget::checkWidgets())
                return false;
        return spacingCO->itemData(spacingCO->currentIndex()).toString() != 
"custom"
diff --git a/src/frontends/qt4/GuiHSpace.h b/src/frontends/qt4/GuiHSpace.h
index 6bc45cc..0913475 100644
--- a/src/frontends/qt4/GuiHSpace.h
+++ b/src/frontends/qt4/GuiHSpace.h
@@ -38,7 +38,7 @@ private:
        FuncCode creationCode() const { return LFUN_INSET_INSERT; }
        void paramsToDialog(Inset const *);
        docstring dialogToParams() const;
-       bool checkWidgets() const;
+       bool checkWidgets(bool readonly = false) const;
        //@}
        ///
        bool const math_mode_;
diff --git a/src/frontends/qt4/GuiHyperlink.cpp 
b/src/frontends/qt4/GuiHyperlink.cpp
index 6cd9262..3111d19 100644
--- a/src/frontends/qt4/GuiHyperlink.cpp
+++ b/src/frontends/qt4/GuiHyperlink.cpp
@@ -102,8 +102,11 @@ docstring GuiHyperlink::dialogToParams() const
 }
 
 
-bool GuiHyperlink::checkWidgets() const
+bool GuiHyperlink::checkWidgets(bool readonly) const
 {
+       targetED->setReadOnly(readonly);
+       nameED->setReadOnly(readonly);
+       typeGB->setEnabled(!readonly);
        if (!InsetParamsWidget::checkWidgets())
                return false;
        return !targetED->text().isEmpty() || !nameED->text().isEmpty();
diff --git a/src/frontends/qt4/GuiHyperlink.h b/src/frontends/qt4/GuiHyperlink.h
index d2dd0ee..0523aaa 100644
--- a/src/frontends/qt4/GuiHyperlink.h
+++ b/src/frontends/qt4/GuiHyperlink.h
@@ -34,7 +34,7 @@ private:
        FuncCode creationCode() const { return LFUN_INSET_INSERT; }
        void paramsToDialog(Inset const *);
        docstring dialogToParams() const;
-       bool checkWidgets() const;
+       bool checkWidgets(bool readonly = false) const;
        bool initialiseParams(std::string const & data);
        //@}
 };
diff --git a/src/frontends/qt4/GuiLabel.cpp b/src/frontends/qt4/GuiLabel.cpp
index 5d1ea4a..d5b207f 100644
--- a/src/frontends/qt4/GuiLabel.cpp
+++ b/src/frontends/qt4/GuiLabel.cpp
@@ -68,8 +68,9 @@ bool GuiLabel::initialiseParams(std::string const & data)
 }
 
 
-bool GuiLabel::checkWidgets() const
+bool GuiLabel::checkWidgets(bool readonly) const
 {
+       keywordED->setReadOnly(readonly);
        if (!InsetParamsWidget::checkWidgets())
                return false;
        return !keywordED->text().isEmpty();
diff --git a/src/frontends/qt4/GuiLabel.h b/src/frontends/qt4/GuiLabel.h
index d616cbf..6ba60ed 100644
--- a/src/frontends/qt4/GuiLabel.h
+++ b/src/frontends/qt4/GuiLabel.h
@@ -34,7 +34,7 @@ private:
        FuncCode creationCode() const { return LFUN_INSET_INSERT; }
        void paramsToDialog(Inset const *);
        docstring dialogToParams() const;
-       bool checkWidgets() const;
+       bool checkWidgets(bool readonly = false) const;
        bool initialiseParams(std::string const &);
        //@}
 };
diff --git a/src/frontends/qt4/GuiLine.cpp b/src/frontends/qt4/GuiLine.cpp
index 4ab2da8..2a8b9de 100644
--- a/src/frontends/qt4/GuiLine.cpp
+++ b/src/frontends/qt4/GuiLine.cpp
@@ -100,8 +100,14 @@ void GuiLine::paramsToDialog(Inset const * inset)
 }
 
 
-bool GuiLine::checkWidgets() const
+bool GuiLine::checkWidgets(bool readonly) const
 {
+       WidthLE->setReadOnly(readonly);
+       HeightLE->setReadOnly(readonly);
+       OffsetLE->setReadOnly(readonly);
+       OffsetUnitCO->setEnabled(!readonly);
+       HeightUnitCO->setEnabled(!readonly);
+       WidthUnitCO->setEnabled(!readonly);
        if (!InsetParamsWidget::checkWidgets())
                return false;
        // FIXME: this should be handled in unsignedGlueLengthValidator!
diff --git a/src/frontends/qt4/GuiLine.h b/src/frontends/qt4/GuiLine.h
index 0ad6833..9fa3e61 100644
--- a/src/frontends/qt4/GuiLine.h
+++ b/src/frontends/qt4/GuiLine.h
@@ -33,7 +33,7 @@ private:
        FuncCode creationCode() const { return LFUN_INSET_INSERT; }
        void paramsToDialog(Inset const *);
        docstring dialogToParams() const;
-       bool checkWidgets() const;
+       bool checkWidgets(bool readonly = false) const;
        //@}
 };
 
diff --git a/src/frontends/qt4/GuiNomenclature.cpp 
b/src/frontends/qt4/GuiNomenclature.cpp
index 7415f7f..0a52bd1 100644
--- a/src/frontends/qt4/GuiNomenclature.cpp
+++ b/src/frontends/qt4/GuiNomenclature.cpp
@@ -70,8 +70,10 @@ bool GuiNomenclature::initialiseParams(std::string const & 
data)
 }
 
 
-bool GuiNomenclature::checkWidgets() const
+bool GuiNomenclature::checkWidgets(bool readonly) const
 {
+       symbolED->setReadOnly(readonly);
+       descriptionTE->setReadOnly(readonly);
        if (!InsetParamsWidget::checkWidgets())
                return false;
        QString const description = descriptionTE->toPlainText();
diff --git a/src/frontends/qt4/GuiNomenclature.h 
b/src/frontends/qt4/GuiNomenclature.h
index dcdd10f..9ec016f 100644
--- a/src/frontends/qt4/GuiNomenclature.h
+++ b/src/frontends/qt4/GuiNomenclature.h
@@ -35,7 +35,7 @@ private:
        FuncCode creationCode() const { return LFUN_INSET_INSERT; }
        void paramsToDialog(Inset const *);
        docstring dialogToParams() const;
-       bool checkWidgets() const;
+       bool checkWidgets(bool readonly = false) const;
        bool initialiseParams(std::string const &);
        //@}
 };
diff --git a/src/frontends/qt4/GuiPrintNomencl.cpp 
b/src/frontends/qt4/GuiPrintNomencl.cpp
index 1e41e3e..93e00e9 100644
--- a/src/frontends/qt4/GuiPrintNomencl.cpp
+++ b/src/frontends/qt4/GuiPrintNomencl.cpp
@@ -101,8 +101,11 @@ docstring GuiPrintNomencl::dialogToParams() const
 }
 
 
-bool GuiPrintNomencl::checkWidgets() const
+bool GuiPrintNomencl::checkWidgets(bool readonly) const
 {
+       valueLE->setReadOnly(readonly);
+       setWidthCO->setEnabled(!readonly);
+       unitLC->setEnabled(!readonly);
        if (!InsetParamsWidget::checkWidgets())
                return false;
        return setWidthCO->itemData(
diff --git a/src/frontends/qt4/GuiPrintNomencl.h 
b/src/frontends/qt4/GuiPrintNomencl.h
index 8005f1d..8589738 100644
--- a/src/frontends/qt4/GuiPrintNomencl.h
+++ b/src/frontends/qt4/GuiPrintNomencl.h
@@ -40,7 +40,7 @@ private:
        void paramsToDialog(Inset const *);
        void paramsToDialog(InsetCommandParams const &);
        docstring dialogToParams() const;
-       bool checkWidgets() const;
+       bool checkWidgets(bool readonly = false) const;
        //@}
 };
 
diff --git a/src/frontends/qt4/InsetParamsDialog.cpp 
b/src/frontends/qt4/InsetParamsDialog.cpp
index f76427d..9777d59 100644
--- a/src/frontends/qt4/InsetParamsDialog.cpp
+++ b/src/frontends/qt4/InsetParamsDialog.cpp
@@ -166,7 +166,8 @@ void InsetParamsDialog::on_synchronizedCB_stateChanged(int)
 
 docstring InsetParamsDialog::checkWidgets(bool immediate)
 {
-       bool const widget_ok = d->widget_->checkWidgets();
+       bool const read_only = buffer().isReadonly();
+       bool const widget_ok = d->widget_->checkWidgets(read_only);
        Inset const * ins = inset(d->widget_->insetCode());
        docstring const argument = d->widget_->dialogToParams();
        bool valid_argument = !argument.empty();
@@ -175,14 +176,13 @@ docstring InsetParamsDialog::checkWidgets(bool immediate)
        FuncCode const code = immediate
                ? d->widget_->creationCode() : LFUN_INSET_MODIFY;
        bool const lfun_ok = lyx::getStatus(FuncRequest(code, 
argument)).enabled();
-       bool const read_only = buffer().isReadonly();
 
        okPB->setEnabled(!immediate && widget_ok && !read_only && 
valid_argument);
        bool const can_be_restored = !immediate && !read_only
                        && ins && (ins != d->inset_ || d->changed_);
        restorePB->setEnabled(can_be_restored);
        applyPB->setEnabled(!immediate && lfun_ok && widget_ok && !read_only && 
valid_argument);
-       d->widget_->setEnabled(!read_only);
+       newPB->setEnabled(widget_ok && !read_only && valid_argument);
        synchronizedCB->setEnabled(!immediate);
        return argument;
 }
diff --git a/src/frontends/qt4/InsetParamsWidget.cpp 
b/src/frontends/qt4/InsetParamsWidget.cpp
index 96d39ab..91e2e7b 100644
--- a/src/frontends/qt4/InsetParamsWidget.cpp
+++ b/src/frontends/qt4/InsetParamsWidget.cpp
@@ -54,7 +54,7 @@ void InsetParamsWidget::addCheckedWidget(QLineEdit * input, 
QWidget * label)
 }
 
 
-bool InsetParamsWidget::checkWidgets() const
+bool InsetParamsWidget::checkWidgets(bool readonly) const
 {
        bool valid = true;
        Q_FOREACH(CheckedWidget const & le, checked_widgets_)
diff --git a/src/frontends/qt4/InsetParamsWidget.h 
b/src/frontends/qt4/InsetParamsWidget.h
index 00286c9..a531645 100644
--- a/src/frontends/qt4/InsetParamsWidget.h
+++ b/src/frontends/qt4/InsetParamsWidget.h
@@ -70,7 +70,7 @@ public:
                { return false; }
 
        /// \return true if all CheckedWidgets are in a valid state.
-       virtual bool checkWidgets() const;
+       virtual bool checkWidgets(bool readonly = false) const;
 
 protected:
        /// Add a widget to the list of all widgets whose validity should

Reply via email to