Add option to reset to default booktabs lines

Addresses: #10106
This commit is contained in:
Juergen Spitzmueller 2019-04-01 07:08:13 +02:00
parent 819c9c1645
commit 3bbcfda3db
11 changed files with 80 additions and 12 deletions

View File

@ -680,6 +680,7 @@ dist_images_DATA1X = \
images/tabular-feature_move-row-up.svgz \
images/tabular-feature_multicolumn.svgz \
images/tabular-feature_multirow.svgz \
images/tabular-feature_reset-formal-default.svgz \
images/tabular-feature_set-all-lines.svgz \
images/tabular-feature_set-longtabular.svgz \
images/tabular-feature_set-rotate-cell.svgz \
@ -1962,6 +1963,7 @@ dist_imagesoxygen_DATA1X = \
images/oxygen/tabular-feature_move-row-up.svgz \
images/oxygen/tabular-feature_multicolumn.svgz \
images/oxygen/tabular-feature_multirow.svgz \
images/oxygen/tabular-feature_reset-formal-default.svgz \
images/oxygen/tabular-feature_set-all-lines.svgz \
images/oxygen/tabular-feature_set-border-lines.svgz \
images/oxygen/tabular-feature_set-inner-lines.svgz \
@ -2160,6 +2162,7 @@ dist_imagesclassic_DATA = \
images/classic/tabular-feature_m-valign-top.png \
images/classic/tabular-feature_multicolumn.png \
images/classic/tabular-feature_multirow.png \
images/classic/tabular-feature_reset-formal-default.png \
images/classic/tabular-feature_set-all-lines.png \
images/classic/tabular-feature_set-border-lines.png \
images/classic/tabular-feature_set-inner-lines.png \

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

View File

@ -435,6 +435,7 @@ Menuset
Item "Bottom|B" "tabular-feature toggle-line-bottom"
Item "Left|L" "tabular-feature toggle-line-left"
Item "Right|R" "tabular-feature toggle-line-right"
OptItem "Reset Formal Defaults|F" "tabular-feature reset-formal-default"
End
Menu "table-alignment"

View File

@ -161,6 +161,7 @@ ToolbarSet
Item "Set all lines" "tabular-feature set-all-lines"
Item "Set inner lines" "tabular-feature set-inner-lines"
Item "Unset all lines" "tabular-feature unset-all-lines"
Item "Reset formal default lines" "tabular-feature reset-formal-default"
Separator
Item "Align left" "command-alternatives tabular-feature m-align-left;tabular-feature align-left"
Item "Align center" "command-alternatives tabular-feature m-align-center;tabular-feature align-center"

View File

@ -3757,7 +3757,8 @@ void LyXAction::init()
valign-top|valign-bottom|valign-middle|longtabular-align-left|\n
longtabular-align-center|longtabular-align-right|m-align-left|m-align-right|\n
m-align-center|m-valign-top|m-valign-bottom|m-valign-middle|multicolumn|\n
set-all-lines|unset-all-lines|toggle-longtabular|set-longtabular|unset-longtabular|set-pwidth|\n
reset-formal-default|set-all-lines|unset-all-lines|toggle-longtabular|\n
set-longtabular|unset-longtabular|set-pwidth|\n
set-mpwidth|set-rotate-tabular|unset-rotate-tabular|toggle-rotate-tabular|\n
set-rotate-cell|unset-rotate-cell|toggle-rotate-cell|set-usebox|set-lthead|\n
unset-lthead|set-ltfirsthead|unset-ltfirsthead|set-ltfoot|unset-ltfoot|\n

View File

