/* ============================================================ * * This file is a part of kipi-plugins project * http://www.kipi-plugins.org * * Date : 2010-01-07 * Description : a plugin to export to a remote Piwigo server. * * Copyright (C) 2003-2005 by Renchi Raju * Copyright (C) 2006 by Colin Guthrie * Copyright (C) 2006-2009 by Gilles Caulier * Copyright (C) 2008 by Andrea Diamantini * Copyright (C) 2010 by Frederic Coiffier * * This program is free software; you can redistribute it * and/or modify it under the terms of the GNU General * Public License as published by the Free Software Foundation; * either version 2, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * ============================================================ */ #include "plugin_piwigoexport.h" #include "plugin_piwigoexport.moc" // Qt includes #include // KDE includes #include #include #include #include #include #include #include #include // LibKIPI includes #include #include // Local includes #include "piwigos.h" #include "piwigoconfig.h" #include "piwigowindow.h" K_PLUGIN_FACTORY(Factory, registerPlugin();) K_EXPORT_PLUGIN(Factory("kipiplugin_piwigoexport")) Plugin_PiwigoExport::Plugin_PiwigoExport(QObject *parent, const QVariantList&) : KIPI::Plugin(Factory::componentData(), parent, "PiwigoExport"), m_action(0), mpPiwigo(0) { kDebug(AREA_CODE_LOADING) << "Plugin_PiwigoExport plugin loaded"; } void Plugin_PiwigoExport::setup(QWidget* widget) { KIconLoader::global()->addAppDir("kipiplugin_piwigoexport"); mpPiwigo = new KIPIPiwigoExportPlugin::Piwigo(); KIPI::Plugin::setup(widget); KIPI::Interface* interface = dynamic_cast(parent()); if (!interface) { kError() << "Kipi interface is null!"; return; } m_action = actionCollection()->addAction("piwigoexport"); m_action->setText(i18n("Export to &Piwigo...")); m_action->setIcon(KIcon("piwigo")); m_action->setEnabled(true); connect(m_action, SIGNAL(triggered(bool)), this, SLOT(slotSync())); addAction(m_action); } Plugin_PiwigoExport::~Plugin_PiwigoExport() { if (mpPiwigo) delete mpPiwigo; } // this slot uses PiwigoWindow Class void Plugin_PiwigoExport::slotSync() { KIPI::Interface* interface = dynamic_cast(parent()); if (!interface) { kError() << "Kipi interface is null!"; return; } QPointer configDlg; QPointer dlg; KConfig config("kipirc"); if (!config.hasGroup("Piwigo Settings") ) { configDlg = new KIPIPiwigoExportPlugin::PiwigoEdit(kapp->activeWindow(), mpPiwigo, i18n("Edit Piwigo Data") ); configDlg->exec(); } dlg = new KIPIPiwigoExportPlugin::PiwigoWindow(interface, kapp->activeWindow(), mpPiwigo); dlg->exec(); delete configDlg; delete dlg; } KIPI::Category Plugin_PiwigoExport::category(KAction* action) const { if (action == m_action) return KIPI::ExportPlugin; kWarning() << "Unrecognized action for plugin category identification"; return KIPI::ExportPlugin; }