From 1dc6154708cdc43d66affe4ba79f7a812db9e987 Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Tue, 18 Dec 2018 08:32:48 +0100 Subject: [PATCH] GuiCharacter: Add "Reset" and "Restore Defaults" buttons Addresses #11415 --- src/frontends/qt4/GuiCharacter.cpp | 54 +++++++++++++++++++++++------ src/frontends/qt4/GuiCharacter.h | 2 ++ src/frontends/qt4/ui/CharacterUi.ui | 43 +++++++++++++++++++---- status.23x | 3 ++ 4 files changed, 85 insertions(+), 17 deletions(-) diff --git a/src/frontends/qt4/GuiCharacter.cpp b/src/frontends/qt4/GuiCharacter.cpp index 9a865ceb59..4f644a1d52 100644 --- a/src/frontends/qt4/GuiCharacter.cpp +++ b/src/frontends/qt4/GuiCharacter.cpp @@ -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(); } diff --git a/src/frontends/qt4/GuiCharacter.h b/src/frontends/qt4/GuiCharacter.h index e9148e7aa0..d460cb0adc 100644 --- a/src/frontends/qt4/GuiCharacter.h +++ b/src/frontends/qt4/GuiCharacter.h @@ -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 diff --git a/src/frontends/qt4/ui/CharacterUi.ui b/src/frontends/qt4/ui/CharacterUi.ui index 80db75151b..fdcdc60ee3 100644 --- a/src/frontends/qt4/ui/CharacterUi.ui +++ b/src/frontends/qt4/ui/CharacterUi.ui @@ -6,8 +6,8 @@ 0 0 - 523 - 365 + 552 + 401 @@ -314,6 +314,33 @@ + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Apply each change automatically + + + Apply changes &immediately + + + + + + 6 @@ -331,12 +358,16 @@ 0 - - - Apply each change automatically + + + Reset + + + + - Apply changes &immediately + Restore Defaults diff --git a/status.23x b/status.23x index a83d30b446..9295df222b 100644 --- a/status.23x +++ b/status.23x @@ -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 -- 2.39.5