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 | /* ============================================================
*
* 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 "htmlparameterspage.h"
// Qt includes
#include <QIcon>
#include <QApplication>
#include <QStyle>
#include <QSpacerItem>
#include <QGridLayout>
#include <QScrollArea>
#include <QMap>
#include <QLabel>
// KDE includes
#include <klocalizedstring.h>
// Local includes
#include "digikam_globals.h"
#include "htmlwizard.h"
#include "galleryinfo.h"
#include "abstractthemeparameter.h"
#include "dlayoutbox.h"
#include "gallerytheme.h"
namespace DigikamGenericHtmlGalleryPlugin
{
class Q_DECL_HIDDEN HTMLParametersPage::Private
{
public:
Private() = default;
QMap<QByteArray, QWidget*> themePrmWdgtList;
QWidget* content = nullptr;
};
HTMLParametersPage::HTMLParametersPage(QWizard* const dialog, const QString& title)
: DWizardPage(dialog, title),
d (new Private)
{
setObjectName(QLatin1String("ThemeParametersPage"));
DVBox* const vbox = new DVBox(this);
QLabel* const textLabel1 = new QLabel(vbox);
textLabel1->setObjectName(QLatin1String("textLabel1"));
textLabel1->setText(i18n("In this page, you can change some theme parameters. "
"Depending on the theme, different parameters are available."));
QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
sizePolicy.setHorizontalStretch(0);
sizePolicy.setVerticalStretch(0);
sizePolicy.setHeightForWidth(textLabel1->sizePolicy().hasHeightForWidth());
textLabel1->setSizePolicy(sizePolicy);
textLabel1->setAlignment(Qt::AlignVCenter);
textLabel1->setWordWrap(true);
QScrollArea* const mScrollArea = new QScrollArea(vbox);
mScrollArea->setObjectName(QLatin1String("mScrollArea"));
mScrollArea->setFrameShape(QFrame::NoFrame);
mScrollArea->setWidgetResizable(true);
d->content = new QWidget();
d->content->setObjectName(QLatin1String("d->content"));
d->content->setGeometry(QRect(0, 0, 600, 430));
mScrollArea->setWidget(d->content);
vbox->setContentsMargins(QMargins());
vbox->setSpacing(layoutSpacing());
setPageWidget(vbox);
setLeftBottomPix(QIcon::fromTheme(QLatin1String("text-css")));
}
HTMLParametersPage::~HTMLParametersPage()
{
delete d;
}
QWidget* HTMLParametersPage::themeParameterWidgetFromName(const QByteArray& name) const
{
return d->themePrmWdgtList[name];
}
void HTMLParametersPage::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
GalleryTheme::Ptr theme = wizard->galleryTheme();
qDeleteAll(d->content->children());
d->themePrmWdgtList.clear();
// Create layout. We need to recreate it every time, to get rid of spacers
QGridLayout* const layout = new QGridLayout(d->content);
layout->setContentsMargins(QMargins());
layout->setSpacing(layoutSpacing());
// Create widgets
GalleryTheme::ParameterList parameterList = theme->parameterList();
QString themeInternalName = theme->internalName();
GalleryTheme::ParameterList::ConstIterator it = parameterList.constBegin();
GalleryTheme::ParameterList::ConstIterator end = parameterList.constEnd();
for ( ; it != end ; ++it)
{
AbstractThemeParameter* const themeParameter = *it;<--- Variable 'themeParameter' can be declared as pointer to const
QByteArray internalName = themeParameter->internalName();
QString value = info->getThemeParameterValue(themeInternalName,
QString::fromLatin1(internalName),
themeParameter->defaultValue());
QString name = themeParameter->name();
name = i18nc("'%1' is a label for a theme parameter", "%1:", name);
QLabel* const label = new QLabel(name, d->content);
label->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
QWidget* const widget = themeParameter->createWidget(d->content, value);
label->setBuddy(widget);
int row = layout->rowCount();
layout->addWidget(label, row, 0);
if (widget->sizePolicy().expandingDirections() & Qt::Horizontal)
{
// Widget wants full width
layout->addWidget(widget, row, 1, 1, 2);
}
else
{
// Widget doesn't like to be stretched, add a spacer next to it
layout->addWidget(widget, row, 1);
QSpacerItem* const spacer = new QSpacerItem(1, 1, QSizePolicy::Expanding,
QSizePolicy::Minimum);
layout->addItem(spacer, row, 2);
}
d->themePrmWdgtList[internalName] = widget;
}
// Add spacer at the end, so that widgets aren't spread on the whole parent height
QSpacerItem* const spacer = new QSpacerItem(1, 1, QSizePolicy::Minimum,
QSizePolicy::Expanding);
layout->addItem(spacer, layout->rowCount(), 0);
}
} // namespace DigikamGenericHtmlGalleryPlugin
#include "moc_htmlparameterspage.cpp"
|