source: extensions/digikam_export/piwigoexport/plugin_piwigoexport.cpp @ 4770

Last change on this file since 4770 was 4770, checked in by fcoiffie, 14 years ago

Premiere version du plugin Digikam piwigoexport

  • Connexion
  • Liste des categories
  • Upload des photos
File size: 3.8 KB
Line 
1/* ============================================================
2 *
3 * This file is a part of kipi-plugins project
4 * http://www.kipi-plugins.org
5 *
6 * Date        : 2010-01-07
7 * Description : a plugin to export to a remote Piwigo server.
8 *
9 * Copyright (C) 2003-2005 by Renchi Raju <renchi dot raju at gmail dot com>
10 * Copyright (C) 2006 by Colin Guthrie <kde@colin.guthr.ie>
11 * Copyright (C) 2006-2009 by Gilles Caulier <caulier dot gilles at gmail dot com>
12 * Copyright (C) 2008 by Andrea Diamantini <adjam7 at gmail dot com>
13 * Copyright (C) 2010 by Frederic Coiffier <frederic dot coiffier at free dot com>
14 *
15 * This program is free software; you can redistribute it
16 * and/or modify it under the terms of the GNU General
17 * Public License as published by the Free Software Foundation;
18 * either version 2, or (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23 * GNU General Public License for more details.
24 *
25 * ============================================================ */
26
27#include "plugin_piwigoexport.h"
28#include "plugin_piwigoexport.moc"
29
30// Qt includes
31
32#include <QPointer>
33
34// KDE includes
35
36#include <kaction.h>
37#include <kactioncollection.h>
38#include <kapplication.h>
39#include <kdebug.h>
40#include <kgenericfactory.h>
41#include <kiconloader.h>
42#include <klocale.h>
43#include <kmessagebox.h>
44
45// LibKIPI includes
46
47#include <libkipi/interface.h>
48#include <libkipi/plugin.h>
49
50// Local includes
51
52#include "piwigos.h"
53#include "piwigoconfig.h"
54#include "piwigowindow.h"
55
56K_PLUGIN_FACTORY(Factory, registerPlugin<Plugin_PiwigoExport>();)
57K_EXPORT_PLUGIN(Factory("kipiplugin_piwigoexport"))
58
59Plugin_PiwigoExport::Plugin_PiwigoExport(QObject *parent, const QVariantList&)
60        : KIPI::Plugin(Factory::componentData(), parent, "PiwigoExport"),
61        m_action(0), mpPiwigo(0)
62{
63    kDebug(AREA_CODE_LOADING) << "Plugin_PiwigoExport plugin loaded";
64}
65
66void Plugin_PiwigoExport::setup(QWidget* widget)
67{
68    KIconLoader::global()->addAppDir("kipiplugin_piwigoexport");
69
70    mpPiwigo = new KIPIPiwigoExportPlugin::Piwigo();
71
72    KIPI::Plugin::setup(widget);
73
74    KIPI::Interface* interface = dynamic_cast<KIPI::Interface*>(parent());
75    if (!interface) {
76        kError() << "Kipi interface is null!";
77        return;
78    }
79
80    m_action = actionCollection()->addAction("piwigoexport");
81    m_action->setText(i18n("Export to &Piwigo..."));
82    m_action->setIcon(KIcon("piwigo"));
83    m_action->setEnabled(true);
84
85    connect(m_action, SIGNAL(triggered(bool)),
86            this, SLOT(slotSync()));
87
88    addAction(m_action);
89}
90
91Plugin_PiwigoExport::~Plugin_PiwigoExport()
92{
93    if (mpPiwigo)
94        delete mpPiwigo;
95}
96
97// this slot uses PiwigoWindow Class
98void Plugin_PiwigoExport::slotSync()
99{
100    KIPI::Interface* interface = dynamic_cast<KIPI::Interface*>(parent());
101    if (!interface) {
102        kError() << "Kipi interface is null!";
103        return;
104    }
105
106    QPointer<KIPIPiwigoExportPlugin::PiwigoEdit>   configDlg;
107    QPointer<KIPIPiwigoExportPlugin::PiwigoWindow> dlg;
108
109    KConfig config("kipirc");
110    if (!config.hasGroup("Piwigo Settings") ) {
111        configDlg = new KIPIPiwigoExportPlugin::PiwigoEdit(kapp->activeWindow(),
112                mpPiwigo, i18n("Edit Piwigo Data") );
113        configDlg->exec();
114    }
115
116    dlg = new KIPIPiwigoExportPlugin::PiwigoWindow(interface, kapp->activeWindow(), mpPiwigo);
117    dlg->exec();
118
119    delete configDlg;
120    delete dlg;
121}
122
123KIPI::Category Plugin_PiwigoExport::category(KAction* action) const
124{
125    if (action == m_action)
126        return KIPI::ExportPlugin;
127//     if (action == m_action_configure)
128//         return KIPI::ToolsPlugin;
129//
130    kWarning() << "Unrecognized action for plugin category identification";
131    return KIPI::ExportPlugin;
132}
Note: See TracBrowser for help on using the repository browser.