File indexing completed on 2025-01-19 03:59:45

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2003-08-03
0007  * Description : setup Metadata tab.
0008  *
0009  * SPDX-FileCopyrightText: 2003-2004 by Ralf Holzer <ralf at well dot com>
0010  * SPDX-FileCopyrightText: 2003-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
0011  * SPDX-FileCopyrightText: 2009-2012 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
0012  * SPDX-FileCopyrightText: 2017      by Simon Frei <freisim93 at gmail dot com>
0013  *
0014  * SPDX-License-Identifier: GPL-2.0-or-later
0015  *
0016  * ============================================================ */
0017 
0018 #include "setupmetadata_p.h"
0019 
0020 namespace Digikam
0021 {
0022 
0023 SetupMetadata::Private::Private()
0024   : exifAutoRotateOriginal   (false),
0025     exifAutoRotateShowedInfo (false),
0026     sidecarFileNameShowedInfo(false),
0027     fieldsGroup              (nullptr),
0028     readWriteGroup           (nullptr),
0029     rotationGroup            (nullptr),
0030     rotationAdvGroup         (nullptr),
0031     saveTagsBox              (nullptr),
0032     saveCommentsBox          (nullptr),
0033     saveRatingBox            (nullptr),
0034     savePickLabelBox         (nullptr),
0035     saveColorLabelBox        (nullptr),
0036     saveDateTimeBox          (nullptr),
0037     saveTemplateBox          (nullptr),
0038     saveFaceTags             (nullptr),
0039     savePosition             (nullptr),
0040     useLazySync              (nullptr),
0041     writeWithExifToolBox     (nullptr),
0042     writeDngFilesBox         (nullptr),
0043     writeRawFilesBox         (nullptr),
0044     writeWithExifToolLabel   (nullptr),
0045     writeXMPSidecarBox       (nullptr),
0046     readXMPSidecarBox        (nullptr),
0047     sidecarFileNameBox       (nullptr),
0048     updateFileTimeStampBox   (nullptr),
0049     rescanImageIfModifiedBox (nullptr),
0050     writingModeCombo         (nullptr),
0051     rotateByFlag             (nullptr),
0052     rotateByContents         (nullptr),
0053     allowRotateByMetadata    (nullptr),
0054     allowLossyRotate         (nullptr),
0055     exifRotateBox            (nullptr),
0056     exifSetOrientationBox    (nullptr),
0057     saveToBalooBox           (nullptr),
0058     readFromBalooBox         (nullptr),
0059     tab                      (nullptr),
0060     displaySubTab            (nullptr),
0061     tagsCfgPanel             (nullptr),
0062     advTab                   (nullptr),
0063     exifToolView             (nullptr),
0064     extensionsEdit           (nullptr)
0065 {
0066 }
0067 
0068 void SetupMetadata::Private::readSettings()
0069 {
0070     MetaEngineSettings* const mSettings = MetaEngineSettings::instance();
0071 
0072     if (!mSettings)
0073     {
0074         return;
0075     }
0076 
0077     MetaEngineSettingsContainer set = mSettings->settings();
0078 
0079     if (set.rotationBehavior & MetaEngineSettingsContainer::RotatingPixels)
0080     {
0081         rotateByContents->setChecked(true);
0082     }
0083     else
0084     {
0085         rotateByFlag->setChecked(true);
0086     }
0087 
0088     allowRotateByMetadata->setChecked(set.rotationBehavior & MetaEngineSettingsContainer::RotateByMetadataFlag);
0089     allowLossyRotate->setChecked(set.rotationBehavior & MetaEngineSettingsContainer::RotateByLossyRotation);
0090 
0091     exifAutoRotateOriginal       = set.exifRotate;
0092     exifRotateBox->setChecked(exifAutoRotateOriginal);
0093     exifSetOrientationBox->setChecked(set.exifSetOrientation);
0094 
0095     saveTagsBox->setChecked(set.saveTags);
0096     saveCommentsBox->setChecked(set.saveComments);
0097     saveRatingBox->setChecked(set.saveRating);
0098     savePickLabelBox->setChecked(set.savePickLabel);
0099     saveColorLabelBox->setChecked(set.saveColorLabel);
0100     saveDateTimeBox->setChecked(set.saveDateTime);
0101     saveTemplateBox->setChecked(set.saveTemplate);
0102     saveFaceTags->setChecked(set.saveFaceTags);
0103     savePosition->setChecked(set.savePosition);
0104 
0105     writeWithExifToolBox->setChecked(set.writeWithExifTool);
0106     writeDngFilesBox->setChecked(set.writeDngFiles);
0107     writeRawFilesBox->setChecked(set.writeRawFiles);
0108 
0109     useLazySync->setChecked(set.useLazySync);
0110     readXMPSidecarBox->setChecked(set.useXMPSidecar4Reading);
0111     sidecarFileNameBox->setChecked(set.useCompatibleFileName);
0112     updateFileTimeStampBox->setChecked(set.updateFileTimeStamp);
0113     rescanImageIfModifiedBox->setChecked(set.rescanImageIfModified);
0114 
0115     if (set.metadataWritingMode == MetaEngine::WRITE_TO_FILE_ONLY)
0116     {
0117         writeXMPSidecarBox->setChecked(false);
0118     }
0119     else
0120     {
0121         writeXMPSidecarBox->setChecked(true);
0122         writingModeCombo->setCurrentIndex(writingModeCombo->findData(set.metadataWritingMode));
0123     }
0124 
0125     extensionsEdit->setText(set.sidecarExtensions.join(QLatin1Char(' ')));
0126 
0127     exifToolView->setExifToolDirectory(set.exifToolPath);
0128 
0129 #ifdef HAVE_KFILEMETADATA
0130 
0131     ApplicationSettings* const aSettings = ApplicationSettings::instance();
0132 
0133     if (!aSettings)
0134     {
0135         return;
0136     }
0137 
0138     saveToBalooBox->setChecked(aSettings->getSyncDigikamToBaloo());
0139     readFromBalooBox->setChecked(aSettings->getSyncBalooToDigikam());
0140 
0141 #endif // HAVE_KFILEMETADATA
0142 
0143 }
0144 
0145 } // namespace Digikam