File indexing completed on 2025-01-05 03:56:01
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2008-09-24 0007 * Description : DNG save settings widgets 0008 * 0009 * SPDX-FileCopyrightText: 2008-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 "dngsettings.h" 0016 0017 // Qt includes 0018 0019 #include <QButtonGroup> 0020 #include <QCheckBox> 0021 #include <QGridLayout> 0022 #include <QLabel> 0023 #include <QRadioButton> 0024 #include <QVBoxLayout> 0025 #include <QComboBox> 0026 #include <QApplication> 0027 #include <QIcon> 0028 #include <QUrl> 0029 0030 // KDE includes 0031 0032 #include <klocalizedstring.h> 0033 0034 // Local includes 0035 0036 #include "dcombobox.h" 0037 #include "dngwriter.h" 0038 #include "exiftoolerrorview.h" 0039 #include "exiftoolparser.h" 0040 0041 namespace Digikam 0042 { 0043 0044 class Q_DECL_HIDDEN DNGSettings::Private 0045 { 0046 public: 0047 0048 explicit Private() 0049 : previewModeLabel (nullptr), 0050 compressLossLess (nullptr), 0051 backupOriginalRawFile(nullptr), 0052 previewModeCB (nullptr), 0053 errorView (nullptr) 0054 { 0055 } 0056 0057 QLabel* previewModeLabel; 0058 0059 QCheckBox* compressLossLess; 0060 QCheckBox* backupOriginalRawFile; 0061 0062 DComboBox* previewModeCB; 0063 0064 ExifToolErrorView* errorView; 0065 }; 0066 0067 DNGSettings::DNGSettings(QWidget* const parent) 0068 : QWidget(parent), 0069 d (new Private) 0070 { 0071 setAttribute(Qt::WA_DeleteOnClose); 0072 0073 const int spacing = qMin(QApplication::style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing), 0074 QApplication::style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing)); 0075 0076 QGridLayout* const settingsBoxLayout = new QGridLayout(this); 0077 0078 // ------------------------------------------------------------------------ 0079 0080 d->backupOriginalRawFile = new QCheckBox(i18n("Embed Original File"), this); 0081 d->compressLossLess = new QCheckBox(i18n("Lossless Compression"), this); 0082 0083 // ------------------------------------------------------------------------ 0084 0085 d->previewModeLabel = new QLabel(i18n("JPEG Preview:"), this); 0086 d->previewModeCB = new DComboBox(this); 0087 d->previewModeCB->insertItem(DNGWriter::NONE, i18nc("embedded preview type in dng file", "None")); 0088 d->previewModeCB->insertItem(DNGWriter::MEDIUM, i18nc("embedded preview type in dng file", "Medium")); 0089 d->previewModeCB->insertItem(DNGWriter::FULL_SIZE, i18nc("embedded preview type in dng file", "Full size")); 0090 d->previewModeCB->setDefaultIndex(DNGWriter::FULL_SIZE); 0091 0092 d->errorView = new ExifToolErrorView(this); 0093 d->errorView->setErrorText(i18n("Warning: ExifTool is not available to post-process metadata. " 0094 "Without ExifTool, DNG will not include all RAW source properties.")); 0095 0096 settingsBoxLayout->addWidget(d->backupOriginalRawFile, 0, 0, 1, 1); 0097 settingsBoxLayout->addWidget(d->compressLossLess, 1, 0, 1, 1); 0098 settingsBoxLayout->addWidget(d->previewModeLabel, 3 ,0, 1, 1); 0099 settingsBoxLayout->addWidget(d->previewModeCB, 4 ,0 ,1, 1); 0100 settingsBoxLayout->addWidget(d->errorView, 5 ,0 ,1, 1); 0101 settingsBoxLayout->setRowStretch(9, 10); 0102 settingsBoxLayout->setContentsMargins(spacing, spacing, spacing, spacing); 0103 settingsBoxLayout->setSpacing(spacing); 0104 0105 // ------------------------------------------------------------------------ 0106 0107 connect(d->backupOriginalRawFile, SIGNAL(toggled(bool)), 0108 this, SIGNAL(signalSettingsChanged())); 0109 0110 connect(d->compressLossLess, SIGNAL(toggled(bool)), 0111 this, SIGNAL(signalSettingsChanged())); 0112 0113 connect(d->previewModeCB, SIGNAL(activated(int)), 0114 this, SIGNAL(signalSettingsChanged())); 0115 0116 connect(d->errorView, SIGNAL(signalSetupExifTool()), 0117 this, SIGNAL(signalSetupExifTool())); 0118 0119 // ------------------------------------------------------------------------ 0120 0121 slotSetupChanged(); 0122 } 0123 0124 DNGSettings::~DNGSettings() 0125 { 0126 delete d; 0127 } 0128 0129 void DNGSettings::setDefaultSettings() 0130 { 0131 d->previewModeCB->slotReset(); 0132 setCompressLossLess(true); 0133 setBackupOriginalRawFile(false); 0134 } 0135 0136 void DNGSettings::setPreviewMode(int mode) 0137 { 0138 d->previewModeCB->setCurrentIndex(mode); 0139 } 0140 0141 int DNGSettings::previewMode() const 0142 { 0143 return d->previewModeCB->currentIndex(); 0144 } 0145 0146 void DNGSettings::setCompressLossLess(bool b) 0147 { 0148 d->compressLossLess->setChecked(b); 0149 } 0150 0151 bool DNGSettings::compressLossLess() const 0152 { 0153 return d->compressLossLess->isChecked(); 0154 } 0155 0156 void DNGSettings::setBackupOriginalRawFile(bool b) 0157 { 0158 d->backupOriginalRawFile->setChecked(b); 0159 } 0160 0161 bool DNGSettings::backupOriginalRawFile() const 0162 { 0163 return d->backupOriginalRawFile->isChecked(); 0164 } 0165 0166 void DNGSettings::slotSetupChanged() 0167 { 0168 QScopedPointer<ExifToolParser> const parser(new ExifToolParser(this)); 0169 0170 d->errorView->setVisible(!parser->exifToolAvailable()); 0171 } 0172 0173 } // namespace Digikam 0174 0175 #include "moc_dngsettings.cpp"