]> git.lyx.org Git - features.git/commitdiff
GuiCharacter: Add "Reset" and "Restore Defaults" buttons
authorJuergen Spitzmueller <spitz@lyx.org>
Tue, 18 Dec 2018 07:32:48 +0000 (08:32 +0100)
committerJuergen Spitzmueller <spitz@lyx.org>
Tue, 18 Dec 2018 07:32:48 +0000 (08:32 +0100)
Addresses #11415

src/frontends/qt4/GuiCharacter.cpp
src/frontends/qt4/GuiCharacter.h
src/frontends/qt4/ui/CharacterUi.ui
status.23x

index 9a865ceb59272c94e714d725f6b10642a6d35c46..4f644a1d52a3986eb7ad78a57560edb264d0505b 100644 (file)
@@ -213,6 +213,7 @@ GuiCharacter::GuiCharacter(GuiView & lv)
        connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
        connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply()));
        connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
+       connect(resetPB, SIGNAL(clicked()), this, SLOT(slotRestore()));
        connect(autoapplyCB, SIGNAL(stateChanged(int)), this,
                SLOT(slotAutoApply()));
 
@@ -252,6 +253,7 @@ GuiCharacter::GuiCharacter(GuiView & lv)
        bc().setApply(applyPB);
        bc().setCancel(closePB);
        bc().setAutoApply(autoapplyCB);
+       bc().setRestore(resetPB);
        bc().addReadOnly(familyCO);
        bc().addReadOnly(seriesCO);
        bc().addReadOnly(sizeCO);
@@ -295,18 +297,12 @@ void GuiCharacter::on_nounCB_clicked()
 }
 
 
-void GuiCharacter::change_adaptor()
+void GuiCharacter::on_restorePB_clicked()
 {
-       changed();
-
-       if (!autoapplyCB->isChecked())
-               return;
-
-       // to be really good here, we should set the combos to the values of
-       // the current text, and make it appear as "no change" if the values
-       // stay the same between applys. Might be difficult though wrt to a
-       // moved cursor - jbl
-       slotApply();
+       Font font(inherit_font);
+       font.setLanguage(reset_language);
+       paramsToDialog(font);
+       change_adaptor();
 }
 
 
@@ -391,6 +387,40 @@ lyx::FontState setMarkupState(Qt::CheckState cs)
 } // end namespace anon
 
 
+void GuiCharacter::change_adaptor()
+{
+       changed();
+
+       checkRestoreDefaults();
+
+       if (!autoapplyCB->isChecked())
+               return;
+
+       // to be really good here, we should set the combos to the values of
+       // the current text, and make it appear as "no change" if the values
+       // stay the same between applys. Might be difficult though wrt to a
+       // moved cursor - jbl
+       slotApply();
+}
+
+
+void GuiCharacter::checkRestoreDefaults()
+{
+       // (De)Activate Restore Defaults button
+       restorePB->setEnabled(
+               family[familyCO->currentIndex()].second != INHERIT_FAMILY
+               || series[seriesCO->currentIndex()].second != INHERIT_SERIES
+               || shape[shapeCO->currentIndex()].second != INHERIT_SHAPE
+               || size[sizeCO->currentIndex()].second != FONT_SIZE_INHERIT
+               || setMarkupState(emphCB->checkState()) != FONT_OFF
+               || setMarkupState(nounCB->checkState()) != FONT_OFF
+               || bar[ulineCO->currentIndex()].second != INHERIT
+               || strike[strikeCO->currentIndex()].second != INHERIT
+               || lcolor.getFromLyXName(fromqstr(colorCO->itemData(colorCO->currentIndex()).toString())) != Color_inherit
+               || languages.getLanguage(fromqstr(language[langCO->currentIndex()].second)) != reset_language);
+}
+
+
 void GuiCharacter::updateContents()
 {
        if (bufferview()->cursor().selection()) {
@@ -443,6 +473,8 @@ void GuiCharacter::updateContents()
                font_.setLanguage(reset_language);
 
        paramsToDialog(font_);
+
+       checkRestoreDefaults();
 }
 
 
index e9148e7aa0b2d5dbe8712da6ab96be5dd3fdbfdc..d460cb0adc86be6e9ac32e40a60b677037a2b6e1 100644 (file)
@@ -65,6 +65,8 @@ protected Q_SLOTS:
        void change_adaptor();
        void on_emphCB_clicked();
        void on_nounCB_clicked();
+       void on_restorePB_clicked();
+       void checkRestoreDefaults();
 
 private:
        /// \name Dialog inherited methods
index 80db75151b2fd1530c4d13c6c66d7b067979f3d3..fdcdc60ee3104f4f62bf6eb6d77997e9a7fc9c66 100644 (file)
@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>523</width>
-    <height>365</height>
+    <width>552</width>
+    <height>401</height>
    </rect>
   </property>
   <property name="windowTitle">
     </spacer>
    </item>
    <item row="3" column="0">
+    <layout class="QHBoxLayout" name="horizontalLayout_3">
+     <item>
+      <spacer name="horizontalSpacer">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>40</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+     <item>
+      <widget class="QCheckBox" name="autoapplyCB">
+       <property name="toolTip">
+        <string>Apply each change automatically</string>
+       </property>
+       <property name="text">
+        <string>Apply changes &amp;immediately</string>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+   <item row="4" column="0">
     <layout class="QHBoxLayout">
      <property name="spacing">
       <number>6</number>
       <number>0</number>
      </property>
      <item>
-      <widget class="QCheckBox" name="autoapplyCB">
-       <property name="toolTip">
-        <string>Apply each change automatically</string>
+      <widget class="QPushButton" name="resetPB">
+       <property name="text">
+        <string>Reset</string>
        </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QPushButton" name="restorePB">
        <property name="text">
-        <string>Apply changes &amp;immediately</string>
+        <string>Restore Defaults</string>
        </property>
       </widget>
      </item>
index a83d30b446c30506d84b585be4bed1bba6edadeb..9295df222b854ae01948396fd22bba1730683f7c 100644 (file)
@@ -33,6 +33,9 @@ What's new
 
 - Make tab movement visible (bug 10733).
 
+- Add "Reset" and "Restore Defaults" buttons to Text Properties
+  dialog (bug 11415).
+
 
 * DOCUMENTATION AND LOCALIZATION