cui/source/inc/numpages.hxx | 9 ++- cui/source/tabpages/numpages.cxx | 46 ++++++++++++------- cui/uiconfig/ui/picknumberingpage.ui | 36 ++++++++++---- sw/qa/uitest/writer_tests2/formatBulletsNumbering.py | 19 ++++--- 4 files changed, 72 insertions(+), 38 deletions(-)
New commits: commit 52160e56b63dd5a02b604ec2a667ba1de141d031 Author: Parth Raiyani <parth.raiy...@collabora.com> AuthorDate: Mon Aug 25 20:54:24 2025 +0530 Commit: Szymon Kłos <szymon.k...@collabora.com> CommitDate: Fri Sep 12 17:10:28 2025 +0200 Switch to IconView from ValueSet for pick numbering page - Replaced SvxNumValueSet with weld::IconView in numpages - Updated UI in picknumberingpage.ui to include GtkIconView and GtkTreeStore - added tooltip support - updated relevant test cases Change-Id: Icd23ad3d7e4abc020f0869f4a90e3ecdbd04d945 Signed-off-by: Parth Raiyani <parth.raiy...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189847 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> diff --git a/cui/source/inc/numpages.hxx b/cui/source/inc/numpages.hxx index 43a44ef3f3b6..d80e4bbfe516 100644 --- a/cui/source/inc/numpages.hxx +++ b/cui/source/inc/numpages.hxx @@ -66,11 +66,12 @@ class SvxSingleNumPickTabPage final : public SfxTabPage bool bPreset : 1; TypedWhichId<SvxNumBulletItem> nNumItemId; - std::unique_ptr<SvxNumValueSet> m_xExamplesVS; - std::unique_ptr<weld::CustomWeld> m_xExamplesVSWin; + std::unique_ptr<weld::IconView> m_xExamplesIV; + Size aPreviewSize; - DECL_LINK(NumSelectHdl_Impl, ValueSet*, void); - DECL_LINK(DoubleClickHdl_Impl, ValueSet*, void); + DECL_LINK(NumSelectHdl_Impl, weld::IconView&, void); + DECL_LINK(DoubleClickHdl_Impl, weld::IconView&, bool); + DECL_LINK(QueryTooltipHdl, const weld::TreeIter&, OUString); public: SvxSingleNumPickTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet); diff --git a/cui/source/tabpages/numpages.cxx b/cui/source/tabpages/numpages.cxx index 4c1327121c0d..d8694cd31222 100644 --- a/cui/source/tabpages/numpages.cxx +++ b/cui/source/tabpages/numpages.cxx @@ -154,13 +154,14 @@ SvxSingleNumPickTabPage::SvxSingleNumPickTabPage(weld::Container* pPage, weld::D , bModified(false) , bPreset(false) , nNumItemId(SID_ATTR_NUMBERING_RULE) - , m_xExamplesVS(new SvxNumValueSet(m_xBuilder->weld_scrolled_window(u"valuesetwin"_ustr, true))) - , m_xExamplesVSWin(new weld::CustomWeld(*m_xBuilder, u"valueset"_ustr, *m_xExamplesVS)) + , m_xExamplesIV(m_xBuilder->weld_icon_view(u"pick_numbering_iconview"_ustr)) + , aPreviewSize(150, 200) { SetExchangeSupport(); - m_xExamplesVS->init(NumberingPageType::SINGLENUM); - m_xExamplesVS->SetSelectHdl(LINK(this, SvxSingleNumPickTabPage, NumSelectHdl_Impl)); - m_xExamplesVS->SetDoubleClickHdl(LINK(this, SvxSingleNumPickTabPage, DoubleClickHdl_Impl)); + SvxBmpNumIconView::PopulateIconView(m_xExamplesIV.get(), NumberingPageType::SINGLENUM, aPreviewSize); + m_xExamplesIV->connect_selection_changed(LINK(this, SvxSingleNumPickTabPage, NumSelectHdl_Impl)); + m_xExamplesIV->connect_item_activated(LINK(this, SvxSingleNumPickTabPage, DoubleClickHdl_Impl)); + m_xExamplesIV->connect_query_tooltip(LINK(this, SvxSingleNumPickTabPage, QueryTooltipHdl)); Reference<XDefaultNumberingProvider> xDefNum = SvxNumOptionsTabPageHelper::GetNumberingProvider(); if(!xDefNum.is()) @@ -184,13 +185,12 @@ SvxSingleNumPickTabPage::SvxSingleNumPickTabPage(weld::Container* pPage, weld::D { } Reference<XNumberingFormatter> xFormat(xDefNum, UNO_QUERY); - m_xExamplesVS->SetNumberingSettings(aNumberings, xFormat, rLocale); + SvxBmpNumIconView::SetNumberingSettings(m_xExamplesIV.get(), aPreviewSize, aNumberings, xFormat, rLocale); } SvxSingleNumPickTabPage::~SvxSingleNumPickTabPage() { - m_xExamplesVSWin.reset(); - m_xExamplesVS.reset(); + m_xExamplesIV.reset(); } std::unique_ptr<SfxTabPage> SvxSingleNumPickTabPage::Create(weld::Container* pPage, weld::DialogController* pController, @@ -230,13 +230,13 @@ void SvxSingleNumPickTabPage::ActivatePage(const SfxItemSet& rSet) if(pActNum && *pSaveNum != *pActNum) { *pActNum = *pSaveNum; - m_xExamplesVS->SetNoSelection(); + m_xExamplesIV->unselect_all(); } if(pActNum && (!lcl_IsNumFmtSet(pActNum.get(), nActNumLvl) || bIsPreset)) { - m_xExamplesVS->SelectItem(1); - NumSelectHdl_Impl(m_xExamplesVS.get()); + m_xExamplesIV->select(0); + NumSelectHdl_Impl(*m_xExamplesIV); bPreset = true; } bPreset |= bIsPreset; @@ -277,14 +277,25 @@ void SvxSingleNumPickTabPage::Reset( const SfxItemSet* rSet ) *pActNum = *pSaveNum; } -IMPL_LINK_NOARG(SvxSingleNumPickTabPage, NumSelectHdl_Impl, ValueSet*, void) +IMPL_LINK(SvxSingleNumPickTabPage, QueryTooltipHdl, const weld::TreeIter&, rIter, OUString) +{ + const OUString sId = m_xExamplesIV->get_id(rIter); + if (sId.isEmpty()) + return OUString(); + + sal_Int32 nIndex = sId.toInt32(); + return SvxBmpNumIconView::GetNumberingDescription(NumberingPageType::SINGLENUM, nIndex); +} + +IMPL_LINK_NOARG(SvxSingleNumPickTabPage, NumSelectHdl_Impl, weld::IconView&, void) { if(!pActNum) return; bPreset = false; bModified = true; - sal_uInt16 nIdx = m_xExamplesVS->GetSelectedItemId() - 1; + OUString sId = m_xExamplesIV->get_selected_id(); + sal_uInt16 nIdx = !sId.isEmpty() ? sId.toInt32() : 0; DBG_ASSERT(aNumSettingsArr.size() > nIdx, "wrong index"); if(aNumSettingsArr.size() <= nIdx) return; @@ -310,11 +321,16 @@ IMPL_LINK_NOARG(SvxSingleNumPickTabPage, NumSelectHdl_Impl, ValueSet*, void) } } -IMPL_LINK_NOARG(SvxSingleNumPickTabPage, DoubleClickHdl_Impl, ValueSet*, void) +IMPL_LINK_NOARG(SvxSingleNumPickTabPage, DoubleClickHdl_Impl, weld::IconView&, bool) { - NumSelectHdl_Impl(m_xExamplesVS.get()); + if(m_xExamplesIV->get_selected_id().isEmpty()) + return false; + + NumSelectHdl_Impl(*m_xExamplesIV); weld::Button& rOk = GetDialogController()->GetOKButton(); rOk.clicked(); + + return true; } SvxBulletPickTabPage::SvxBulletPickTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet) diff --git a/cui/uiconfig/ui/picknumberingpage.ui b/cui/uiconfig/ui/picknumberingpage.ui index 0b80d533a1d6..78a08526f978 100644 --- a/cui/uiconfig/ui/picknumberingpage.ui +++ b/cui/uiconfig/ui/picknumberingpage.ui @@ -2,32 +2,46 @@ <!-- Generated with glade 3.40.0 --> <interface domain="cui"> <requires lib="gtk+" version="3.20"/> - <object class="GtkScrolledWindow" id="PickNumberingPage"> + <object class="GtkTreeStore" id="liststore1"> + <columns> + <!-- column-name pixbuf --> + <column type="GdkPixbuf"/> + <!-- column-name id --> + <column type="gchararray"/> + </columns> + </object> + <object class="GtkGrid" id="PickNumberingPage"> <property name="visible">True</property> - <property name="can-focus">True</property> + <property name="can-focus">False</property> <property name="margin-start">6</property> <property name="margin-end">6</property> <property name="margin-top">6</property> <property name="margin-bottom">6</property> <property name="hexpand">True</property> <property name="vexpand">True</property> - <property name="hscrollbar-policy">never</property> - <property name="vscrollbar-policy">never</property> - <property name="shadow-type">in</property> <child> - <object class="GtkViewport"> + <object class="GtkScrolledWindow"> <property name="visible">True</property> - <property name="can-focus">False</property> + <property name="can-focus">True</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="hscrollbar-policy">never</property> + <property name="vscrollbar-policy">never</property> + <property name="shadow-type">in</property> <child> - <object class="GtkDrawingArea" id="valueset"> + <object class="GtkIconView" id="pick_numbering_iconview"> <property name="visible">True</property> <property name="can-focus">True</property> - <property name="events">GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_STRUCTURE_MASK</property> <property name="hexpand">True</property> <property name="vexpand">True</property> + <property name="model">liststore1</property> + <property name="pixbuf-column">0</property> + <property name="columns">4</property> + <property name="item-width">80</property> + <property name="selection-mode">single</property> <child internal-child="accessible"> - <object class="AtkObject" id="valueset-atkobject"> - <property name="AtkObject::accessible-description" translatable="yes" context="picknumberingpage|extended_tip|valueset">Click the numbering scheme that you want to use.</property> + <object class="AtkObject" id="pick_numbering_iconview-atkobject"> + <property name="AtkObject::accessible-description" translatable="yes" context="picknumberingpage|extended_tip|pick_numbering_iconview">Click the numbering scheme that you want to use.</property> </object> </child> </object> diff --git a/sw/qa/uitest/writer_tests2/formatBulletsNumbering.py b/sw/qa/uitest/writer_tests2/formatBulletsNumbering.py index 888564076111..ac14d0ed80f8 100644 --- a/sw/qa/uitest/writer_tests2/formatBulletsNumbering.py +++ b/sw/qa/uitest/writer_tests2/formatBulletsNumbering.py @@ -264,18 +264,21 @@ class formatBulletsNumbering(UITestCase): xTabs = xDialog.getChild("tabcontrol") select_pos(xTabs, "1") xNumberingPage = xDialog.getChild("PickNumberingPage") - xselector = xNumberingPage.getChild("valueset") - self.assertEqual(get_state_as_dict(xselector)["ItemsCount"], "8") + xselector = xNumberingPage.getChild("pick_numbering_iconview") # Select element num 5 - xselector.executeAction("CHOOSE", mkPropertyValues({"POS": "5"})) + element5 = xselector.getChild("4") + element5.executeAction("SELECT", mkPropertyValues({})) + self.assertEqual(get_state_as_dict(xselector)["VisibleCount"], "8") self.assertEqual(get_state_as_dict(xselector)["SelectedItemPos"], "4") - self.assertEqual(get_state_as_dict(xselector)["SelectedItemId"], "5") - self.assertEqual(get_state_as_dict(xselector)["ItemText"], "Uppercase letter A) B) C)") + self.assertEqual(get_state_as_dict(xselector)["SelectedItemId"], "4") + self.assertEqual(get_state_as_dict(xselector)["SelectEntryText"], "Uppercase letter A) B) C)") # Select element num 8 - xselector.executeAction("CHOOSE", mkPropertyValues({"POS": "8"})) + element8 = xselector.getChild("7") + element8.executeAction("SELECT", mkPropertyValues({})) + self.assertEqual(get_state_as_dict(xselector)["VisibleCount"], "8") self.assertEqual(get_state_as_dict(xselector)["SelectedItemPos"], "7") - self.assertEqual(get_state_as_dict(xselector)["SelectedItemId"], "8") - self.assertEqual(get_state_as_dict(xselector)["ItemText"], "Lowercase Roman number i. ii. iii.") + self.assertEqual(get_state_as_dict(xselector)["SelectedItemId"], "7") + self.assertEqual(get_state_as_dict(xselector)["SelectEntryText"], "Lowercase Roman number i. ii. iii.") # Select the OutlinePage's Selector xTabs = xDialog.getChild("tabcontrol")