]> git.lyx.org Git - lyx.git/commitdiff
Add option to reset to default booktabs lines
authorJuergen Spitzmueller <spitz@lyx.org>
Mon, 1 Apr 2019 05:08:13 +0000 (07:08 +0200)
committerJuergen Spitzmueller <spitz@lyx.org>
Mon, 1 Apr 2019 05:08:13 +0000 (07:08 +0200)
Addresses: #10106

lib/Makefile.am
lib/images/classic/tabular-feature_reset-formal-default.png [new file with mode: 0644]
lib/images/oxygen/tabular-feature_reset-formal-default.svgz [new file with mode: 0644]
lib/images/tabular-feature_reset-formal-default.svgz [new file with mode: 0644]
lib/ui/stdcontext.inc
lib/ui/stdtoolbars.inc
src/LyXAction.cpp
src/frontends/qt4/GuiTabular.cpp
src/frontends/qt4/ui/TabularUi.ui
src/insets/InsetTabular.cpp
src/insets/InsetTabular.h

index fd3ad852ecd49fa24e4cf3d3ca73d0f5834d2bd3..1df01b2f9c7ac6d1fba1f8b393af5451e39fe4d1 100644 (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  \
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 (file)
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 (file)
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 (file)
index 0000000..dadd0d1
Binary files /dev/null and b/lib/images/tabular-feature_reset-formal-default.svgz differ
index e358ce910aa2e932273280d75982f9b9d478efe0..6f86dd124c51d32e375f421863cfe0f0946889f3 100644 (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"
index f48f27b73fc4a26b8c553a1cb286a17daa385924..10bb531b5db3643022fb75ca9fcaed2a295820f5 100644 (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"
index 1374ab5ff08ef1ae3c5842883503fdba4ea95ba8..59bdbe8d1c50b7b9bcf7b3c60092dac06a462900 100644 (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
index 8168b56a5131ca5ecf14c20f7a3428388a7c4613..dd25e9dad550fe15cd9a0a807eae38d38b27c6c7 100644 (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()
index 5ced77a086ddf499a946714d9146e42fec5de89a..4b266804992ee326f0bf33f9647df9cc8664a6bb 100644 (file)
                  </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">
                  </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">
                  </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>
           <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&amp;rmal</string>
+             <string>De&amp;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 &amp;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&amp;fault</string>
+             <string>Fo&amp;rmal</string>
+            </property>
+            <property name="checked">
+             <bool>true</bool>
             </property>
            </widget>
           </item>
index 44f251a72867df4bc6eed6325256a2b14cc4368b..2bb49f87816c700edb841370761b4594498697ed 100644 (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);
index 92ccdb6bc2a6475b57db667f904c6f80ba17fb16..9bc1746195f49f34a9aa0d1adec3d440c30ed3c1 100644 (file)
@@ -223,6 +223,8 @@ public:
                ///
                SET_ALL_LINES,
                ///
+               RESET_FORMAL_DEFAULT,
+               ///
                UNSET_ALL_LINES,
                ///
                TOGGLE_LONGTABULAR,