Fix enabling/disabling in InsetParams derived dialogs (#9541)

This commit is contained in:
Juergen Spitzmueller 2015-05-11 11:35:02 +02:00
parent 75a87193a9
commit 1d3b7e5085
8 changed files with 85 additions and 58 deletions

View File

@ -222,7 +222,7 @@ void FloatPlacement::changedSlot()
} }
void FloatPlacement::checkAllowed() void FloatPlacement::checkAllowed() const
{ {
bool const defaults = defaultsCB->isChecked(); bool const defaults = defaultsCB->isChecked();
bool const ignore = topCB->isChecked() || bottomCB->isChecked() bool const ignore = topCB->isChecked() || bottomCB->isChecked()
@ -254,11 +254,14 @@ void FloatPlacement::checkAllowed()
bool FloatPlacement::checkWidgets(bool readonly) const bool FloatPlacement::checkWidgets(bool readonly) const
{ {
floatTypeCO->setEnabled(!readonly); if (readonly) {
defaultsCB->setEnabled(!readonly); floatTypeCO->setEnabled(false);
options->setEnabled(!readonly); defaultsCB->setEnabled(false);
spanCB->setEnabled(!readonly); options->setEnabled(false);
sidewaysCB->setEnabled(!readonly); spanCB->setEnabled(false);
sidewaysCB->setEnabled(false);
} else
checkAllowed();
return InsetParamsWidget::checkWidgets(); return InsetParamsWidget::checkWidgets();
} }

View File

@ -54,7 +54,7 @@ private Q_SLOTS:
private: private:
/// ///
void checkAllowed(); void checkAllowed() const;
/// ///
std::string const get(bool & wide, bool & sideways) const; std::string const get(bool & wide, bool & sideways) const;
/// ///

View File

@ -99,7 +99,7 @@ void GuiHSpace::changedSlot()
} }
void GuiHSpace::enableWidgets() void GuiHSpace::enableWidgets() const
{ {
QString const selection = spacingCO->itemData(spacingCO->currentIndex()).toString(); QString const selection = spacingCO->itemData(spacingCO->currentIndex()).toString();
bool const custom = selection == "custom"; bool const custom = selection == "custom";
@ -301,11 +301,17 @@ docstring GuiHSpace::dialogToParams() const
bool GuiHSpace::checkWidgets(bool readonly) const bool GuiHSpace::checkWidgets(bool readonly) const
{ {
spacingCO->setEnabled(!readonly);
unitCO->setEnabled(!readonly);
fillPatternCO->setEnabled(!readonly);
keepCB->setEnabled(!readonly);
valueLE->setReadOnly(readonly); valueLE->setReadOnly(readonly);
if (readonly) {
spacingCO->setEnabled(false);
unitCO->setEnabled(false);
fillPatternCO->setEnabled(false);
keepCB->setEnabled(false);
valueLE->setEnabled(false);
} else
enableWidgets();
if (!InsetParamsWidget::checkWidgets()) if (!InsetParamsWidget::checkWidgets())
return false; return false;
return spacingCO->itemData(spacingCO->currentIndex()).toString() != "custom" return spacingCO->itemData(spacingCO->currentIndex()).toString() != "custom"

View File

@ -29,7 +29,7 @@ private Q_SLOTS:
/// ///
void changedSlot(); void changedSlot();
/// ///
void enableWidgets(); void enableWidgets() const;
private: private:
/// \name InsetParamsWidget inherited methods /// \name InsetParamsWidget inherited methods

View File

@ -53,13 +53,8 @@ GuiPrintNomencl::GuiPrintNomencl(QWidget * parent) : InsetParamsWidget(parent)
} }
void GuiPrintNomencl::on_setWidthCO_activated(int i) void GuiPrintNomencl::on_setWidthCO_activated(int /*i*/)
{ {
bool const custom =
(setWidthCO->itemData(i).toString() == "custom");
valueLE->setEnabled(custom);
unitLC->setEnabled(custom);
valueLA->setEnabled(custom);
changed(); changed();
} }
@ -71,12 +66,6 @@ void GuiPrintNomencl::paramsToDialog(InsetCommandParams const & params)
lengthToWidgets(valueLE, unitLC, lengthToWidgets(valueLE, unitLC,
params["width"], Length::defaultUnit()); params["width"], Length::defaultUnit());
bool const custom =
(setWidthCO->itemData(setWidthCO->currentIndex()).toString() == "custom");
valueLE->setEnabled(custom);
unitLC->setEnabled(custom);
valueLA->setEnabled(custom);
} }
@ -104,8 +93,18 @@ docstring GuiPrintNomencl::dialogToParams() const
bool GuiPrintNomencl::checkWidgets(bool readonly) const bool GuiPrintNomencl::checkWidgets(bool readonly) const
{ {
valueLE->setReadOnly(readonly); valueLE->setReadOnly(readonly);
setWidthCO->setEnabled(!readonly); if (readonly) {
unitLC->setEnabled(!readonly); setWidthCO->setEnabled(false);
unitLC->setEnabled(false);
valueLA->setEnabled(false);
} else {
bool const custom =
(setWidthCO->itemData(setWidthCO->currentIndex()).toString() == "custom");
valueLE->setEnabled(custom);
unitLC->setEnabled(custom);
valueLA->setEnabled(custom);
}
if (!InsetParamsWidget::checkWidgets()) if (!InsetParamsWidget::checkWidgets())
return false; return false;
return setWidthCO->itemData( return setWidthCO->itemData(

View File

@ -199,7 +199,7 @@ void GuiTabular::on_interlinespaceCO_activated(int index)
} }
void GuiTabular::checkEnabled() void GuiTabular::enableWidgets() const
{ {
// if there is a LaTeX argument, the width and alignment will be overwritten // if there is a LaTeX argument, the width and alignment will be overwritten
// therefore disable them in this case // therefore disable them in this case
@ -320,7 +320,12 @@ void GuiTabular::checkEnabled()
multirowOffsetLA->setEnabled(enable_mr); multirowOffsetLA->setEnabled(enable_mr);
multirowOffsetED->setEnabled(enable_mr); multirowOffsetED->setEnabled(enable_mr);
multirowOffsetUnitLC->setEnabled(enable_mr); multirowOffsetUnitLC->setEnabled(enable_mr);
}
void GuiTabular::checkEnabled()
{
enableWidgets();
changed(); changed();
} }
@ -1016,37 +1021,41 @@ bool GuiTabular::checkWidgets(bool readonly) const
{ {
tabularRowED->setReadOnly(readonly); tabularRowED->setReadOnly(readonly);
tabularColumnED->setReadOnly(readonly); tabularColumnED->setReadOnly(readonly);
multicolumnCB->setEnabled(!readonly);
multirowCB->setEnabled(!readonly);
specialAlignmentED->setReadOnly(readonly);
rotateCellCB->setEnabled(!readonly);
rotateCellAngleSB->setEnabled(!readonly);
rotateTabularCB->setEnabled(!readonly);
rotateTabularAngleSB->setEnabled(!readonly);
longTabularCB->setEnabled(!readonly);
borders->setEnabled(!readonly);
tabularWidthED->setReadOnly(readonly); tabularWidthED->setReadOnly(readonly);
tabularWidthUnitLC->setEnabled(!readonly); specialAlignmentED->setReadOnly(readonly);
columnWidthED->setReadOnly(readonly); columnWidthED->setReadOnly(readonly);
columnWidthUnitLC->setEnabled(!readonly);
multirowOffsetED->setReadOnly(readonly); multirowOffsetED->setReadOnly(readonly);
multirowOffsetUnitLC->setEnabled(!readonly);
setBordersGB->setEnabled(!readonly);
allBordersGB->setEnabled(!readonly);
borderStyleGB->setEnabled(!readonly);
booktabsRB->setEnabled(!readonly);
topspaceCO->setEnabled(!readonly);
topspaceUnitLC->setEnabled(!readonly);
bottomspaceCO->setEnabled(!readonly);
bottomspaceUnitLC->setEnabled(!readonly);
interlinespaceCO->setEnabled(!readonly);
interlinespaceUnitLC->setEnabled(!readonly);
hAlignCO->setEnabled(!readonly);
decimalPointED->setReadOnly(readonly); decimalPointED->setReadOnly(readonly);
vAlignCO->setEnabled(!readonly);
TableAlignCO->setEnabled(!readonly); if (readonly) {
longtableGB->setEnabled(!readonly); multicolumnCB->setEnabled(false);
alignmentGB->setEnabled(!readonly); multirowCB->setEnabled(false);
rotateCellCB->setEnabled(false);
rotateCellAngleSB->setEnabled(false);
rotateTabularCB->setEnabled(false);
rotateTabularAngleSB->setEnabled(false);
longTabularCB->setEnabled(false);
borders->setEnabled(false);
tabularWidthUnitLC->setEnabled(false);
columnWidthUnitLC->setEnabled(false);
multirowOffsetUnitLC->setEnabled(false);
setBordersGB->setEnabled(false);
allBordersGB->setEnabled(false);
borderStyleGB->setEnabled(false);
booktabsRB->setEnabled(false);
topspaceCO->setEnabled(false);
topspaceUnitLC->setEnabled(false);
bottomspaceCO->setEnabled(false);
bottomspaceUnitLC->setEnabled(false);
interlinespaceCO->setEnabled(false);
interlinespaceUnitLC->setEnabled(false);
hAlignCO->setEnabled(false);
vAlignCO->setEnabled(false);
TableAlignCO->setEnabled(false);
longtableGB->setEnabled(false);
alignmentGB->setEnabled(false);
} else
enableWidgets();
return InsetParamsWidget::checkWidgets(); return InsetParamsWidget::checkWidgets();
} }

View File

@ -47,6 +47,8 @@ private:
bool checkWidgets(bool readonly) const; bool checkWidgets(bool readonly) const;
//@} //@}
///
void enableWidgets() const;
/// ///
void setHAlign(std::string & param_str) const; void setHAlign(std::string & param_str) const;
/// ///

View File

@ -150,10 +150,18 @@ void GuiVSpace::paramsToDialog(Inset const * inset)
bool GuiVSpace::checkWidgets(bool readonly) const bool GuiVSpace::checkWidgets(bool readonly) const
{ {
valueLE->setReadOnly(readonly); valueLE->setReadOnly(readonly);
spacingCO->setEnabled(!readonly);
unitCO->setEnabled(!readonly);
keepCB->setEnabled(!readonly); keepCB->setEnabled(!readonly);
if (readonly) {
spacingCO->setEnabled(false);
unitCO->setEnabled(false);
} else {
bool const enable = (spacingCO->currentIndex() == 5);
valueLE->setEnabled(enable);
valueL->setEnabled(enable);
unitCO->setEnabled(enable);
}
return InsetParamsWidget::checkWidgets(); return InsetParamsWidget::checkWidgets();
} }