File indexing completed on 2025-01-05 03:53:42
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2008-12-07 0007 * Description : a tool to export images to Smugmug web service 0008 * 0009 * SPDX-FileCopyrightText: 2008-2009 by Luka Renko <lure at kubuntu dot org> 0010 * SPDX-FileCopyrightText: 2008-2024 by Gilles Caulier <caulier dot gilles at gmail dot com> 0011 * SPDX-FileCopyrightText: 2018 by Thanh Trung Dinh <dinhthanhtrung1996 at gmail dot com> 0012 * 0013 * SPDX-License-Identifier: GPL-2.0-or-later 0014 * 0015 * ============================================================ */ 0016 0017 #include "smugnewalbumdlg.h" 0018 0019 // Qt includes 0020 0021 #include <QFormLayout> 0022 #include <QVBoxLayout> 0023 #include <QHBoxLayout> 0024 #include <QRadioButton> 0025 #include <QApplication> 0026 #include <QLineEdit> 0027 #include <QDialogButtonBox> 0028 #include <QPushButton> 0029 0030 // KDE includes 0031 0032 #include <klocalizedstring.h> 0033 0034 // local includes 0035 0036 #include "smugitem.h" 0037 #include "dtextedit.h" 0038 0039 using namespace Digikam; 0040 0041 namespace DigikamGenericSmugPlugin 0042 { 0043 0044 class Q_DECL_HIDDEN SmugNewAlbumDlg::Private 0045 { 0046 public: 0047 0048 explicit Private() 0049 : templateCoB(nullptr), 0050 /* 0051 categCoB(nullptr) 0052 subCategCoB(nullptr), 0053 */ 0054 privBox(nullptr), 0055 titleEdt(nullptr), 0056 passwdEdt(nullptr), 0057 hintEdt(nullptr), 0058 descEdt(nullptr), 0059 publicRBtn(nullptr), 0060 unlistedRBtn(nullptr) 0061 { 0062 } 0063 0064 QComboBox* templateCoB; 0065 0066 /* Categories are deprecated 0067 QComboBox* categCoB; 0068 QComboBox* subCategCoB; 0069 */ 0070 0071 QGroupBox* privBox; 0072 DTextEdit* titleEdt; 0073 QLineEdit* passwdEdt; 0074 QLineEdit* hintEdt; 0075 DTextEdit* descEdt; 0076 QRadioButton* publicRBtn; 0077 QRadioButton* unlistedRBtn; 0078 }; 0079 0080 SmugNewAlbumDlg::SmugNewAlbumDlg(QWidget* const parent) 0081 : QDialog(parent), 0082 d (new Private) 0083 { 0084 QString header(i18n("SmugMug New Album")); 0085 setWindowTitle(header); 0086 setModal(false); 0087 setMinimumSize(400, 400); 0088 0089 // ------------------------------------------------------------------------ 0090 0091 const int spacing = qMin(QApplication::style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing), 0092 QApplication::style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing)); 0093 0094 QGroupBox* const albumBox = new QGroupBox(i18n("Album"), this); 0095 albumBox->setWhatsThis(i18n("These are basic settings for the new SmugMug album.")); 0096 0097 d->titleEdt = new DTextEdit; 0098 d->titleEdt->setWhatsThis(i18n("Title of the album that will be created (required).")); 0099 0100 /* Categories are deprecated 0101 d->categCoB = new QComboBox; 0102 d->categCoB->setEditable(false); 0103 d->categCoB->setWhatsThis(i18n("Category of the album that will be created (required).")); 0104 0105 d->subCategCoB = new QComboBox; 0106 d->subCategCoB->setEditable(false); 0107 d->subCategCoB->setWhatsThis(i18n("Subcategory of the album that will be created (optional).")); 0108 */ 0109 0110 d->descEdt = new DTextEdit(0, nullptr); 0111 d->descEdt->setWhatsThis(i18n("Description of the album that will be created (optional).")); 0112 0113 d->templateCoB = new QComboBox; 0114 d->templateCoB->setEditable(false); 0115 d->templateCoB->setWhatsThis(i18n("Album template for the new album (optional).")); 0116 0117 QFormLayout* const albumBoxLayout = new QFormLayout; 0118 albumBoxLayout->addRow(i18nc("new smug album dialog", "Title:"), d->titleEdt); 0119 0120 /* 0121 albumBoxLayout->addRow(i18nc("new smug album dialog", "Category:"), d->categCoB); 0122 albumBoxLayout->addRow(i18nc("new smug album dialog", "Subcategory:"), d->subCategCoB); 0123 */ 0124 0125 albumBoxLayout->addRow(i18nc("new smug album dialog", "Description:"), d->descEdt); 0126 albumBoxLayout->addRow(i18nc("new smug album dialog", "Template:"), d->templateCoB); 0127 albumBoxLayout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow); 0128 albumBoxLayout->setContentsMargins(spacing, spacing, spacing, spacing); 0129 albumBoxLayout->setSpacing(spacing); 0130 albumBox->setLayout(albumBoxLayout); 0131 0132 // ------------------------------------------------------------------------ 0133 0134 d->privBox = new QGroupBox(i18n("Security && Privacy"), this); 0135 d->privBox->setWhatsThis(i18n("These are security and privacy settings for the new SmugMug album.")); 0136 0137 d->publicRBtn = new QRadioButton(i18nc("smug album privacy", "Public")); 0138 d->publicRBtn->setChecked(true); 0139 d->publicRBtn->setWhatsThis(i18n("Public album is listed on your public SmugMug page.")); 0140 d->unlistedRBtn = new QRadioButton(i18nc("smug album privacy", "Unlisted")); 0141 d->unlistedRBtn->setWhatsThis(i18n("Unlisted album is only accessible via URL.")); 0142 0143 QHBoxLayout* const radioLayout = new QHBoxLayout; 0144 radioLayout->addWidget(d->publicRBtn); 0145 radioLayout->addWidget(d->unlistedRBtn); 0146 0147 d->passwdEdt = new QLineEdit; 0148 d->passwdEdt->setWhatsThis(i18n("Require password to access the album (optional).")); 0149 0150 d->hintEdt = new QLineEdit; 0151 d->hintEdt->setWhatsThis(i18n("Password hint to present to users in the password prompt (optional).")); 0152 0153 QFormLayout* const privBoxLayout = new QFormLayout; 0154 privBoxLayout->addRow(i18n("Privacy:"), radioLayout); 0155 privBoxLayout->addRow(i18n("Password:"), d->passwdEdt); 0156 privBoxLayout->addRow(i18n("Password Hint:"), d->hintEdt); 0157 privBoxLayout->setContentsMargins(spacing, spacing, spacing, spacing); 0158 privBoxLayout->setSpacing(spacing); 0159 d->privBox->setLayout(privBoxLayout); 0160 0161 // ------------------------------------------------------------------------ 0162 0163 QDialogButtonBox* const buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this); 0164 buttonBox->button(QDialogButtonBox::Cancel)->setDefault(true); 0165 0166 connect(buttonBox, &QDialogButtonBox::accepted, 0167 this, &QDialog::accept); 0168 0169 connect(buttonBox, &QDialogButtonBox::rejected, 0170 this, &QDialog::reject); 0171 0172 // ------------------------------------------------------------------------ 0173 0174 QVBoxLayout* const mainLayout = new QVBoxLayout(this); 0175 mainLayout->addWidget(albumBox); 0176 mainLayout->addWidget(d->privBox); 0177 mainLayout->addWidget(buttonBox); 0178 mainLayout->setContentsMargins(QMargins()); 0179 mainLayout->setSpacing(spacing); 0180 setLayout(mainLayout); 0181 } 0182 0183 SmugNewAlbumDlg::~SmugNewAlbumDlg() 0184 { 0185 delete d; 0186 } 0187 0188 void SmugNewAlbumDlg::getAlbumProperties(SmugAlbum& album) 0189 { 0190 album.title = d->titleEdt->text(); 0191 0192 /* Categories are deprecated 0193 album.category = d->categCoB->currentText(); 0194 album.categoryID = d->categCoB->itemData(d->categCoB->currentIndex()).toLongLong(); 0195 0196 album.subCategory = d->subCategCoB->currentText(); 0197 album.subCategoryID = d->subCategCoB->itemData(d->subCategCoB->currentIndex()).toLongLong(); 0198 */ 0199 0200 album.description = d->descEdt->toPlainText(); 0201 0202 album.tmpl = d->templateCoB->currentText(); 0203 album.tmplID = d->templateCoB->itemData(d->templateCoB->currentIndex()).toLongLong(); 0204 0205 album.isPublic = d->publicRBtn->isChecked(); 0206 album.password = d->passwdEdt->text(); 0207 album.passwordHint = d->hintEdt->text(); 0208 } 0209 0210 /* 0211 * Categories are deprecated 0212 * 0213 QComboBox* SmugNewAlbumDlg::categoryCombo() const 0214 { 0215 return d->categCoB; 0216 } 0217 0218 QComboBox* SmugNewAlbumDlg::subCategoryCombo() const 0219 { 0220 return d->subCategCoB; 0221 } 0222 */ 0223 0224 QComboBox* SmugNewAlbumDlg::templateCombo() const 0225 { 0226 return d->templateCoB; 0227 } 0228 0229 QGroupBox* SmugNewAlbumDlg::privateGroupBox() const 0230 { 0231 return d->privBox; 0232 } 0233 0234 } // namespace DigikamGenericSmugPlugin 0235 0236 #include "moc_smugnewalbumdlg.cpp"