From 3574ac13706242a24733b334d62bf49aa3d0dca2 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 24 Apr 2023 12:52:22 +0100 Subject: Resolves: tdf#153441 use a TriStateEnabled helper MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I976e4271a072bfb53c676091509e1d4ef7dbcccb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150915 Tested-by: Jenkins Reviewed-by: خالد حسني --- cui/source/dialogs/FontFeaturesDialog.cxx | 30 ++++++++++++++++++++++++------ cui/source/inc/FontFeaturesDialog.hxx | 8 +++++++- cui/uiconfig/ui/fontfragment.ui | 1 + 3 files changed, 32 insertions(+), 7 deletions(-) (limited to 'cui') diff --git a/cui/source/dialogs/FontFeaturesDialog.cxx b/cui/source/dialogs/FontFeaturesDialog.cxx index ab6063c9b6c3..b394495b3ae3 100644 --- a/cui/source/dialogs/FontFeaturesDialog.cxx +++ b/cui/source/dialogs/FontFeaturesDialog.cxx @@ -109,19 +109,21 @@ int FontFeaturesDialog::fillGrid(std::vector const& rFontFea { nIdx = nStylisticSets++; m_xStylisticSetsBox->set_visible(true); - m_aFeatureItems.emplace_back(m_xStylisticSetsGrid.get()); + m_aFeatureItems.emplace_back( + std::make_unique(m_xStylisticSetsGrid.get())); } else if (rFontFeature.isCharacterVariant()) { nIdx = nCharacterVariants++; m_xCharacterVariantsBox->set_visible(true); - m_aFeatureItems.emplace_back(m_xCharacterVariantsGrid.get()); + m_aFeatureItems.emplace_back( + std::make_unique(m_xCharacterVariantsGrid.get())); } else { nIdx = nOtherFeatures++; m_xContentBox->set_visible(true); - m_aFeatureItems.emplace_back(m_xContentGrid.get()); + m_aFeatureItems.emplace_back(std::make_unique(m_xContentGrid.get())); } int32_t nValue = 0; @@ -130,7 +132,7 @@ int FontFeaturesDialog::fillGrid(std::vector const& rFontFea else nValue = aDefinition.getDefault(); - FontFeatureItem& aCurrentItem = m_aFeatureItems.back(); + FontFeatureItem& aCurrentItem = *m_aFeatureItems.back(); aCurrentItem.m_aFeatureCode = nFontFeatureCode; aCurrentItem.m_nDefault = aDefinition.getDefault(); @@ -158,11 +160,19 @@ int FontFeaturesDialog::fillGrid(std::vector const& rFontFea else { if (nValue < 0) + { aCurrentItem.m_xCheck->set_state(TRISTATE_INDET); + aCurrentItem.m_aTriStateEnabled.bTriStateEnabled = true; + aCurrentItem.m_aTriStateEnabled.eState = TRISTATE_INDET; + } else + { aCurrentItem.m_xCheck->set_state(nValue > 0 ? TRISTATE_TRUE : TRISTATE_FALSE); + aCurrentItem.m_aTriStateEnabled.bTriStateEnabled = false; + aCurrentItem.m_aTriStateEnabled.eState = aCurrentItem.m_xCheck->get_state(); + } aCurrentItem.m_xCheck->set_label(aDefinition.getDescription()); - aCurrentItem.m_xCheck->connect_toggled(aCheckBoxToggleHandler); + aCurrentItem.m_aToggleHdl = aCheckBoxToggleHandler; aCurrentItem.m_xCheck->show(); } @@ -188,6 +198,13 @@ void FontFeaturesDialog::updateFontPreview() m_aPreviewWindow.SetFont(rPreviewFont, rPreviewFontCJK, rPreviewFontCTL); } +IMPL_LINK(FontFeatureItem, CheckBoxToggledHdl, weld::Toggleable&, rToggle, void) +{ + m_aTriStateEnabled.ButtonToggled(rToggle); + m_aTriStateEnabled.bTriStateEnabled = false; + m_aToggleHdl.Call(rToggle); +} + IMPL_LINK_NOARG(FontFeaturesDialog, CheckBoxToggledHdl, weld::Toggleable&, void) { updateFontPreview(); @@ -204,8 +221,9 @@ OUString FontFeaturesDialog::createFontNameWithFeatures() OUStringBuffer sNameSuffix; bool bFirst = true; - for (const FontFeatureItem& rItem : m_aFeatureItems) + for (const auto& rEntry : m_aFeatureItems) { + const FontFeatureItem& rItem(*rEntry); if (rItem.m_xCheck->get_visible()) { if (rItem.m_xCheck->get_state() != TRISTATE_INDET) diff --git a/cui/source/inc/FontFeaturesDialog.hxx b/cui/source/inc/FontFeaturesDialog.hxx index c4eb43b79e98..93ba0cb9f80d 100644 --- a/cui/source/inc/FontFeaturesDialog.hxx +++ b/cui/source/inc/FontFeaturesDialog.hxx @@ -29,21 +29,27 @@ struct FontFeatureItem , m_xCombo(m_xBuilder->weld_combo_box("combo")) , m_xCheck(m_xBuilder->weld_check_button("check")) { + m_xCheck->connect_toggled(LINK(this, FontFeatureItem, CheckBoxToggledHdl)); } sal_uInt32 m_aFeatureCode; sal_Int32 m_nDefault; + weld::TriStateEnabled m_aTriStateEnabled; + Link m_aToggleHdl; std::unique_ptr m_xBuilder; std::unique_ptr m_xContainer; std::unique_ptr m_xText; std::unique_ptr m_xCombo; std::unique_ptr m_xCheck; + +private: + DECL_LINK(CheckBoxToggledHdl, weld::Toggleable&, void); }; class FontFeaturesDialog : public weld::GenericDialogController { private: - std::vector m_aFeatureItems; + std::vector> m_aFeatureItems; OUString m_sFontName; OUString m_sResultFontName; diff --git a/cui/uiconfig/ui/fontfragment.ui b/cui/uiconfig/ui/fontfragment.ui index e66cd71b7ba6..dca735e5fe1e 100644 --- a/cui/uiconfig/ui/fontfragment.ui +++ b/cui/uiconfig/ui/fontfragment.ui @@ -30,6 +30,7 @@ True False True + True True -- cgit