1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198
|
/* ============================================================
*
* This file is a part of KDE project
*
*
* Date : 2013-11-18
* Description : a kipi plugin to export images to Google-Drive web service
*
* Copyright (C) 2013 by Pankaj Kumar <me at panks dot me>
* Copyright (C) 2008-2016 by Caulier Gilles <caulier dot gilles at gmail dot com>
*
* 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_googleservices.h"
//Qt includes
#include <QApplication>
#include <QAction>
// KDE includes
#include <kactioncollection.h>
#include <klocalizedstring.h>
#include <kpluginfactory.h>
#include <kwindowsystem.h>
// LibKIPI includes
#include <KIPI/Interface>
// Local includes
#include "kputil.h"
#include "gswindow.h"
#include "kipiplugins_debug.h"
namespace KIPIGoogleServicesPlugin
{
K_PLUGIN_FACTORY(GoogleDriveFactory, registerPlugin<Plugin_GoogleServices>(); )
Plugin_GoogleServices::Plugin_GoogleServices(QObject* const parent, const QVariantList& /*args*/)
: Plugin(parent, "Google Services")
{
qCDebug(KIPIPLUGINS_LOG) << "Plugin_GoogleServices Plugin Loaded";
setUiBaseName("kipiplugin_googleservicesui.rc");
setupXML();
m_actionGDriveExport = nullptr;
m_actionGPhotoExport = nullptr;
m_actionGPhotoImport = nullptr;
m_dlgGDriveExport = nullptr;
m_dlgGPhotoExport = nullptr;
m_dlgGPhotoImport = nullptr;
}
Plugin_GoogleServices::~Plugin_GoogleServices()
{
delete m_dlgGDriveExport;
delete m_dlgGPhotoExport;
delete m_dlgGPhotoImport;
removeTemporaryDir("gs");
}
void Plugin_GoogleServices::setup(QWidget* const widget)
{
m_dlgGDriveExport = nullptr;
m_dlgGPhotoExport = nullptr;
m_dlgGPhotoImport = nullptr;
Plugin::setup(widget);
if (!interface())
{
qCCritical(KIPIPLUGINS_LOG) << "kipi interface is null";
return;
}
setupActions();
}
void Plugin_GoogleServices::setupActions()
{
setDefaultCategory(ExportPlugin);
m_actionGDriveExport = new QAction(this);
m_actionGDriveExport->setText(i18n("Export to &Google Drive..."));
m_actionGDriveExport->setIcon(QIcon::fromTheme(QString::fromLatin1("kipi-googledrive")));
actionCollection()->setDefaultShortcut(m_actionGDriveExport, Qt::ALT + Qt::SHIFT + Qt::CTRL + Qt::Key_G);
connect(m_actionGDriveExport, SIGNAL(triggered(bool)),
this,SLOT(slotGDriveExport()));
addAction(QString::fromLatin1("googledriveexport"), m_actionGDriveExport);
m_actionGPhotoExport = new QAction(this);
m_actionGPhotoExport->setText(i18n("Export to &Google Photos/PicasaWeb..."));
m_actionGPhotoExport->setIcon(QIcon::fromTheme(QString::fromLatin1("kipi-googlephoto")));
actionCollection()->setDefaultShortcut(m_actionGPhotoExport, Qt::ALT + Qt::SHIFT + Qt::Key_P);
connect(m_actionGPhotoExport, SIGNAL(triggered(bool)),
this, SLOT(slotGPhotoExport()));
addAction(QString::fromLatin1("googlephotoexport"), m_actionGPhotoExport);
m_actionGPhotoImport = new QAction(this);
m_actionGPhotoImport->setText(i18n("Import from &Google Photos/PicasaWeb..."));
m_actionGPhotoImport->setIcon(QIcon::fromTheme(QString::fromLatin1("kipi-googlephoto")));
actionCollection()->setDefaultShortcut(m_actionGPhotoImport, Qt::ALT + Qt::SHIFT + Qt::CTRL + Qt::Key_P);
connect(m_actionGPhotoImport, SIGNAL(triggered(bool)),
this, SLOT(slotGPhotoImport()) );
addAction(QString::fromLatin1("googlephotoimport"), m_actionGPhotoImport, ImportPlugin);
}
void Plugin_GoogleServices::slotGDriveExport()
{
QString tmp = makeTemporaryDir("gs").absolutePath() + QLatin1Char('/');
if (!m_dlgGDriveExport)
{
m_dlgGDriveExport = new GSWindow(tmp, QApplication::activeWindow(),
QString::fromLatin1("googledriveexport"));
}
else
{
if (m_dlgGDriveExport->isMinimized())
{
KWindowSystem::unminimizeWindow(m_dlgGDriveExport->winId());
}
KWindowSystem::activateWindow(m_dlgGDriveExport->winId());
}
m_dlgGDriveExport->reactivate();
}
void Plugin_GoogleServices::slotGPhotoExport()
{
QString tmp = makeTemporaryDir("gs").absolutePath() + QLatin1Char('/');
if (!m_dlgGPhotoExport)
{
m_dlgGPhotoExport = new GSWindow(tmp, QApplication::activeWindow(),
QString::fromLatin1("googlephotoexport"));
}
else
{
if (m_dlgGPhotoExport->isMinimized())
{
KWindowSystem::unminimizeWindow(m_dlgGPhotoExport->winId());
}
KWindowSystem::activateWindow(m_dlgGPhotoExport->winId());
}
m_dlgGPhotoExport->reactivate();
}
void Plugin_GoogleServices::slotGPhotoImport()
{
QString tmp = makeTemporaryDir("gs").absolutePath() + QLatin1Char('/');
if (!m_dlgGPhotoImport)
{
m_dlgGPhotoImport = new GSWindow(tmp, QApplication::activeWindow(),
QString::fromLatin1("googlephotoimport"));
}
else
{
if (m_dlgGPhotoImport->isMinimized())
{
KWindowSystem::unminimizeWindow(m_dlgGPhotoImport->winId());
}
KWindowSystem::activateWindow(m_dlgGPhotoImport->winId());
}
m_dlgGPhotoImport->reactivate();
}
} // namespace KIPIGoogleServicesPlugin
#include "plugin_googleservices.moc"
|