Commit 9aa9b09a authored by Nate Graham's avatar Nate Graham 🔩
Browse files

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
parent 21013f96
......@@ -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);
......
......@@ -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>
......
......@@ -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
......
......@@ -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 (&eg; 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 (&eg; 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>
......
......@@ -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());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment