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

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 Google 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 "gsplugin.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 "gswindow.h"
0028 
0029 namespace DigikamGenericGoogleServicesPlugin
0030 {
0031 
0032 GSPlugin::GSPlugin(QObject* const parent)
0033     : DPluginGeneric(parent)
0034 {
0035 }
0036 
0037 GSPlugin::~GSPlugin()
0038 {
0039 }
0040 
0041 void GSPlugin::cleanUp()
0042 {
0043     delete m_toolDlgExportGphoto;
0044     delete m_toolDlgImportGphoto;
0045     delete m_toolDlgExportGdrive;
0046 }
0047 
0048 QString GSPlugin::name() const
0049 {
0050     return i18nc("@title", "Google");
0051 }
0052 
0053 QString GSPlugin::iid() const
0054 {
0055     return QLatin1String(DPLUGIN_IID);
0056 }
0057 
0058 QIcon GSPlugin::icon() const
0059 {
0060     return QIcon::fromTheme(QLatin1String("dk-googlephoto"));
0061 }
0062 
0063 QString GSPlugin::description() const
0064 {
0065     return i18nc("@info", "A tool to export and import items with Google web-service");
0066 }
0067 
0068 QString GSPlugin::details() const
0069 {
0070     return i18nc("@info", "This tool allows users to export and import items with Google web-services.\n\n"
0071                  "Google Photo and Google Drive web services are supported.\n\n"
0072                  "See Google web sites for details: %1",
0073                  QLatin1String("</ br><a href='https://photos.google.com'>https://photos.google.com</a></ br><a href='https://www.google.com/drive/'>https://www.google.com/drive/</a>"));
0074 }
0075 
0076 QString GSPlugin::handbookSection() const
0077 {
0078     return QLatin1String("export_tools");
0079 }
0080 
0081 QString GSPlugin::handbookChapter() const
0082 {
0083     return QLatin1String("google_export");
0084 }
0085 
0086 QList<DPluginAuthor> GSPlugin::authors() const
0087 {
0088     return QList<DPluginAuthor>()
0089             << DPluginAuthor(QString::fromUtf8("Saurabh Patel"),
0090                              QString::fromUtf8("saurabhpatel7717 at gmail dot co"),
0091                              QString::fromUtf8("(C) 2013"))
0092             << DPluginAuthor(QString::fromUtf8("Shourya Singh Gupta"),
0093                              QString::fromUtf8("shouryasgupta at gmail dot com"),
0094                              QString::fromUtf8("(C) 2015"))
0095             << DPluginAuthor(QString::fromUtf8("Maik Qualmann"),
0096                              QString::fromUtf8("metzpinguin at gmail dot com"),
0097                              QString::fromUtf8("(C) 2017-2021"))
0098             << DPluginAuthor(QString::fromUtf8("Gilles Caulier"),
0099                              QString::fromUtf8("caulier dot gilles at gmail dot com"),
0100                              QString::fromUtf8("(C) 2013-2021"))
0101             ;
0102 }
0103 
0104 void GSPlugin::setup(QObject* const parent)
0105 {
0106     DPluginAction* const ac1 = new DPluginAction(parent);
0107     ac1->setIcon(icon());
0108     ac1->setText(i18nc("@action", "Export to &Google Photos..."));
0109     ac1->setObjectName(QLatin1String("export_googlephoto"));
0110     ac1->setActionCategory(DPluginAction::GenericExport);
0111     ac1->setShortcut(Qt::CTRL | Qt::ALT | Qt::SHIFT | Qt::Key_P);
0112 
0113     connect(ac1, SIGNAL(triggered(bool)),
0114             this, SLOT(slotExportGphoto()));
0115 
0116     addAction(ac1);
0117 
0118     DPluginAction* const ac2 = new DPluginAction(parent);
0119     ac2->setIcon(icon());
0120     ac2->setText(i18nc("@action", "Import from &Google Photos..."));
0121     ac2->setObjectName(QLatin1String("import_googlephoto"));
0122     ac2->setActionCategory(DPluginAction::GenericImport);
0123     ac2->setShortcut(Qt::ALT | Qt::SHIFT | Qt::Key_P);
0124 
0125     connect(ac2, SIGNAL(triggered(bool)),
0126             this, SLOT(slotImportGphoto()));
0127 
0128     addAction(ac2);
0129 
0130     DPluginAction* const ac3 = new DPluginAction(parent);
0131     ac3->setIcon(icon());
0132     ac3->setText(i18nc("@action", "Export to &Google Drive..."));
0133     ac3->setObjectName(QLatin1String("export_googledrive"));
0134     ac3->setActionCategory(DPluginAction::GenericExport);
0135     ac3->setShortcut(Qt::CTRL | Qt::ALT | Qt::SHIFT | Qt::Key_G);
0136 
0137     connect(ac3, SIGNAL(triggered(bool)),
0138             this, SLOT(slotExportGdrive()));
0139 
0140     addAction(ac3);
0141 }
0142 
0143 void GSPlugin::slotImportGphoto()
0144 {
0145     if (!reactivateToolDialog(m_toolDlgImportGphoto))
0146     {
0147         DInfoInterface* const iface = infoIface(sender());
0148 
0149         delete m_toolDlgImportGphoto;
0150         m_toolDlgImportGphoto = new GSWindow(iface, nullptr, QLatin1String("googlephotoimport"));
0151         m_toolDlgImportGphoto->setPlugin(this);
0152 
0153         connect(m_toolDlgImportGphoto, SIGNAL(updateHostApp(QUrl)),
0154                 iface, SLOT(slotMetadataChangedForUrl(QUrl)));
0155 
0156         m_toolDlgImportGphoto->show();
0157     }
0158 }
0159 
0160 void GSPlugin::slotExportGphoto()
0161 {
0162     if (!reactivateToolDialog(m_toolDlgExportGphoto))
0163     {
0164         delete m_toolDlgExportGphoto;
0165         m_toolDlgExportGphoto = new GSWindow(infoIface(sender()), nullptr, QLatin1String("googlephotoexport"));
0166         m_toolDlgExportGphoto->setPlugin(this);
0167         m_toolDlgExportGphoto->show();
0168     }
0169 }
0170 
0171 void GSPlugin::slotExportGdrive()
0172 {
0173     if (!reactivateToolDialog(m_toolDlgExportGdrive))
0174     {
0175         delete m_toolDlgExportGdrive;
0176         m_toolDlgExportGdrive = new GSWindow(infoIface(sender()), nullptr, QLatin1String("googledriveexport"));
0177         m_toolDlgExportGdrive->setPlugin(this);
0178         m_toolDlgExportGdrive->show();
0179     }
0180 }
0181 
0182 } // namespace DigikamGenericGoogleServicesPlugin
0183 
0184 #include "moc_gsplugin.cpp"