summaryrefslogtreecommitdiffstats
path: root/kipi-plugins/flickrexport/flickrwidget.cpp
blob: 1fb6d8cdf7c4a9b15bd77e173add5475e3915b67 (plain)
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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
/* ============================================================
 *
 * This file is a part of kipi-plugins project
 * http://www.kipi-plugins.org
 *
 * Date        : 2005-07-07
 * Description : a kipi plugin to export images to Flickr web service
 *
 * Copyright (C) 2005-2008 by Vardhman Jain <vardhman at gmail dot com>
 * Copyright (C) 2008 by Gilles Caulier <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.
 *
 * ============================================================ */

// TQt includes.

#include <tqpushbutton.h>
#include <tqlabel.h>
#include <tqframe.h>
#include <tqheader.h>
#include <tqbuttongroup.h>
#include <tqradiobutton.h>
#include <tqgroupbox.h>
#include <tqspinbox.h>
#include <tqcheckbox.h>
#include <tqlayout.h>
#include <tqtooltip.h>
#include <tqwhatsthis.h>

// KDE includes.

#include <ktabwidget.h>
#include <klineedit.h>
#include <kdialog.h>
#include <kactivelabel.h>
#include <klocale.h>
#include <tdehtml_part.h>
#include <tdehtmlview.h>
#include <kseparator.h>
#include <kiconloader.h>
#include <kapplication.h>

// Libkipi includes.

#include <libkipi/interface.h>

// Local includes.

#include "imageslist.h"
#include "flickrwidget.h"
#include "flickrwidget.moc"

