include/svx/compressgraphicdialog.hxx | 3 + svx/source/dialog/compressgraphicdialog.cxx | 51 ++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+)
New commits: commit 90546b02d70cb9a9c3ee88428d99635a2f7eb22a Author: Heiko Tietze <tietze.he...@gmail.com> AuthorDate: Mon Feb 14 08:23:45 2022 +0100 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Sun Feb 20 22:17:57 2022 +0100 Resolves tdf#146929 - Remember user input for the compress dialog Change-Id: I23a0cd10b6936de920a294901f860620fc2af0a9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129894 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/include/svx/compressgraphicdialog.hxx b/include/svx/compressgraphicdialog.hxx index 1ef8d387bf62..87556ecbce1d 100644 --- a/include/svx/compressgraphicdialog.hxx +++ b/include/svx/compressgraphicdialog.hxx @@ -51,6 +51,7 @@ private: std::unique_ptr<weld::Scale> m_xQualitySlider; std::unique_ptr<weld::Button> m_xBtnCalculate; std::unique_ptr<weld::ComboBox> m_xInterpolationCombo; + std::unique_ptr<weld::Button> m_xBtnOkay; SdrGrafObj* m_xGraphicObj; Graphic m_aGraphic; @@ -62,6 +63,7 @@ private: sal_Int32 m_aNativeSize; void Initialize(); + void recallParameter(); DECL_DLLPRIVATE_LINK( SlideHdl, weld::Scale&, void ); DECL_DLLPRIVATE_LINK( NewInterpolationModifiedHdl, weld::ComboBox&, void ); @@ -74,6 +76,7 @@ private: DECL_DLLPRIVATE_LINK( ToggleReduceResolutionRB, weld::Toggleable&, void ); DECL_DLLPRIVATE_LINK( CalculateClickHdl, weld::Button&, void ); + DECL_DLLPRIVATE_LINK( OkayClickHdl, weld::Button&, void ); void Update(); void UpdateNewWidthMF(); diff --git a/svx/source/dialog/compressgraphicdialog.cxx b/svx/source/dialog/compressgraphicdialog.cxx index 1eb6a32501f2..7c9a8a44be33 100644 --- a/svx/source/dialog/compressgraphicdialog.cxx +++ b/svx/source/dialog/compressgraphicdialog.cxx @@ -39,6 +39,23 @@ #include <tools/stream.hxx> #include <unotools/localedatawrapper.hxx> +// tdf#146929 - remember user settings within the currect session +// memp is filled in dtor and restored after initialization +namespace +{ + struct memParam { + bool ReduceResolutionCB = false; + int MFNewWidth = 1; + int MFNewHeight = 1; + bool LosslessRB = true; + bool JpegCompRB = false; + int CompressionMF = 6; + int QualityMF = 80; + int InterpolationCombo = 3; + }; + memParam memp; +} + using namespace com::sun::star::uno; using namespace com::sun::star::beans; @@ -66,12 +83,31 @@ CompressGraphicsDialog::CompressGraphicsDialog( weld::Window* pParent, Graphic c m_dResolution ( 300 ) { Initialize(); + recallParameter(); } CompressGraphicsDialog::~CompressGraphicsDialog() { } +void CompressGraphicsDialog::recallParameter() +{ + m_xReduceResolutionCB->set_active( memp.ReduceResolutionCB ); + if (memp.ReduceResolutionCB && (memp.MFNewWidth > 1)) + m_xMFNewWidth->set_value( memp.MFNewWidth ); + if (memp.ReduceResolutionCB && (memp.MFNewHeight > 1)) + m_xMFNewHeight->set_value( memp.MFNewHeight ); + + m_xLosslessRB->set_active( memp.LosslessRB ); + m_xJpegCompRB->set_active( memp.JpegCompRB ); + m_xCompressionMF->set_value( memp.CompressionMF ); + m_xCompressionSlider->set_value( memp.CompressionMF ); + m_xQualityMF->set_value( memp.QualityMF ); + m_xQualitySlider->set_value( memp.QualityMF ); + + m_xInterpolationCombo->set_active( memp.InterpolationCombo ); +} + void CompressGraphicsDialog::Initialize() { m_xLabelGraphicType = m_xBuilder->weld_label("label-graphic-type"); @@ -91,6 +127,7 @@ void CompressGraphicsDialog::Initialize() m_xResolutionLB = m_xBuilder->weld_combo_box("combo-resolution"); m_xBtnCalculate = m_xBuilder->weld_button("calculate"); m_xInterpolationCombo = m_xBuilder->weld_combo_box("interpolation-method-combo"); + m_xBtnOkay = m_xBuilder->weld_button("ok"); m_xInterpolationCombo->set_active_text("Lanczos"); @@ -115,6 +152,7 @@ void CompressGraphicsDialog::Initialize() m_xJpegCompRB->set_active(true); m_xReduceResolutionCB->set_active(true); + m_xBtnOkay->connect_clicked( LINK( this, CompressGraphicsDialog, OkayClickHdl ) ); UpdateNewWidthMF(); UpdateNewHeightMF(); UpdateResolutionLB(); @@ -235,6 +273,19 @@ void CompressGraphicsDialog::Compress(SvStream& aStream) rFilter.ExportGraphic( aScaledGraphic, "none", aStream, nFilterFormat, &aFilterData ); } +IMPL_LINK_NOARG( CompressGraphicsDialog, OkayClickHdl, weld::Button&, void ) +{ + memp.ReduceResolutionCB = m_xReduceResolutionCB->get_active(); + memp.MFNewWidth = m_xMFNewWidth->get_value(); + memp.MFNewHeight = m_xMFNewHeight->get_value(); + memp.LosslessRB = m_xLosslessRB->get_active(); + memp.JpegCompRB = m_xJpegCompRB->get_active(); + memp.CompressionMF = m_xCompressionMF->get_value(); + memp.QualityMF = m_xQualityMF->get_value(); + memp.InterpolationCombo = m_xInterpolationCombo->get_active(); + CompressGraphicsDialog::response(RET_OK); +} + IMPL_LINK_NOARG( CompressGraphicsDialog, NewWidthModifiedHdl, weld::Entry&, void ) { m_dResolution = m_xMFNewWidth->get_value() / GetViewWidthInch();