File indexing completed on 2025-01-19 03:53:02

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2021-03-20
0007  * Description : a tool to export images to iNaturalist web service
0008  *
0009  * SPDX-FileCopyrightText: 2021-2022 by Joerg Lohse <joergmlpts at gmail dot com>
0010  *
0011  * SPDX-License-Identifier: GPL-2.0-or-later
0012  *
0013  * ============================================================ */
0014 
0015 #include "inatplugin.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 "inatwindow.h"
0028 
0029 namespace DigikamGenericINatPlugin
0030 {
0031 
0032 INatPlugin::INatPlugin(QObject* const parent)
0033     : DPluginGeneric(parent)
0034 {
0035 }
0036 
0037 INatPlugin::~INatPlugin()
0038 {
0039 }
0040 
0041 void INatPlugin::cleanUp()
0042 {
0043     delete m_toolDlg;
0044 }
0045 
0046 QString INatPlugin::name() const
0047 {
0048     return i18nc("@title", "iNaturalist");
0049 }
0050 
0051 QString INatPlugin::iid() const
0052 {
0053     return QLatin1String(DPLUGIN_IID);
0054 }
0055 
0056 QIcon INatPlugin::icon() const
0057 {
0058     return QIcon::fromTheme(QLatin1String("dk-inat"));
0059 }
0060 
0061 QString INatPlugin::description() const
0062 {
0063     return i18nc("@info",
0064                  "A tool to export photos as iNaturalist observations.");
0065 }
0066 
0067 QString INatPlugin::details() const
0068 {
0069     return i18nc("@info",
0070                  "This tool exports photos as iNaturalist observations.\n\n"
0071                  "See iNaturalist web site for details: %1.",
0072                  QLatin1String("<a href='https://www.inaturalist.org/'>"
0073                                "https://www.inaturalist.org/</a>"));
0074 }
0075 
0076 QString INatPlugin::handbookSection() const
0077 {
0078     return QLatin1String("export_tools");
0079 }
0080 
0081 QString INatPlugin::handbookChapter() const
0082 {
0083     return QLatin1String("inaturalist_export");
0084 }
0085 
0086 QList<DPluginAuthor> INatPlugin::authors() const
0087 {
0088     return QList<DPluginAuthor>()
0089            << DPluginAuthor(QString::fromUtf8("Joerg Lohse"),
0090                             QString::fromUtf8("joergmlpts at gmail dot com"),
0091                             QString::fromUtf8("(C) 2021-2022"));
0092 }
0093 
0094 void INatPlugin::setup(QObject* const parent)
0095 {
0096     DPluginAction* const ac = new DPluginAction(parent);
0097     ac->setIcon(icon());
0098     ac->setText(i18nc("@action", "Export to &iNaturalist..."));
0099     ac->setObjectName(QLatin1String("export_inaturalist"));
0100     ac->setActionCategory(DPluginAction::GenericExport);
0101     ac->setShortcut(Qt::CTRL | Qt::ALT | Qt::SHIFT | Qt::Key_N);
0102 
0103     connect(ac, SIGNAL(triggered(bool)),
0104             this, SLOT(slotINat()));
0105 
0106     addAction(ac);
0107 }
0108 
0109 void INatPlugin::slotINat()
0110 {
0111     if (!reactivateToolDialog(m_toolDlg))
0112     {
0113         delete m_toolDlg;
0114         m_toolDlg = new INatWindow(infoIface(sender()), nullptr);
0115         m_toolDlg->setPlugin(this);
0116         m_toolDlg->show();
0117     }
0118 }
0119 
0120 } // namespace DigikamGenericINatPlugin
0121 
0122 #include "moc_inatplugin.cpp"