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

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2010-02-01
0007  * Description : a tool to export items to Google web services
0008  *
0009  * SPDX-FileCopyrightText: 2010 by Jens Mueller <tschenser at gmx dot de>
0010  *
0011  * SPDX-License-Identifier: GPL-2.0-or-later
0012  *
0013  * ============================================================ */
0014 
0015 #include "gsnewalbumdlg.h"
0016 
0017 // Qt includes
0018 
0019 #include <QFormLayout>
0020 #include <QVBoxLayout>
0021 #include <QHBoxLayout>
0022 #include <QGroupBox>
0023 #include <QDialogButtonBox>
0024 #include <QIcon>
0025 #include <QApplication>
0026 #include <QPushButton>
0027 
0028 // KDE includes
0029 
0030 #include <klocalizedstring.h>
0031 
0032 // Local includes
0033 
0034 #include "gsitem.h"
0035 
0036 namespace DigikamGenericGoogleServicesPlugin
0037 {
0038 
0039 class Q_DECL_HIDDEN GSNewAlbumDlg::Private
0040 {
0041 public:
0042 
0043     explicit Private()
0044       : publicRBtn   (nullptr),
0045         unlistedRBtn (nullptr),
0046         protectedRBtn(nullptr)
0047     {
0048     }
0049 
0050     QString        serviceName;
0051     QRadioButton*  publicRBtn;
0052     QRadioButton*  unlistedRBtn;
0053     QRadioButton*  protectedRBtn;
0054 };
0055 
0056 GSNewAlbumDlg::GSNewAlbumDlg(QWidget* const parent,
0057                              const QString& serviceName,
0058                              const QString& toolName)
0059     : WSNewAlbumDialog(parent, toolName),
0060       d               (new Private)
0061 {
0062     d->serviceName           = serviceName;
0063     const int spacing        = qMin(QApplication::style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing),
0064                                     QApplication::style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing));
0065 
0066     QGroupBox* const privBox = new QGroupBox(i18n("Access Level"), getMainWidget());
0067     privBox->setWhatsThis(i18n("These are security and privacy settings for the new Google Photos album."));
0068 
0069     d->publicRBtn        = new QRadioButton(i18nc("google photos album privacy", "Public"));
0070     d->publicRBtn->setChecked(true);
0071     d->publicRBtn->setWhatsThis(i18n("Public album is listed on your public Google Photos page."));
0072     d->unlistedRBtn      = new QRadioButton(i18nc("google photos album privacy", "Unlisted / Private"));
0073     d->unlistedRBtn->setWhatsThis(i18n("Unlisted album is only accessible via URL."));
0074     d->protectedRBtn     = new QRadioButton(i18nc("google photos album privacy", "Sign-In Required to View"));
0075     d->protectedRBtn->setWhatsThis(i18n("Unlisted album require Sign-In to View"));
0076 
0077     QVBoxLayout* const radioLayout = new QVBoxLayout;
0078     radioLayout->addWidget(d->publicRBtn);
0079     radioLayout->addWidget(d->unlistedRBtn);
0080     radioLayout->addWidget(d->protectedRBtn);
0081 
0082     QFormLayout* const privBoxLayout = new QFormLayout;
0083     privBoxLayout->addRow(i18n("Privacy:"), radioLayout);
0084     privBoxLayout->setContentsMargins(spacing, spacing, spacing, spacing);
0085     privBoxLayout->setSpacing(spacing);
0086     privBox->setLayout(privBoxLayout);
0087 
0088 /*  Album on google-photos now only needs title to create, so gdrive and gphoto now share the same newalbumdlg
0089 
0090     if (!(QString::compare(d->serviceName,
0091                            QLatin1String("googledriveexport"),
0092                            Qt::CaseInsensitive) == 0))
0093     {
0094         addToMainLayout(privBox);
0095     }
0096     else
0097     {
0098         privBox->hide();
0099         hideDateTime();
0100         hideDesc();
0101         hideLocation();
0102         getMainWidget()->setMinimumSize(300,0);
0103     }
0104 */
0105 
0106     privBox->hide();
0107     hideDateTime();
0108     hideDesc();
0109     hideLocation();
0110     getMainWidget()->setMinimumSize(300,0);
0111 
0112 }
0113 
0114 GSNewAlbumDlg::~GSNewAlbumDlg()
0115 {
0116     delete d;
0117 }
0118 
0119 void GSNewAlbumDlg::getAlbumProperties(GSFolder& album)
0120 {
0121 /*  Album on google-photos now only needs title to create, so gdrive and gphoto now share the same newalbumdlg
0122 
0123     if (QString::compare(d->serviceName,
0124                          QLatin1String("googledriveexport"),
0125                          Qt::CaseInsensitive) == 0)
0126     {
0127         album.title = getTitleEdit()->text();
0128         return;
0129     }
0130 
0131     album.title       = getTitleEdit()->text();
0132     album.description = getDescEdit()->toPlainText();
0133     album.location    = getLocEdit()->text();
0134 
0135     if (d->publicRBtn->isChecked())
0136     {
0137         album.access = QLatin1String("public");
0138     }
0139     else if (d->unlistedRBtn->isChecked())
0140     {
0141         album.access = QLatin1String("private");
0142     }
0143     else
0144     {
0145         album.access = QLatin1String("protected");
0146     }
0147 
0148     long long timestamp = getDateTimeEdit()->dateTime().toTime_t();
0149     album.timestamp     = QString::number(timestamp * 1000);
0150 */
0151 
0152     album.title = getTitleEdit()->text();
0153     return;
0154 }
0155 
0156 } // namespace DigikamGenericGoogleServicesPlugin
0157 
0158 #include "moc_gsnewalbumdlg.cpp"