@ -86,6 +86,8 @@ GuiTabular::GuiTabular(QWidget * parent)
this, SLOT(borderSet_clicked()));
connect(borderUnsetPB, SIGNAL(clicked()),
this, SLOT(borderUnset_clicked()));
connect(resetFormalCB, SIGNAL(clicked()),
this, SLOT(checkEnabled()));
connect(hAlignCO, SIGNAL(activated(int)),
this, SLOT(checkEnabled()));
connect(vAlignCO, SIGNAL(activated(int)),
@ -234,6 +236,7 @@ void GuiTabular::enableWidgets() const
hAlignCO->itemData(hAlignCO->currentIndex()).toString() == QString("decimal");
decimalPointED->setEnabled(dalign);
decimalLA->setEnabled(dalign);
resetFormalCB->setEnabled(booktabsRB->isChecked());
bool const setwidth = TableAlignCO->currentText() == qt_("Middle");
tabularWidthLA->setEnabled(setwidth);
@ -558,7 +561,9 @@ docstring GuiTabular::dialogToParams() const
}
//
if (borders->topLineSet() && borders->bottomLineSet() && borders->leftLineSet()
if (resetFormalCB->isChecked())
setParam(param_str, Tabular::RESET_FORMAL_DEFAULT);
else if (borders->topLineSet() && borders->bottomLineSet() && borders->leftLineSet()
&& borders->rightLineSet())
setParam(param_str, Tabular::SET_ALL_LINES);
else if (borders->topLineUnset() && borders->bottomLineUnset() && borders->leftLineUnset()

View File

@ -739,6 +739,15 @@
</color>
</brush>
</colorrole>
<colorrole role="PlaceholderText">
<brush brushstyle="NoBrush">
<color alpha="128">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
@ -894,6 +903,15 @@
</color>
</brush>
</colorrole>
<colorrole role="PlaceholderText">
<brush brushstyle="NoBrush">
<color alpha="128">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
@ -1049,6 +1067,15 @@
</color>
</brush>
</colorrole>
<colorrole role="PlaceholderText">
<brush brushstyle="NoBrush">
<color alpha="128">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
@ -1119,6 +1146,26 @@
<bool>true</bool>
</property>
<layout class="QGridLayout">
<item row="0" column="0">
<widget class="QRadioButton" name="borderDefaultRB">
<property name="toolTip">
<string>Use default (grid-like) border style</string>
</property>
<property name="text">
<string>De&amp;fault</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="resetFormalCB">
<property name="toolTip">
<string>If this is checked, the table will be reset to the formal default style (only top and bottom row have vertical lines)</string>
</property>
<property name="text">
<string>Use Default &amp;Formal Style</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QRadioButton" name="booktabsRB">
<property name="toolTip">
@ -1132,16 +1179,6 @@
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QRadioButton" name="borderDefaultRB">
<property name="toolTip">
<string>Use default (grid-like) border style</string>
</property>
<property name="text">
<string>De&amp;fault</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>

View File

@ -155,6 +155,7 @@ TabularFeature tabularFeature[] =
{ Tabular::UNSET_MULTIROW, "unset-multirow", false },
{ Tabular::SET_MROFFSET, "set-mroffset", true },
{ Tabular::SET_ALL_LINES, "set-all-lines", false },
{ Tabular::RESET_FORMAL_DEFAULT, "reset-formal-default", false },
{ Tabular::UNSET_ALL_LINES, "unset-all-lines", false },
{ Tabular::TOGGLE_LONGTABULAR, "toggle-longtabular", false },
{ Tabular::SET_LONGTABULAR, "set-longtabular", false },
@ -4983,6 +4984,10 @@ bool InsetTabular::getFeatureStatus(Cursor & cur, string const & s,
status.setEnabled(!tabular.ltCaption(tabular.cellRow(cur.idx())));
break;
case Tabular::RESET_FORMAL_DEFAULT:
status.setEnabled(tabular.use_booktabs);
break;
case Tabular::SET_LINE_TOP:
case Tabular::SET_LINE_BOTTOM:
status.setEnabled(!tabular.ltCaption(tabular.cellRow(cur.idx())));
@ -6165,6 +6170,19 @@ void InsetTabular::tabularFeatures(Cursor & cur,
}
break;
case Tabular::RESET_FORMAL_DEFAULT:
for (row_type r = 0; r < tabular.nrows(); ++r) {
bool const head_or_foot = r == 0 || r == tabular.nrows() - 1;
for (col_type c = 0; c < tabular.ncols(); ++c) {
idx_type const cell = tabular.cellIndex(r, c);
tabular.setTopLine(cell, head_or_foot);
tabular.setBottomLine(cell, head_or_foot);
tabular.setRightLine(cell, false);
tabular.setLeftLine(cell, false);
}
}
break;
case Tabular::SET_BORDER_LINES:
for (row_type r = sel_row_start; r <= sel_row_end; ++r) {
tabular.setLeftLine(tabular.cellIndex(r, sel_col_start), true);

View File

@ -223,6 +223,8 @@ public:
///
SET_ALL_LINES,
///
RESET_FORMAL_DEFAULT,
///
UNSET_ALL_LINES,
///
TOGGLE_LONGTABULAR,