namespace KIPIFlickrExportPlugin
{

FlickrWidget::FlickrWidget(TQWidget* parent, KIPI::Interface *iface)
            : TQWidget(parent)
{
    setName("FlickrWidget");

    TQVBoxLayout* flickrWidgetLayout = new TQVBoxLayout(this, 5, 5);

    m_photoView               = 0; //new TDEHTMLPart(splitter);
    KSeparator *line          = new KSeparator(Horizontal, this);
    m_tab                     = new KTabWidget(this);
    KActiveLabel *headerLabel = new KActiveLabel(this);
    headerLabel->setFocusPolicy(TQ_NoFocus);
    headerLabel->setLinkUnderline(false);
    headerLabel->setText(i18n("<qt><b><h2><a href='http://www.flickr.com'>"
                              "<font color=\"#0065DE\">flick</font>"
                              "<font color=\"#FF0084\">r</font></a>"
                              " Export"
                              "</h2></b></qt>"));

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

    m_imglst                       = new ImagesList(m_tab, iface);
    TQWidget* settingsBox           = new TQWidget(m_tab);
    TQVBoxLayout* settingsBoxLayout = new TQVBoxLayout(settingsBox);

    //m_newAlbumBtn = new TQPushButton(settingsBox, "m_newAlbumBtn");
    //m_newAlbumBtn->setSizePolicy(TQSizePolicy::Fixed, TQSizePolicy::Fixed);
    //m_newAlbumBtn->setText(i18n("&New Album"));

    TQGridLayout* tagsLayout  = new TQGridLayout(1, 1);
    TQLabel* tagsLabel        = new TQLabel(i18n("Added Tags: "), settingsBox);
    m_tagsLineEdit           = new KLineEdit(settingsBox);
    m_exportHostTagsCheckBox = new TQCheckBox(settingsBox);
    m_exportHostTagsCheckBox->setText(i18n("Use Host Application Tags"));
    m_stripSpaceTagsCheckBox = new TQCheckBox(settingsBox);
    m_stripSpaceTagsCheckBox->setText(i18n("Strip Space From Host Application Tags"));
    TQToolTip::add(m_tagsLineEdit, i18n("Enter here new tags separated by space."));

    tagsLayout->addWidget(tagsLabel,                0, 0);
    tagsLayout->addWidget(m_tagsLineEdit,           0, 1);
    tagsLayout->addWidget(m_exportHostTagsCheckBox, 1, 1);
    tagsLayout->addWidget(m_stripSpaceTagsCheckBox, 2, 1);

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

    TQGroupBox* optionsBox         = new TQGroupBox(i18n("Override Default Options"), settingsBox);
    optionsBox->setColumnLayout(0, Qt::Vertical);
    optionsBox->layout()->setSpacing(KDialog::spacingHint());
    optionsBox->layout()->setMargin(KDialog::spacingHint());
    TQGridLayout* optionsBoxLayout = new TQGridLayout(optionsBox->layout(), 5, 3);

    m_publicCheckBox = new TQCheckBox(optionsBox);
    m_publicCheckBox->setText(i18n("As in accessible for people", "Public (anyone can see them)"));

    m_familyCheckBox = new TQCheckBox(optionsBox);
    m_familyCheckBox->setText(i18n("Visible to Family"));

    m_friendsCheckBox = new TQCheckBox(optionsBox);
    m_friendsCheckBox->setText(i18n("Visible to Friends"));

    m_resizeCheckBox = new TQCheckBox(optionsBox);
    m_resizeCheckBox->setText(i18n("Resize photos before uploading"));
    m_resizeCheckBox->setChecked(false);

    m_dimensionSpinBox = new TQSpinBox(0, 5000, 10, optionsBox);
    m_dimensionSpinBox->setValue(600);
    m_dimensionSpinBox->setSizePolicy(TQSizePolicy::Fixed, TQSizePolicy::Fixed);
    m_dimensionSpinBox->setEnabled(false);

    TQLabel* resizeLabel = new TQLabel(i18n("Maximum dimension (pixels):"), optionsBox);

    m_imageQualitySpinBox = new TQSpinBox(0, 100, 1, optionsBox);
    m_imageQualitySpinBox->setValue(85);
    m_imageQualitySpinBox->setSizePolicy(TQSizePolicy::Fixed, TQSizePolicy::Fixed);

    // NOTE: The term Compression factor may be to technical to write in the label
    TQLabel* imageQualityLabel = new TQLabel(i18n("JPEG Image Quality (higher is better):"), optionsBox);

    optionsBoxLayout->addMultiCellWidget(m_publicCheckBox,      0, 0, 0, 3);
    optionsBoxLayout->addMultiCellWidget(m_familyCheckBox,      1, 1, 0, 3);
    optionsBoxLayout->addMultiCellWidget(m_friendsCheckBox,     2, 2, 0, 3);
    optionsBoxLayout->addMultiCellWidget(imageQualityLabel,     3, 3, 0, 2);
    optionsBoxLayout->addMultiCellWidget(m_imageQualitySpinBox, 3, 3, 3, 3);
    optionsBoxLayout->addMultiCellWidget(m_resizeCheckBox,      4, 4, 0, 3);
    optionsBoxLayout->addMultiCellWidget(resizeLabel,           5, 5, 1, 2);
    optionsBoxLayout->addMultiCellWidget(m_dimensionSpinBox,    5, 5, 3, 3);
    optionsBoxLayout->setColSpacing(0, KDialog::spacingHint());
    optionsBoxLayout->setColStretch(1, 10);
    optionsBoxLayout->setSpacing(KDialog::spacingHint());
    optionsBoxLayout->setMargin(0);

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

    TQGroupBox* accountBox = new TQGroupBox(i18n("Account"), settingsBox);
    accountBox->setColumnLayout(0, Qt::Vertical);
    accountBox->layout()->setSpacing(KDialog::spacingHint());
    accountBox->layout()->setMargin(KDialog::spacingHint());
    TQGridLayout* accountBoxLayout = new TQGridLayout(accountBox->layout(), 1, 3);

    TQLabel *userNameLabel  = new TQLabel(i18n("User Name: "), accountBox);
    m_userNameDisplayLabel = new TQLabel(accountBox);
    m_changeUserButton     = new TQPushButton(accountBox);
    m_changeUserButton->setText(i18n("Use a different account"));
    m_changeUserButton->setIconSet(SmallIcon("switchuser"));

    accountBoxLayout->addMultiCellWidget(userNameLabel,          0, 0, 0, 0);
    accountBoxLayout->addMultiCellWidget(m_userNameDisplayLabel, 0, 0, 1, 1);
    accountBoxLayout->addMultiCellWidget(m_changeUserButton,     0, 0, 3, 3);
    accountBoxLayout->setColStretch(2, 10);
    accountBoxLayout->setSpacing(KDialog::spacingHint());
    accountBoxLayout->setMargin(0);

    settingsBoxLayout->addLayout(tagsLayout);
    settingsBoxLayout->addWidget(optionsBox);
    settingsBoxLayout->addWidget(accountBox);
    settingsBoxLayout->addStretch(10);
    settingsBoxLayout->setSpacing(KDialog::spacingHint());
    settingsBoxLayout->setMargin(KDialog::spacingHint());

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

    flickrWidgetLayout->addWidget(headerLabel);
    flickrWidgetLayout->addWidget(line);
    flickrWidgetLayout->addWidget(m_tab, 5);
    flickrWidgetLayout->setSpacing(KDialog::spacingHint());
    flickrWidgetLayout->setMargin(0);

    m_tab->insertTab(m_imglst,    i18n("Files List"),     FILELIST);
    m_tab->insertTab(settingsBox, i18n("Upload Options"), UPLOAD);

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

    connect(m_resizeCheckBox, TQT_SIGNAL(clicked()),
            this, TQT_SLOT(slotResizeChecked()));

    connect(m_exportHostTagsCheckBox, TQT_SIGNAL(clicked()),
            this, TQT_SLOT(slotExportHostTagsChecked()));
}

FlickrWidget::~FlickrWidget()
{
}

void FlickrWidget::slotResizeChecked()
{
    m_dimensionSpinBox->setEnabled(m_resizeCheckBox->isChecked());
}

void FlickrWidget::slotExportHostTagsChecked()
{
    m_stripSpaceTagsCheckBox->setEnabled(m_exportHostTagsCheckBox->isChecked());
}

} // namespace KIPIFlickrExportPlugin