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(-)
New commits:
commit 04ae8bda4a219d1b6b3628813d76b5d8c984ced9
Author: Caolán McNamara
AuthorDate: Mon Apr 24 12:52:22 2023 +0100
Commit: Caolán McNamara
CommitDate: Tue Apr 25 10:28:31 2023 +0200
Resolves: tdf#153441 use a TriStateEnabled helper
Change-Id: I976e4271a072bfb53c676091509e1d4ef7dbcccb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150916
Reviewed-by: خالد حسني
Reviewed-by: Xisco Fauli
Tested-by: Caolán McNamara
Reviewed-by: Caolán McNamara
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_p