commit 4480b72a9dc8a5453a17edf55d4d4a60847a68ae
Author: Juergen Spitzmueller <[email protected]>
Date:   Fri Dec 21 12:31:25 2018 +0100

    GuiCharacter: Add menu to Restore button
    
    and allow for resetting all widgets to "No Change" besides "Default"
    
    (cherry picked from commit ac8aac5b36e5895746aa145b20305cb909271e17)
---
 src/frontends/qt4/GuiCharacter.cpp |   47 +++++++++++++++++++++++++++++++++--
 src/frontends/qt4/GuiCharacter.h   |   10 +++++++-
 status.23x                         |    2 +-
 3 files changed, 54 insertions(+), 5 deletions(-)

diff --git a/src/frontends/qt4/GuiCharacter.cpp 
b/src/frontends/qt4/GuiCharacter.cpp
index 4f644a1..71eb61f 100644
--- a/src/frontends/qt4/GuiCharacter.cpp
+++ b/src/frontends/qt4/GuiCharacter.cpp
@@ -35,6 +35,7 @@
 
 #include <QAbstractItemModel>
 #include <QComboBox>
+#include <QMenu>
 #include <QModelIndex>
 #include <QSettings>
 #include <QVariant>
@@ -266,6 +267,18 @@ GuiCharacter::GuiCharacter(GuiView & lv)
        bc().addReadOnly(colorCO);
        bc().addReadOnly(autoapplyCB);
 
+       // Add button menu to restore button to reset
+       // all widgets to "Defaults" or "No Change"
+       resetdefault_ = new QAction(qt_("Reset All To &Default"), this);
+       resetnochange_ = new QAction(qt_("Reset All To No Chan&ge"), this);
+       QMenu * resetmenu = new QMenu();
+       resetmenu->addAction(resetdefault_);
+       resetmenu->addAction(resetnochange_);
+       restorePB->setMenu(resetmenu);
+       restorePB->setText(qt_("&Reset All Fields"));
+       connect(resetdefault_, SIGNAL(triggered()), this, 
SLOT(resetToDefault()));
+       connect(resetnochange_, SIGNAL(triggered()), this, 
SLOT(resetToNoChange()));
+
 #ifdef Q_OS_MAC
        // On Mac it's common to have tool windows which are always in the
        // foreground and are hidden when the main window is not focused.
@@ -297,7 +310,7 @@ void GuiCharacter::on_nounCB_clicked()
 }
 
 
-void GuiCharacter::on_restorePB_clicked()
+void GuiCharacter::resetToDefault()
 {
        Font font(inherit_font);
        font.setLanguage(reset_language);
@@ -306,6 +319,15 @@ void GuiCharacter::on_restorePB_clicked()
 }
 
 
+void GuiCharacter::resetToNoChange()
+{
+       Font font(ignore_font);
+       font.setLanguage(ignore_language);
+       paramsToDialog(font);
+       change_adaptor();
+}
+
+
 template<class P, class B>
 static int findPos2nd(QList<P> const & vec, B const & val)
 {
@@ -406,8 +428,15 @@ void GuiCharacter::change_adaptor()
 
 void GuiCharacter::checkRestoreDefaults()
 {
-       // (De)Activate Restore Defaults button
-       restorePB->setEnabled(
+       if (familyCO->currentIndex() == -1 || seriesCO->currentIndex() == -1
+           || shapeCO->currentIndex() == -1 || sizeCO->currentIndex() == -1
+           || ulineCO->currentIndex() == -1 || strikeCO->currentIndex() == -1
+           || colorCO->currentIndex() == -1 || langCO->currentIndex() == -1)
+               // dialog not yet built
+               return;
+
+       // (De)Activate Restore Defaults menu items
+       resetdefault_->setEnabled(
                family[familyCO->currentIndex()].second != INHERIT_FAMILY
                || series[seriesCO->currentIndex()].second != INHERIT_SERIES
                || shape[shapeCO->currentIndex()].second != INHERIT_SHAPE
@@ -418,6 +447,18 @@ void GuiCharacter::checkRestoreDefaults()
                || strike[strikeCO->currentIndex()].second != INHERIT
                || 
lcolor.getFromLyXName(fromqstr(colorCO->itemData(colorCO->currentIndex()).toString()))
 != Color_inherit
                || 
languages.getLanguage(fromqstr(language[langCO->currentIndex()].second)) != 
reset_language);
+
+       resetnochange_->setEnabled(
+               family[familyCO->currentIndex()].second != IGNORE_FAMILY
+               || series[seriesCO->currentIndex()].second != IGNORE_SERIES
+               || shape[shapeCO->currentIndex()].second != IGNORE_SHAPE
+               || size[sizeCO->currentIndex()].second != FONT_SIZE_IGNORE
+               || setMarkupState(emphCB->checkState()) != FONT_IGNORE
+               || setMarkupState(nounCB->checkState()) != FONT_IGNORE
+               || bar[ulineCO->currentIndex()].second != IGNORE
+               || strike[strikeCO->currentIndex()].second != IGNORE
+               || 
lcolor.getFromLyXName(fromqstr(colorCO->itemData(colorCO->currentIndex()).toString()))
 != Color_ignore
+               || 
languages.getLanguage(fromqstr(language[langCO->currentIndex()].second)) != 
ignore_language);
 }
 
 
diff --git a/src/frontends/qt4/GuiCharacter.h b/src/frontends/qt4/GuiCharacter.h
index d460cb0..6cfecbe 100644
--- a/src/frontends/qt4/GuiCharacter.h
+++ b/src/frontends/qt4/GuiCharacter.h
@@ -18,6 +18,8 @@
 #include "ui_CharacterUi.h"
 #include "Font.h"
 
+#include <QAction>
+
 #include <utility>
 
 #ifdef IGNORE
@@ -65,7 +67,8 @@ protected Q_SLOTS:
        void change_adaptor();
        void on_emphCB_clicked();
        void on_nounCB_clicked();
-       void on_restorePB_clicked();
+       void resetToDefault();
+       void resetToNoChange();
        void checkRestoreDefaults();
 
 private:
@@ -104,6 +107,11 @@ private:
        bool emph_;
        ///
        bool noun_;
+
+       ///
+       QAction * resetdefault_ = new QAction(this);
+       ///
+       QAction * resetnochange_ = new QAction(this);
 };
 
 } // namespace frontend
diff --git a/status.23x b/status.23x
index 386df1a..46ba3a6 100644
--- a/status.23x
+++ b/status.23x
@@ -34,7 +34,7 @@ What's new
 
 - Make tab movement visible (bug 10733).
 
-- Add "Reset" and "Restore Defaults" buttons to Text Properties
+- Add "Reset" and "Reset All Fields" buttons to Text Properties
   dialog (bug 11415).
 
 - Insert new graphics inset on the correct cursor position.

Reply via email to