1 /* ============================================================
2 *
3 * This file is a part of digiKam project
4 * https://www.digikam.org
5 *
6 * Date : 2018-07-30
7 * Description : a plugin to export and import items with a remote location.
8 *
9 * Copyright (C) 2018-2021 by Gilles Caulier <caulier dot gilles at gmail dot com>
10 *
11 * This program is free software; you can redistribute it
12 * and/or modify it under the terms of the GNU General
13 * Public License as published by the Free Software Foundation;
14 * either version 2, or (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * ============================================================ */
22
23 #include "ftplugin.h"
24
25 // Qt includes
26
27 #include <QPointer>
28
29 // KDE includes
30
31 #include <klocalizedstring.h>
32
33 // Local includes
34
35 #include "ftexportwindow.h"
36 #include "ftimportwindow.h"
37
38 namespace DigikamGenericFileTransferPlugin
39 {
40
FTPlugin(QObject * const parent)41 FTPlugin::FTPlugin(QObject* const parent)
42 : DPluginGeneric(parent)
43 {
44 }
45
~FTPlugin()46 FTPlugin::~FTPlugin()
47 {
48 }
49
cleanUp()50 void FTPlugin::cleanUp()
51 {
52 delete m_toolDlgExport;
53 delete m_toolDlgImport;
54 }
55
name() const56 QString FTPlugin::name() const
57 {
58 return i18nc("@title", "File Transfer");
59 }
60
iid() const61 QString FTPlugin::iid() const
62 {
63 return QLatin1String(DPLUGIN_IID);
64 }
65
icon() const66 QIcon FTPlugin::icon() const
67 {
68 return QIcon::fromTheme(QLatin1String("folder-html"));
69 }
70
description() const71 QString FTPlugin::description() const
72 {
73 return i18nc("@info", "A tool to export and import items with a remote location");
74 }
75
details() const76 QString FTPlugin::details() const
77 {
78 return i18nc("@info", "This tool allows users to export and import items with a remote location.\n\n"
79 "Many protocols can be used, as FTP, SFTP, SAMBA, etc.");
80 }
81
authors() const82 QList<DPluginAuthor> FTPlugin::authors() const
83 {
84 return QList<DPluginAuthor>()
85 << DPluginAuthor(QString::fromUtf8("Johannes Wienke"),
86 QString::fromUtf8("languitar at semipol dot de"),
87 QString::fromUtf8("(C) 2009"))
88 << DPluginAuthor(QString::fromUtf8("Maik Qualmann"),
89 QString::fromUtf8("metzpinguin at gmail dot com"),
90 QString::fromUtf8("(C) 2017-2021"))
91 << DPluginAuthor(QString::fromUtf8("Gilles Caulier"),
92 QString::fromUtf8("caulier dot gilles at gmail dot com"),
93 QString::fromUtf8("(C) 2010-2021"))
94 ;
95 }
96
setup(QObject * const parent)97 void FTPlugin::setup(QObject* const parent)
98 {
99 DPluginAction* const ac = new DPluginAction(parent);
100 ac->setIcon(icon());
101 ac->setText(i18nc("@action", "Export to remote storage..."));
102 ac->setObjectName(QLatin1String("export_filetransfer"));
103 ac->setActionCategory(DPluginAction::GenericExport);
104 ac->setShortcut(Qt::CTRL + Qt::ALT + Qt::SHIFT + Qt::Key_K);
105
106 connect(ac, SIGNAL(triggered(bool)),
107 this, SLOT(slotFileTransferExport()));
108
109 addAction(ac);
110
111 DPluginAction* const ac2 = new DPluginAction(parent);
112 ac2->setIcon(icon());
113 ac2->setText(i18nc("@action", "Import from remote storage..."));
114 ac2->setObjectName(QLatin1String("import_filetransfer"));
115 ac2->setActionCategory(DPluginAction::GenericImport);
116 ac2->setShortcut(Qt::ALT + Qt::SHIFT + Qt::Key_K);
117
118 connect(ac2, SIGNAL(triggered(bool)),
119 this, SLOT(slotFileTransferImport()));
120
121 addAction(ac2);
122
123 }
124
slotFileTransferExport()125 void FTPlugin::slotFileTransferExport()
126 {
127 if (!reactivateToolDialog(m_toolDlgExport))
128 {
129 delete m_toolDlgExport;
130 m_toolDlgExport = new FTExportWindow(infoIface(sender()), nullptr);
131 m_toolDlgExport->setPlugin(this);
132 m_toolDlgExport->show();
133 }
134 }
135
slotFileTransferImport()136 void FTPlugin::slotFileTransferImport()
137 {
138 if (!reactivateToolDialog(m_toolDlgImport))
139 {
140 delete m_toolDlgImport;
141 m_toolDlgImport = new FTImportWindow(infoIface(sender()), nullptr);
142 m_toolDlgImport->setPlugin(this);
143 m_toolDlgImport->show();
144 }
145 }
146
147 } // namespace DigikamGenericFileTransferPlugin
148