From 4b743a2cc1b6d29404873205a25432baf4f9c933 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Tue, 18 Sep 2018 12:10:37 +0100 Subject: [PATCH] weld GraphicFilterSolarize MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: If729ea1688e9dc15372a59d75c972ee37511f76e Reviewed-on: https://gerrit.libreoffice.org/60680 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- cui/source/dialogs/cuigrfflt.cxx | 44 +++++++++---------------------- cui/source/factory/dlgfact.cxx | 5 ++-- cui/source/factory/dlgfact.hxx | 2 +- cui/source/inc/cuigrfflt.hxx | 22 +++++++--------- cui/uiconfig/ui/embossdialog.ui | 1 + cui/uiconfig/ui/solarizedialog.ui | 33 +++++++++++++++++++---- include/svx/svxdlg.hxx | 2 +- svx/source/dialog/grfflt.cxx | 2 +- 8 files changed, 55 insertions(+), 56 deletions(-) diff --git a/cui/source/dialogs/cuigrfflt.cxx b/cui/source/dialogs/cuigrfflt.cxx index f8f2b76bc4a5..c8268ac38f02 100644 --- a/cui/source/dialogs/cuigrfflt.cxx +++ b/cui/source/dialogs/cuigrfflt.cxx @@ -449,53 +449,33 @@ Graphic GraphicFilterSmooth::GetFilteredGraphic( const Graphic& rGraphic, double return aRet; } - -GraphicFilterSolarize::GraphicFilterSolarize( vcl::Window* pParent, const Graphic& rGraphic, - sal_uInt8 cGreyThreshold, bool bInvert ) - : GraphicFilterDialog(pParent, "SolarizeDialog", - "cui/ui/solarizedialog.ui", rGraphic) +GraphicFilterSolarize::GraphicFilterSolarize(weld::Window* pParent, const Graphic& rGraphic, + sal_uInt8 cGreyThreshold, bool bInvert) + : GraphicFilterDialogController(pParent, "cui/ui/solarizedialog.ui", "SolarizeDialog", rGraphic) + , mxMtrThreshold(m_xBuilder->weld_metric_spin_button("value", FUNIT_PERCENT)) + , mxCbxInvert(m_xBuilder->weld_check_button("invert")) { - get(mpMtrThreshold, "value"); - get(mpCbxInvert, "invert"); + mxMtrThreshold->set_value(FRound(cGreyThreshold / 2.55), FUNIT_PERCENT); + mxMtrThreshold->connect_value_changed(LINK(this, GraphicFilterSolarize, EditModifyHdl)); - mpMtrThreshold->SetValue( FRound( cGreyThreshold / 2.55 ) ); - mpMtrThreshold->SetModifyHdl( LINK(this, GraphicFilterSolarize, EditModifyHdl) ); - - mpCbxInvert->Check( bInvert ); - mpCbxInvert->SetToggleHdl( LINK(this, GraphicFilterSolarize, CheckBoxModifyHdl) ); + mxCbxInvert->set_active(bInvert); + mxCbxInvert->connect_toggled(LINK(this, GraphicFilterSolarize, CheckBoxModifyHdl)); } - -IMPL_LINK_NOARG(GraphicFilterSolarize, CheckBoxModifyHdl, CheckBox&, void) +IMPL_LINK_NOARG(GraphicFilterSolarize, CheckBoxModifyHdl, weld::ToggleButton&, void) { GetModifyHdl().Call(nullptr); } - -IMPL_LINK_NOARG(GraphicFilterSolarize, EditModifyHdl, Edit&, void) +IMPL_LINK_NOARG(GraphicFilterSolarize, EditModifyHdl, weld::MetricSpinButton&, void) { GetModifyHdl().Call(nullptr); } - -GraphicFilterSolarize::~GraphicFilterSolarize() -{ - disposeOnce(); -} - - -void GraphicFilterSolarize::dispose() -{ - mpMtrThreshold.clear(); - mpCbxInvert.clear(); - GraphicFilterDialog::dispose(); -} - - Graphic GraphicFilterSolarize::GetFilteredGraphic( const Graphic& rGraphic, double, double ) { Graphic aRet; - sal_uInt8 nGreyThreshold = static_cast(FRound( mpMtrThreshold->GetValue() * 2.55 )); + sal_uInt8 nGreyThreshold = static_cast(FRound(mxMtrThreshold->get_value(FUNIT_PERCENT) * 2.55)); if( rGraphic.IsAnimated() ) { diff --git a/cui/source/factory/dlgfact.cxx b/cui/source/factory/dlgfact.cxx index 63868ad23534..0534e2e006f8 100644 --- a/cui/source/factory/dlgfact.cxx +++ b/cui/source/factory/dlgfact.cxx @@ -1306,11 +1306,10 @@ VclPtr AbstractDialogFactory_Impl::CreateGraphicFil return VclPtr::Create( pDlg ); } -VclPtr AbstractDialogFactory_Impl::CreateGraphicFilterSolarize (vcl::Window* pParent, +VclPtr AbstractDialogFactory_Impl::CreateGraphicFilterSolarize(weld::Window* pParent, const Graphic& rGraphic) { - VclPtrInstance pDlg( pParent, rGraphic, 128, false/*bInvert*/ ); - return VclPtr::Create( pDlg ); + return VclPtr::Create(o3tl::make_unique(pParent, rGraphic, 128, false /*bInvert*/)); } VclPtr AbstractDialogFactory_Impl::CreateGraphicFilterMosaic (vcl::Window* pParent, diff --git a/cui/source/factory/dlgfact.hxx b/cui/source/factory/dlgfact.hxx index 6df50a3b0f52..968685e8994c 100644 --- a/cui/source/factory/dlgfact.hxx +++ b/cui/source/factory/dlgfact.hxx @@ -761,7 +761,7 @@ public: const Graphic& rGraphic) override; virtual VclPtr CreateGraphicFilterSmooth (vcl::Window* pParent, const Graphic& rGraphic, double nRadius) override; - virtual VclPtr CreateGraphicFilterSolarize (vcl::Window* pParent, + virtual VclPtr CreateGraphicFilterSolarize(weld::Window* pParent, const Graphic& rGraphic) override; virtual VclPtr CreateGraphicFilterMosaic (vcl::Window* pParent, const Graphic& rGraphic) override; diff --git a/cui/source/inc/cuigrfflt.hxx b/cui/source/inc/cuigrfflt.hxx index 2a8a8f35229c..1d369d560fcd 100644 --- a/cui/source/inc/cuigrfflt.hxx +++ b/cui/source/inc/cuigrfflt.hxx @@ -184,23 +184,19 @@ public: bool IsEnhanceEdges() const { return mpCbxEdges->IsChecked(); } }; -class GraphicFilterSolarize : public GraphicFilterDialog +class GraphicFilterSolarize : public GraphicFilterDialogController { private: - VclPtr mpMtrThreshold; - VclPtr mpCbxInvert; - DECL_LINK(CheckBoxModifyHdl, CheckBox&, void); - DECL_LINK(EditModifyHdl, Edit&, void); + std::unique_ptr mxMtrThreshold; + std::unique_ptr mxCbxInvert; + DECL_LINK(CheckBoxModifyHdl, weld::ToggleButton&, void); + DECL_LINK(EditModifyHdl, weld::MetricSpinButton&, void); public: - - GraphicFilterSolarize( vcl::Window* pParent, const Graphic& rGraphic, - sal_uInt8 nGreyThreshold, bool bInvert ); - virtual ~GraphicFilterSolarize() override; - virtual void dispose() override; - - virtual Graphic GetFilteredGraphic( const Graphic& rGraphic, double fScaleX, double fScaleY ) override; - bool IsInvert() const { return mpCbxInvert->IsChecked(); } + GraphicFilterSolarize(weld::Window* pParent, const Graphic& rGraphic, + sal_uInt8 nGreyThreshold, bool bInvert); + virtual Graphic GetFilteredGraphic( const Graphic& rGraphic, double fScaleX, double fScaleY ) override; + bool IsInvert() const { return mxCbxInvert->get_active(); } }; class GraphicFilterSepia : public GraphicFilterDialog diff --git a/cui/uiconfig/ui/embossdialog.ui b/cui/uiconfig/ui/embossdialog.ui index d8457c5f91ce..07a8ef559513 100644 --- a/cui/uiconfig/ui/embossdialog.ui +++ b/cui/uiconfig/ui/embossdialog.ui @@ -6,6 +6,7 @@ False 6 Emboss + True 0 0 dialog diff --git a/cui/uiconfig/ui/solarizedialog.ui b/cui/uiconfig/ui/solarizedialog.ui index 75e056062812..e711ddde360b 100644 --- a/cui/uiconfig/ui/solarizedialog.ui +++ b/cui/uiconfig/ui/solarizedialog.ui @@ -1,5 +1,5 @@ - + @@ -13,7 +13,13 @@ 6 Solarization False + True + 0 + 0 dialog + + + False @@ -100,11 +106,28 @@ True 24 - + True False True True + never + never + in + + + True + False + + + True + False + True + True + + + + 1 @@ -117,7 +140,7 @@ False 6 - + True True adjustment1 @@ -131,10 +154,10 @@ True False - 0 Threshold _value: True - value:0% + value + 0 0 diff --git a/include/svx/svxdlg.hxx b/include/svx/svxdlg.hxx index 7fc73b72e4a3..81e4fd933543 100644 --- a/include/svx/svxdlg.hxx +++ b/include/svx/svxdlg.hxx @@ -421,7 +421,7 @@ public: virtual VclPtr CreateGraphicFilterSmooth (vcl::Window* pParent, const Graphic& rGraphic, double nRadius)=0; - virtual VclPtr CreateGraphicFilterSolarize (vcl::Window* pParent, + virtual VclPtr CreateGraphicFilterSolarize(weld::Window* pParent, const Graphic& rGraphic)=0; virtual VclPtr CreateGraphicFilterMosaic (vcl::Window* pParent, const Graphic& rGraphic)=0; diff --git a/svx/source/dialog/grfflt.cxx b/svx/source/dialog/grfflt.cxx index a73aba142da8..bc53e6cfa92d 100644 --- a/svx/source/dialog/grfflt.cxx +++ b/svx/source/dialog/grfflt.cxx @@ -220,7 +220,7 @@ SvxGraphicFilterResult SvxGraphicFilter::ExecuteGrfFilterSlot( SfxRequest const case SID_GRFFILTER_SOLARIZE: { SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); - ScopedVclPtr aDlg(pFact->CreateGraphicFilterSolarize(pWindow, rGraphic)); + ScopedVclPtr aDlg(pFact->CreateGraphicFilterSolarize(pWindow ? pWindow->GetFrameWeld() : nullptr, rGraphic)); if( aDlg->Execute() == RET_OK ) aGraphic = aDlg->GetFilteredGraphic( rGraphic, 1.0, 1.0 ); }