rajcewindow.cpp 3.54 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/* ============================================================
 *
 * This file is a part of kipi-plugins project
 * http://www.kipi-plugins.org
 *
 * Date        : 2011-04-12
 * Description : A KIPI Plugin to export albums to rajce.net
 *
 * Copyright (C) 2011 by Lukas Krejci <krejci.l at centrum dot cz>
 *
 * 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
23
#include "rajcewindow.moc"
24
25

#include <QAction>
Gilles Caulier's avatar
Gilles Caulier committed
26

27
28
29
30
31
32
#include <KLocalizedString>
#include <KToolInvocation>
#include <KHelpMenu>
#include <KMenu>
#include <KPushButton>

Gilles Caulier's avatar
Gilles Caulier committed
33
34
35
#include "kpaboutdata.h"
#include "rajcewidget.h"

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
namespace KIPIRajceExportPlugin
{

RajceWindow::RajceWindow(KIPI::Interface* interface, const QString& tmpFolder, QWidget* parent,
    Qt::WFlags flags): KDialog(0), _interface(interface)
{
    _widget = new RajceWidget(interface, tmpFolder, this);

    _widget->readSettings();

    setMainWidget(_widget);
    setWindowIcon(KIcon("rajce"));
    setButtons(Help|User1|Close);
    setDefaultButton(Close);
    setModal(false);

    setWindowTitle(i18n("Export to Rajce.net"));
    setButtonGuiItem(User1,
                     KGuiItem(i18n("Start Upload"), "network-workgroup",
                                   i18n("Start upload to Rajce.net")));
    _widget->setMinimumSize(700, 500);

    connect(this, SIGNAL(user1Clicked()),
            _widget, SLOT(startUpload()));

    connect(this, SIGNAL(closeClicked()),
            this, SLOT(slotClose()));

    connect(_widget, SIGNAL(loginStatusChanged(bool)),
            this, SLOT(slotSetUploadButtonEnabled(bool)));

    //--------------------------------------------------------------------

    m_about = new KIPIPlugins::KPAboutData(ki18n("Rajce.net Export"),
                              0,
                              KAboutData::License_GPL,
                              ki18n("A Kipi plugin to export image collections to "
                              "Rajce.net."),
                              ki18n( "(c) 2011, Lukas Krejci" ));

                              m_about->addAuthor(ki18n( "Lukas Krejci" ), ki18n("Author and maintainer"),
                                                        "metlosh at gmail dot com");

    disconnect(this, SIGNAL( helpClicked() ),
               this, SLOT( showHelp()) );

    KHelpMenu* helpMenu = new KHelpMenu(this, m_about, false);
    helpMenu->menu()->removeAction(helpMenu->menu()->actions().first());
    QAction *handbook   = new QAction(i18n("Handbook"), this);
    connect(handbook, SIGNAL(triggered(bool)),
            this, SLOT(showHelp()));
    helpMenu->menu()->insertAction(helpMenu->menu()->actions().first(), handbook);
    button(Help)->setMenu(helpMenu->menu());

    button(User1)->setEnabled(false);
}

void RajceWindow::reactivate()
{
    _widget->reactivate();
    show();
}

void RajceWindow::showHelp()
{
    KToolInvocation::invokeHelp("rajceexport", "kipi-plugins");
}

void RajceWindow::slotSetUploadButtonEnabled(bool enabled)
{
    button(User1)->setEnabled(enabled);
}

void RajceWindow::slotClose()
{
    _widget->cancelUpload();
    _widget->writeSettings();
}

} //namespace KIPIRajceExportPlugin