Debian Codegraph @

core/dplugins/generic/tools/jalbum/wizard/jalbumoutputpage.cpp

raw
1 /* ============================================================
2 *
3 * This file is a part of digiKam project
4 * https://www.digikam.org
5 *
6 * Date : 2006-04-04
7 * Description : a tool to generate jAlbum image galleries
8 *
9 * SPDX-FileCopyrightText: 2013-2019 by Andrew Goodbody <ajg zero two at elfringham dot co dot uk>
10 *
11 * SPDX-License-Identifier: GPL-2.0-or-later
12 *
13 * ============================================================ */
14
15 #include "jalbumoutputpage.h"
16
17 // Qt includes
18
19 #include <QIcon>
20 #include <QLabel>
21 #include <QUrl>
22 #include <QWidget>
23 #include <QApplication>
24 #include <QStyle>
25 #include <QComboBox>
26 #include <QGridLayout>
27
28 // KDE includes
29
30 #include <klocalizedstring.h>
31
32 // Local includes
33
34 #include "digikam_globals.h"
35 #include "jalbumwizard.h"
36 #include "jalbumsettings.h"
37 #include "dfileselector.h"
38 #include "dtextedit.h"
39
40 namespace DigikamGenericJAlbumPlugin
41 {
42
43 class Q_DECL_HIDDEN JAlbumOutputPage::Private
44 {
45 public:
46
47 Private() = default;
48
49 public:
50
51 DFileSelector* destUrl = nullptr;
52 QLabel* titleLabel = nullptr;
53 DPlainTextEdit* imageSelectionTitle = nullptr;
54 };
55
56 JAlbumOutputPage::JAlbumOutputPage(QWizard* const dialog, const QString& title)
57 : DWizardPage(dialog, title),
58 d (new Private)
59 {
60 setObjectName(QLatin1String("OutputPage"));
61
62 QWidget* const main = new QWidget(this);
63
64 // --------------------
65
66 d->titleLabel = new QLabel(main);
67 d->titleLabel->setWordWrap(false);
68 d->titleLabel->setText(i18n("Project Title:"));
69
70 d->imageSelectionTitle = new DPlainTextEdit(main);
71 d->imageSelectionTitle->setLinesVisible(1);
72 d->imageSelectionTitle->setPlaceholderText(i18n("Set here the project title"));
73 d->titleLabel->setBuddy(d->imageSelectionTitle);
74
75 // --------------------
76
77 QLabel* const textLabel1 = new QLabel(main);
78 textLabel1->setWordWrap(false);
79 textLabel1->setText(i18n("Projects folder:"));
80
81 d->destUrl = new DFileSelector(main);
82 d->destUrl->setFileDlgTitle(i18nc("@title:window", "Projects Folder"));
83 d->destUrl->setFileDlgMode(QFileDialog::Directory);
84 d->destUrl->setFileDlgOptions(QFileDialog::ShowDirsOnly);
85 textLabel1->setBuddy(d->destUrl);
86
87 // --------------------
88
89 QGridLayout* const grid = new QGridLayout(main);
90 grid->setSpacing(layoutSpacing());
91 grid->addWidget(d->titleLabel, 0, 0, 1, 1);
92 grid->addWidget(d->imageSelectionTitle, 0, 1, 1, 1);
93 grid->addWidget(textLabel1, 1, 0, 1, 1);
94 grid->addWidget(d->destUrl, 1, 1, 1, 1);
95 grid->setRowStretch(2, 10);
96
97 // --------------------
98
99 setPageWidget(main);
100 setLeftBottomPix(QIcon::fromTheme(QLatin1String("folder-html")));
101
102 connect(d->destUrl->lineEdit(), SIGNAL(textEdited(QString)),
103 this, SIGNAL(completeChanged()));
104
105 connect(d->destUrl, SIGNAL(signalUrlSelected(QUrl)),
106 this, SIGNAL(completeChanged()));
107
108 connect(d->imageSelectionTitle, SIGNAL(textEdited(QString)),
109 this, SIGNAL(completeChanged()));
110 }
111
112 JAlbumOutputPage::~JAlbumOutputPage()
113 {
114 delete d;
115 }
116
117 void JAlbumOutputPage::initializePage()
118 {
119 JAlbumWizard* const wizard = dynamic_cast<JAlbumWizard*>(assistant());
120
121 if (!wizard)
122 {
123 return;
124 }
125
126 JAlbumSettings* const info = wizard->settings();
127
128 d->destUrl->setFileDlgPath(info->m_destPath);
129 d->imageSelectionTitle->setText(info->m_imageSelectionTitle);
130 }
131
132 bool JAlbumOutputPage::validatePage()
133 {
134 if (d->destUrl->fileDlgPath().isEmpty())
135 {
136 return false;
137 }
138
139 if (d->imageSelectionTitle->text().isEmpty())
140 {
141 return false;
142 }
143
144 JAlbumWizard* const wizard = dynamic_cast<JAlbumWizard*>(assistant());
145
146 if (!wizard)
147 {
148 return false;
149 }
150
151 JAlbumSettings* const settings = wizard->settings();
152 settings->m_destPath = d->destUrl->fileDlgPath();
153 settings->m_imageSelectionTitle = d->imageSelectionTitle->text();
154
155 return true;
156 }
157
158 bool JAlbumOutputPage::isComplete() const
159 {
160 const JAlbumWizard* const wizard = dynamic_cast<JAlbumWizard*>(assistant());
161
162 if (!wizard)
163 {
164 return false;
165 }
166
167 bool b = !d->destUrl->fileDlgPath().isEmpty();
168 b = b && !d->imageSelectionTitle->text().isEmpty();
169
170 return b;
171 }
172
173 } // namespace DigikamGenericJAlbumPlugin
174
175 #include "moc_jalbumoutputpage.cpp"