File indexing completed on 2025-01-05 03:52:07
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2006-04-04 0007 * Description : a tool to generate jAlbum image galleries 0008 * 0009 * SPDX-FileCopyrightText: 2013-2019 by Andrew Goodbody <ajg zero two at elfringham dot co dot uk> 0010 * 0011 * SPDX-License-Identifier: GPL-2.0-or-later 0012 * 0013 * ============================================================ */ 0014 0015 #include "jalbumoutputpage.h" 0016 0017 // Qt includes 0018 0019 #include <QIcon> 0020 #include <QLabel> 0021 #include <QUrl> 0022 #include <QWidget> 0023 #include <QApplication> 0024 #include <QStyle> 0025 #include <QComboBox> 0026 #include <QGridLayout> 0027 0028 // KDE includes 0029 0030 #include <klocalizedstring.h> 0031 0032 // Local includes 0033 0034 #include "jalbumwizard.h" 0035 #include "jalbumsettings.h" 0036 #include "dfileselector.h" 0037 #include "dtextedit.h" 0038 0039 namespace DigikamGenericJAlbumPlugin 0040 { 0041 0042 class Q_DECL_HIDDEN JAlbumOutputPage::Private 0043 { 0044 public: 0045 0046 explicit Private() 0047 : destUrl (nullptr), 0048 titleLabel (nullptr), 0049 imageSelectionTitle (nullptr) 0050 { 0051 } 0052 0053 DFileSelector* destUrl; 0054 QLabel* titleLabel; 0055 DPlainTextEdit* imageSelectionTitle; 0056 }; 0057 0058 JAlbumOutputPage::JAlbumOutputPage(QWizard* const dialog, const QString& title) 0059 : DWizardPage(dialog, title), 0060 d (new Private) 0061 { 0062 setObjectName(QLatin1String("OutputPage")); 0063 0064 QWidget* const main = new QWidget(this); 0065 0066 // -------------------- 0067 0068 d->titleLabel = new QLabel(main); 0069 d->titleLabel->setWordWrap(false); 0070 d->titleLabel->setText(i18n("Project Title:")); 0071 0072 d->imageSelectionTitle = new DPlainTextEdit(main); 0073 d->imageSelectionTitle->setLinesVisible(1); 0074 d->imageSelectionTitle->setPlaceholderText(i18n("Set here the project title")); 0075 d->titleLabel->setBuddy(d->imageSelectionTitle); 0076 0077 // -------------------- 0078 0079 QLabel* const textLabel1 = new QLabel(main); 0080 textLabel1->setWordWrap(false); 0081 textLabel1->setText(i18n("Projects folder:")); 0082 0083 d->destUrl = new DFileSelector(main); 0084 d->destUrl->setFileDlgTitle(i18nc("@title:window", "Projects Folder")); 0085 d->destUrl->setFileDlgMode(QFileDialog::Directory); 0086 d->destUrl->setFileDlgOptions(QFileDialog::ShowDirsOnly); 0087 textLabel1->setBuddy(d->destUrl); 0088 0089 // -------------------- 0090 0091 QGridLayout* const grid = new QGridLayout(main); 0092 grid->setSpacing(qMin(QApplication::style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing), 0093 QApplication::style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing))); 0094 grid->addWidget(d->titleLabel, 0, 0, 1, 1); 0095 grid->addWidget(d->imageSelectionTitle, 0, 1, 1, 1); 0096 grid->addWidget(textLabel1, 1, 0, 1, 1); 0097 grid->addWidget(d->destUrl, 1, 1, 1, 1); 0098 grid->setRowStretch(2, 10); 0099 0100 // -------------------- 0101 0102 setPageWidget(main); 0103 setLeftBottomPix(QIcon::fromTheme(QLatin1String("folder-html"))); 0104 0105 connect(d->destUrl->lineEdit(), SIGNAL(textEdited(QString)), 0106 this, SIGNAL(completeChanged())); 0107 0108 connect(d->destUrl, SIGNAL(signalUrlSelected(QUrl)), 0109 this, SIGNAL(completeChanged())); 0110 0111 connect(d->imageSelectionTitle, SIGNAL(textEdited(QString)), 0112 this, SIGNAL(completeChanged())); 0113 } 0114 0115 JAlbumOutputPage::~JAlbumOutputPage() 0116 { 0117 delete d; 0118 } 0119 0120 void JAlbumOutputPage::initializePage() 0121 { 0122 JAlbumWizard* const wizard = dynamic_cast<JAlbumWizard*>(assistant()); 0123 0124 if (!wizard) 0125 return; 0126 0127 JAlbumSettings* const info = wizard->settings(); 0128 0129 d->destUrl->setFileDlgPath(info->m_destPath); 0130 d->imageSelectionTitle->setText(info->m_imageSelectionTitle); 0131 } 0132 0133 bool JAlbumOutputPage::validatePage() 0134 { 0135 if (d->destUrl->fileDlgPath().isEmpty()) 0136 return false; 0137 0138 if (d->imageSelectionTitle->text().isEmpty()) 0139 return false; 0140 0141 JAlbumWizard* const wizard = dynamic_cast<JAlbumWizard*>(assistant()); 0142 0143 if (!wizard) 0144 return false; 0145 0146 JAlbumSettings* const settings = wizard->settings(); 0147 settings->m_destPath = d->destUrl->fileDlgPath(); 0148 settings->m_imageSelectionTitle = d->imageSelectionTitle->text(); 0149 0150 return true; 0151 } 0152 0153 bool JAlbumOutputPage::isComplete() const 0154 { 0155 JAlbumWizard* const wizard = dynamic_cast<JAlbumWizard*>(assistant()); 0156 0157 if (!wizard) 0158 return false; 0159 0160 bool b = !d->destUrl->fileDlgPath().isEmpty(); 0161 b = b && !d->imageSelectionTitle->text().isEmpty(); 0162 0163 return b; 0164 } 0165 0166 } // namespace DigikamGenericJAlbumPlugin 0167 0168 #include "moc_jalbumoutputpage.cpp"