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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199 | /* ============================================================
*
* This file is a part of digiKam project
* https://www.digikam.org
*
* Date : 2006-04-04
* Description : a tool to generate HTML image galleries
*
* SPDX-FileCopyrightText: 2012-2025 by Gilles Caulier <caulier dot gilles at gmail dot com>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*
* ============================================================ */
#include "htmloutputpage.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 "dtextedit.h"
#include "htmlwizard.h"
#include "galleryinfo.h"
#include "dfileselector.h"
namespace DigikamGenericHtmlGalleryPlugin
{
class Q_DECL_HIDDEN HTMLOutputPage::Private
{
public:
Private() = default;
DFileSelector* destUrl = nullptr;
QComboBox* openInBrowser = nullptr;
QLabel* titleLabel = nullptr;
DTextEdit* imageSelectionTitle = nullptr;
};
HTMLOutputPage::HTMLOutputPage(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(i18nc("@label", "Gallery Title:"));
d->imageSelectionTitle = new DTextEdit(main);
d->imageSelectionTitle->setLinesVisible(1);
d->titleLabel->setBuddy(d->imageSelectionTitle);
// --------------------
QLabel* const textLabel1 = new QLabel(main);
textLabel1->setWordWrap(false);
textLabel1->setText(i18nc("@label", "Destination folder:"));
d->destUrl = new DFileSelector(main);
d->destUrl->setFileDlgTitle(i18nc("@title:window", "Destination Folder"));
d->destUrl->setFileDlgMode(QFileDialog::Directory);
d->destUrl->setFileDlgOptions(QFileDialog::ShowDirsOnly);
textLabel1->setBuddy(d->destUrl);
// --------------------
QLabel* const browserLabel = new QLabel(main);
browserLabel->setWordWrap(false);
browserLabel->setText(i18nc("@label", "Open in Browser:"));
d->openInBrowser = new QComboBox(main);
d->openInBrowser->addItem(i18nc("@item: open in browser", "None"), GalleryConfig::NOBROWSER);
d->openInBrowser->addItem(i18nc("@item: open in browser", "Internal"), GalleryConfig::INTERNAL);
d->openInBrowser->addItem(i18nc("@item: open in browser", "Default from Desktop"), GalleryConfig::DESKTOP);
d->openInBrowser->setEditable(false);
browserLabel->setBuddy(d->openInBrowser);
// --------------------
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->addWidget(browserLabel, 2, 0, 1, 1);
grid->addWidget(d->openInBrowser, 2, 1, 1, 1);
grid->setRowStretch(3, 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()));
}
HTMLOutputPage::~HTMLOutputPage()
{
delete d;
}
void HTMLOutputPage::initializePage()
{
HTMLWizard* const wizard = dynamic_cast<HTMLWizard*>(assistant());<--- Variable 'wizard' can be declared as pointer to const
if (!wizard)
{
return;
}
GalleryInfo* const info = wizard->galleryInfo();<--- Variable 'info' can be declared as pointer to const
d->destUrl->setFileDlgPath(info->destUrl().toLocalFile());
d->openInBrowser->setCurrentIndex(info->openInBrowser());
d->imageSelectionTitle->setText(info->imageSelectionTitle());
d->titleLabel->setVisible(info->m_getOption == GalleryInfo::IMAGES);
d->imageSelectionTitle->setVisible(info->m_getOption == GalleryInfo::IMAGES);
}
bool HTMLOutputPage::validatePage()
{
if (d->destUrl->fileDlgPath().isEmpty())
{
return false;
}
HTMLWizard* const wizard = dynamic_cast<HTMLWizard*>(assistant());
if (!wizard)
{
return false;
}
GalleryInfo* const info = wizard->galleryInfo();
if (info->m_getOption == GalleryInfo::IMAGES && d->imageSelectionTitle->text().isEmpty())
{
return false;
}
info->setDestUrl(QUrl::fromLocalFile(d->destUrl->fileDlgPath()));
info->setOpenInBrowser(d->openInBrowser->currentIndex());
info->setImageSelectionTitle(d->imageSelectionTitle->text());
return true;
}
bool HTMLOutputPage::isComplete() const
{
HTMLWizard* const wizard = dynamic_cast<HTMLWizard*>(assistant());<--- Variable 'wizard' can be declared as pointer to const
if (!wizard)
{
return false;
}
GalleryInfo* const info = wizard->galleryInfo();<--- Variable 'info' can be declared as pointer to const
bool b = !d->destUrl->fileDlgPath().isEmpty();
if (info->m_getOption == GalleryInfo::IMAGES)
{
b = (b && !d->imageSelectionTitle->text().isEmpty());
}
return b;
}
} // namespace DigikamGenericHtmlGalleryPlugin
#include "moc_htmloutputpage.cpp"
|