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

View File

@ -54,7 +54,7 @@ private Q_SLOTS:
private:
///
void checkAllowed();
void checkAllowed() 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();
bool const custom = selection == "custom";
@ -301,11 +301,17 @@ docstring GuiHSpace::dialogToParams() const
bool GuiHSpace::checkWidgets(bool readonly) const
{
spacingCO->setEnabled(!readonly);
unitCO->setEnabled(!readonly);
fillPatternCO->setEnabled(!readonly);
keepCB->setEnabled(!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())
return false;
return spacingCO->itemData(spacingCO->currentIndex()).toString() != "custom"

View File

@ -29,7 +29,7 @@ private Q_SLOTS:
///
void changedSlot();
///
void enableWidgets();
void enableWidgets() const;
private:
/// \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();
}
@ -68,15 +63,9 @@ void GuiPrintNomencl::paramsToDialog(InsetCommandParams const & params)
{
setWidthCO->setCurrentIndex(
setWidthCO->findData(toqstr(params["set_width"])));
lengthToWidgets(valueLE, unitLC,
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
{
valueLE->setReadOnly(readonly);
setWidthCO->setEnabled(!readonly);
unitLC->setEnabled(!readonly);
if (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())
return false;
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
// therefore disable them in this case
@ -320,7 +320,12 @@ void GuiTabular::checkEnabled()
multirowOffsetLA->setEnabled(enable_mr);
multirowOffsetED->setEnabled(enable_mr);
multirowOffsetUnitLC->setEnabled(enable_mr);
}
void GuiTabular::checkEnabled()
{
enableWidgets();
changed();
}
@ -1016,37 +1021,41 @@ bool GuiTabular::checkWidgets(bool readonly) const
{
tabularRowED->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);
tabularWidthUnitLC->setEnabled(!readonly);
specialAlignmentED->setReadOnly(readonly);
columnWidthED->setReadOnly(readonly);
columnWidthUnitLC->setEnabled(!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);
vAlignCO->setEnabled(!readonly);
TableAlignCO->setEnabled(!readonly);
longtableGB->setEnabled(!readonly);
alignmentGB->setEnabled(!readonly);
if (readonly) {
multicolumnCB->setEnabled(false);
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();
}

View File

@ -47,6 +47,8 @@ private:
bool checkWidgets(bool readonly) const;
//@}
///
void enableWidgets() 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
{
valueLE->setReadOnly(readonly);
spacingCO->setEnabled(!readonly);
unitCO->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();
}