diff options
author | Caolán McNamara <caolanm@redhat.com> | 2019-12-20 10:59:50 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2019-12-20 16:40:34 +0100 |
commit | 8c0a015f7f4a007b1cb6ac293838d75741f8ae0a (patch) | |
tree | 13a2f03a0c24ca970ca5eb547f68d0d31c6a7aaa /sw/source | |
parent | 1d273e238d0f1cbb193811d30d2569b0d02d1dc3 (diff) |
weld ThemePanel
Change-Id: I5eca63762e5e243ae791e15655fac60cc9437aa5
Reviewed-on: https://gerrit.libreoffice.org/85591
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/uibase/sidebar/ThemePanel.cxx | 55 | ||||
-rw-r--r-- | sw/source/uibase/sidebar/ThemePanel.hxx | 20 |
2 files changed, 39 insertions, 36 deletions
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(); }; |