plugin_vkontakte.cpp 3.35 KB
Newer Older
1
2
3
/* ============================================================
 *
 * This file is a part of kipi-plugins project
4
 * http://www.digikam.org
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 *
 * Date        : 2010-11-15
 * Description : a kipi plugin to export images to VKontakte.ru web service
 *
 * Copyright (C) 2010 by Roman Tsisyk <roman at tsisyk dot com>
 * Copyright (C) 2011 by Alexander Potashev <aspotashev 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.
 *
 * ============================================================ */

Gilles Caulier's avatar
Gilles Caulier committed
24
#include "plugin_vkontakte.moc"
Alexander Potashev's avatar
Alexander Potashev committed
25

26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// KDE includes

#include <klocale.h>
#include <kaction.h>
#include <kgenericfactory.h>
#include <klibloader.h>
#include <kconfig.h>
#include <kdebug.h>
#include <kapplication.h>
#include <kactioncollection.h>
#include <kwindowsystem.h>

// LibKIPI includes

#include <libkipi/interface.h>

// Local includes

#include "vkwindow.h"

Gilles Caulier's avatar
Gilles Caulier committed
46
47
48
namespace KIPIVkontaktePlugin
{

49
50
51
K_PLUGIN_FACTORY( Factory, registerPlugin<Plugin_Vkontakte>(); )
K_EXPORT_PLUGIN ( Factory("kipiplugin_vkontakte") )

Gilles Caulier's avatar
Gilles Caulier committed
52
Plugin_Vkontakte::Plugin_Vkontakte(QObject* const parent, const QVariantList&)
53
54
55
56
57
58
59
60
    : Plugin(Factory::componentData(), parent, "VKontakte")
{
    m_dlgExport = 0;
    // m_dlgImport = 0;

    kDebug(AREA_CODE_LOADING) << "Plugin_Vkontakte plugin loaded" ;
}

Gilles Caulier's avatar
Gilles Caulier committed
61
void Plugin_Vkontakte::setup(QWidget* widget)
62
{
Gilles Caulier's avatar
Gilles Caulier committed
63
    Plugin::setup(widget);
64
65
66
67
68
69
70

    KIconLoader::global()->addAppDir("kipiplugin_vkontakte");

    m_actionExport = actionCollection()->addAction("VKontakte");
    m_actionExport->setText(i18n("Export to &VKontakte..."));
    // TODO: icon file
    //m_actionExport->setIcon(KIcon("vkontakte"));
Gilles Caulier's avatar
Gilles Caulier committed
71
    m_actionExport->setIcon(KIcon("preferences-web-browser-shortcuts"));
72
73
74
75
76
77
78
    //m_actionExport->setShortcut(KShortcut(Qt::ALT+Qt::SHIFT+Qt::Key_Y));

    connect(m_actionExport, SIGNAL(triggered(bool)),
            this, SLOT(slotExport()));

    addAction(m_actionExport);

Gilles Caulier's avatar
Gilles Caulier committed
79
    Interface *interface = dynamic_cast<Interface*>(parent());
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

    if (!interface)
    {
        kError() << "Kipi interface is null!";
        m_actionExport->setEnabled(false);
        return;
    }

    m_actionExport->setEnabled(true);
}

Plugin_Vkontakte::~Plugin_Vkontakte()
{
}

/*
void Plugin_Vkontakte::slotImport()
{

}
*/

void Plugin_Vkontakte::slotExport()
{
    if (!m_dlgExport)
    {
106
107
        // This object will live forever, we will reuse it on future accesses
        // to the plugin.
Gilles Caulier's avatar
Gilles Caulier committed
108
        m_dlgExport = new VkontakteWindow(false, kapp->activeWindow());
109
110
111
112
113
114
115
116
117
118
119
120
    }
    else
    {
        if (m_dlgExport->isMinimized())
            KWindowSystem::unminimizeWindow(m_dlgExport->winId());

        KWindowSystem::activateWindow(m_dlgExport->winId());
    }

    m_dlgExport->startReactivation();
}

Gilles Caulier's avatar
Gilles Caulier committed
121
Category Plugin_Vkontakte::category(KAction* action) const
122
123
124
{
    if (action == m_actionExport)
    {
Gilles Caulier's avatar
Gilles Caulier committed
125
        return ExportPlugin;
126
127
128
    }

    kWarning() << "Unrecognized action for plugin category identification" ;
Gilles Caulier's avatar
Gilles Caulier committed
129
    return ExportPlugin;
130
131
}

Gilles Caulier's avatar
Gilles Caulier committed
132
} // namespace KIPIVkontaktePlugin