File indexing completed on 2025-01-05 03:53:31

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2012-02-02
0007  * Description : a tool to export items to ImageShack web service
0008  *
0009  * SPDX-FileCopyrightText: 2012      by Dodon Victor <dodonvictor at gmail dot com>
0010  * SPDX-FileCopyrightText: 2013-2023 by Caulier Gilles <caulier dot gilles at gmail dot com>
0011  *
0012  * SPDX-License-Identifier: GPL-2.0-or-later
0013  *
0014  * ============================================================ */
0015 
0016 #include "imageshackwidget_p.h"
0017 
0018 namespace DigikamGenericImageShackPlugin
0019 {
0020 
0021 ImageShackWidget::ImageShackWidget(QWidget* const parent,
0022                                    ImageShackSession* const session,
0023                                    DInfoInterface* const iface,
0024                                    const QString& toolName)
0025     : WSSettingsWidget(parent, iface, toolName),
0026       d               (new Private)
0027 {
0028     d->session            = session;
0029     d->iface              = iface;
0030     d->imgList            = imagesList();
0031     d->headerLbl          = getHeaderLbl();
0032     d->accountNameLbl     = getUserNameLabel();
0033     d->chgRegCodeBtn      = getChangeUserBtn();
0034     d->reloadGalleriesBtn = getReloadBtn();
0035     d->galleriesCob       = getAlbumsCoB();
0036     d->progressBar        = progressBar();
0037 
0038     connect(d->reloadGalleriesBtn, SIGNAL(clicked()),
0039             this, SLOT(slotReloadGalleries()));
0040 
0041     QGroupBox* const tagsBox      = new QGroupBox(QLatin1String(""), getSettingsBox());
0042     QGridLayout* const tagsLayout = new QGridLayout(tagsBox);
0043 
0044     d->privateImagesChb    = new QCheckBox(tagsBox);
0045     d->privateImagesChb->setText(i18nc("@option", "Make private"));
0046     d->privateImagesChb->setChecked(false);
0047 
0048     d->tagsFld             = new DTextEdit(tagsBox);
0049     d->tagsFld->setLinesVisible(1);
0050     QLabel* const tagsLbl  = new QLabel(i18nc("@label", "Tags (optional):"), tagsBox);
0051 
0052     d->remBarChb           = new QCheckBox(i18nc("@option", "Remove information bar on thumbnails"));
0053     d->remBarChb->setChecked(false);
0054 
0055     tagsLayout->addWidget(d->privateImagesChb, 0, 0);
0056     tagsLayout->addWidget(tagsLbl,             1, 0);
0057     tagsLayout->addWidget(d->tagsFld,          1, 1);
0058 
0059     addWidgetToSettingsBox(tagsBox);
0060 
0061     getUploadBox()->hide();
0062     getSizeBox()->hide();
0063 
0064     this->updateLabels();
0065 }
0066 
0067 ImageShackWidget::~ImageShackWidget()
0068 {
0069     delete d;
0070 }
0071 
0072 void ImageShackWidget::updateLabels(const QString& /*name*/, const QString& /*url*/)
0073 {
0074     if (d->session->loggedIn())
0075     {
0076         d->accountNameLbl->setText(d->session->username());
0077     }
0078     else
0079     {
0080         d->accountNameLbl->clear();
0081     }
0082 }
0083 
0084 void ImageShackWidget::slotGetGalleries(const QStringList& gTexts, const QStringList& gNames)
0085 {
0086     d->galleriesCob->clear();
0087 
0088     d->galleriesCob->addItem(i18nc("@item:inlistbox", "Add to root folder"),
0089                              QLatin1String("--add-to-root--"));
0090 
0091     d->galleriesCob->addItem(i18nc("@item:inlistbox", "Create new gallery"),
0092                              QLatin1String("--new-gallery--"));
0093 
0094     // TODO check if the lists have the same size
0095 
0096     for (int i = 0 ; i < gTexts.size() ; ++i)
0097     {
0098         qCDebug(DIGIKAM_WEBSERVICES_LOG) << "gTexts is "<<gTexts[i] << " gNames is "<<gNames[i];
0099         d->galleriesCob->addItem(gTexts[i], gNames[i]);
0100     }
0101 
0102 //     slotEnableNewGalleryLE(d->galleriesCob->currentIndex());
0103 }
0104 
0105 void ImageShackWidget::slotReloadGalleries()
0106 {
0107     Q_EMIT signalReloadGalleries();
0108 }
0109 
0110 } // namespace DigikamGenericImageShackPlugin
0111 
0112 #include "moc_imageshackwidget.cpp"