1 /* ============================================================
2 *
3 * This file is a part of KDE project
4 *
5 *
6 * Date : 2011-02-11
7 * Description : A kipi plugin to export images to a MediaWiki wiki
8 *
9 * Copyright (C) 2011 by Alexandre Mendes <alex dot mendes1988 at gmail dot com>
10 * Copyright (C) 2011-2018 by Gilles Caulier <caulier dot gilles at gmail dot com>
11 * Copyright (C) 2012 by Parthasarathy Gopavarapu <gparthasarathy93 at gmail dot com>
12 * Copyright (C) 2012 by Nathan Damie <nathan dot damie at gmail dot com>
13 * Copyright (C) 2012 by Iliya Ivanov <ilko2002 at abv dot bg>
14 * Copyright (C) 2012-2016 by Peter Potrowl <peter dot potrowl at gmail dot com>
15 *
16 * This program is free software; you can redistribute it
17 * and/or modify it under the terms of the GNU General
18 * Public License as published by the Free Software Foundation;
19 * either version 2, or (at your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * ============================================================ */
27
28 #include "wmwidget.h"
29
30 // Qt includes
31
32 #include <QButtonGroup>
33 #include <QCheckBox>
34 #include <QComboBox>
35 #include <QGridLayout>
36 #include <QGroupBox>
37 #include <QHBoxLayout>
38 #include <QLabel>
39 #include <QMap>
40 #include <QProgressBar>
41 #include <QRadioButton>
42 #include <QScrollArea>
43 #include <QSpinBox>
44 #include <QTabWidget>
45 #include <QVBoxLayout>
46 #include <QApplication>
47 #include <QPushButton>
48 #include <QTextEdit>
49 #include <QLineEdit>
50
51 // KDE includes
52
53 #include <kconfiggroup.h>
54 #include <klocalizedstring.h>
55
56 // Libkipi includes
57
58 #include <KIPI/UploadWidget>
59 #include <KIPI/Interface>
60
61 // Local includes
62
63 #include "kputil.h"
64 #include "kpimageinfo.h"
65 #include "kpimageslist.h"
66 #include "kpprogresswidget.h"
67 #include "kipiplugins_debug.h"
68
69 using namespace KIPI;
70
71 namespace KIPIWikiMediaPlugin
72 {
73
74 class WmWidget::Private
75 {
76 public:
77
Private()78 Private()
79 {
80 fileBox = nullptr;
81 titleEdit = nullptr;
82 descEdit = nullptr;
83 dateEdit = nullptr;
84 longitudeEdit = nullptr;
85 latitudeEdit = nullptr;
86 categoryEdit = nullptr;
87 loginHeaderLbl = nullptr;
88 nameEdit = nullptr;
89 passwdEdit = nullptr;
90 newWikiSv = nullptr;
91 newWikiNameEdit = nullptr;
92 newWikiUrlEdit = nullptr;
93 wikiSelect = nullptr;
94 authorEdit = nullptr;
95 sourceEdit = nullptr;
96 genCatEdit = nullptr;
97 genTxtEdit = nullptr;
98 genComEdit = nullptr;
99 headerLbl = nullptr;
100 wikiNameDisplayLbl = nullptr;
101 userNameDisplayLbl = nullptr;
102 changeUserBtn = nullptr;
103 resizeChB = nullptr;
104 dimensionSpB = nullptr;
105 imageQualitySpB = nullptr;
106 removeMetaChB = nullptr;
107 removeGeoChB = nullptr;
108 licenseComboBox = nullptr;
109 progressBar = nullptr;
110 imgList = nullptr;
111 uploadWidget = nullptr;
112 defaultMessage = i18n("Select an image");
113 loginGBox = nullptr;
114 userGBox = nullptr;
115 }
116
117 QWidget* fileBox;
118 QLineEdit* titleEdit;
119 QTextEdit* descEdit;
120 QLineEdit* dateEdit;
121 QLineEdit* longitudeEdit;
122 QLineEdit* latitudeEdit;
123 QTextEdit* categoryEdit;
124
125 QLabel* loginHeaderLbl;
126 QLineEdit* nameEdit;
127 QLineEdit* passwdEdit;
128 QScrollArea* newWikiSv;
129 QLineEdit* newWikiNameEdit;
130 QLineEdit* newWikiUrlEdit;
131 QComboBox* wikiSelect;
132
133 QLineEdit* authorEdit;
134 QLineEdit* sourceEdit;
135
136 QTextEdit* genCatEdit;
137 QTextEdit* genTxtEdit;
138 QTextEdit* genComEdit;
139
140 QLabel* headerLbl;
141 QLabel* wikiNameDisplayLbl;
142 QLabel* userNameDisplayLbl;
143 QPushButton* changeUserBtn;
144
145 QCheckBox* resizeChB;
146 QSpinBox* dimensionSpB;
147 QSpinBox* imageQualitySpB;
148 QCheckBox* removeMetaChB;
149 QCheckBox* removeGeoChB;
150 QComboBox* licenseComboBox;
151
152 QGroupBox* loginGBox;
153 QGroupBox* userGBox;
154
155 KPProgressWidget* progressBar;
156
157 KPImagesList* imgList;
158 UploadWidget* uploadWidget;
159
160 QStringList WikisHistory;
161 QStringList UrlsHistory;
162
163 QString defaultMessage;
164
165 QMap <QString, QMap <QString, QString> > imagesDescInfo;
166 };
167
WmWidget(QWidget * const parent)168 WmWidget::WmWidget(QWidget* const parent)
169 : QWidget(parent),
170 d(new Private)
171 {
172 setObjectName(QLatin1String("WmWidget"));
173
174 const int spacing = QApplication::style()->pixelMetric(QStyle::PM_DefaultLayoutSpacing);
175
176 QVBoxLayout* const mainLayout = new QVBoxLayout(this);
177
178 // -------------------------------------------------------------------
179
180 d->headerLbl = new QLabel(this);
181 d->headerLbl->setWhatsThis(i18n("This is a clickable link to open the MediaWiki home page in a web browser."));
182 d->headerLbl->setOpenExternalLinks(true);
183 d->headerLbl->setFocusPolicy(Qt::NoFocus);
184
185 d->imgList = new KPImagesList(this);
186 d->imgList->setControlButtonsPlacement(KPImagesList::ControlButtonsBelow);
187 d->imgList->setAllowRAW(true);
188 d->imgList->loadImagesFromCurrentSelection();
189 d->imgList->listView()->setWhatsThis(i18n("This is the list of images to upload to the wiki."));
190
191 // --------------------- Upload tab ----------------------------------
192
193 QScrollArea* const wrapperScroll = new QScrollArea(this);
194 KPVBox* const wrapperPan = new KPVBox(wrapperScroll->viewport());
195 wrapperScroll->setWidget(wrapperPan);
196 wrapperScroll->setWidgetResizable(true);
197 wrapperScroll->setVisible(false);
198
199 QWidget* const wrapper = new QWidget(wrapperPan);
200 QHBoxLayout* const wrapperLayout = new QHBoxLayout(wrapper);
201
202 QScrollArea* const upload = new QScrollArea(wrapper);
203 KPVBox* const pan = new KPVBox(upload->viewport());
204 pan->setAutoFillBackground(true);
205
206 upload->setWidget(pan);
207 upload->setWidgetResizable(true);
208
209 KPVBox* const uploadBox = new KPVBox(pan);
210 QWidget* const uploadPanel = new QWidget(uploadBox);
211 QVBoxLayout* const uploadBoxLayout = new QVBoxLayout(uploadPanel);
212
213 d->fileBox = new QWidget(uploadBox);
214 d->fileBox->setWhatsThis(i18n("This is the login form to your account on the chosen wiki."));
215 QGridLayout* const fileBoxLayout = new QGridLayout(d->fileBox);
216
217 loadImageInfoFirstLoad();
218
219 d->titleEdit = new QLineEdit(d->defaultMessage, d->fileBox);
220 d->dateEdit = new QLineEdit(d->defaultMessage, d->fileBox);
221
222 d->descEdit = new QTextEdit(d->fileBox);
223 d->descEdit->setPlainText(d->defaultMessage);
224 d->descEdit->setTabChangesFocus(1);
225 d->descEdit->setAcceptRichText(false);
226 d->categoryEdit = new QTextEdit(d->fileBox);
227 d->categoryEdit->setPlainText(d->defaultMessage);
228 d->categoryEdit->setTabChangesFocus(1);
229 d->categoryEdit->setAcceptRichText(false);
230
231 d->latitudeEdit = new QLineEdit(d->defaultMessage, d->fileBox);
232 d->longitudeEdit = new QLineEdit(d->defaultMessage, d->fileBox);
233
234 QLabel* const titleLabel = new QLabel(d->fileBox);
235 titleLabel->setText(i18n("Title:"));
236 QLabel* const dateLabel = new QLabel(d->fileBox);
237 dateLabel->setText(i18n("Date:"));
238 QLabel* const descLabel = new QLabel(d->fileBox);
239 descLabel->setText(i18n("Description:"));
240 QLabel* const categoryLabel = new QLabel(d->fileBox);
241 categoryLabel->setText(i18n("Categories:"));
242 QLabel* const latitudeLabel = new QLabel(d->fileBox);
243 latitudeLabel->setText(i18n("Latitude:"));
244 QLabel* const longitudeLabel = new QLabel(d->fileBox);
245 longitudeLabel->setText(i18n("Longitude:"));
246
247 uploadBoxLayout->setSpacing(spacing);
248 uploadBoxLayout->addWidget(d->fileBox, 0, Qt::AlignTop);
249
250 fileBoxLayout->addWidget(titleLabel, 1, 0, 1, 1);
251 fileBoxLayout->addWidget(dateLabel, 2, 0, 1, 1);
252 fileBoxLayout->addWidget(descLabel, 3, 0, 1, 1);
253 fileBoxLayout->addWidget(categoryLabel, 4, 0, 1, 1);
254 fileBoxLayout->addWidget(latitudeLabel, 5, 0, 1, 1);
255 fileBoxLayout->addWidget(longitudeLabel, 6, 0, 1, 1);
256 fileBoxLayout->addWidget(d->titleEdit, 1, 1, 1, 3);
257 fileBoxLayout->addWidget(d->dateEdit, 2, 1, 1, 3);
258 fileBoxLayout->addWidget(d->descEdit, 3, 1, 1, 3);
259 fileBoxLayout->addWidget(d->categoryEdit, 4, 1, 1, 3);
260 fileBoxLayout->addWidget(d->latitudeEdit, 5, 1, 1, 3);
261 fileBoxLayout->addWidget(d->longitudeEdit, 6, 1, 1, 3);
262
263 // --------------------- Config tab ----------------------------------
264
265 QScrollArea* const config = new QScrollArea(wrapper);
266 KPVBox* const panel2 = new KPVBox(config->viewport());
267 config->setWidget(panel2);
268 config->setWidgetResizable(true);
269
270 // --------------------- Account area ----------------------------------
271
272 d->userGBox = new QGroupBox(panel2);
273 d->userGBox->setTitle(i18n("Account"));
274 d->userGBox->setWhatsThis(i18n("This is the login form to your MediaWiki account."));
275
276 QGridLayout* const loginBoxLayout = new QGridLayout(d->userGBox);
277 d->userGBox->setLayout(loginBoxLayout);
278
279 d->wikiSelect = new QComboBox(d->userGBox);
280 d->wikiSelect->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLength);
281 QPushButton* const newWikiBtn = new QPushButton(QIcon::fromTheme(QLatin1String("list-add")), i18n("New"), d->userGBox);
282 newWikiBtn->setToolTip(i18n("Add a wiki to this list"));
283 d->nameEdit = new QLineEdit(d->userGBox);
284 d->passwdEdit = new QLineEdit(d->userGBox);
285 d->passwdEdit->setEchoMode(QLineEdit::Password);
286
287 d->wikiSelect->addItem(i18n("Wikimedia Commons"), QLatin1String("https://commons.wikimedia.org/w/api.php"));
288 d->wikiSelect->addItem(i18n("Wikimedia Meta"), QLatin1String("https://meta.wikimedia.org/w/api.php"));
289 d->wikiSelect->addItem(i18n("Wikipedia"), QLatin1String("https://en.wikipedia.org/w/api.php"));
290 d->wikiSelect->addItem(i18n("Wikibooks"), QLatin1String("https://en.wikibooks.org/w/api.php"));
291 d->wikiSelect->addItem(i18n("Wikinews"), QLatin1String("https://en.wikinews.org/w/api.php"));
292 d->wikiSelect->addItem(i18n("Wikiquote"), QLatin1String("https://en.wikiquote.org/w/api.php"));
293 d->wikiSelect->addItem(i18n("Wikisource"), QLatin1String("https://en.wikinews.org/w/api.php"));
294 d->wikiSelect->addItem(i18n("Wiktionary"), QLatin1String("https://en.wiktionary.org/w/api.php"));
295 d->wikiSelect->addItem(i18n("MediaWiki"), QLatin1String("https://www.mediawiki.org/w/api.php"));
296 d->wikiSelect->addItem(i18n("Wikia Foto"), QLatin1String("https://foto.wikia.com/api.php"));
297 d->wikiSelect->addItem(i18n("Wikia Uncyclopedia"), QLatin1String("https://uncyclopedia.wikia.com/api.php"));
298
299 d->wikiSelect->setEditable(false);
300
301 QLabel* const wikiLabel = new QLabel(d->userGBox);
302 wikiLabel->setText(i18n("Wiki:"));
303
304 // --------------------- New wiki area ----------------------------------
305
306 d->newWikiSv = new QScrollArea(this);
307 KPVBox* const newWikiPanel = new KPVBox(d->newWikiSv->viewport());
308 d->newWikiSv->setWidget(newWikiPanel);
309 d->newWikiSv->setWidgetResizable(true);
310 d->newWikiSv->setVisible(false);
311
312 QWidget* const newWikiBox = new QWidget(newWikiPanel);
313 newWikiBox->setWhatsThis(i18n("These are options for adding a Wiki."));
314
315 QGridLayout* const newWikiLayout = new QGridLayout(newWikiBox);
316
317 QLabel* const newWikiNameLabel = new QLabel(newWikiPanel);
318 newWikiNameLabel->setText(i18n("Name:"));
319
320 QLabel* const newWikiUrlLabel = new QLabel(newWikiPanel);
321 newWikiUrlLabel->setText(i18n("API URL:"));
322
323 d->newWikiNameEdit = new QLineEdit(newWikiPanel);
324 d->newWikiUrlEdit = new QLineEdit(newWikiPanel);
325
326 QPushButton* const addWikiBtn = new QPushButton(QIcon::fromTheme(QLatin1String("list-add")), i18n("Add"), newWikiPanel);
327 addWikiBtn->setToolTip(i18n("Add a new wiki"));
328
329 newWikiLayout->addWidget(newWikiNameLabel, 0, 0, 1, 1);
330 newWikiLayout->addWidget(d->newWikiNameEdit, 0, 1, 1, 1);
331 newWikiLayout->addWidget(newWikiUrlLabel, 1, 0, 1, 1);
332 newWikiLayout->addWidget(d->newWikiUrlEdit, 1, 1, 1, 1);
333 newWikiLayout->addWidget(addWikiBtn, 2, 1, 1, 1);
334
335 QLabel* const nameLabel = new QLabel(d->userGBox);
336 nameLabel->setText(i18n( "Login:" ));
337
338 QLabel* const passwdLabel = new QLabel(d->userGBox);
339 passwdLabel->setText(i18n("Password:"));
340
341 QPushButton* const loginBtn = new QPushButton(d->userGBox);
342 loginBtn->setAutoDefault(true);
343 loginBtn->setDefault(true);
344 loginBtn->setText(i18n("&Log in"));
345
346 loginBoxLayout->addWidget(wikiLabel, 0, 0, 1, 1);
347 loginBoxLayout->addWidget(d->wikiSelect, 0, 1, 1, 1);
348 loginBoxLayout->addWidget(newWikiBtn, 0, 2, 1, 1);
349 loginBoxLayout->addWidget(d->newWikiSv, 1, 1, 3, 3);
350 loginBoxLayout->addWidget(nameLabel, 4, 0, 1, 1);
351 loginBoxLayout->addWidget(d->nameEdit, 4, 1, 1, 1);
352 loginBoxLayout->addWidget(passwdLabel, 5, 0, 1, 1);
353 loginBoxLayout->addWidget(d->passwdEdit, 5, 1, 1, 1);
354 loginBoxLayout->addWidget(loginBtn, 6, 0, 1, 1);
355 loginBoxLayout->setObjectName(QLatin1String("loginBoxLayout"));
356
357 // --------------------- Login info area ----------------------------------
358
359 d->loginGBox = new QGroupBox(panel2);
360 d->loginGBox->setTitle(i18n("Login Information"));
361
362 QGridLayout* const linfoBoxLayout = new QGridLayout(d->loginGBox);
363 d->loginGBox->setLayout(linfoBoxLayout);
364
365 QLabel* const wikiNameLbl = new QLabel(d->loginGBox);
366 wikiNameLbl->setText(i18nc("Name of the wiki the user is currently logged on", "Logged on: "));
367 d->wikiNameDisplayLbl = new QLabel(d->loginGBox);
368
369 QLabel* const userNameLbl = new QLabel(d->loginGBox);
370 userNameLbl->setText(i18nc("Username which is used to connect to the wiki", "Logged as: "));
371 d->userNameDisplayLbl = new QLabel(d->loginGBox);
372
373 d->changeUserBtn = new QPushButton(QIcon::fromTheme(QLatin1String("system-switch-user")), i18n("Change Account"), d->loginGBox);
374 d->changeUserBtn->setToolTip(i18n("Logout and change the account used for transfer"));
375
376 linfoBoxLayout->addWidget(wikiNameLbl, 0, 0, 1, 1);
377 linfoBoxLayout->addWidget(d->wikiNameDisplayLbl, 0, 1, 1, 1);
378 linfoBoxLayout->addWidget(userNameLbl, 1, 0, 1, 1);
379 linfoBoxLayout->addWidget(d->userNameDisplayLbl, 1, 1, 1, 1);
380 linfoBoxLayout->addWidget(d->changeUserBtn, 2, 0, 1, 2);
381 d->loginGBox->hide();
382
383 // --------------------- Info area ----------------------------------
384
385 QGroupBox* const textGBox = new QGroupBox(panel2);
386 textGBox->setTitle(i18n("Information"));
387 textGBox->setWhatsThis(i18n("This is the login form to your account on the chosen wiki."));
388
389 QGridLayout* const textBoxLayout = new QGridLayout(textGBox);
390 textGBox->setLayout(textBoxLayout);
391
392 QLabel* const authorLbl = new QLabel(i18n("Author:"), textGBox);
393 d->authorEdit = new QLineEdit(textGBox);
394
395 QLabel* const sourceLbl = new QLabel(i18n("Source:"), textGBox);
396 d->sourceEdit = new QLineEdit(textGBox);
397
398 QLabel* const licenseLbl = new QLabel(i18n("License:"), textGBox);
399 d->licenseComboBox = new QComboBox(textGBox);
400 d->licenseComboBox->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLength);
401
402 d->licenseComboBox->addItem(i18n("Own work, Creative Commons Attribution-Share Alike 4.0"),
403 QLatin1String("{{self|cc-by-sa-4.0}}"));
404 d->licenseComboBox->addItem(i18n("Own work, multi-license with CC-BY-SA-3.0 and GFDL"),
405 QLatin1String("{{self|cc-by-sa-3.0|GFDL|migration=redundant}}"));
406 d->licenseComboBox->addItem(i18n("Own work, multi-license with CC-BY-SA-3.0 and older"),
407 QLatin1String("{{self|cc-by-sa-3.0,2.5,2.0,1.0}}"));
408 d->licenseComboBox->addItem(i18n("Own work, Creative Commons Attribution-Share Alike 3.0"),
409 QLatin1String("{{self|cc-by-sa-3.0}}"));
410 d->licenseComboBox->addItem(i18n("Own work, Creative Commons Attribution 3.0"),
411 QLatin1String("{{self|cc-by-3.0}}"));
412 d->licenseComboBox->addItem(i18n("Own work, release into public domain under the CC-Zero license"),
413 QLatin1String("{{self|cc-zero}}"));
414 d->licenseComboBox->addItem(i18n("Author died more than 100 years ago"),
415 QLatin1String("{{PD-old}}"));
416 d->licenseComboBox->addItem(i18n("Photo of a two-dimensional work whose author died more than 100 years ago"),
417 QLatin1String("{{PD-art}}"));
418 d->licenseComboBox->addItem(i18n("First published in the United States before 1923"),
419 QLatin1String("{{PD-US}}"));
420 d->licenseComboBox->addItem(i18n("Work of a U.S. government agency"),
421 QLatin1String("{{PD-USGov}}"));
422 d->licenseComboBox->addItem(i18n("Simple typefaces, individual words or geometric shapes"),
423 QLatin1String("{{PD-text}}"));
424 d->licenseComboBox->addItem(i18n("Logos with only simple typefaces, individual words or geometric shapes"),
425 QLatin1String("{{PD-textlogo}}"));
426 d->licenseComboBox->addItem(i18n("No license specified (not recommended for public wiki sites)"),
427 QLatin1String(""));
428
429 QLabel* const genCatLbl = new QLabel(i18n("Generic categories:"), textGBox);
430 d->genCatEdit = new QTextEdit(textGBox);
431 d->genCatEdit->setTabChangesFocus(1);
432 d->genCatEdit->setWhatsThis(i18n("This is a place to enter categories that will be added to all the files."));
433 d->genCatEdit->setAcceptRichText(false);
434
435 QLabel* const genTxtLbl = new QLabel(i18n("Generic text:"), textGBox);
436 d->genTxtEdit = new QTextEdit(textGBox);
437 d->genTxtEdit->setTabChangesFocus(1);
438 d->genTxtEdit->setWhatsThis(i18n("This is a place to enter text that will be added to all the files, "
439 "below the Information template."));
440 d->genTxtEdit->setAcceptRichText(false);
441
442 QLabel* const genComLbl = new QLabel(i18n("Upload comments:"), textGBox);
443 d->genComEdit = new QTextEdit(textGBox);
444 d->genComEdit->setTabChangesFocus(1);
445 d->genComEdit->setWhatsThis(i18n("This is a place to enter text that will be used as upload comments. "
446 "The default of 'Uploaded via KIPI uploader' will be used if empty."));
447 d->genComEdit->setAcceptRichText(false);
448
449 textBoxLayout->addWidget(authorLbl, 1, 0, 1, 1);
450 textBoxLayout->addWidget(sourceLbl, 2, 0, 1, 1);
451 textBoxLayout->addWidget(licenseLbl, 3, 0, 1, 1);
452 textBoxLayout->addWidget(genCatLbl, 4, 0, 1, 1);
453 textBoxLayout->addWidget(genTxtLbl, 5, 0, 1, 1);
454 textBoxLayout->addWidget(genComLbl, 6, 0, 1, 1);
455
456 textBoxLayout->addWidget(d->authorEdit, 1, 2, 1, 2);
457 textBoxLayout->addWidget(d->sourceEdit, 2, 2, 1, 2);
458 textBoxLayout->addWidget(d->licenseComboBox, 3, 2, 1, 2);
459 textBoxLayout->addWidget(d->genCatEdit, 4, 2, 1, 2);
460 textBoxLayout->addWidget(d->genTxtEdit, 5, 2, 1, 2);
461 textBoxLayout->addWidget(d->genComEdit, 6, 2, 1, 2);
462 textBoxLayout->setObjectName(QLatin1String("textBoxLayout"));
463
464 // --------------------- Options area ----------------------------------
465
466 QGroupBox* const optGBox = new QGroupBox(panel2);
467 optGBox->setTitle(i18n("Options"));
468 optGBox->setWhatsThis(i18n("These are options that will be applied to photos before upload."));
469
470 QGridLayout* const optionsBoxLayout = new QGridLayout(optGBox);
471 optGBox->setLayout(optionsBoxLayout);
472
473 d->resizeChB = new QCheckBox(optGBox);
474 d->resizeChB->setText(i18n("Resize photos before uploading"));
475 d->resizeChB->setChecked(false);
476
477 d->dimensionSpB = new QSpinBox(optGBox);
478 d->dimensionSpB->setMinimum(0);
479 d->dimensionSpB->setMaximum(10000);
480 d->dimensionSpB->setSingleStep(10);
481 d->dimensionSpB->setValue(1600);
482 d->dimensionSpB->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
483 d->dimensionSpB->setEnabled(false);
484 QLabel* const dimensionLbl = new QLabel(i18n("Maximum size:"), optGBox);
485
486 d->imageQualitySpB = new QSpinBox(optGBox);
487 d->imageQualitySpB->setMinimum(0);
488 d->imageQualitySpB->setMaximum(100);
489 d->imageQualitySpB->setSingleStep(1);
490 d->imageQualitySpB->setValue(85);
491 d->imageQualitySpB->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
492 QLabel* const imageQualityLbl = new QLabel(i18n("JPEG quality:"), optGBox);
493
494 d->removeMetaChB = new QCheckBox(optGBox);
495 d->removeMetaChB->setText(i18n("Remove metadata from file"));
496 d->removeMetaChB->setChecked(false);
497
498 d->removeGeoChB = new QCheckBox(optGBox);
499 d->removeGeoChB->setText(i18n("Remove coordinates from file"));
500 d->removeGeoChB->setChecked(false);
501
502 optionsBoxLayout->addWidget(d->resizeChB, 0, 0, 1, 2);
503 optionsBoxLayout->addWidget(dimensionLbl, 1, 0, 1, 1);
504 optionsBoxLayout->addWidget(imageQualityLbl, 2, 0, 1, 1);
505 optionsBoxLayout->addWidget(d->dimensionSpB, 1, 1, 1, 1);
506 optionsBoxLayout->addWidget(d->imageQualitySpB, 2, 1, 1, 1);
507 optionsBoxLayout->addWidget(d->removeMetaChB, 3, 0, 1, 2);
508 optionsBoxLayout->addWidget(d->removeGeoChB, 4, 0, 1, 2);
509 optionsBoxLayout->setRowStretch(3, 10);
510 optionsBoxLayout->setSpacing(spacing);
511 optionsBoxLayout->setContentsMargins(spacing, spacing, spacing, spacing);
512
513 // ------------------------------------------------------------------------
514
515 QTabWidget* const tabWidget = new QTabWidget;
516 tabWidget->addTab(upload, i18n("Items Properties"));
517 tabWidget->addTab(config, i18n("Upload Settings"));
518 tabWidget->setMinimumWidth(350);
519
520 // ------------------------------------------------------------------------
521
522 d->progressBar = new KPProgressWidget(this);
523 d->progressBar->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
524 d->progressBar->hide();
525
526 // ------------------------------------------------------------------------
527
528 wrapperLayout->addWidget(d->imgList);
529 wrapperLayout->addWidget(tabWidget);
530 wrapperLayout->setStretch(0, 10);
531 wrapperLayout->setStretch(1, 5);
532
533 mainLayout->addWidget(d->headerLbl);
534 mainLayout->addWidget(wrapper);
535 mainLayout->setSpacing(spacing);
536 mainLayout->addWidget(d->progressBar);
537 mainLayout->setContentsMargins(QMargins());
538
539 updateLabels(); // use empty labels until login
540
541 // --------------------- Slots definition ----------------------------------
542
543 connect(d->resizeChB, SIGNAL(clicked()),
544 this, SLOT(slotResizeChecked()));
545
546 connect(d->removeMetaChB, SIGNAL(clicked()),
547 this, SLOT(slotRemoveMetaChecked()));
548
549 connect(d->changeUserBtn, SIGNAL(clicked()),
550 this, SLOT(slotChangeUserClicked()));
551
552 connect(loginBtn, SIGNAL(clicked()),
553 this, SLOT(slotLoginClicked()));
554
555 connect(newWikiBtn, SIGNAL(clicked()),
556 this, SLOT(slotNewWikiClicked()));
557
558 connect(addWikiBtn, SIGNAL(clicked()),
559 this, SLOT(slotAddWikiClicked()));
560
561 connect(d->titleEdit, SIGNAL(editingFinished()),
562 this, SLOT(slotRestoreExtension()));
563
564 connect(d->titleEdit, SIGNAL(textEdited(QString)),
565 this, SLOT(slotApplyTitle()));
566
567 connect(d->dateEdit, SIGNAL(textEdited(QString)),
568 this, SLOT(slotApplyDate()));
569
570 // Problem: textChanged() is also called when the text is changed by setText()
571 // textEdited() would be better, but QTextEdit does not have this.
572 // Solution for the moment: we do not setText() when the selection changes
573 connect(d->categoryEdit, SIGNAL(textChanged()),
574 this, SLOT(slotApplyCategories()));
575
576 // Problem: textChanged() is also called when the text is changed by setText()
577 // textEdited() would be better, but QTextEdit does not have this.
578 // Solution for the moment: we do not setText() when the selection changes
579 connect(d->descEdit, SIGNAL(textChanged()),
580 this, SLOT(slotApplyDescription()));
581
582 connect(d->latitudeEdit, SIGNAL(textEdited(QString)),
583 this, SLOT(slotApplyLatitude()));
584
585 connect(d->longitudeEdit, SIGNAL(textEdited(QString)),
586 this, SLOT(slotApplyLongitude()));
587
588 connect(d->imgList, SIGNAL(signalItemClicked(QTreeWidgetItem*)),
589 this, SLOT(slotLoadImagesDesc(QTreeWidgetItem*)));
590
591 connect(d->imgList, SIGNAL(signalRemovedItems(QList<QUrl>)),
592 this, SLOT(slotRemoveImagesDesc(QList<QUrl>)));
593 }
594
~WmWidget()595 WmWidget::~WmWidget()
596 {
597 delete d;
598 }
599
readSettings(KConfigGroup & group)600 void WmWidget::readSettings(KConfigGroup& group)
601 {
602 qCDebug(KIPIPLUGINS_LOG) << "Read settings from" << group.name();
603
604 d->authorEdit->setText(group.readEntry("Author", ""));
605 d->sourceEdit->setText(group.readEntry("Source", "{{own}}"));
606
607 d->genCatEdit->setText(group.readEntry("genCategories", "Uploaded with KIPI uploader"));
608 d->genTxtEdit->setText(group.readEntry("genText", ""));
609
610 d->genComEdit->setText(group.readEntry("Comments", "Uploaded with KIPI uploader"));
611 d->resizeChB->setChecked(group.readEntry("Resize", false));
612 d->dimensionSpB->setValue(group.readEntry("Dimension", 1600));
613 d->imageQualitySpB->setValue(group.readEntry("Quality", 85));
614 d->removeMetaChB->setChecked(group.readEntry("RemoveMeta", false));
615 d->removeGeoChB->setChecked(group.readEntry("RemoveGeo", false));
616 slotResizeChecked();
617 slotRemoveMetaChecked();
618
619 d->WikisHistory = group.readEntry("Wikis history", QStringList());
620 d->UrlsHistory = group.readEntry("Urls history", QStringList());
621
622 qCDebug(KIPIPLUGINS_LOG) << "UrlHistory.size: " << d->UrlsHistory.size() << "; WikisHistory.size:" << d->WikisHistory.size();
623
624 for(int i = 0 ; i < d->UrlsHistory.size() && i < d->WikisHistory.size() ; i++)
625 {
626 d->wikiSelect->addItem(d->WikisHistory.at(i), d->UrlsHistory.at(i));
627 }
628 }
629
saveSettings(KConfigGroup & group)630 void WmWidget::saveSettings(KConfigGroup& group)
631 {
632 qCDebug(KIPIPLUGINS_LOG) << "Save settings to" << group.name();
633
634 group.writeEntry("Author", d->authorEdit->text());
635 group.writeEntry("Source", d->sourceEdit->text());
636
637 group.writeEntry("genCategories", d->genCatEdit->toPlainText());
638 group.writeEntry("genText", d->genTxtEdit->toPlainText());
639 group.writeEntry("Comments", d->genComEdit->toPlainText());
640
641 group.writeEntry("Resize", d->resizeChB->isChecked());
642 group.writeEntry("Dimension", d->dimensionSpB->value());
643 group.writeEntry("Quality", d->imageQualitySpB->value());
644
645 group.writeEntry("RemoveMeta", d->removeMetaChB->isChecked());
646 group.writeEntry("RemoveGeo", d->removeGeoChB->isChecked());
647 }
648
imagesList() const649 KPImagesList* WmWidget::imagesList() const
650 {
651 return d->imgList;
652 }
653
progressBar() const654 KPProgressWidget* WmWidget::progressBar() const
655 {
656 return d->progressBar;
657 }
658
updateLabels(const QString & userName,const QString & wikiName,const QString & url)659 void WmWidget::updateLabels(const QString& userName, const QString& wikiName, const QString& url)
660 {
661 QString web = QLatin1String("https://www.mediawiki.org");
662
663 if (url.isEmpty())
664 {
665 d->wikiNameDisplayLbl->clear();
666 }
667 else
668 {
669 web = url;
670 d->wikiNameDisplayLbl->setText(QString::fromLatin1("<b>%1</b>").arg(wikiName));
671 }
672
673 d->headerLbl->setText(QString::fromUtf8("<h2><b><a href='%1'><font color=\"#3B5998\">%2</font></a></b></h2>").arg(web).arg(wikiName));
674
675 if (userName.isEmpty())
676 {
677 d->userNameDisplayLbl->clear();
678 }
679 else
680 {
681 d->userNameDisplayLbl->setText(QString::fromLatin1("<b>%1</b>").arg(userName));
682 }
683 }
684
invertAccountLoginBox()685 void WmWidget::invertAccountLoginBox()
686 {
687 if (d->loginGBox->isHidden())
688 {
689 d->userGBox->hide();
690 d->loginGBox->show();
691 }
692 else
693 {
694 d->userGBox->show();
695 d->loginGBox->hide();
696 }
697 }
698
slotResizeChecked()699 void WmWidget::slotResizeChecked()
700 {
701 d->dimensionSpB->setEnabled(d->resizeChB->isChecked());
702 d->imageQualitySpB->setEnabled(d->resizeChB->isChecked());
703 }
704
slotRemoveMetaChecked()705 void WmWidget::slotRemoveMetaChecked()
706 {
707 d->removeGeoChB->setEnabled(!d->removeMetaChB->isChecked());
708 d->removeGeoChB->setChecked(d->removeMetaChB->isChecked());
709 }
710
slotChangeUserClicked()711 void WmWidget::slotChangeUserClicked()
712 {
713 emit signalChangeUserRequest();
714 }
715
slotLoginClicked()716 void WmWidget::slotLoginClicked()
717 {
718 emit signalLoginRequest(d->nameEdit->text(), d->passwdEdit->text(),
719 d->wikiSelect->itemText(d->wikiSelect->currentIndex()),
720 d->wikiSelect->itemData(d->wikiSelect->currentIndex()).toUrl());
721 }
722
slotNewWikiClicked()723 void WmWidget::slotNewWikiClicked()
724 {
725 if (d->newWikiSv->isVisible())
726 {
727 d->newWikiSv->setVisible(false);
728 }
729 else
730 {
731 d->newWikiSv->setVisible(true);
732 }
733 }
734
slotAddWikiClicked()735 void WmWidget::slotAddWikiClicked()
736 {
737 KConfig config(QLatin1String("kipirc"));
738 KConfigGroup group = config.group(QLatin1String("MediaWiki export settings"));
739
740 d->UrlsHistory << d->newWikiUrlEdit->text();
741 group.writeEntry(QLatin1String("Urls history"), d->UrlsHistory);
742
743 d->WikisHistory << d->newWikiNameEdit->text();
744 group.writeEntry(QLatin1String("Wikis history"), d->WikisHistory);
745
746 d->wikiSelect->addItem(d->newWikiNameEdit->text(), d->newWikiUrlEdit->text());
747 d->wikiSelect->setCurrentIndex(d->wikiSelect->count()-1);
748
749 slotNewWikiClicked();
750 }
751
loadImageInfoFirstLoad()752 void WmWidget::loadImageInfoFirstLoad()
753 {
754 QList<QUrl> urls = d->imgList->imageUrls(false);
755
756 d->imagesDescInfo.clear();
757
758 for (int j = 0; j < urls.size(); j++)
759 {
760 loadImageInfo(urls.at(j));
761 }
762 }
763
loadImageInfo(const QUrl & url)764 void WmWidget::loadImageInfo(const QUrl& url)
765 {
766 KPImageInfo info(url);
767 QStringList keywar = info.keywords();
768 QString date = info.date().toString(Qt::ISODate).replace(QLatin1String("T"), QLatin1String(" "), Qt::CaseSensitive);
769 QString title = info.name();
770 QString description = info.title();
771 QString currentCategories;
772 QString latitude;
773 QString longitude;
774
775 for (int i = 0; i < keywar.size(); i++)
776 {
777 if (i == keywar.size() - 1)
778 {
779 currentCategories.append(keywar.at(i));
780 }
781 else
782 {
783 currentCategories.append(keywar.at(i)).append(QLatin1String("\n"));
784 }
785 }
786
787 if (info.hasLatitude())
788 {
789 latitude = QString::number(info.latitude(), 'f', 9);
790 }
791
792 if (info.hasLongitude())
793 {
794 longitude = QString::number(info.longitude(), 'f', 9);
795 }
796
797 QMap<QString, QString> imageMetaData;
798 imageMetaData[QLatin1String("title")] = title;
799 imageMetaData[QLatin1String("date")] = date;
800 imageMetaData[QLatin1String("categories")] = currentCategories;
801 imageMetaData[QLatin1String("description")] = description;
802 imageMetaData[QLatin1String("latitude")] = latitude;
803 imageMetaData[QLatin1String("longitude")] = longitude;
804 d->imagesDescInfo.insert(url.toLocalFile(), imageMetaData);
805 }
806
clearEditFields()807 void WmWidget::clearEditFields()
808 {
809 d->titleEdit->setText(d->defaultMessage);
810 d->dateEdit->setText(d->defaultMessage);
811 d->descEdit->setText(d->defaultMessage);
812 d->categoryEdit->setText(d->defaultMessage);
813 d->latitudeEdit->setText(d->defaultMessage);
814 d->longitudeEdit->setText(d->defaultMessage);
815 }
816
slotLoadImagesDesc(QTreeWidgetItem * item)817 void WmWidget::slotLoadImagesDesc(QTreeWidgetItem* item)
818 {
819 QList<QTreeWidgetItem*> selectedItems = d->imgList->listView()->selectedItems();
820 KPImagesListViewItem* const l_item = dynamic_cast<KPImagesListViewItem*>(item);
821
822 if (!l_item)
823 return;
824
825 QMap<QString, QString> imageMetaData;
826
827 if (!d->imagesDescInfo.contains(l_item->url().toLocalFile()))
828 {
829 loadImageInfo(l_item->url());
830 }
831
832 imageMetaData = d->imagesDescInfo[l_item->url().toLocalFile()];
833
834 d->titleEdit->setText(imageMetaData[QLatin1String("title")]);
835 d->dateEdit->setText(imageMetaData[QLatin1String("date")].replace(QLatin1String("T"), QLatin1String(" "), Qt::CaseSensitive));
836 d->latitudeEdit->setText(imageMetaData[QLatin1String("latitude")]);
837 d->longitudeEdit->setText(imageMetaData[QLatin1String("longitude")]);
838
839 if (selectedItems.size() == 1)
840 {
841 d->categoryEdit->setText(imageMetaData[QLatin1String("categories")]);
842 d->descEdit->setText(imageMetaData[QLatin1String("description")]);
843 }
844 }
845
slotRemoveImagesDesc(const QList<QUrl> urls)846 void WmWidget::slotRemoveImagesDesc(const QList<QUrl> urls)
847 {
848 for (QList<QUrl>::const_iterator it = urls.begin(); it != urls.end(); ++it)
849 {
850 QString path = (*it).toLocalFile();
851 d->imagesDescInfo.remove(path);
852 qCDebug(KIPIPLUGINS_LOG) << "Remove" << path << "; new length:" << d->imagesDescInfo.size();
853 }
854 }
855
slotRestoreExtension()856 void WmWidget::slotRestoreExtension()
857 {
858 qCDebug(KIPIPLUGINS_LOG) << "RestoreExtension";
859
860 QString imageTitle;
861 QString originalExtension;
862 QString currentExtension;
863 QList<QUrl> urls;
864 QMap<QString, QString> imageMetaData;
865 QList<QTreeWidgetItem*> selectedItems = d->imgList->listView()->selectedItems();
866
867 // Build the list of items to rename
868 for (int i = 0; i < selectedItems.size(); ++i)
869 {
870 KPImagesListViewItem* const l_item = dynamic_cast<KPImagesListViewItem*>(selectedItems.at(i));
871
872 if (l_item)
873 urls.append(l_item->url());
874 }
875
876 for (int i = 0; i < urls.size(); ++i)
877 {
878 imageMetaData = d->imagesDescInfo[urls.at(i).toLocalFile()];
879 imageTitle = imageMetaData[QLatin1String("title")];
880
881 // Add original extension if removed
882 currentExtension = imageTitle.split(QLatin1Char('.')).last();
883 originalExtension = urls.at(i).toLocalFile().split(QLatin1Char('.')).last();
884
885 if (QString::compare(currentExtension, originalExtension, Qt::CaseInsensitive) != 0)
886 {
887 imageTitle.append(QLatin1String(".")).append(originalExtension);
888 d->titleEdit->setText(imageTitle);
889 }
890
891 qCDebug(KIPIPLUGINS_LOG) << urls.at(i).toLocalFile() << "renamed to" << imageTitle;
892 imageMetaData[QLatin1String("title")] = imageTitle;
893 d->imagesDescInfo[urls.at(i).toLocalFile()] = imageMetaData;
894 }
895 }
896
slotApplyTitle()897 void WmWidget::slotApplyTitle()
898 {
899 qCDebug(KIPIPLUGINS_LOG) << "ApplyTitle";
900
901 QString givenTitle = title();
902 QString imageTitle;
903 QString number;
904 QList<QUrl> urls;
905 QMap<QString, QString> imageMetaData;
906 QList<QTreeWidgetItem*> selectedItems = d->imgList->listView()->selectedItems();
907 QStringList parts;
908
909 const int minLength = givenTitle.count(QLatin1String("#"));
910
911 // Build the list of items to rename
912 for (int i = 0; i < selectedItems.size(); ++i)
913 {
914 KPImagesListViewItem* const l_item = dynamic_cast<KPImagesListViewItem*>(selectedItems.at(i));
915
916 if (l_item)
917 urls.append(l_item->url());
918 }
919
920 for (int i = 0; i < urls.size(); ++i)
921 {
922 imageMetaData = d->imagesDescInfo[urls.at(i).toLocalFile()];
923 imageTitle = givenTitle;
924
925 // If there is at least one #, replace it the correct number
926 if (minLength > 0)
927 {
928 parts = imageTitle.split(QLatin1String("#"), QString::KeepEmptyParts);
929 imageTitle = parts.first().append(QLatin1String("#")).append(parts.last());
930 number = QString::number(i + 1);
931
932 while (number.length() < minLength)
933 {
934 number.prepend(QLatin1String("0"));
935 }
936
937 imageTitle.replace(imageTitle.indexOf(QLatin1String("#")), 1, number);
938 }
939
940 qCDebug(KIPIPLUGINS_LOG) << urls.at(i).toLocalFile() << "renamed to" << imageTitle;
941 imageMetaData[QLatin1String("title")] = imageTitle;
942 d->imagesDescInfo[urls.at(i).toLocalFile()] = imageMetaData;
943 }
944 }
945
slotApplyDate()946 void WmWidget::slotApplyDate()
947 {
948 QList<QUrl> urls;
949 QList<QTreeWidgetItem*> selectedItems = d->imgList->listView()->selectedItems();
950
951 for (int i = 0; i < selectedItems.size(); ++i)
952 {
953 KPImagesListViewItem* const l_item = dynamic_cast<KPImagesListViewItem*>(selectedItems.at(i));
954
955 if (l_item)
956 urls.append(l_item->url());
957 }
958
959 for (int i = 0; i < urls.size(); ++i)
960 {
961 QMap<QString, QString> imageMetaData;
962 imageMetaData = d->imagesDescInfo[urls.at(i).toLocalFile()];
963 imageMetaData[QLatin1String("date")] = date();
964 d->imagesDescInfo[urls.at(i).toLocalFile()] = imageMetaData;
965 }
966 }
967
slotApplyCategories()968 void WmWidget::slotApplyCategories()
969 {
970 QList<QUrl> urls;
971 QList<QTreeWidgetItem*> selectedItems = d->imgList->listView()->selectedItems();
972
973 for (int i = 0; i < selectedItems.size(); ++i)
974 {
975 KPImagesListViewItem* const l_item = dynamic_cast<KPImagesListViewItem*>(selectedItems.at(i));
976
977 if (l_item)
978 urls.append(l_item->url());
979 }
980
981 for (int i = 0; i < urls.size(); ++i)
982 {
983 QMap<QString, QString> imageMetaData;
984 imageMetaData = d->imagesDescInfo[urls.at(i).toLocalFile()];
985 imageMetaData[QLatin1String("categories")] = categories();
986 d->imagesDescInfo[urls.at(i).toLocalFile()] = imageMetaData;
987 }
988 }
989
slotApplyDescription()990 void WmWidget::slotApplyDescription()
991 {
992 QList<QUrl> urls;
993 QList<QTreeWidgetItem*> selectedItems = d->imgList->listView()->selectedItems();
994
995 for (int i = 0; i < selectedItems.size(); ++i)
996 {
997 KPImagesListViewItem* const l_item = dynamic_cast<KPImagesListViewItem*>(selectedItems.at(i));
998
999 if (l_item)
1000 urls.append(l_item->url());
1001 }
1002
1003 for (int i = 0; i < urls.size(); ++i)
1004 {
1005 QMap<QString, QString> imageMetaData;
1006 imageMetaData = d->imagesDescInfo[urls.at(i).toLocalFile()];
1007 imageMetaData[QLatin1String("description")] = description();
1008 d->imagesDescInfo[urls.at(i).toLocalFile()] = imageMetaData;
1009 }
1010 }
1011
slotApplyLatitude()1012 void WmWidget::slotApplyLatitude()
1013 {
1014
1015 QList<QUrl> urls;
1016 QList<QTreeWidgetItem*> selectedItems = d->imgList->listView()->selectedItems();
1017
1018 for (int i = 0; i < selectedItems.size(); ++i)
1019 {
1020 KPImagesListViewItem* const l_item = dynamic_cast<KPImagesListViewItem*>(selectedItems.at(i));
1021
1022 if (l_item)
1023 urls.append(l_item->url());
1024 }
1025
1026 for (int i = 0; i < urls.size(); ++i)
1027 {
1028 QMap<QString, QString> imageMetaData;
1029 imageMetaData = d->imagesDescInfo[urls.at(i).toLocalFile()];
1030 imageMetaData[QLatin1String("latitude")] = latitude();
1031 d->imagesDescInfo[urls.at(i).toLocalFile()] = imageMetaData;
1032 }
1033 }
1034
slotApplyLongitude()1035 void WmWidget::slotApplyLongitude()
1036 {
1037 QList<QUrl> urls;
1038 QList<QTreeWidgetItem*> selectedItems = d->imgList->listView()->selectedItems();
1039
1040 for (int i = 0; i < selectedItems.size(); ++i)
1041 {
1042 KPImagesListViewItem* const l_item = dynamic_cast<KPImagesListViewItem*>(selectedItems.at(i));
1043
1044 if (l_item)
1045 urls.append(l_item->url());
1046 }
1047
1048 for (int i = 0; i < urls.size(); ++i)
1049 {
1050 QMap<QString, QString> imageMetaData;
1051 imageMetaData = d->imagesDescInfo[urls.at(i).toLocalFile()];
1052 imageMetaData[QLatin1String("longitude")] = longitude();
1053 d->imagesDescInfo[urls.at(i).toLocalFile()] = imageMetaData;
1054 }
1055 }
1056
allImagesDesc()1057 QMap <QString,QMap <QString,QString> > WmWidget::allImagesDesc()
1058 {
1059 QList<QUrl> urls = d->imgList->imageUrls(false);
1060
1061 for (int i = 0; i < urls.size(); ++i)
1062 {
1063 QMap<QString, QString> imageMetaData = d->imagesDescInfo[urls.at(i).toLocalFile()];
1064 imageMetaData[QLatin1String("author")] = author();
1065 imageMetaData[QLatin1String("source")] = source();
1066 imageMetaData[QLatin1String("license")] = license();
1067 imageMetaData[QLatin1String("genCategories")] = genCategories();
1068 imageMetaData[QLatin1String("genText")] = genText();
1069 imageMetaData[QLatin1String("comments")] = genComments();
1070 d->imagesDescInfo[urls.at(i).toLocalFile()] = imageMetaData;
1071 }
1072
1073 return d->imagesDescInfo;
1074 }
1075
author() const1076 QString WmWidget::author() const
1077 {
1078 qCDebug(KIPIPLUGINS_LOG) << "WmWidget::author()";
1079 return d->authorEdit->text();
1080 }
1081
source() const1082 QString WmWidget::source() const
1083 {
1084 qCDebug(KIPIPLUGINS_LOG) << "WmWidget::source()";
1085 return d->sourceEdit->text();
1086 }
1087
genCategories() const1088 QString WmWidget::genCategories() const
1089 {
1090 qCDebug(KIPIPLUGINS_LOG) << "WmWidget::genCategories()";
1091 return d->genCatEdit->toPlainText();
1092 }
1093
genText() const1094 QString WmWidget::genText() const
1095 {
1096 qCDebug(KIPIPLUGINS_LOG) << "WmWidget::genText()";
1097 return d->genTxtEdit->toPlainText();
1098 }
1099
genComments() const1100 QString WmWidget::genComments() const
1101 {
1102 qCDebug(KIPIPLUGINS_LOG) << "WmWidget::genComments()";
1103 return d->genComEdit->toPlainText();
1104 }
1105
quality() const1106 int WmWidget::quality() const
1107 {
1108 qCDebug(KIPIPLUGINS_LOG) << "WmWidget::quality()";
1109 return d->imageQualitySpB->value();
1110 }
1111
dimension() const1112 int WmWidget::dimension() const
1113 {
1114 qCDebug(KIPIPLUGINS_LOG) << "WmWidget::dimension()";
1115 return d->dimensionSpB->value();
1116 }
1117
resize() const1118 bool WmWidget::resize() const
1119 {
1120 qCDebug(KIPIPLUGINS_LOG) << "WmWidget::resize()";
1121 return d->resizeChB->isChecked();
1122 }
1123
removeMeta() const1124 bool WmWidget::removeMeta() const
1125 {
1126 qCDebug(KIPIPLUGINS_LOG) << "WmWidget::removeMeta()";
1127 return d->removeMetaChB->isChecked();
1128 }
1129
removeGeo() const1130 bool WmWidget::removeGeo() const
1131 {
1132 qCDebug(KIPIPLUGINS_LOG) << "WmWidget::removeGeo()";
1133 return d->removeGeoChB->isChecked();
1134 }
1135
license() const1136 QString WmWidget::license() const
1137 {
1138 qCDebug(KIPIPLUGINS_LOG) << "WmWidget::license()";
1139 return d->licenseComboBox->itemData(d->licenseComboBox->currentIndex()).toString();
1140 }
1141
title() const1142 QString WmWidget::title() const
1143 {
1144 qCDebug(KIPIPLUGINS_LOG) << "WmWidget::title()";
1145 return d->titleEdit->text();
1146 }
1147
categories() const1148 QString WmWidget::categories() const
1149 {
1150 qCDebug(KIPIPLUGINS_LOG) << "WmWidget::categories()";
1151 return d->categoryEdit->toPlainText();
1152 }
1153
description() const1154 QString WmWidget::description() const
1155 {
1156 qCDebug(KIPIPLUGINS_LOG) << "WmWidget::description()";
1157 return d->descEdit->toPlainText();
1158 }
1159
date() const1160 QString WmWidget::date() const
1161 {
1162 qCDebug(KIPIPLUGINS_LOG) << "WmWidget::date()";
1163 return d->dateEdit->text();
1164 }
1165
latitude() const1166 QString WmWidget::latitude() const
1167 {
1168 qCDebug(KIPIPLUGINS_LOG) << "WmWidget::latitude()";
1169 return d->latitudeEdit->text();
1170 }
1171
longitude() const1172 QString WmWidget::longitude() const
1173 {
1174 qCDebug(KIPIPLUGINS_LOG) << "WmWidget::longitude()";
1175 return d->longitudeEdit->text();
1176 }
1177
1178 } // namespace KIPIWikimediaPlugin
1179