1 /* ============================================================
2 *
3 * This file is a part of KDE project
4 *
5 *
6 * Date : 2010-11-15
7 * Description : a kipi plugin to export images to VKontakte.ru web service
8 *
9 * Copyright (C) 2010 by Roman Tsisyk <roman at tsisyk dot com>
10 * Copyright (C) 2011, 2015 by Alexander Potashev <aspotashev@gmail.com>
11 *
12 * This program is free software; you can redistribute it
13 * and/or modify it under the terms of the GNU General
14 * Public License as published by the Free Software Foundation;
15 * either version 2, or (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * ============================================================ */
23
24 #include "plugin_vkontakte.h"
25
26 // Qt includes
27
28 #include <QApplication>
29
30 // KDE includes
31
32 #include <klocalizedstring.h>
33 #include <kpluginfactory.h>
34 #include <kwindowsystem.h>
35
36 // Local includes
37
38 #include "vkwindow.h"
39 #include "kipiplugins_debug.h"
40
41 namespace KIPIVkontaktePlugin
42 {
43
K_PLUGIN_FACTORY(Factory,registerPlugin<Plugin_Vkontakte> ();)44 K_PLUGIN_FACTORY( Factory, registerPlugin<Plugin_Vkontakte>(); )
45
46 Plugin_Vkontakte::Plugin_Vkontakte(QObject* const parent, const QVariantList&)
47 : Plugin(parent, "VKontakte")
48 {
49 m_dlgExport = nullptr;
50 m_actionExport = nullptr;
51
52 qCDebug(KIPIPLUGINS_LOG) << "Plugin_Vkontakte plugin loaded";
53
54 setUiBaseName("kipiplugin_vkontakteui.rc");
55 setupXML();
56 }
57
~Plugin_Vkontakte()58 Plugin_Vkontakte::~Plugin_Vkontakte()
59 {
60 }
61
setup(QWidget * const widget)62 void Plugin_Vkontakte::setup(QWidget* const widget)
63 {
64 Plugin::setup(widget);
65
66 setupActions();
67
68 if (!interface())
69 {
70 qCCritical(KIPIPLUGINS_LOG) << "Kipi interface is null!";
71 return;
72 }
73
74 m_actionExport->setEnabled(true);
75 }
76
setupActions()77 void Plugin_Vkontakte::setupActions()
78 {
79 setDefaultCategory(ExportPlugin);
80
81 m_actionExport = new QAction(this);
82 m_actionExport->setText(i18n("Export to &VKontakte..."));
83 // TODO: icon file
84 //m_actionExport->setIcon(KIcon("vkontakte"));
85 m_actionExport->setIcon(QIcon::fromTheme(QString::fromLatin1("preferences-web-browser-shortcuts")));
86 //m_actionExport->setShortcut(KShortcut(Qt::ALT+Qt::SHIFT+Qt::Key_Y));
87 m_actionExport->setEnabled(false);
88
89 connect(m_actionExport, SIGNAL(triggered(bool)),
90 this, SLOT(slotExport()));
91
92 addAction(QString::fromLatin1("VKontakte"), m_actionExport);
93 }
94
slotExport()95 void Plugin_Vkontakte::slotExport()
96 {
97 if (!m_dlgExport)
98 {
99 // This object will live forever, we will reuse it on future accesses
100 // to the plugin.
101 m_dlgExport = new VkontakteWindow(false, QApplication::activeWindow());
102 }
103 else
104 {
105 if (m_dlgExport->isMinimized())
106 KWindowSystem::unminimizeWindow(m_dlgExport->winId());
107
108 KWindowSystem::activateWindow(m_dlgExport->winId());
109 }
110
111 m_dlgExport->startReactivation();
112 }
113
114 } // namespace KIPIVkontaktePlugin
115
116 #include "plugin_vkontakte.moc"
117