File indexing completed on 2025-01-19 03:51:24
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2006-10-12 0007 * Description : IPTC status settings page. 0008 * 0009 * SPDX-FileCopyrightText: 2006-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 "iptcstatus.h" 0016 0017 // Qt includes 0018 0019 #include <QCheckBox> 0020 #include <QLabel> 0021 #include <QGridLayout> 0022 #include <QApplication> 0023 #include <QStyle> 0024 #include <QLineEdit> 0025 #include <QToolTip> 0026 0027 // KDE includes 0028 0029 #include <klocalizedstring.h> 0030 0031 // Local includes 0032 0033 #include "dtextedit.h" 0034 #include "dlayoutbox.h" 0035 0036 namespace DigikamGenericMetadataEditPlugin 0037 { 0038 0039 class Q_DECL_HIDDEN IPTCStatus::Private 0040 { 0041 public: 0042 0043 explicit Private() 0044 : statusCheck (nullptr), 0045 jobIDCheck (nullptr), 0046 specialInstructionCheck (nullptr), 0047 objectNameCheck (nullptr), 0048 objectNameEdit (nullptr), 0049 statusEdit (nullptr), 0050 jobIDEdit (nullptr), 0051 specialInstructionEdit (nullptr) 0052 { 0053 } 0054 0055 QCheckBox* statusCheck; 0056 QCheckBox* jobIDCheck; 0057 QCheckBox* specialInstructionCheck; 0058 QCheckBox* objectNameCheck; 0059 0060 DPlainTextEdit* objectNameEdit; 0061 DPlainTextEdit* statusEdit; 0062 DPlainTextEdit* jobIDEdit; 0063 DPlainTextEdit* specialInstructionEdit; 0064 }; 0065 0066 IPTCStatus::IPTCStatus(QWidget* const parent) 0067 : MetadataEditPage(parent), 0068 d (new Private) 0069 { 0070 QGridLayout* const grid = new QGridLayout(widget()); 0071 0072 // -------------------------------------------------------- 0073 0074 d->objectNameCheck = new QCheckBox(i18nc("image title", "Title:"), this); 0075 d->objectNameEdit = new DPlainTextEdit(this); 0076 d->objectNameEdit->setMaxLength(64); 0077 d->objectNameEdit->setPlaceholderText(i18n("Set here the content title")); 0078 d->objectNameEdit->setWhatsThis(i18n("Set here the shorthand reference of content. " 0079 "This field is limited to 64 characters.")); 0080 0081 // -------------------------------------------------------- 0082 0083 d->statusCheck = new QCheckBox(i18n("Edit Status:"), this); 0084 d->statusEdit = new DPlainTextEdit(this); 0085 d->statusEdit->setMaxLength(64); 0086 d->statusEdit->setPlaceholderText(i18n("Set here the content status")); 0087 d->statusEdit->setWhatsThis(i18n("Set here the title of content status. This field is limited " 0088 "to 64 characters.")); 0089 0090 // -------------------------------------------------------- 0091 0092 d->jobIDCheck = new QCheckBox(i18n("Job Identifier:"), this); 0093 d->jobIDEdit = new DPlainTextEdit(this); 0094 d->jobIDEdit->setMaxLength(32); 0095 d->jobIDEdit->setPlaceholderText(i18n("Set here the job ID")); 0096 d->jobIDEdit->setWhatsThis(i18n("Set here the string that identifies content that recurs. " 0097 "This field is limited to 32 characters.")); 0098 0099 // -------------------------------------------------------- 0100 0101 d->specialInstructionCheck = new QCheckBox(i18n("Special Instructions:"), this); 0102 d->specialInstructionEdit = new DPlainTextEdit(this); 0103 d->specialInstructionEdit->setMaxLength(256); 0104 d->specialInstructionEdit->setPlaceholderText(i18n("Set here the content instructions")); 0105 d->specialInstructionEdit->setWhatsThis(i18n("Enter the editorial usage instructions. " 0106 "This field is limited to 256 characters.")); 0107 0108 // -------------------------------------------------------- 0109 0110 QLabel* const note = new QLabel(i18n("<b>Note: " 0111 "<a href='https://en.wikipedia.org/wiki/IPTC_Information_Interchange_Model'>IPTC</a> " 0112 "text tags are limited string sizes. Use contextual help for details. " 0113 "Consider to use <a href='https://en.wikipedia.org/wiki/Extensible_Metadata_Platform'>XMP</a> instead.</b>"), 0114 this); 0115 note->setOpenExternalLinks(true); 0116 note->setWordWrap(true); 0117 note->setFrameStyle(QFrame::StyledPanel | QFrame::Raised); 0118 0119 // -------------------------------------------------------- 0120 0121 grid->addWidget(d->objectNameCheck, 0, 0, 1, 3); 0122 grid->addWidget(d->objectNameEdit, 1, 0, 1, 3); 0123 grid->addWidget(d->statusCheck, 2, 0, 1, 3); 0124 grid->addWidget(d->statusEdit, 3, 0, 1, 3); 0125 grid->addWidget(d->jobIDCheck, 4, 0, 1, 3); 0126 grid->addWidget(d->jobIDEdit, 5, 0, 1, 3); 0127 grid->addWidget(d->specialInstructionCheck, 6, 0, 1, 3); 0128 grid->addWidget(d->specialInstructionEdit, 7, 0, 1, 3); 0129 grid->addWidget(note, 9, 0, 1, 3); 0130 grid->setColumnStretch(2, 10); 0131 grid->setRowStretch(10, 10); 0132 0133 int spacing = qMin(QApplication::style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing), 0134 QApplication::style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing)); 0135 0136 grid->setContentsMargins(spacing, spacing, spacing, spacing); 0137 grid->setSpacing(spacing); 0138 0139 // -------------------------------------------------------- 0140 0141 connect(d->objectNameCheck, SIGNAL(toggled(bool)), 0142 d->objectNameEdit, SLOT(setEnabled(bool))); 0143 0144 connect(d->statusCheck, SIGNAL(toggled(bool)), 0145 d->statusEdit, SLOT(setEnabled(bool))); 0146 0147 connect(d->jobIDCheck, SIGNAL(toggled(bool)), 0148 d->jobIDEdit, SLOT(setEnabled(bool))); 0149 0150 connect(d->specialInstructionCheck, SIGNAL(toggled(bool)), 0151 d->specialInstructionEdit, SLOT(setEnabled(bool))); 0152 0153 // -------------------------------------------------------- 0154 0155 connect(d->objectNameCheck, SIGNAL(toggled(bool)), 0156 this, SIGNAL(signalModified())); 0157 0158 connect(d->statusCheck, SIGNAL(toggled(bool)), 0159 this, SIGNAL(signalModified())); 0160 0161 connect(d->jobIDCheck, SIGNAL(toggled(bool)), 0162 this, SIGNAL(signalModified())); 0163 0164 connect(d->specialInstructionCheck, SIGNAL(toggled(bool)), 0165 this, SIGNAL(signalModified())); 0166 0167 // -------------------------------------------------------- 0168 0169 connect(d->objectNameEdit, SIGNAL(textChanged()), 0170 this, SIGNAL(signalModified())); 0171 0172 connect(d->statusEdit, SIGNAL(textChanged()), 0173 this, SIGNAL(signalModified())); 0174 0175 connect(d->jobIDEdit, SIGNAL(textChanged()), 0176 this, SIGNAL(signalModified())); 0177 0178 connect(d->specialInstructionEdit, SIGNAL(textChanged()), 0179 this, SIGNAL(signalModified())); 0180 } 0181 0182 IPTCStatus::~IPTCStatus() 0183 { 0184 delete d; 0185 } 0186 0187 void IPTCStatus::readMetadata(const DMetadata& meta) 0188 { 0189 blockSignals(true); 0190 0191 QString data; 0192 QStringList list; 0193 0194 d->objectNameEdit->clear(); 0195 d->objectNameCheck->setChecked(false); 0196 data = meta.getIptcTagString("Iptc.Application2.ObjectName", false); 0197 0198 if (!data.isNull()) 0199 { 0200 d->objectNameEdit->setText(data); 0201 d->objectNameCheck->setChecked(true); 0202 } 0203 0204 d->objectNameEdit->setEnabled(d->objectNameCheck->isChecked()); 0205 0206 d->statusEdit->clear(); 0207 d->statusCheck->setChecked(false); 0208 data = meta.getIptcTagString("Iptc.Application2.EditStatus", false); 0209 0210 if (!data.isNull()) 0211 { 0212 d->statusEdit->setText(data); 0213 d->statusCheck->setChecked(true); 0214 } 0215 0216 d->statusEdit->setEnabled(d->statusCheck->isChecked()); 0217 0218 d->jobIDEdit->clear(); 0219 d->jobIDCheck->setChecked(false); 0220 data = meta.getIptcTagString("Iptc.Application2.FixtureId", false); 0221 0222 if (!data.isNull()) 0223 { 0224 d->jobIDEdit->setText(data); 0225 d->jobIDCheck->setChecked(true); 0226 } 0227 0228 d->jobIDEdit->setEnabled(d->jobIDCheck->isChecked()); 0229 0230 d->specialInstructionEdit->clear(); 0231 d->specialInstructionCheck->setChecked(false); 0232 data = meta.getIptcTagString("Iptc.Application2.SpecialInstructions", false); 0233 0234 if (!data.isNull()) 0235 { 0236 d->specialInstructionEdit->setPlainText(data); 0237 d->specialInstructionCheck->setChecked(true); 0238 } 0239 0240 d->specialInstructionEdit->setEnabled(d->specialInstructionCheck->isChecked()); 0241 0242 blockSignals(false); 0243 } 0244 0245 void IPTCStatus::applyMetadata(const DMetadata& meta) 0246 { 0247 if (d->objectNameCheck->isChecked()) 0248 meta.setIptcTagString("Iptc.Application2.ObjectName", d->objectNameEdit->text()); 0249 else 0250 meta.removeIptcTag("Iptc.Application2.ObjectName"); 0251 0252 if (d->statusCheck->isChecked()) 0253 meta.setIptcTagString("Iptc.Application2.EditStatus", d->statusEdit->text()); 0254 else 0255 meta.removeIptcTag("Iptc.Application2.EditStatus"); 0256 0257 if (d->jobIDCheck->isChecked()) 0258 meta.setIptcTagString("Iptc.Application2.FixtureId", d->jobIDEdit->text()); 0259 else 0260 meta.removeIptcTag("Iptc.Application2.FixtureId"); 0261 0262 if (d->specialInstructionCheck->isChecked()) 0263 meta.setIptcTagString("Iptc.Application2.SpecialInstructions", d->specialInstructionEdit->toPlainText()); 0264 else 0265 meta.removeIptcTag("Iptc.Application2.SpecialInstructions"); 0266 } 0267 0268 } // namespace DigikamGenericMetadataEditPlugin 0269 0270 #include "moc_iptcstatus.cpp"