File indexing completed on 2023-10-03 07:22:43
0001 /* ============================================================ 0002 * 0003 * This file is a part of KDE project 0004 * 0005 * 0006 * Date : 2008-12-26 0007 * Description : a kipi plugin to export images to Facebook web service 0008 * 0009 * Copyright (C) 2005-2008 by Vardhman Jain <vardhman at gmail dot com> 0010 * Copyright (C) 2008-2018 by Gilles Caulier <caulier dot gilles at gmail dot com> 0011 * Copyright (C) 2008-2009 by Luka Renko <lure at kubuntu dot org> 0012 * 0013 * This program is free software; you can redistribute it 0014 * and/or modify it under the terms of the GNU General 0015 * Public License as published by the Free Software Foundation; 0016 * either version 2, or (at your option) any later version. 0017 * 0018 * This program is distributed in the hope that it will be useful, 0019 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0021 * GNU General Public License for more details. 0022 * 0023 * ============================================================ */ 0024 0025 #include "plugin_facebook.h" 0026 0027 // Qt includes 0028 0029 #include <QApplication> 0030 #include <QAction> 0031 0032 // KDE includes 0033 0034 #include <kactioncollection.h> 0035 #include <klocalizedstring.h> 0036 #include <kpluginfactory.h> 0037 #include <kwindowsystem.h> 0038 0039 // Libkipi includes 0040 0041 #include <KIPI/Interface> 0042 #include <KIPI/ImageCollection> 0043 0044 // Local includes 0045 0046 #include "kputil.h" 0047 #include "fbwindow.h" 0048 #include "kipiplugins_debug.h" 0049 0050 namespace KIPIFacebookPlugin 0051 { 0052 0053 K_PLUGIN_FACTORY( FacebookFactory, registerPlugin<Plugin_Facebook>(); ) 0054 0055 Plugin_Facebook::Plugin_Facebook(QObject* const parent, const QVariantList& /*args*/) 0056 : Plugin(parent, "Facebook") 0057 { 0058 qCDebug(KIPIPLUGINS_LOG) << "Plugin_Facebook plugin loaded"; 0059 0060 setUiBaseName("kipiplugin_facebookui.rc"); 0061 setupXML(); 0062 0063 m_actionExport = nullptr; 0064 m_dlgExport = nullptr; 0065 } 0066 0067 Plugin_Facebook::~Plugin_Facebook() 0068 { 0069 delete m_dlgExport; 0070 0071 removeTemporaryDir("fb"); 0072 } 0073 0074 void Plugin_Facebook::setup(QWidget* const widget) 0075 { 0076 m_dlgExport = nullptr; 0077 0078 Plugin::setup(widget); 0079 0080 if (!interface()) 0081 { 0082 qCCritical(KIPIPLUGINS_LOG) << "Kipi interface is null!"; 0083 return; 0084 } 0085 0086 setupActions(); 0087 } 0088 0089 void Plugin_Facebook::setupActions() 0090 { 0091 setDefaultCategory(ExportPlugin); 0092 0093 m_actionExport = new QAction(this); 0094 m_actionExport->setText(i18n("Export to &Facebook...")); 0095 m_actionExport->setIcon(QIcon::fromTheme(QString::fromLatin1("kipi-facebook"))); 0096 actionCollection()->setDefaultShortcut(m_actionExport, Qt::ALT + Qt::SHIFT + Qt::Key_F); 0097 0098 connect(m_actionExport, SIGNAL(triggered(bool)), 0099 this, SLOT(slotExport()) ); 0100 0101 addAction(QString::fromLatin1("facebookexport"), m_actionExport); 0102 } 0103 0104 void Plugin_Facebook::slotExport() 0105 { 0106 QString tmp = makeTemporaryDir("fb").absolutePath() + QLatin1Char('/'); 0107 0108 if (!m_dlgExport) 0109 { 0110 // We clean it up in the close button 0111 m_dlgExport = new FbWindow(tmp, QApplication::activeWindow()); 0112 } 0113 else 0114 { 0115 if (m_dlgExport->isMinimized()) 0116 KWindowSystem::unminimizeWindow(m_dlgExport->winId()); 0117 0118 KWindowSystem::activateWindow(m_dlgExport->winId()); 0119 } 0120 0121 m_dlgExport->reactivate(); 0122 } 0123 0124 } // namespace KIPIFacebookPlugin 0125 0126 #include "plugin_facebook.moc" 0127 0128 #include "moc_plugin_facebook.cpp"