commit 3bbcfda3dbf0bd9e2f79a04b26d8913481f30dfb
Author: Juergen Spitzmueller <[email protected]>
Date: Mon Apr 1 07:08:13 2019 +0200
Add option to reset to default booktabs lines
Addresses: #10106
---
lib/Makefile.am | 3 +
.../tabular-feature_reset-formal-default.png | Bin 0 -> 6672 bytes
.../tabular-feature_reset-formal-default.svgz | Bin 0 -> 1263 bytes
.../tabular-feature_reset-formal-default.svgz | Bin 0 -> 1256 bytes
lib/ui/stdcontext.inc | 1 +
lib/ui/stdtoolbars.inc | 1 +
src/LyXAction.cpp | 3 +-
src/frontends/qt4/GuiTabular.cpp | 7 ++-
src/frontends/qt4/ui/TabularUi.ui | 57 ++++++++++++++++----
src/insets/InsetTabular.cpp | 18 ++++++
src/insets/InsetTabular.h | 2 +
11 files changed, 80 insertions(+), 12 deletions(-)
diff --git a/lib/Makefile.am b/lib/Makefile.am
index fd3ad85..1df01b2 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -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 \
diff --git a/lib/images/classic/tabular-feature_reset-formal-default.png
b/lib/images/classic/tabular-feature_reset-formal-default.png
new file mode 100644
index 0000000..382d562
Binary files /dev/null and
b/lib/images/classic/tabular-feature_reset-formal-default.png differ
diff --git a/lib/images/oxygen/tabular-feature_reset-formal-default.svgz
b/lib/images/oxygen/tabular-feature_reset-formal-default.svgz
new file mode 100644
index 0000000..04b410b
Binary files /dev/null and
b/lib/images/oxygen/tabular-feature_reset-formal-default.svgz differ
diff --git a/lib/images/tabular-feature_reset-formal-default.svgz
b/lib/images/tabular-feature_reset-formal-default.svgz
new file mode 100644
index 0000000..dadd0d1
Binary files /dev/null and
b/lib/images/tabular-feature_reset-formal-default.svgz differ
diff --git a/lib/ui/stdcontext.inc b/lib/ui/stdcontext.inc
index e358ce9..6f86dd1 100644
--- a/lib/ui/stdcontext.inc
+++ b/lib/ui/stdcontext.inc
@@ -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"
diff --git a/lib/ui/stdtoolbars.inc b/lib/ui/stdtoolbars.inc
index f48f27b..10bb531 100644
--- a/lib/ui/stdtoolbars.inc
+++ b/lib/ui/stdtoolbars.inc
@@ -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"
diff --git a/src/LyXAction.cpp b/src/LyXAction.cpp
index 1374ab5..59bdbe8 100644
--- a/src/LyXAction.cpp
+++ b/src/LyXAction.cpp
@@ -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
diff --git a/src/frontends/qt4/GuiTabular.cpp b/src/frontends/qt4/GuiTabular.cpp
index 8168b56..dd25e9d 100644
--- a/src/frontends/qt4/GuiTabular.cpp
+++ b/src/frontends/qt4/GuiTabular.cpp
@@ -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()
diff --git a/src/frontends/qt4/ui/TabularUi.ui
b/src/frontends/qt4/ui/TabularUi.ui
index 5ced77a..4b26680 100644
--- a/src/frontends/qt4/ui/TabularUi.ui
+++ b/src/frontends/qt4/ui/TabularUi.ui
@@ -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,26 +1146,36 @@
<bool>true</bool>
</property>
<layout class="QGridLayout">
- <item row="1" column="0">
- <widget class="QRadioButton" name="booktabsRB">
+ <item row="0" column="0">
+ <widget class="QRadioButton" name="borderDefaultRB">
<property name="toolTip">
- <string>Use formal (a.k.a. booktabs) border style (no vertical
borders)</string>
+ <string>Use default (grid-like) border style</string>
</property>
<property name="text">
- <string>Fo&rmal</string>
+ <string>De&fault</string>
</property>
- <property name="checked">
- <bool>true</bool>
+ </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 &Formal Style</string>
</property>
</widget>
</item>
- <item row="0" column="0">
- <widget class="QRadioButton" name="borderDefaultRB">
+ <item row="1" column="0">
+ <widget class="QRadioButton" name="booktabsRB">
<property name="toolTip">
- <string>Use default (grid-like) border style</string>
+ <string>Use formal (a.k.a. booktabs) border style (no vertical
borders)</string>
</property>
<property name="text">
- <string>De&fault</string>
+ <string>Fo&rmal</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
</property>
</widget>
</item>
diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp
index 44f251a..2bb49f8 100644
--- a/src/insets/InsetTabular.cpp
+++ b/src/insets/InsetTabular.cpp
@@ -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);
diff --git a/src/insets/InsetTabular.h b/src/insets/InsetTabular.h
index 92ccdb6..9bc1746 100644
--- a/src/insets/InsetTabular.h
+++ b/src/insets/InsetTabular.h
@@ -223,6 +223,8 @@ public:
///
SET_ALL_LINES,
///
+ RESET_FORMAL_DEFAULT,
+ ///
UNSET_ALL_LINES,
///
TOGGLE_LONGTABULAR,