[4770] | 1 | /* ============================================================ |
---|
| 2 | * |
---|
| 3 | * This file is a part of kipi-plugins project |
---|
| 4 | * http://www.kipi-plugins.org |
---|
| 5 | * |
---|
| 6 | * Date : 2010-01-07 |
---|
| 7 | * Description : a plugin to export to a remote Piwigo server. |
---|
| 8 | * |
---|
| 9 | * Copyright (C) 2003-2005 by Renchi Raju <renchi dot raju at gmail dot com> |
---|
| 10 | * Copyright (C) 2006 by Colin Guthrie <kde@colin.guthr.ie> |
---|
| 11 | * Copyright (C) 2006-2009 by Gilles Caulier <caulier dot gilles at gmail dot com> |
---|
| 12 | * Copyright (C) 2008 by Andrea Diamantini <adjam7 at gmail dot com> |
---|
| 13 | * Copyright (C) 2010 by Frederic Coiffier <frederic dot coiffier at free dot com> |
---|
| 14 | * |
---|
| 15 | * This program is free software; you can redistribute it |
---|
| 16 | * and/or modify it under the terms of the GNU General |
---|
| 17 | * Public License as published by the Free Software Foundation; |
---|
| 18 | * either version 2, or (at your option) any later version. |
---|
| 19 | * |
---|
| 20 | * This program is distributed in the hope that it will be useful, |
---|
| 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 23 | * GNU General Public License for more details. |
---|
| 24 | * |
---|
| 25 | * ============================================================ */ |
---|
| 26 | |
---|
| 27 | #include "piwigoconfig.h" |
---|
| 28 | #include "piwigoconfig.moc" |
---|
| 29 | |
---|
| 30 | // Qt includes |
---|
| 31 | |
---|
| 32 | #include <QFrame> |
---|
| 33 | #include <QGridLayout> |
---|
| 34 | #include <QPushButton> |
---|
| 35 | |
---|
| 36 | // KDE includes |
---|
| 37 | |
---|
| 38 | #include <kdebug.h> |
---|
| 39 | #include <klocale.h> |
---|
| 40 | |
---|
| 41 | // LibKIPI includes |
---|
| 42 | |
---|
| 43 | #include <libkipi/version.h> |
---|
| 44 | #include <libkipi/interface.h> |
---|
| 45 | |
---|
| 46 | // Local includes |
---|
| 47 | |
---|
| 48 | #include "piwigos.h" |
---|
| 49 | |
---|
| 50 | namespace KIPIPiwigoExportPlugin |
---|
| 51 | { |
---|
| 52 | |
---|
| 53 | PiwigoEdit::PiwigoEdit(QWidget* pParent, Piwigo* pPiwigo, const QString& title) |
---|
| 54 | : KDialog(pParent, Qt::Dialog) |
---|
| 55 | { |
---|
| 56 | mpPiwigo = pPiwigo; |
---|
| 57 | |
---|
| 58 | setCaption(title); |
---|
| 59 | |
---|
| 60 | QFrame *page = new QFrame(this); |
---|
| 61 | QGridLayout* centerLayout = new QGridLayout(); |
---|
| 62 | page->setMinimumSize(500, 200); |
---|
| 63 | setMainWidget(page); |
---|
| 64 | |
---|
| 65 | mpNameEdit = new KLineEdit(this); |
---|
| 66 | centerLayout->addWidget(mpNameEdit, 0, 1); |
---|
| 67 | |
---|
| 68 | mpUrlEdit = new KLineEdit(this); |
---|
| 69 | centerLayout->addWidget(mpUrlEdit, 1, 1); |
---|
| 70 | |
---|
| 71 | mpUsernameEdit = new KLineEdit(this); |
---|
| 72 | centerLayout->addWidget(mpUsernameEdit, 2, 1); |
---|
| 73 | |
---|
| 74 | mpPasswordEdit = new KLineEdit(this); |
---|
| 75 | mpPasswordEdit->setEchoMode(KLineEdit::Password); |
---|
| 76 | centerLayout->addWidget(mpPasswordEdit, 3, 1); |
---|
| 77 | |
---|
| 78 | QLabel* namelabel = new QLabel(this); |
---|
| 79 | namelabel->setText(i18nc("piwigo login settings", "Name:")); |
---|
| 80 | centerLayout->addWidget(namelabel, 0, 0); |
---|
| 81 | |
---|
| 82 | QLabel* urlLabel = new QLabel(this); |
---|
| 83 | urlLabel->setText(i18nc("piwigo login settings", "URL:")); |
---|
| 84 | centerLayout->addWidget(urlLabel, 1, 0); |
---|
| 85 | |
---|
| 86 | QLabel* usernameLabel = new QLabel(this); |
---|
| 87 | usernameLabel->setText(i18nc("piwigo login settings", "Username:")); |
---|
| 88 | centerLayout->addWidget(usernameLabel, 2, 0); |
---|
| 89 | |
---|
| 90 | QLabel* passwdLabel = new QLabel(this); |
---|
| 91 | passwdLabel->setText(i18nc("piwigo login settings", "Password:")); |
---|
| 92 | centerLayout->addWidget(passwdLabel, 3, 0); |
---|
| 93 | |
---|
| 94 | //--------------------------------------------- |
---|
| 95 | |
---|
| 96 | page->setLayout(centerLayout); |
---|
| 97 | |
---|
| 98 | resize(QSize(300, 150).expandedTo(minimumSizeHint())); |
---|
| 99 | |
---|
| 100 | // setting initial data |
---|
| 101 | mpNameEdit->setText(pPiwigo->name()); |
---|
| 102 | mpUrlEdit->setText(pPiwigo->url()); |
---|
| 103 | mpUsernameEdit->setText(pPiwigo->username()); |
---|
| 104 | mpPasswordEdit->setText(pPiwigo->password()); |
---|
| 105 | |
---|
| 106 | connect(this, SIGNAL( okClicked() ), |
---|
| 107 | this, SLOT( slotOk() )); |
---|
| 108 | } |
---|
| 109 | |
---|
| 110 | PiwigoEdit::~PiwigoEdit() |
---|
| 111 | { |
---|
| 112 | } |
---|
| 113 | |
---|
| 114 | void PiwigoEdit::slotOk() |
---|
| 115 | { |
---|
| 116 | if (mpNameEdit->isModified()) |
---|
| 117 | mpPiwigo->setName(mpNameEdit->text()); |
---|
| 118 | |
---|
| 119 | if (mpUrlEdit->isModified()) |
---|
| 120 | mpPiwigo->setUrl(mpUrlEdit->text()); |
---|
| 121 | |
---|
| 122 | if (mpUsernameEdit->isModified()) |
---|
| 123 | mpPiwigo->setUsername(mpUsernameEdit->text()); |
---|
| 124 | |
---|
| 125 | if (mpPasswordEdit->isModified()) |
---|
| 126 | mpPiwigo->setPassword(mpPasswordEdit->text()); |
---|
| 127 | |
---|
| 128 | mpPiwigo->save(); |
---|
| 129 | accept(); |
---|
| 130 | } |
---|
| 131 | |
---|
| 132 | } // namespace KIPIPiwigoExportPlugin |
---|