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