chart2/source/controller/dialogs/ChartResourceGroups.cxx | 90 +++++++++------ chart2/source/inc/ChartResourceGroups.hxx | 8 - include/svtools/ctrlbox.hxx | 8 - svtools/source/control/ctrlbox.cxx | 10 - vcl/jsdialog/enabled.cxx | 4 5 files changed, 72 insertions(+), 48 deletions(-)
New commits: commit fcb4e31983515d2231957e894d54649eba5c62cf Author: Szymon Kłos <szymon.k...@collabora.com> AuthorDate: Fri Mar 17 19:45:42 2023 +0100 Commit: Szymon Kłos <szymon.k...@collabora.com> CommitDate: Tue Apr 4 20:38:11 2023 +0200 Convert SvtLineListBox to WeldToolbarPopup Change-Id: I1849e40508a8754ec567da5913d3454571da5bee Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149063 Tested-by: Szymon Kłos <szymon.k...@collabora.com> Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150015 Tested-by: Jenkins diff --git a/include/svtools/ctrlbox.hxx b/include/svtools/ctrlbox.hxx index 57b9094284ee..0d7293fc77eb 100644 --- a/include/svtools/ctrlbox.hxx +++ b/include/svtools/ctrlbox.hxx @@ -20,6 +20,7 @@ #pragma once #include <svtools/svtdllapi.h> +#include <svtools/toolbarmenu.hxx> #include <editeng/borderline.hxx> #include <vcl/idle.hxx> #include <vcl/metric.hxx> @@ -198,7 +199,7 @@ inline Color sameDistColor( Color /*rMain*/, Color rDefault ) class ValueSet; -class SVT_DLLPUBLIC SvtLineListBox +class SVT_DLLPUBLIC SvtLineListBox final : public WeldToolbarPopup { public: typedef Color (*ColorFunc)(Color); @@ -244,6 +245,8 @@ public: void set_sensitive(bool bSensitive) { m_xControl->set_sensitive(bSensitive); } + virtual void GrabFocus() override; + private: SVT_DLLPRIVATE void ImpGetLine( tools::Long nLine1, tools::Long nLine2, tools::Long nDistance, @@ -251,7 +254,6 @@ private: SvxBorderLineStyle nStyle, BitmapEx& rBmp ); DECL_DLLPRIVATE_LINK(ValueSelectHdl, ValueSet*, void); - DECL_DLLPRIVATE_LINK(FocusHdl, weld::Widget&, void); DECL_DLLPRIVATE_LINK(ToggleHdl, weld::Toggleable&, void); DECL_DLLPRIVATE_LINK(NoneHdl, weld::Button&, void); DECL_DLLPRIVATE_LINK(StyleUpdatedHdl, weld::Widget&, void); @@ -264,8 +266,6 @@ private: SvtLineListBox& operator =( const SvtLineListBox& ) = delete; std::unique_ptr<weld::MenuButton> m_xControl; - std::unique_ptr<weld::Builder> m_xBuilder; - std::unique_ptr<weld::Widget> m_xTopLevel; std::unique_ptr<weld::Button> m_xNoneButton; std::unique_ptr<ValueSet> m_xLineSet; std::unique_ptr<weld::CustomWeld> m_xLineSetWin; diff --git a/svtools/source/control/ctrlbox.cxx b/svtools/source/control/ctrlbox.cxx index a17172d5ca44..ef6334a856c9 100644 --- a/svtools/source/control/ctrlbox.cxx +++ b/svtools/source/control/ctrlbox.cxx @@ -1399,9 +1399,8 @@ void SvtLineListBox::ImpGetLine( tools::Long nLine1, tools::Long nLine2, tools:: } SvtLineListBox::SvtLineListBox(std::unique_ptr<weld::MenuButton> pControl) - : m_xControl(std::move(pControl)) - , m_xBuilder(Application::CreateBuilder(m_xControl.get(), "svt/ui/linewindow.ui")) - , m_xTopLevel(m_xBuilder->weld_widget("line_popup_window")) + : WeldToolbarPopup(css::uno::Reference<css::frame::XFrame>(), pControl.get(), "svt/ui/linewindow.ui", "line_popup_window") + , m_xControl(std::move(pControl)) , m_xNoneButton(m_xBuilder->weld_button("none_line_button")) , m_xLineSet(new ValueSet(nullptr)) , m_xLineSetWin(new weld::CustomWeld(*m_xBuilder, "lineset", *m_xLineSet)) @@ -1417,7 +1416,6 @@ SvtLineListBox::SvtLineListBox(std::unique_ptr<weld::MenuButton> pControl) m_xNoneButton->connect_clicked(LINK(this, SvtLineListBox, NoneHdl)); - m_xTopLevel->connect_focus_in(LINK(this, SvtLineListBox, FocusHdl)); m_xControl->set_popover(m_xTopLevel.get()); m_xControl->connect_toggled(LINK(this, SvtLineListBox, ToggleHdl)); m_xControl->connect_style_updated(LINK(this, SvtLineListBox, StyleUpdatedHdl)); @@ -1438,7 +1436,7 @@ SvtLineListBox::SvtLineListBox(std::unique_ptr<weld::MenuButton> pControl) aVirDev->SetMapMode(MapMode(MapUnit::MapTwip)); } -IMPL_LINK_NOARG(SvtLineListBox, FocusHdl, weld::Widget&, void) +void SvtLineListBox::GrabFocus() { if (GetSelectEntryStyle() == SvxBorderLineStyle::NONE) m_xNoneButton->grab_focus(); @@ -1449,7 +1447,7 @@ IMPL_LINK_NOARG(SvtLineListBox, FocusHdl, weld::Widget&, void) IMPL_LINK(SvtLineListBox, ToggleHdl, weld::Toggleable&, rButton, void) { if (rButton.get_active()) - FocusHdl(*m_xTopLevel); + GrabFocus(); } IMPL_LINK_NOARG(SvtLineListBox, StyleUpdatedHdl, weld::Widget&, void) diff --git a/vcl/jsdialog/enabled.cxx b/vcl/jsdialog/enabled.cxx index 8070bc708db7..2069890bad2a 100644 --- a/vcl/jsdialog/enabled.cxx +++ b/vcl/jsdialog/enabled.cxx @@ -238,6 +238,8 @@ bool isBuilderEnabledForPopup(std::u16string_view rUIFile) || rUIFile == u"modules/scalc/ui/filtersubdropdown.ui" || rUIFile == u"modules/scalc/ui/floatingborderstyle.ui" || rUIFile == u"modules/scalc/ui/floatinglinestyle.ui" + // svt + || rUIFile == u"svt/ui/linewindow.ui" // svx || rUIFile == u"svx/ui/colorwindow.ui" || rUIFile == u"svx/ui/currencywindow.ui" commit 65752e649872edfd98915035b61aca510ae8f271 Author: Szymon Kłos <szymon.k...@collabora.com> AuthorDate: Fri Mar 24 10:52:13 2023 +0100 Commit: Szymon Kłos <szymon.k...@collabora.com> CommitDate: Tue Apr 4 20:37:59 2023 +0200 jsdialog: enable and make async chart line prop dialog Change-Id: I21817b21fe6d2ce0a6f6bd784c0e24fe35b17fec Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149502 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150014 Tested-by: Szymon Kłos <szymon.k...@collabora.com> diff --git a/chart2/source/controller/dialogs/ChartResourceGroups.cxx b/chart2/source/controller/dialogs/ChartResourceGroups.cxx index 19534aa1e0b0..3cf5996ed300 100644 --- a/chart2/source/controller/dialogs/ChartResourceGroups.cxx +++ b/chart2/source/controller/dialogs/ChartResourceGroups.cxx @@ -205,22 +205,22 @@ SplineResourceGroup::SplineResourceGroup(weld::Builder* pBuilder, weld::Window* m_xLB_LineType->connect_changed(LINK(this, SplineResourceGroup, LineTypeChangeHdl)); } -SplinePropertiesDialog& SplineResourceGroup::getSplinePropertiesDialog() +std::shared_ptr<SplinePropertiesDialog> SplineResourceGroup::getSplinePropertiesDialog() { if (!m_xSplinePropertiesDialog) { m_xSplinePropertiesDialog.reset(new SplinePropertiesDialog(m_pParent)); } - return *m_xSplinePropertiesDialog; + return m_xSplinePropertiesDialog; } -SteppedPropertiesDialog& SplineResourceGroup::getSteppedPropertiesDialog() +std::shared_ptr<SteppedPropertiesDialog> SplineResourceGroup::getSteppedPropertiesDialog() { if (!m_xSteppedPropertiesDialog) { m_xSteppedPropertiesDialog.reset(new SteppedPropertiesDialog(m_pParent)); } - return *m_xSteppedPropertiesDialog; + return m_xSteppedPropertiesDialog; } void SplineResourceGroup::showControls(bool bShow) @@ -245,7 +245,7 @@ void SplineResourceGroup::fillControls(const ChartTypeParameter& rParameter) m_xPB_DetailsDialog->connect_clicked( LINK(this, SplineResourceGroup, SplineDetailsDialogHdl)); m_xPB_DetailsDialog->set_tooltip_text(SchResId(STR_DLG_SMOOTH_LINE_PROPERTIES)); - getSplinePropertiesDialog().fillControls(rParameter); + getSplinePropertiesDialog()->fillControls(rParameter); break; case CurveStyle_STEP_START: case CurveStyle_STEP_END: @@ -256,7 +256,7 @@ void SplineResourceGroup::fillControls(const ChartTypeParameter& rParameter) m_xPB_DetailsDialog->connect_clicked( LINK(this, SplineResourceGroup, SteppedDetailsDialogHdl)); m_xPB_DetailsDialog->set_tooltip_text(SchResId(STR_DLG_STEPPED_LINE_PROPERTIES)); - getSteppedPropertiesDialog().fillControls(rParameter); + getSteppedPropertiesDialog()->fillControls(rParameter); break; default: m_xLB_LineType->set_active(-1); @@ -268,10 +268,10 @@ void SplineResourceGroup::fillParameter(ChartTypeParameter& rParameter) switch (m_xLB_LineType->get_active()) { case POS_LINETYPE_SMOOTH: - getSplinePropertiesDialog().fillParameter(rParameter, true); + getSplinePropertiesDialog()->fillParameter(rParameter, true); break; case POS_LINETYPE_STEPPED: - getSteppedPropertiesDialog().fillParameter(rParameter, true); + getSteppedPropertiesDialog()->fillParameter(rParameter, true); break; default: // includes POS_LINETYPE_STRAIGHT rParameter.eCurveStyle = CurveStyle_LINES; @@ -288,43 +288,65 @@ IMPL_LINK_NOARG(SplineResourceGroup, LineTypeChangeHdl, weld::ComboBox&, void) IMPL_LINK_NOARG(SplineResourceGroup, SplineDetailsDialogHdl, weld::Button&, void) { ChartTypeParameter aOldParameter; - getSplinePropertiesDialog().fillParameter(aOldParameter, - m_xLB_LineType->get_active() == POS_LINETYPE_SMOOTH); + std::shared_ptr<SplinePropertiesDialog> xDlg = getSplinePropertiesDialog(); + xDlg->fillParameter(aOldParameter, m_xLB_LineType->get_active() == POS_LINETYPE_SMOOTH); const sal_Int32 iOldLineTypePos = m_xLB_LineType->get_active(); m_xLB_LineType->set_active(POS_LINETYPE_SMOOTH); - if (getSplinePropertiesDialog().run() == RET_OK) - { - if (m_pChangeListener) - m_pChangeListener->stateChanged(); - } - else - { - //restore old state: - m_xLB_LineType->set_active(iOldLineTypePos); - getSplinePropertiesDialog().fillControls(aOldParameter); - } + weld::GenericDialogController::runAsync(xDlg, [this, xDlg, aOldParameter, + iOldLineTypePos](sal_Int32 nResult) { + m_xSplinePropertiesDialog = nullptr; + auto xNewDlg = getSplinePropertiesDialog(); + + if (nResult == RET_OK) + { + ChartTypeParameter aNewParameter; + xDlg->fillParameter(aNewParameter, m_xLB_LineType->get_active() == POS_LINETYPE_SMOOTH); + xNewDlg->fillControls(aNewParameter); + + if (m_pChangeListener) + m_pChangeListener->stateChanged(); + } + else + { + //restore old state: + m_xLB_LineType->set_active(iOldLineTypePos); + xNewDlg->fillControls(aOldParameter); + } + }); } IMPL_LINK_NOARG(SplineResourceGroup, SteppedDetailsDialogHdl, weld::Button&, void) { ChartTypeParameter aOldParameter; - getSteppedPropertiesDialog().fillParameter(aOldParameter, m_xLB_LineType->get_active() - == POS_LINETYPE_STEPPED); + std::shared_ptr<SteppedPropertiesDialog> xDlg = getSteppedPropertiesDialog(); + xDlg->fillParameter(aOldParameter, m_xLB_LineType->get_active() == POS_LINETYPE_STEPPED); const sal_Int32 iOldLineTypePos = m_xLB_LineType->get_active(); m_xLB_LineType->set_active(POS_LINETYPE_STEPPED); - if (getSteppedPropertiesDialog().run() == RET_OK) - { - if (m_pChangeListener) - m_pChangeListener->stateChanged(); - } - else - { - //restore old state: - m_xLB_LineType->set_active(iOldLineTypePos); - getSteppedPropertiesDialog().fillControls(aOldParameter); - } + + weld::GenericDialogController::runAsync( + xDlg, [this, xDlg, aOldParameter, iOldLineTypePos](sal_Int32 nResult) { + m_xSteppedPropertiesDialog = nullptr; + auto xNewDlg = getSplinePropertiesDialog(); + + if (nResult == RET_OK) + { + ChartTypeParameter aNewParameter; + xDlg->fillParameter(aNewParameter, + m_xLB_LineType->get_active() == POS_LINETYPE_STEPPED); + xNewDlg->fillControls(aNewParameter); + + if (m_pChangeListener) + m_pChangeListener->stateChanged(); + } + else + { + //restore old state: + m_xLB_LineType->set_active(iOldLineTypePos); + xDlg->fillControls(aOldParameter); + } + }); } GeometryResourceGroup::GeometryResourceGroup(weld::Builder* pBuilder) diff --git a/chart2/source/inc/ChartResourceGroups.hxx b/chart2/source/inc/ChartResourceGroups.hxx index 8c263a7a6a75..9ae397d84f2f 100644 --- a/chart2/source/inc/ChartResourceGroups.hxx +++ b/chart2/source/inc/ChartResourceGroups.hxx @@ -113,16 +113,16 @@ private: DECL_LINK(LineTypeChangeHdl, weld::ComboBox&, void); DECL_LINK(SplineDetailsDialogHdl, weld::Button&, void); DECL_LINK(SteppedDetailsDialogHdl, weld::Button&, void); - SplinePropertiesDialog& getSplinePropertiesDialog(); - SteppedPropertiesDialog& getSteppedPropertiesDialog(); + std::shared_ptr<SplinePropertiesDialog> getSplinePropertiesDialog(); + std::shared_ptr<SteppedPropertiesDialog> getSteppedPropertiesDialog(); private: weld::Window* m_pParent; std::unique_ptr<weld::Label> m_xFT_LineType; std::unique_ptr<weld::ComboBox> m_xLB_LineType; std::unique_ptr<weld::Button> m_xPB_DetailsDialog; - std::unique_ptr<SplinePropertiesDialog> m_xSplinePropertiesDialog; - std::unique_ptr<SteppedPropertiesDialog> m_xSteppedPropertiesDialog; + std::shared_ptr<SplinePropertiesDialog> m_xSplinePropertiesDialog; + std::shared_ptr<SteppedPropertiesDialog> m_xSteppedPropertiesDialog; }; class GeometryResourceGroup final : public ChangingResource diff --git a/vcl/jsdialog/enabled.cxx b/vcl/jsdialog/enabled.cxx index 4eacaf3312b7..8070bc708db7 100644 --- a/vcl/jsdialog/enabled.cxx +++ b/vcl/jsdialog/enabled.cxx @@ -133,6 +133,8 @@ bool isBuilderEnabled(std::u16string_view rUIFile, bool bMobile) || rUIFile == u"modules/schart/ui/datarangedialog.ui" || rUIFile == u"modules/schart/ui/insertaxisdlg.ui" || rUIFile == u"modules/schart/ui/inserttitledlg.ui" + || rUIFile == u"modules/schart/ui/smoothlinesdlg.ui" + || rUIFile == u"modules/schart/ui/steppedlinesdlg.ui" || rUIFile == u"modules/schart/ui/tp_ChartType.ui" || rUIFile == u"modules/schart/ui/tp_RangeChooser.ui" || rUIFile == u"modules/schart/ui/tp_DataSource.ui"