File indexing completed on 2025-01-05 03:53:42

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 export and import items with SmugMug web-service.
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 "smugplugin.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 "smugwindow.h"
0028 
0029 namespace DigikamGenericSmugPlugin
0030 {
0031 
0032 SmugPlugin::SmugPlugin(QObject* const parent)
0033     : DPluginGeneric(parent)
0034 {
0035 }
0036 
0037 SmugPlugin::~SmugPlugin()
0038 {
0039 }
0040 
0041 void SmugPlugin::cleanUp()
0042 {
0043     delete m_toolDlgExport;
0044     delete m_toolDlgImport;
0045 }
0046 
0047 QString SmugPlugin::name() const
0048 {
0049     return i18nc("@title", "SmugMug");
0050 }
0051 
0052 QString SmugPlugin::iid() const
0053 {
0054     return QLatin1String(DPLUGIN_IID);
0055 }
0056 
0057 QIcon SmugPlugin::icon() const
0058 {
0059     return QIcon::fromTheme(QLatin1String("dk-smugmug"));
0060 }
0061 
0062 QString SmugPlugin::description() const
0063 {
0064     return i18nc("@info", "A tool to export and import items with SmugMug web-service");
0065 }
0066 
0067 QString SmugPlugin::details() const
0068 {
0069     return i18nc("@info", "This tool allows users to export and import items with SmugMug web-service.\n\n"
0070                  "See SmugMug web site for details: %1",
0071                  QLatin1String("<a href='https://www.smugmug.com'>https://www.smugmug.com</a></p>"));
0072 }
0073 
0074 QString SmugPlugin::handbookSection() const
0075 {
0076     return QLatin1String("export_tools");
0077 }
0078 
0079 QString SmugPlugin::handbookChapter() const
0080 {
0081     return QLatin1String("smugmug_export");
0082 }
0083 
0084 QList<DPluginAuthor> SmugPlugin::authors() const
0085 {
0086     return QList<DPluginAuthor>()
0087             << DPluginAuthor(QString::fromUtf8("Luka Renko"),
0088                              QString::fromUtf8("lure at kubuntu dot org"),
0089                              QString::fromUtf8("(C) 2008-2009"))
0090             << DPluginAuthor(QString::fromUtf8("Vardhman Jain"),
0091                              QString::fromUtf8("vardhman at gmail dot com"),
0092                              QString::fromUtf8("(C) 2005-2008"))
0093             << DPluginAuthor(QString::fromUtf8("Maik Qualmann"),
0094                              QString::fromUtf8("metzpinguin at gmail dot com"),
0095                              QString::fromUtf8("(C) 2017-2021"))
0096             << DPluginAuthor(QString::fromUtf8("Gilles Caulier"),
0097                              QString::fromUtf8("caulier dot gilles at gmail dot com"),
0098                              QString::fromUtf8("(C) 2008-2021"))
0099             ;
0100 }
0101 
0102 void SmugPlugin::setup(QObject* const parent)
0103 {
0104     DPluginAction* const ac = new DPluginAction(parent);
0105     ac->setIcon(icon());
0106     ac->setText(i18nc("@action", "Export to &SmugMug..."));
0107     ac->setObjectName(QLatin1String("export_smugmug"));
0108     ac->setActionCategory(DPluginAction::GenericExport);
0109     ac->setShortcut(Qt::CTRL | Qt::ALT | Qt::SHIFT | Qt::Key_S);
0110 
0111     connect(ac, SIGNAL(triggered(bool)),
0112             this, SLOT(slotSmugMugExport()));
0113 
0114     addAction(ac);
0115 
0116     DPluginAction* const ac2 = new DPluginAction(parent);
0117     ac2->setIcon(icon());
0118     ac2->setText(i18nc("@action", "Import from &SmugMug..."));
0119     ac2->setObjectName(QLatin1String("import_smugmug"));
0120     ac2->setActionCategory(DPluginAction::GenericImport);
0121     ac2->setShortcut(Qt::ALT | Qt::SHIFT | Qt::Key_S);
0122 
0123     connect(ac2, SIGNAL(triggered(bool)),
0124             this, SLOT(slotSmugMugImport()));
0125 
0126     addAction(ac2);
0127 
0128 }
0129 
0130 void SmugPlugin::slotSmugMugExport()
0131 {
0132     if (!reactivateToolDialog(m_toolDlgExport))
0133     {
0134         delete m_toolDlgExport;
0135         m_toolDlgExport = new SmugWindow(infoIface(sender()), nullptr);
0136         m_toolDlgExport->setPlugin(this);
0137         m_toolDlgExport->show();
0138     }
0139 }
0140 
0141 void SmugPlugin::slotSmugMugImport()
0142 {
0143     if (!reactivateToolDialog(m_toolDlgImport))
0144     {
0145         DInfoInterface* const iface = infoIface(sender());
0146 
0147         delete m_toolDlgImport;
0148         m_toolDlgImport = new SmugWindow(iface, nullptr, true);
0149         m_toolDlgImport->setPlugin(this);
0150 
0151         connect(m_toolDlgImport, SIGNAL(updateHostApp(QUrl)),
0152                 iface, SLOT(slotMetadataChangedForUrl(QUrl)));
0153 
0154         m_toolDlgImport->show();
0155     }
0156 }
0157 
0158 } // namespace DigikamGenericSmugPlugin
0159 
0160 #include "moc_smugplugin.cpp"