File indexing completed on 2025-01-19 03:51:26
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2018-07-30 0007 * Description : a plugin to edit items metadata. 0008 * 0009 * SPDX-FileCopyrightText: 2018-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 "metadataeditplugin.h" 0016 0017 // Qt includes 0018 0019 #include <QPointer> 0020 0021 // KDE includes 0022 0023 #include <klocalizedstring.h> 0024 0025 // Local includes 0026 0027 #include "metadataeditdialog.h" 0028 0029 namespace DigikamGenericMetadataEditPlugin 0030 { 0031 0032 MetadataEditPlugin::MetadataEditPlugin(QObject* const parent) 0033 : DPluginGeneric(parent) 0034 { 0035 } 0036 0037 MetadataEditPlugin::~MetadataEditPlugin() 0038 { 0039 } 0040 0041 QString MetadataEditPlugin::name() const 0042 { 0043 return i18nc("@title", "Metadata Edit"); 0044 } 0045 0046 QString MetadataEditPlugin::iid() const 0047 { 0048 return QLatin1String(DPLUGIN_IID); 0049 } 0050 0051 QIcon MetadataEditPlugin::icon() const 0052 { 0053 return QIcon::fromTheme(QLatin1String("format-text-code")); 0054 } 0055 0056 QString MetadataEditPlugin::description() const 0057 { 0058 return i18nc("@info", "A tool to edit items metadata"); 0059 } 0060 0061 QString MetadataEditPlugin::details() const 0062 { 0063 return i18nc("@info", "This tool allows users to changes plenty of metadata from items.\n\n" 0064 "Most common Exif, Iptc, and Xmp tags used in photography are listed for editing with standardized values.\n\n" 0065 "For photo agencies, pre-configured subjects can be used to describe the items contents based on Iptc reference codes."); 0066 } 0067 0068 QString MetadataEditPlugin::handbookSection() const 0069 { 0070 return QLatin1String("post_processing"); 0071 } 0072 0073 QString MetadataEditPlugin::handbookChapter() const 0074 { 0075 return QLatin1String("metadata_editor"); 0076 } 0077 0078 QList<DPluginAuthor> MetadataEditPlugin::authors() const 0079 { 0080 return QList<DPluginAuthor>() 0081 << DPluginAuthor(QString::fromUtf8("Victor Dodon"), 0082 QString::fromUtf8("victor dot dodon at cti dot pub dot ro"), 0083 QString::fromUtf8("(C) 2010-2012")) 0084 << DPluginAuthor(QString::fromUtf8("Gilles Caulier"), 0085 QString::fromUtf8("caulier dot gilles at gmail dot com"), 0086 QString::fromUtf8("(C) 2006-2022")) 0087 << DPluginAuthor(QString::fromUtf8("Alan Pater"), 0088 QString::fromUtf8("alan dot pater at gmail dot com"), 0089 QString::fromUtf8("(C) 2014")) 0090 << DPluginAuthor(QString::fromUtf8("Andi Clemens"), 0091 QString::fromUtf8("andi dot clemens at googlemail dot com"), 0092 QString::fromUtf8("(C) 2009")) 0093 ; 0094 } 0095 0096 void MetadataEditPlugin::setup(QObject* const parent) 0097 { 0098 DPluginAction* const ac = new DPluginAction(parent); 0099 ac->setIcon(icon()); 0100 ac->setText(i18nc("@action", "Edit Metadata...")); 0101 ac->setObjectName(QLatin1String("metadata_edit")); 0102 ac->setActionCategory(DPluginAction::GenericMetadata); 0103 ac->setShortcut(Qt::CTRL | Qt::SHIFT | Qt::Key_M); 0104 0105 connect(ac, SIGNAL(triggered(bool)), 0106 this, SLOT(slotEditMetadata())); 0107 0108 addAction(ac); 0109 } 0110 0111 void MetadataEditPlugin::slotEditMetadata() 0112 { 0113 DInfoInterface* const iface = infoIface(sender()); 0114 0115 if (!iface) 0116 { 0117 return; 0118 } 0119 0120 QList<QUrl> urls = iface->currentSelectedItems(); 0121 0122 if (urls.isEmpty()) 0123 { 0124 return; 0125 } 0126 0127 QPointer<MetadataEditDialog> dialog = new MetadataEditDialog(nullptr, iface); 0128 dialog->setPlugin(this); 0129 dialog->exec(); 0130 delete dialog; 0131 } 0132 0133 } // namespace DigikamGenericMetadataEditPlugin 0134 0135 #include "moc_metadataeditplugin.cpp"