Git commit 9aa9b09afc3422c2c2de0d4891b799f5277baa64 by Nate Graham. Committed on 11/02/2021 at 15:45. Pushed by ngraham into branch 'master'.
Show quality chooser for other lossy image formats too WEBP, AVIF, HEIF, and HEIC are also compressed image formats, so it makes sense to allow the user to choose the compression level for them too, just like with JPEG images. This commit makes the internal variable names a little odd since they still have "jpeg" in them. This can be corrected in a follow-up commit. BUG: 431680 FIXED-IN: 21.04 M +2 -1 app/configdialog.cpp M +15 -5 app/generalconfigpage.ui M +7 -3 app/gvcore.cpp M +2 -2 doc/index.docbook M +6 -1 lib/document/documentloadedimpl.cpp https://invent.kde.org/graphics/gwenview/commit/9aa9b09afc3422c2c2de0d4891b799f5277baa64 diff --git a/app/configdialog.cpp b/app/configdialog.cpp index a1133c55..b52dd0c7 100644 --- a/app/configdialog.cpp +++ b/app/configdialog.cpp @@ -71,7 +71,8 @@ ConfigDialog::ConfigDialog(QWidget* parent) connect(mGeneralConfigPage.jpegQualitySpinner, QOverload<int>::of(&QSpinBox::valueChanged), this, [=] (int value) {mGeneralConfigPage.kcfg_JPEGQuality->setValue(value);}); mGeneralConfigPage.jpegQualitySpinner->setValue(mGeneralConfigPage.kcfg_JPEGQuality->value()); mGeneralConfigPage.backgroundValueFrame->setMinimumWidth(mGeneralConfigPage.jpegQualitySpinner->width()); - + mGeneralConfigPage.lossyImageFormatHelpLabel->setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont)); + mGeneralConfigPage.kcfg_AutoplayVideos->setEnabled(mGeneralConfigPage.kcfg_ListVideos->isChecked()); connect(mGeneralConfigPage.kcfg_ListVideos, &QCheckBox::stateChanged, [=](const int &state) { mGeneralConfigPage.kcfg_AutoplayVideos->setEnabled(state == Qt::Checked); diff --git a/app/generalconfigpage.ui b/app/generalconfigpage.ui index 54769fd4..2ab19994 100644 --- a/app/generalconfigpage.ui +++ b/app/generalconfigpage.ui @@ -169,7 +169,7 @@ <item row="8" column="0"> <widget class="QLabel" name="label_4"> <property name="text"> - <string>JPEG save quality:</string> + <string>Lossy image save quality:</string> </property> </widget> </item> @@ -232,6 +232,16 @@ </layout> </item> <item row="9" column="1"> + <widget class="QLabel" name="lossyImageFormatHelpLabel"> + <property name="text"> + <string>The quality level when saving images using lossy image formats such as JPEG, WEBP, AVIF, HEIF, and HEIC. Higher quality increases the file size.</string> + </property> + <property name="wordWrap"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="10" column="1"> <spacer name="verticalSpacer_3"> <property name="orientation"> <enum>Qt::Vertical</enum> @@ -247,28 +257,28 @@ </property> </spacer> </item> - <item row="10" column="0"> + <item row="11" column="0"> <widget class="QLabel" name="label_5"> <property name="text"> <string>Thumbnail actions:</string> </property> </widget> </item> - <item row="10" column="1"> + <item row="12" column="1"> <widget class="QRadioButton" name="allButtonsThumbnailActionsRadioButton"> <property name="text"> <string>All buttons</string> </property> </widget> </item> - <item row="11" column="1"> + <item row="13" column="1"> <widget class="QRadioButton" name="selectionOnlyThumbnailActionsRadioButton"> <property name="text"> <string>Show selection button only</string> </property> </widget> </item> - <item row="12" column="1"> + <item row="14" column="1"> <widget class="QRadioButton" name="noneThumbnailActionsRadioButton"> <property name="text"> <string>None</string> diff --git a/app/gvcore.cpp b/app/gvcore.cpp index 8d58a1b6..865de421 100644 --- a/app/gvcore.cpp +++ b/app/gvcore.cpp @@ -79,7 +79,7 @@ struct GvCorePrivate JPEGQualityChooserWidget->setVisible(false); // shown only for JPEGs QLabel* JPEGQualityChooserLabel = new QLabel; - JPEGQualityChooserLabel->setText(i18n("JPEG quality:")); + JPEGQualityChooserLabel->setText(i18n("Image quality:")); JPEGQualityChooserLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); QSpinBox* JPEGQualityChooserSpinBox = new QSpinBox; @@ -124,10 +124,14 @@ struct GvCorePrivate fileWidget->setMimeFilter(supportedMimetypes, MimeTypeUtils::urlMimeType(url)); - // Only show the JPEG quality chooser when saving a JPEG image + // Only show the lossy image quality chooser when saving a lossy image QObject::connect(fileWidget, &KFileWidget::filterChanged, JPEGQualityChooserWidget, [=](const QString &filter) { - JPEGQualityChooserWidget->setVisible(filter.contains(QLatin1String("jpeg"))); + JPEGQualityChooserWidget->setVisible(filter.contains(QLatin1String("jpeg")) || + filter.contains(QLatin1String("webp")) || + filter.contains(QLatin1String("avif")) || + filter.contains(QLatin1String("heif")) || + filter.contains(QLatin1String("heic")) ); }); // Show dialog diff --git a/doc/index.docbook b/doc/index.docbook index abe76126..12b93d16 100644 --- a/doc/index.docbook +++ b/doc/index.docbook @@ -739,9 +739,9 @@ Link an image.</para></listitem> </listitem> </varlistentry> <varlistentry> - <term><guilabel>JPEG save quality</guilabel></term> + <term><guilabel>Lossy image save quality</guilabel></term> <listitem> - <para>JPEG save/compression quality setting, which can be temporarily overridden in the <guilabel>Save As</guilabel> dialog when saving a file as a JPEG. When saving an existing JPEG file with a new name or after performing a non-lossy edit (⪚ rotation, which only changes the EXIF rotation tag), the appearance of the file is not changed because no actual image manipulation is done.</para> + <para>Save/compression quality setting for lossy image formats like JPEG, WEBP, AVIF, HEIF, and HEIC, which can be temporarily overridden in the <guilabel>Save As</guilabel> dialog when saving a file in a lossy image format. When saving an existing lossy image with a new name or after performing a non-lossy edit (⪚ rotation, which only changes the EXIF rotation tag), the appearance of the file is not changed because no actual image manipulation is done.</para> </listitem> </varlistentry> <varlistentry> diff --git a/lib/document/documentloadedimpl.cpp b/lib/document/documentloadedimpl.cpp index 285ded5f..fcffb46c 100644 --- a/lib/document/documentloadedimpl.cpp +++ b/lib/document/documentloadedimpl.cpp @@ -83,7 +83,12 @@ bool DocumentLoadedImpl::saveInternal(QIODevice* device, const QByteArray& forma { QImageWriter writer(device, format); // If we're saving a non-JPEG image as a JPEG, respect the quality setting - if (format == QByteArrayLiteral("jpeg")) { + if (format == QByteArrayLiteral("jpeg") || + format == QByteArrayLiteral("webp") || + format == QByteArrayLiteral("avif") || + format == QByteArrayLiteral("heif") || + format == QByteArrayLiteral("heic") + ) { writer.setQuality(GwenviewConfig::jPEGQuality()); } bool ok = writer.write(document()->image());