[graphics/krita] /: Make diffusewhite use profile diffuse white if possible.

Wolthera van Hövell <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit a2e264f3d79e7b117065ab8a936f1828c448409e by Wolthera van Hövell, on behalf of Wolthera van Hövell tot Westerflier.
Committed on 07/08/2026 at 09:24.
Pushed by woltherav into branch 'master'.

Make diffusewhite use profile diffuse white if possible.

Also change the spinbox to a combobox to limit the options.

M  +1    -1    libs/image/commands_new/KisChangeImageHdrDiffuseWhiteCommand.cpp
M  +7    -0    libs/image/kis_image.cc
M  +12   -4    libs/ui/dialogs/kis_dlg_image_properties.cc
M  +7    -14   libs/ui/forms/wdgimageproperties.ui
M  +1    -1    plugins/impex/libkra/kis_kra_saver.cpp

https://invent.kde.org/graphics/krita/-/commit/a2e264f3d79e7b117065ab8a936f1828c448409e

diff --git a/libs/image/commands_new/KisChangeImageHdrDiffuseWhiteCommand.cpp b/libs/image/commands_new/KisChangeImageHdrDiffuseWhiteCommand.cpp
index c0e17ac6ee1..9971df271d5 100644
--- a/libs/image/commands_new/KisChangeImageHdrDiffuseWhiteCommand.cpp
+++ b/libs/image/commands_new/KisChangeImageHdrDiffuseWhiteCommand.cpp
@@ -16,7 +16,7 @@ KisChangeImageHdrDiffuseWhiteCommand::KisChangeImageHdrDiffuseWhiteCommand(KisIm
 {
     KisImageSP img = m_image.toStrongRef();
     if (img) {
-        m_diffuseWhite = img->diffuseWhiteLightLevel();
+        m_oldDiffuseWhite = img->diffuseWhiteLightLevel();
     }
 }
 
diff --git a/libs/image/kis_image.cc b/libs/image/kis_image.cc
index 63ecbdf6965..80600376811 100644
--- a/libs/image/kis_image.cc
+++ b/libs/image/kis_image.cc
@@ -2118,11 +2118,18 @@ void KisImage::setColorVolumeInformation(const std::optional<KisColorVolumeInfor
 
 std::optional<double> KisImage::diffuseWhiteLightLevel() const
 {
+    if (m_d->colorSpace->profile()->hdrReferenceWhite()) {
+        return m_d->colorSpace->profile()->hdrReferenceWhite();
+    }
     return m_d->diffuseWhiteLightLevel;
 }
 
 void KisImage::setDiffuseWhiteLightLevel(const std::optional<double> cdm2)
 {
+    if (m_d->colorSpace->profile()->hdrReferenceWhite()) {
+        qWarning() << "Cannot set diffuse white on image: profile provides the diffuse white for this image.";
+        return;
+    }
     if (!m_d->diffuseWhiteLightLevel ||
         !qFuzzyCompare(*m_d->diffuseWhiteLightLevel, *cdm2)) {
         m_d->diffuseWhiteLightLevel = cdm2;
diff --git a/libs/ui/dialogs/kis_dlg_image_properties.cc b/libs/ui/dialogs/kis_dlg_image_properties.cc
index 21c952f3b7f..246db42774e 100644
--- a/libs/ui/dialogs/kis_dlg_image_properties.cc
+++ b/libs/ui/dialogs/kis_dlg_image_properties.cc
@@ -130,8 +130,11 @@ KisDlgImageProperties::KisDlgImageProperties(KisImageWSP image, KisDisplayColorC
     connect(d->image, &KisImage::sigDiffuseWhiteLightLevelChanged, this, &KisDlgImageProperties::updateHDRLightLevels);
     connect(d->image, &KisImage::sigColorVolumeInformationChanged, this, &KisDlgImageProperties::updateHDRColorVolume);
 
+    m_page->cmbDiffuseWhite->addItem(i18n("80 cd/m²"), 80.0);
+    m_page->cmbDiffuseWhite->addItem(i18n("203 cd/m²"), 203.0);
+
     connect(m_page->gbxDiffuseWhite, &QGroupBox::clicked, this, &KisDlgImageProperties::setHDRDiffuseLevelOnImage);
-    connect(m_page->spnDiffuseWhite, &QDoubleSpinBox::valueChanged, this, &KisDlgImageProperties::setHDRDiffuseLevelOnImage);
+    connect(m_page->cmbDiffuseWhite, SIGNAL(activated(int)), this, SLOT(setHDRDiffuseLevelOnImage()));
 
     connect(m_page->gbxContentLightLevel, &QGroupBox::clicked, this, &KisDlgImageProperties::setHDRLightLevelsOnImage);
     connect(m_page->spnMaxCll, &QDoubleSpinBox::valueChanged, this, &KisDlgImageProperties::setHDRLightLevelsOnImage);
@@ -254,10 +257,15 @@ void KisDlgImageProperties::updateHDRLightLevels()
 {
     if (d->image->diffuseWhiteLightLevel()) {
         m_page->gbxDiffuseWhite->setChecked(true);
-        m_page->spnDiffuseWhite->setValue(*d->image->diffuseWhiteLightLevel());
+        m_page->cmbDiffuseWhite->setCurrentIndex(m_page->cmbDiffuseWhite->findData(*d->image->diffuseWhiteLightLevel()));
+        if (d->image->colorSpace()->profile()->hdrReferenceWhite()) {
+            m_page->gbxDiffuseWhite->setEnabled(false);
+            m_page->cmbDiffuseWhite->setEnabled(false);
+        }
+
     } else {
         m_page->gbxDiffuseWhite->setChecked(false);
-        m_page->spnDiffuseWhite->setValue(80);
+        m_page->cmbDiffuseWhite->setCurrentIndex(0);
     }
     if (d->image->relativeContentLightLevelInformation()) {
         m_page->gbxContentLightLevel->setChecked(true);
@@ -318,7 +326,7 @@ void KisDlgImageProperties::setHDRDiffuseLevelOnImage()
 {
     KUndo2Command *cmd;
     if (m_page->gbxDiffuseWhite->isChecked()) {
-        cmd = new KisChangeImageHdrDiffuseWhiteCommand(d->image, std::make_optional(m_page->spnDiffuseWhite->value()));
+        cmd = new KisChangeImageHdrDiffuseWhiteCommand(d->image, std::make_optional(m_page->cmbDiffuseWhite->currentData().toDouble()));
     } else {
         cmd = new KisChangeImageHdrDiffuseWhiteCommand(d->image, std::nullopt);
     }
diff --git a/libs/ui/forms/wdgimageproperties.ui b/libs/ui/forms/wdgimageproperties.ui
index 8de9c45a966..c16a41e6a76 100644
--- a/libs/ui/forms/wdgimageproperties.ui
+++ b/libs/ui/forms/wdgimageproperties.ui
@@ -315,14 +315,7 @@
          </property>
          <layout class="QVBoxLayout" name="verticalLayout_8">
           <item>
-           <widget class="QDoubleSpinBox" name="spnDiffuseWhite">
-            <property name="suffix">
-             <string>cd/m²</string>
-            </property>
-            <property name="maximum">
-             <double>10000.000000000000000</double>
-            </property>
-           </widget>
+           <widget class="QComboBox" name="cmbDiffuseWhite"/>
           </item>
          </layout>
         </widget>
@@ -671,17 +664,17 @@
   </layout>
  </widget>
  <customwidgets>
-  <customwidget>
-   <class>KisColorButton</class>
-   <extends>QPushButton</extends>
-   <header>kis_color_button.h</header>
-  </customwidget>
   <customwidget>
    <class>KisColorSpaceSelector</class>
    <extends>QWidget</extends>
-   <header>widgets/kis_color_space_selector.h</header>
+   <header>kis_color_space_selector.h</header>
    <container>1</container>
   </customwidget>
+  <customwidget>
+   <class>KisColorButton</class>
+   <extends>QPushButton</extends>
+   <header>kis_color_button.h</header>
+  </customwidget>
   <customwidget>
    <class>KisDoubleSliderSpinBox</class>
    <extends>QDoubleSpinBox</extends>
diff --git a/plugins/impex/libkra/kis_kra_saver.cpp b/plugins/impex/libkra/kis_kra_saver.cpp
index 1db647a6349..e3c7f379ef2 100644
--- a/plugins/impex/libkra/kis_kra_saver.cpp
+++ b/plugins/impex/libkra/kis_kra_saver.cpp
@@ -709,7 +709,7 @@ void KisKraSaver::saveHDRMetadata(QDomDocument &doc, QDomElement &element, KisIm
         return;
     }
     QDomElement hdr = doc.createElement(HDRMETADATA);
-    if (image->diffuseWhiteLightLevel()) {
+    if (image->diffuseWhiteLightLevel() && !image->colorSpace()->profile()->hdrReferenceWhite()) {
         KisDomUtils::saveValue(&hdr, DIFFUSEWHITE, *image->diffuseWhiteLightLevel());
     }
     if (image->relativeContentLightLevelInformation()) {
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.