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 | /* ============================================================
*
* 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 "htmlthemepage.h"
// Qt includes
#include <QIcon>
#include <QHBoxLayout>
#include <QApplication>
#include <QStyle>
// KDE includes
#include <klocalizedstring.h>
// Local includes
#include "digikam_globals.h"
#include "galleryinfo.h"
#include "htmlwizard.h"
#include "dlayoutbox.h"
namespace DigikamGenericHtmlGalleryPlugin
{
class Q_DECL_HIDDEN HTMLThemePage::Private
{
public:
Private() = default;
QListWidget* themeList = nullptr;
QTextBrowser* themeInfo = nullptr;
};
HTMLThemePage::HTMLThemePage(QWizard* const dialog, const QString& title)
: DWizardPage(dialog, title),
d (new Private)
{
setObjectName(QLatin1String("ThemePage"));
DHBox* const hbox = new DHBox(this);
d->themeList = new QListWidget(hbox);
d->themeList->setObjectName(QLatin1String("ThemeList"));
d->themeInfo = new QTextBrowser(hbox);
d->themeInfo->setObjectName(QLatin1String("ThemeInfo"));
hbox->setContentsMargins(QMargins());
hbox->setSpacing(layoutSpacing());
connect(d->themeList, SIGNAL(itemSelectionChanged()),
this, SLOT(slotThemeSelectionChanged()));
setPageWidget(hbox);
setLeftBottomPix(QIcon::fromTheme(QLatin1String("application-x-theme")));
}
HTMLThemePage::~HTMLThemePage()
{
delete d;
}
void HTMLThemePage::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::List list = GalleryTheme::getList();
GalleryTheme::List::ConstIterator it = list.constBegin();
GalleryTheme::List::ConstIterator end = list.constEnd();
d->themeList->clear();
for ( ; it != end ; ++it)
{
GalleryTheme::Ptr theme = *it;
ThemeListBoxItem* const item = new ThemeListBoxItem(theme);
d->themeList->addItem(item);
if (theme->internalName() == info->theme())
{
d->themeList->setCurrentItem(item);
}
}
// Set page states, whoch can only be disabled after they have *all* been added.
slotThemeSelectionChanged();
}
bool HTMLThemePage::validatePage()
{
if (!d->themeList->currentItem())
{
return false;
}
return true;
}
void HTMLThemePage::slotThemeSelectionChanged()
{
if (d->themeList->currentItem())
{
GalleryTheme::Ptr curTheme = currentTheme();
QString url = curTheme->authorUrl();
QString author = curTheme->authorName();
if (!url.isEmpty())
{
author = QString::fromUtf8("<a href='%1'>%2</a>").arg(url).arg(author);
}
QString preview = curTheme->previewUrl();
QString image = QLatin1String("");
if (!preview.isEmpty())
{
image = QString::fromUtf8("<img src='%1/%2' /><br/><br/>")
.arg(curTheme->directory(), curTheme->previewUrl());
}
QString advSet = (curTheme->parameterList().size() > 0) ? i18n("can be customized")
: i18n("no customization available");
QString txt = image + QString::fromUtf8("<b>%3</b><br/><br/>%4<br/><br/>")
.arg(curTheme->name(), curTheme->comment())
+ i18n("Author: %1<br/><br/>", author)
+ QString::fromUtf8("<i>%1</i>").arg(advSet);
d->themeInfo->setHtml(txt);
}
else
{
d->themeInfo->clear();
}
}
GalleryTheme::Ptr HTMLThemePage::currentTheme() const
{
ThemeListBoxItem* const item = dynamic_cast<ThemeListBoxItem*>(d->themeList->currentItem());
if (item)
{
return item->m_theme;
}
return GalleryTheme::Ptr(nullptr);
}
} // namespace DigikamGenericHtmlGalleryPlugin
#include "moc_htmlthemepage.cpp"
|