rajcewindow.cpp 3.62 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

Gilles Caulier's avatar
polish    
Gilles Caulier committed
25
26
// Qt includes

27
#include <QAction>
Gilles Caulier's avatar
Gilles Caulier committed
28

Gilles Caulier's avatar
polish    
Gilles Caulier committed
29
30
31
32
33
34
35
36
37
// KDE includes

#include <klocalizedstring.h>
#include <ktoolinvocation.h>
#include <khelpmenu.h>
#include <kmenu.h>
#include <kpushbutton.h>

// Local includes
38

Gilles Caulier's avatar
Gilles Caulier committed
39
40
41
#include "kpaboutdata.h"
#include "rajcewidget.h"

42
43
44
namespace KIPIRajceExportPlugin
{

Gilles Caulier's avatar
polish    
Gilles Caulier committed
45
46
RajceWindow::RajceWindow(KIPI::Interface* interface, const QString& tmpFolder,
                         QWidget* /*parent*/, Qt::WFlags /*flags*/)
Gilles Caulier's avatar
polish    
Gilles Caulier committed
47
    : KDialog(0), m_interface(interface)
48
{
Gilles Caulier's avatar
polish    
Gilles Caulier committed
49
50
    m_widget = new RajceWidget(interface, tmpFolder, this);
    m_widget->readSettings();
51

Gilles Caulier's avatar
polish    
Gilles Caulier committed
52
    setMainWidget(m_widget);
53
54
55
56
57
58
    setWindowIcon(KIcon("rajce"));
    setButtons(Help|User1|Close);
    setDefaultButton(Close);
    setModal(false);

    setWindowTitle(i18n("Export to Rajce.net"));
Gilles Caulier's avatar
polish    
Gilles Caulier committed
59
60
    setButtonGuiItem(User1, KGuiItem(i18n("Start Upload"), "network-workgroup",
                                     i18n("Start upload to Rajce.net")));
Gilles Caulier's avatar
polish    
Gilles Caulier committed
61
    m_widget->setMinimumSize(700, 500);
62
63

    connect(this, SIGNAL(user1Clicked()),
Gilles Caulier's avatar
polish    
Gilles Caulier committed
64
            m_widget, SLOT(startUpload()));
65
66
67
68

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

Gilles Caulier's avatar
polish    
Gilles Caulier committed
69
    connect(m_widget, SIGNAL(loginStatusChanged(bool)),
70
71
72
73
74
            this, SLOT(slotSetUploadButtonEnabled(bool)));

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

    m_about = new KIPIPlugins::KPAboutData(ki18n("Rajce.net Export"),
Gilles Caulier's avatar
polish    
Gilles Caulier committed
75
76
77
78
79
                               0,
                               KAboutData::License_GPL,
                               ki18n("A Kipi plugin to export image collections to "
                               "Rajce.net."),
                               ki18n( "(c) 2011, Lukas Krejci" ));
80

Gilles Caulier's avatar
polish    
Gilles Caulier committed
81
82
    m_about->addAuthor(ki18n( "Lukas Krejci" ), ki18n("Author and maintainer"),
                       "metlosh at gmail dot com");
83
84
85
86
87
88

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

    KHelpMenu* helpMenu = new KHelpMenu(this, m_about, false);
    helpMenu->menu()->removeAction(helpMenu->menu()->actions().first());
Gilles Caulier's avatar
polish    
Gilles Caulier committed
89
    QAction* handbook   = new QAction(i18n("Handbook"), this);
90
91
92
93
94
95
96
97
    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);
}

Gilles Caulier's avatar
polish    
Gilles Caulier committed
98
99
100
101
102
RajceWindow::~RajceWindow()
{
    delete m_about;
}

103
104
void RajceWindow::reactivate()
{
Gilles Caulier's avatar
polish    
Gilles Caulier committed
105
    m_widget->reactivate();
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
    show();
}

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

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

void RajceWindow::slotClose()
{
Gilles Caulier's avatar
polish    
Gilles Caulier committed
121
122
    m_widget->cancelUpload();
    m_widget->writeSettings();
123
124
125
}

} //namespace KIPIRajceExportPlugin