Add optional image rank/color load/save from/to xmp sidecar

Add optional ability to load/save image rank property from/to xmp
sidecar "xmp.Rating" and color property from xmp "xmp.Label" ignoring
the ones provided in the processing params file.

This behavior is disabled by default and an option under settings ->
file browser has been added to enable it.

When enabled:

* On load:
  * rank and color are not read from processing params.
  * rank is mapped from xmp sidecar file rating entry.
  * color is mapped from xmp sidecar file label entry.

* On save:
  * rank and color are saved to the xmp sidecar
  * rank and color are also saved to the processing param (pp3) files to
    keep them in sync

Rating mapping:

Since rating can be also -1 but rank only goes from 0 to 5, the -1 value
is ignored like already done when importing from embedded xmp data.

Color mapping:

XMP has no color concept, usually programs like digikam uses the label
field to write a color name ("Red", "Orange"). The problem is that this
isn't standardized and label can be any string. Additionally Rawtherapee
has 5 specific colors while other programs can have different colors
with different name so they won't be shown if they don't map to the 5
color names supported by rawtherapee. On save only the 5 color supported
by rawtherapee wil be saved.

Trash is kept only in the profile files for multiple reasons:

* There's no trash concept in xmp, there's the rejected concept assigned
  to a rating == -1.
* We could map rejected to trash but in rawtherapee rank and trash are two different values and
  an image can have both rank >= 0 and trashed set to true.
  Using an unique value like rating for rank and trash (when -1) will
  require changing the current rawtherapee logic.
* Also digikam only handles ratings from 0 to 5 (no -1) and handles
  trash in its own internal way without reflecting it in the xmp
  sidecar.
This commit is contained in:
Simone Gotti
2024-03-12 18:12:49 +01:00
parent 68fd35d881
commit 1098966a8b
9 changed files with 152 additions and 17 deletions

View File

@@ -1470,6 +1470,9 @@ Gtk::Widget* Preferences::getFileBrowserPanel()
vbro->pack_start(*sameThumbSize, Gtk::PACK_SHRINK, 0);
vbro->pack_start(*ckbInternalThumbIfUntouched, Gtk::PACK_SHRINK, 0);
thumbnailRankColorMode = Gtk::manage(new Gtk::CheckButton(M("PREFERENCES_THUMBNAIL_RANK_COLOR_MODE")));
vbro->pack_start(*thumbnailRankColorMode, Gtk::PACK_SHRINK, 0);
Gtk::Box* hbrecent = Gtk::manage(new Gtk::Box());
Gtk::Label* labrecent = Gtk::manage (new Gtk::Label (M("PREFERENCES_MAXRECENTFOLDERS") + ":", Gtk::ALIGN_START));
maxRecentFolders = Gtk::manage(new Gtk::SpinButton());
@@ -2029,6 +2032,8 @@ void Preferences::storePreferences()
moptions.rtSettings.metadata_xmp_sync = rtengine::Settings::MetadataXmpSync(metadataSyncCombo->get_active_row_number());
moptions.rtSettings.xmp_sidecar_style = rtengine::Settings::XmpSidecarStyle(xmpSidecarCombo->get_active_row_number());
moptions.thumbnailRankColorMode = thumbnailRankColorMode->get_active() ? Options::ThumbnailPropertyMode::XMP : Options::ThumbnailPropertyMode::PROCPARAMS;
}
void Preferences::fillPreferences()
@@ -2287,6 +2292,8 @@ void Preferences::fillPreferences()
metadataSyncCombo->set_active(int(moptions.rtSettings.metadata_xmp_sync));
xmpSidecarCombo->set_active(int(moptions.rtSettings.xmp_sidecar_style));
thumbnailRankColorMode->set_active(moptions.thumbnailRankColorMode == Options::ThumbnailPropertyMode::XMP);
}
/*