File indexing completed on 2025-01-05 03:56:30
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2010-08-20 0007 * Description : MetaEngine Settings Container. 0008 * 0009 * SPDX-FileCopyrightText: 2010-2024 by Gilles Caulier <caulier dot gilles at gmail dot com> 0010 * 0011 * SPDX-License-Identifier: GPL-2.0-or-later 0012 * 0013 * ============================================================ */ 0014 0015 #include "metaenginesettingscontainer.h" 0016 0017 // Qt includes 0018 0019 0020 // KDE includes 0021 0022 #include <kconfiggroup.h> 0023 0024 // Local includes 0025 0026 #include "metaenginesettings.h" 0027 #include "digikam_globals.h" 0028 0029 namespace Digikam 0030 { 0031 0032 MetaEngineSettingsContainer::MetaEngineSettingsContainer() 0033 : exifRotate (true), 0034 exifSetOrientation (true), 0035 saveComments (false), 0036 saveDateTime (false), 0037 savePickLabel (false), 0038 saveColorLabel (false), 0039 saveRating (false), 0040 saveTemplate (false), 0041 saveTags (false), 0042 saveFaceTags (false), 0043 savePosition (false), 0044 writeWithExifTool (false), 0045 writeRawFiles (false), 0046 writeDngFiles (false), 0047 updateFileTimeStamp (true), 0048 rescanImageIfModified (false), 0049 useXMPSidecar4Reading (false), 0050 useCompatibleFileName (false), 0051 useLazySync (false), 0052 useFastScan (false), 0053 metadataWritingMode (MetaEngine::WRITE_TO_FILE_ONLY), 0054 rotationBehavior (RotatingFlags | RotateByLosslessRotation), 0055 albumDateFrom (OldestItemDate), 0056 sidecarExtensions (QStringList()) 0057 { 0058 } 0059 0060 MetaEngineSettingsContainer::~MetaEngineSettingsContainer() 0061 { 0062 } 0063 0064 void MetaEngineSettingsContainer::readFromConfig(KConfigGroup& group) 0065 { 0066 exifRotate = group.readEntry("EXIF Rotate", true); 0067 exifSetOrientation = group.readEntry("EXIF Set Orientation", true); 0068 0069 saveTags = group.readEntry("Save Tags", false); 0070 saveTemplate = group.readEntry("Save Template", false); 0071 saveFaceTags = group.readEntry("Save FaceTags", false); 0072 savePosition = group.readEntry("Save Position", false); 0073 0074 saveComments = group.readEntry("Save EXIF Comments", false); 0075 saveDateTime = group.readEntry("Save Date Time", false); 0076 savePickLabel = group.readEntry("Save Pick Label", false); 0077 saveColorLabel = group.readEntry("Save Color Label", false); 0078 saveRating = group.readEntry("Save Rating", false); 0079 0080 writeWithExifTool = group.readEntry("Write Metadata To Files With ExifTool", false); 0081 writeRawFiles = group.readEntry("Write Metadata To RAW Files", false); 0082 writeDngFiles = group.readEntry("Write Metadata To DNG Files", false); 0083 0084 useXMPSidecar4Reading = group.readEntry("Use XMP Sidecar For Reading", false); 0085 useCompatibleFileName = group.readEntry("Use Compatible File Name", false); 0086 metadataWritingMode = (MetaEngine::MetadataWritingMode) 0087 group.readEntry("Metadata Writing Mode", (int)MetaEngine::WRITE_TO_FILE_ONLY); 0088 updateFileTimeStamp = group.readEntry("Update File Timestamp", true); 0089 rescanImageIfModified = group.readEntry("Rescan File If Modified", false); 0090 useLazySync = group.readEntry("Use Lazy Synchronization", false); 0091 useFastScan = group.readEntry("Use Fast Scan At Startup", false); 0092 0093 rotationBehavior = NoRotation; 0094 0095 sidecarExtensions = group.readEntry("Custom Sidecar Extensions", QStringList()); 0096 0097 exifToolPath = group.readEntry("ExifTool Path", defaultExifToolSearchPaths().first()); 0098 0099 if (group.readEntry("Rotate By Internal Flag", true)) 0100 { 0101 rotationBehavior |= RotateByInternalFlag; 0102 } 0103 0104 if (group.readEntry("Rotate By Metadata Flag", true)) 0105 { 0106 rotationBehavior |= RotateByMetadataFlag; 0107 } 0108 0109 if (group.readEntry("Rotate Contents Lossless", true)) 0110 { 0111 rotationBehavior |= RotateByLosslessRotation; 0112 } 0113 0114 if (group.readEntry("Rotate Contents Lossy", false)) 0115 { 0116 rotationBehavior |= RotateByLossyRotation; 0117 } 0118 0119 albumDateFrom = (AlbumDateSource) 0120 group.readEntry("Album Date Source", (int)OldestItemDate); 0121 } 0122 0123 void MetaEngineSettingsContainer::writeToConfig(KConfigGroup& group) const 0124 { 0125 group.writeEntry("EXIF Rotate", exifRotate); 0126 group.writeEntry("EXIF Set Orientation", exifSetOrientation); 0127 0128 group.writeEntry("Save Tags", saveTags); 0129 group.writeEntry("Save Template", saveTemplate); 0130 group.writeEntry("Save FaceTags", saveFaceTags); 0131 group.writeEntry("Save Position", savePosition); 0132 0133 group.writeEntry("Save EXIF Comments", saveComments); 0134 group.writeEntry("Save Date Time", saveDateTime); 0135 group.writeEntry("Save Pick Label", savePickLabel); 0136 group.writeEntry("Save Color Label", saveColorLabel); 0137 group.writeEntry("Save Rating", saveRating); 0138 0139 group.writeEntry("Write Metadata To Files With ExifTool", writeWithExifTool); 0140 group.writeEntry("Write Metadata To RAW Files", writeRawFiles); 0141 group.writeEntry("Write Metadata To DNG Files", writeDngFiles); 0142 0143 group.writeEntry("Use XMP Sidecar For Reading", useXMPSidecar4Reading); 0144 group.writeEntry("Use Compatible File Name", useCompatibleFileName); 0145 group.writeEntry("Metadata Writing Mode", (int)metadataWritingMode); 0146 group.writeEntry("Update File Timestamp", updateFileTimeStamp); 0147 group.writeEntry("Rescan File If Modified", rescanImageIfModified); 0148 0149 group.writeEntry("Rotate By Internal Flag", bool(rotationBehavior & RotateByInternalFlag)); 0150 group.writeEntry("Rotate By Metadata Flag", bool(rotationBehavior & RotateByMetadataFlag)); 0151 group.writeEntry("Rotate Contents Lossless", bool(rotationBehavior & RotateByLosslessRotation)); 0152 group.writeEntry("Rotate Contents Lossy", bool(rotationBehavior & RotateByLossyRotation)); 0153 group.writeEntry("Album Date Source", (int)albumDateFrom); 0154 group.writeEntry("Use Lazy Synchronization", useLazySync); 0155 group.writeEntry("Use Fast Scan At Startup", useFastScan); 0156 0157 group.writeEntry("Custom Sidecar Extensions", sidecarExtensions); 0158 0159 group.writeEntry("ExifTool Path", exifToolPath); 0160 } 0161 0162 QStringList MetaEngineSettingsContainer::defaultExifToolSearchPaths() const 0163 { 0164 QStringList defPaths; 0165 0166 #ifdef Q_OS_MACOS 0167 0168 // Install path for the official ExifTool DMG package 0169 defPaths << QLatin1String("/usr/local/bin"); 0170 0171 // digiKam Bundle PKG install path 0172 defPaths << macOSBundlePrefix() + QLatin1String("bin"); 0173 0174 // Std Macports install path 0175 defPaths << QLatin1String("/opt/local/bin"); 0176 0177 #endif 0178 0179 #ifdef Q_OS_WIN 0180 0181 defPaths << QLatin1String("C:/Program Files/digiKam"); 0182 0183 #endif 0184 0185 #ifdef Q_OS_UNIX 0186 0187 defPaths << QLatin1String("/usr/bin"); 0188 defPaths << QLatin1String("/usr/local/bin"); 0189 defPaths << QLatin1String("/bin"); 0190 0191 #endif 0192 0193 return defPaths; 0194 } 0195 0196 QDebug operator<<(QDebug dbg, const MetaEngineSettingsContainer& inf) 0197 { 0198 dbg.nospace() << "[MetaEngineSettingsContainer] exifRotate(" 0199 << inf.exifRotate << "), "; 0200 dbg.nospace() << "exifSetOrientation(" 0201 << inf.exifSetOrientation << "), "; 0202 dbg.nospace() << "saveComments(" 0203 << inf.saveComments << "), "; 0204 dbg.nospace() << "saveDateTime(" 0205 << inf.saveDateTime << "), "; 0206 dbg.nospace() << "savePickLabel(" 0207 << inf.saveColorLabel << "), "; 0208 dbg.nospace() << "saveColorLabel(" 0209 << inf.savePickLabel << "), "; 0210 dbg.nospace() << "saveRating(" 0211 << inf.saveRating << "), "; 0212 dbg.nospace() << "saveTemplate(" 0213 << inf.saveTemplate << "), "; 0214 dbg.nospace() << "saveTags(" 0215 << inf.saveTags << "), "; 0216 dbg.nospace() << "saveFaceTags(" 0217 << inf.saveFaceTags << "), "; 0218 dbg.nospace() << "savePosition(" 0219 << inf.savePosition << "), "; 0220 dbg.nospace() << "writeWithExifTool(" 0221 << inf.writeWithExifTool << "), "; 0222 dbg.nospace() << "writeRawFiles(" 0223 << inf.writeRawFiles << "), "; 0224 dbg.nospace() << "writeDngFiles(" 0225 << inf.writeDngFiles << "), "; 0226 dbg.nospace() << "updateFileTimeStamp(" 0227 << inf.updateFileTimeStamp << "), "; 0228 dbg.nospace() << "rescanImageIfModified(" 0229 << inf.rescanImageIfModified << "), "; 0230 dbg.nospace() << "useXMPSidecar4Reading(" 0231 << inf.useXMPSidecar4Reading << "), "; 0232 dbg.nospace() << "useCompatibleFileName(" 0233 << inf.useCompatibleFileName << "), "; 0234 dbg.nospace() << "useLazySync(" 0235 << inf.useLazySync << "), "; 0236 dbg.nospace() << "metadataWritingMode(" 0237 << inf.metadataWritingMode << "), "; 0238 dbg.nospace() << "rotationBehavior(" 0239 << inf.rotationBehavior << "), "; 0240 dbg.nospace() << "sidecarExtensions(" 0241 << inf.sidecarExtensions << ")"; 0242 0243 return dbg.space(); 0244 } 0245 0246 } // namespace Digikam