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

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 to ImgUr 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 "imgurplugin.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 "imgurwindow.h"
0028 
0029 namespace DigikamGenericImgUrPlugin
0030 {
0031 
0032 ImgUrPlugin::ImgUrPlugin(QObject* const parent)
0033     : DPluginGeneric(parent)
0034 {
0035 }
0036 
0037 ImgUrPlugin::~ImgUrPlugin()
0038 {
0039 }
0040 
0041 void ImgUrPlugin::cleanUp()
0042 {
0043     delete m_toolDlg;
0044 }
0045 
0046 QString ImgUrPlugin::name() const
0047 {
0048     return i18nc("@title", "ImgUr");
0049 }
0050 
0051 QString ImgUrPlugin::iid() const
0052 {
0053     return QLatin1String(DPLUGIN_IID);
0054 }
0055 
0056 QIcon ImgUrPlugin::icon() const
0057 {
0058     return QIcon::fromTheme(QLatin1String("dk-imgur"));
0059 }
0060 
0061 QString ImgUrPlugin::description() const
0062 {
0063     return i18nc("@info", "A tool to export to ImgUr web-service");
0064 }
0065 
0066 QString ImgUrPlugin::details() const
0067 {
0068     return i18nc("@info", "This tool allows users to export items to ImgUr web-service.\n\n"
0069                  "You can export items as anonymous or with an user account.\n\n"
0070                  "See ImgUr web site for details: %1",
0071                  QLatin1String("<a href='https://imgur.com/'>https://imgur.com/</a>"));
0072 }
0073 
0074 QString ImgUrPlugin::handbookSection() const
0075 {
0076     return QLatin1String("export_tools");
0077 }
0078 
0079 QString ImgUrPlugin::handbookChapter() const
0080 {
0081     return QLatin1String("imgur_export");
0082 }
0083 
0084 QList<DPluginAuthor> ImgUrPlugin::authors() const
0085 {
0086     return QList<DPluginAuthor>()
0087             << DPluginAuthor(QString::fromUtf8("Marius Orcsik"),
0088                              QString::fromUtf8("marius at habarnam dot ro"),
0089                              QString::fromUtf8("(C) 2012-2013"))
0090             << DPluginAuthor(QString::fromUtf8("Fabian Vogt"),
0091                              QString::fromUtf8("fabian at ritter dash vogt dot de"),
0092                              QString::fromUtf8("(C) 2014"))
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) 2012-2021"))
0099             ;
0100 }
0101 
0102 void ImgUrPlugin::setup(QObject* const parent)
0103 {
0104     DPluginAction* const ac = new DPluginAction(parent);
0105     ac->setIcon(icon());
0106     ac->setText(i18nc("@action", "Export to &Imgur..."));
0107     ac->setObjectName(QLatin1String("export_imgur"));
0108     ac->setActionCategory(DPluginAction::GenericExport);
0109 
0110     connect(ac, SIGNAL(triggered(bool)),
0111             this, SLOT(slotImgUr()));
0112 
0113     addAction(ac);
0114 }
0115 
0116 void ImgUrPlugin::slotImgUr()
0117 {
0118     if (!reactivateToolDialog(m_toolDlg))
0119     {
0120         delete m_toolDlg;
0121         m_toolDlg = new ImgurWindow(infoIface(sender()), nullptr);
0122         m_toolDlg->setPlugin(this);
0123         m_toolDlg->show();
0124     }
0125 }
0126 
0127 } // namespace DigikamGenericImgUrPlugin
0128 
0129 #include "moc_imgurplugin.cpp"