mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
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.
This commit is contained in:
parent
7b72010408
commit
99f7b916e6
@ -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();
|
||||
|
@ -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;
|
||||
//@}
|
||||
};
|
||||
|
||||
|
@ -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"
|
||||
|
@ -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_;
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
//@}
|
||||
};
|
||||
|
@ -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();
|
||||
|
@ -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 &);
|
||||
//@}
|
||||
};
|
||||
|
@ -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!
|
||||
|
@ -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;
|
||||
//@}
|
||||
};
|
||||
|
||||
|
@ -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();
|
||||
|
@ -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 &);
|
||||
//@}
|
||||
};
|
||||
|
@ -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(
|
||||
|
@ -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;
|
||||
//@}
|
||||
};
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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_)
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user