solenv/sanitizers/ui/modules/swriter.suppr | 3 - sw/source/uibase/sidebar/ThemePanel.cxx | 55 +++++++++++-------- sw/source/uibase/sidebar/ThemePanel.hxx | 20 ++----- sw/uiconfig/swriter/ui/sidebartheme.ui | 80 +++++++++++++++++++++++++---- 4 files changed, 108 insertions(+), 50 deletions(-)
New commits: commit 8c0a015f7f4a007b1cb6ac293838d75741f8ae0a Author: Caolán McNamara <[email protected]> AuthorDate: Fri Dec 20 10:59:50 2019 +0000 Commit: Caolán McNamara <[email protected]> CommitDate: Fri Dec 20 16:40:34 2019 +0100 weld ThemePanel Change-Id: I5eca63762e5e243ae791e15655fac60cc9437aa5 Reviewed-on: https://gerrit.libreoffice.org/85591 Tested-by: Jenkins Reviewed-by: Caolán McNamara <[email protected]> Tested-by: Caolán McNamara <[email protected]> diff --git a/solenv/sanitizers/ui/modules/swriter.suppr b/solenv/sanitizers/ui/modules/swriter.suppr index c02c0c77d3cb..9fad88ba117b 100644 --- a/solenv/sanitizers/ui/modules/swriter.suppr +++ b/solenv/sanitizers/ui/modules/swriter.suppr @@ -207,9 +207,6 @@ sw/uiconfig/swriter/ui/selectaddressdialog.ui://GtkLabel[@id='connecting'] orpha sw/uiconfig/swriter/ui/selecttabledialog.ui://GtkLabel[@id='select'] orphan-label sw/uiconfig/swriter/ui/sidebarwrap.ui://GtkLabel[@id='label1'] orphan-label sw/uiconfig/swriter/ui/sidebarwrap.ui://GtkLabel[@id='customlabel'] orphan-label -sw/uiconfig/swriter/ui/sidebartheme.ui://GtkLabel[@id='label1'] orphan-label -sw/uiconfig/swriter/ui/sidebartheme.ui://GtkTreeView[@id='listbox_fonts'] no-labelled-by -sw/uiconfig/swriter/ui/sidebartheme.ui://GtkLabel[@id='label2'] orphan-label sw/uiconfig/swriter/ui/spellmenu.ui://GtkMenuItem[@id='spelldialog'] button-no-label sw/uiconfig/swriter/ui/spellmenu.ui://GtkMenuItem[@id='correctdialog'] button-no-label sw/uiconfig/swriter/ui/statisticsinfopage.ui://GtkLabel[@id='nopages'] orphan-label diff --git a/sw/source/uibase/sidebar/ThemePanel.cxx b/sw/source/uibase/sidebar/ThemePanel.cxx index 499863889217..d2f6e64cd08b 100644 --- a/sw/source/uibase/sidebar/ThemePanel.cxx +++ b/sw/source/uibase/sidebar/ThemePanel.cxx @@ -426,25 +426,24 @@ VclPtr<vcl::Window> ThemePanel::Create (vcl::Window* pParent, ThemePanel::ThemePanel(vcl::Window* pParent, const css::uno::Reference<css::frame::XFrame>& rxFrame) - : PanelLayout(pParent, "ThemePanel", "modules/swriter/ui/sidebartheme.ui", rxFrame) + : PanelLayout(pParent, "ThemePanel", "modules/swriter/ui/sidebartheme.ui", rxFrame, true) + , mxListBoxFonts(m_xBuilder->weld_tree_view("listbox_fonts")) + , mxValueSetColors(new SvtValueSet(nullptr)) + , mxValueSetColorsWin(new weld::CustomWeld(*m_xBuilder, "valueset_colors", *mxValueSetColors)) + , mxApplyButton(m_xBuilder->weld_button("apply")) , maColorSets() { - get(mpListBoxFonts, "listbox_fonts"); - get(mpValueSetColors, "valueset_colors"); - get(mpApplyButton, "apply"); + mxValueSetColors->SetColCount(2); + mxValueSetColors->SetLineCount(3); - mpValueSetColors->SetColCount(2); - mpValueSetColors->SetLineCount(4); - - mpApplyButton->SetClickHdl(LINK(this, ThemePanel, ClickHdl)); - mpListBoxFonts->SetDoubleClickHdl(LINK(this, ThemePanel, DoubleClickHdl)); - mpValueSetColors->SetDoubleClickHdl(LINK(this, ThemePanel, DoubleClickValueSetHdl)); + mxApplyButton->connect_clicked(LINK(this, ThemePanel, ClickHdl)); + mxListBoxFonts->connect_row_activated(LINK(this, ThemePanel, DoubleClickHdl)); + mxValueSetColors->SetDoubleClickHdl(LINK(this, ThemePanel, DoubleClickValueSetHdl)); std::vector<FontSet> aFontSets = initFontSets(); for (const FontSet & rFontSet : aFontSets) - { - mpListBoxFonts->InsertEntry(rFontSet.maName); - } + mxListBoxFonts->append_text(rFontSet.maName); + mxListBoxFonts->set_size_request(-1, mxListBoxFonts->get_height_rows(aFontSets.size())); maColorSets.init(); @@ -455,8 +454,12 @@ ThemePanel::ThemePanel(vcl::Window* pParent, const OUString& aName = rColorSet.getName(); BitmapEx aPreview = GenerateColorPreview(rColorSet); - mpValueSetColors->InsertItem(i, Image(aPreview), aName); + + sal_uInt16 nId = i + 1; + mxValueSetColors->InsertItem(nId, Image(aPreview), aName); } + + mxValueSetColors->SetOptimalSize(); } ThemePanel::~ThemePanel() @@ -466,33 +469,39 @@ ThemePanel::~ThemePanel() void ThemePanel::dispose() { - mpListBoxFonts.clear(); - mpValueSetColors.clear(); - mpApplyButton.clear(); + mxListBoxFonts.reset(); + mxValueSetColorsWin.reset(); + mxValueSetColors.reset(); + mxApplyButton.reset(); PanelLayout::dispose(); } -IMPL_LINK_NOARG(ThemePanel, ClickHdl, Button*, void) +IMPL_LINK_NOARG(ThemePanel, ClickHdl, weld::Button&, void) { DoubleClickHdl(); } -IMPL_LINK_NOARG(ThemePanel, DoubleClickValueSetHdl, ValueSet*, void) + +IMPL_LINK_NOARG(ThemePanel, DoubleClickValueSetHdl, SvtValueSet*, void) { DoubleClickHdl(); } -IMPL_LINK_NOARG(ThemePanel, DoubleClickHdl, ListBox&, void) + +IMPL_LINK_NOARG(ThemePanel, DoubleClickHdl, weld::TreeView&, bool) { DoubleClickHdl(); + return true; } + void ThemePanel::DoubleClickHdl() { SwDocShell* pDocSh = static_cast<SwDocShell*>(SfxObjectShell::Current()); if (pDocSh) { - OUString sEntryFonts = mpListBoxFonts->GetSelectedEntry(); - sal_uInt32 nItemId = mpValueSetColors->GetSelectedItemId(); - OUString sEntryColors = maColorSets.getColorSet(nItemId).getName(); + OUString sEntryFonts = mxListBoxFonts->get_selected_text(); + sal_uInt32 nItemId = mxValueSetColors->GetSelectedItemId(); + sal_uInt32 nIndex = nItemId - 1; + OUString sEntryColors = maColorSets.getColorSet(nIndex).getName(); StyleSet aStyleSet = setupThemes(); diff --git a/sw/source/uibase/sidebar/ThemePanel.hxx b/sw/source/uibase/sidebar/ThemePanel.hxx index 898caae9fc4a..1eafe682d450 100644 --- a/sw/source/uibase/sidebar/ThemePanel.hxx +++ b/sw/source/uibase/sidebar/ThemePanel.hxx @@ -12,16 +12,9 @@ #define INCLUDED_SW_SOURCE_UIBASE_SIDEBAR_THEMEPANEL_HXX #include <com/sun/star/frame/XFrame.hpp> - #include <svx/sidebar/PanelLayout.hxx> - #include <sfx2/sidebar/ControllerItem.hxx> - -#include <vcl/button.hxx> -#include <vcl/lstbox.hxx> - #include <svtools/valueset.hxx> - #include <svx/ColorSets.hxx> namespace sw { namespace sidebar { @@ -45,15 +38,16 @@ private: virtual void dispose() override; - VclPtr<ListBox> mpListBoxFonts; - VclPtr<ValueSet> mpValueSetColors; - VclPtr<PushButton> mpApplyButton; + std::unique_ptr<weld::TreeView> mxListBoxFonts; + std::unique_ptr<SvtValueSet> mxValueSetColors; + std::unique_ptr<weld::CustomWeld> mxValueSetColorsWin; + std::unique_ptr<weld::Button> mxApplyButton; svx::ColorSets maColorSets; - DECL_LINK(ClickHdl, Button*, void); - DECL_LINK(DoubleClickHdl, ListBox&, void); - DECL_LINK(DoubleClickValueSetHdl, ValueSet*, void); + DECL_LINK(ClickHdl, weld::Button&, void); + DECL_LINK(DoubleClickHdl, weld::TreeView&, bool); + DECL_LINK(DoubleClickValueSetHdl, SvtValueSet*, void); void DoubleClickHdl(); }; diff --git a/sw/uiconfig/swriter/ui/sidebartheme.ui b/sw/uiconfig/swriter/ui/sidebartheme.ui index b93c6504345d..f4734aae3adc 100644 --- a/sw/uiconfig/swriter/ui/sidebartheme.ui +++ b/sw/uiconfig/swriter/ui/sidebartheme.ui @@ -1,9 +1,15 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.18.3 --> +<!-- Generated with glade 3.22.1 --> <interface domain="sw"> <requires lib="gtk+" version="3.18"/> - <requires lib="LibreOffice" version="1.0"/> - + <object class="GtkTreeStore" id="liststore1"> + <columns> + <!-- column-name text --> + <column type="gchararray"/> + <!-- column-name id --> + <column type="gchararray"/> + </columns> + </object> <object class="GtkGrid" id="ThemePanel"> <property name="visible">True</property> <property name="can_focus">False</property> @@ -13,18 +19,24 @@ <object class="GtkAlignment" id="alignment1"> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> <child> <object class="GtkGrid" id="grid1"> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> <property name="row_spacing">6</property> <property name="column_spacing">6</property> <child> <object class="GtkLabel" id="label1"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes" context="sidebartheme|label1">Fonts</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">listbox_fonts</property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">0</property> @@ -32,13 +44,37 @@ </packing> </child> <child> - <object class="GtkTreeView" id="listbox_fonts"> + <object class="GtkScrolledWindow"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="hexpand">True</property> - <property name="show_expanders">False</property> - <child internal-child="selection"> - <object class="GtkTreeSelection" id="treeview-selection1"/> + <property name="vexpand">True</property> + <property name="shadow_type">in</property> + <child> + <object class="GtkTreeView" id="listbox_fonts"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="model">liststore1</property> + <property name="headers_visible">False</property> + <property name="headers_clickable">False</property> + <property name="search_column">0</property> + <property name="show_expanders">False</property> + <child internal-child="selection"> + <object class="GtkTreeSelection"/> + </child> + <child> + <object class="GtkTreeViewColumn" id="treeviewcolumn1"> + <child> + <object class="GtkCellRendererText" id="cellrenderertext1"/> + <attributes> + <attribute name="text">0</attribute> + </attributes> + </child> + </object> + </child> + </object> </child> </object> <packing> @@ -50,8 +86,10 @@ <object class="GtkLabel" id="label2"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes" context="sidebartheme|label2">Colors</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">valueset_colors</property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">0</property> @@ -72,9 +110,29 @@ </packing> </child> <child> - <object class="svtlo-ValueSet" id="valueset_colors"> + <object class="GtkScrolledWindow" id="valuesetwin"> <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="GtkViewport"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkDrawingArea" id="valueset_colors"> + <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> + </object> + </child> + </object> + </child> </object> <packing> <property name="left_attach">0</property> _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
