svx/source/dialog/compressgraphicdialog.cxx | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-)
New commits: commit e6afe9d1bc118a9b83d7a7d275d33e4a3c902336 Author: asif196 <asifmohaideen123....@gmail.com> AuthorDate: Sun Jan 26 15:08:17 2025 +0530 Commit: Sahil Gautam <sahil.gautam.ext...@allotropia.de> CommitDate: Tue Jun 3 14:21:21 2025 +0200 tdf#145160 Set default choice in Image Compression dialog per last format Currently the compression format selected by default in the compressed dialog box for an image depends on the option last selected by the user to compress an image except when it is opened for the first time after opening libreoffice in which case the `PNG Compression` option is selected. This happens regardless of the image format. This patch sets the default option based on the format of the image each time the dialog box is opened. If it is a JPG, then `JPEG Quality` will be chosen otherwise the 'PNG Compression' will be chosen. Change-Id: Ib8eb84b6b1e226f5bf6e98aa1e0477ffced9be73 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180758 Reviewed-by: Sahil Gautam <sahil.gautam.ext...@allotropia.de> Tested-by: Jenkins diff --git a/svx/source/dialog/compressgraphicdialog.cxx b/svx/source/dialog/compressgraphicdialog.cxx index 90f3b21892c5..bf427e5a99c5 100644 --- a/svx/source/dialog/compressgraphicdialog.cxx +++ b/svx/source/dialog/compressgraphicdialog.cxx @@ -48,10 +48,6 @@ namespace bool ReduceResolutionCB = true; int MFNewWidth = 1; int MFNewHeight = 1; - bool LosslessRB = true; - bool JpegCompRB = false; - int CompressionMF = 6; - int QualityMF = 80; int InterpolationCombo = 3; }; memParam memp; @@ -100,13 +96,6 @@ void CompressGraphicsDialog::recallParameter() 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 ); UpdateSensitivity(m_xReduceResolutionCB->get_active()); @@ -153,7 +142,14 @@ void CompressGraphicsDialog::Initialize() m_xQualityMF->connect_value_changed( LINK( this, CompressGraphicsDialog, NewQualityModifiedHdl )); m_xCompressionMF->connect_value_changed( LINK( this, CompressGraphicsDialog, NewCompressionModifiedHdl )); - m_xJpegCompRB->set_active(true); + const auto& pGfxLink = m_aGraphic.GetSharedGfxLink(); + bool bDefaultChoice = (pGfxLink) ? (pGfxLink->GetType() == GfxLinkType::NativeJpg) : false; + + m_xJpegCompRB->set_active(bDefaultChoice); + m_xQualitySlider->set_sensitive(bDefaultChoice); + m_xQualityMF->set_sensitive(bDefaultChoice); + + m_xReduceResolutionCB->set_active(true); m_xBtnOkay->connect_clicked( LINK( this, CompressGraphicsDialog, OkayClickHdl ) ); @@ -290,10 +286,6 @@ 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); }