6#include "whatsnewwidget.h"
8#include <KLocalizedString>
14constexpr int allVersion = -1;
19 , mWhatsNewInfo(infos)
21 , mWhatsNewComboBoxWidget(new WhatsNewComboBoxWidget(this))
24 mainLayout->setObjectName(QStringLiteral(
"mainLayout"));
25 mainLayout->setContentsMargins({});
27 mWhatsNewComboBoxWidget->setObjectName(QStringLiteral(
"mWhatsNewComboBoxWidget"));
28 mainLayout->addWidget(mWhatsNewComboBoxWidget);
30 mLabelInfo->setObjectName(QStringLiteral(
"mLabelInfo"));
31 mLabelInfo->setReadOnly(
true);
32 mLabelInfo->setOpenExternalLinks(
true);
34 connect(mWhatsNewComboBoxWidget, &WhatsNewComboBoxWidget::versionChanged,
this, &WhatsNewWidget::slotVersionChanged);
35 mainLayout->addWidget(mLabelInfo);
37 mWhatsNewComboBoxWidget->initializeVersion(currentVersion());
40WhatsNewWidget::~WhatsNewWidget() =
default;
42void WhatsNewWidget::fillComboBox()
44 mWhatsNewComboBoxWidget->addVersion(
i18n(
"All Version"), allVersion);
45 for (
int i = mWhatsNewInfo.
count() - 1; i >= 0; i--) {
46 const WhatsNewInfo &info = mWhatsNewInfo.
at(i);
47 mWhatsNewComboBoxWidget->addVersion(
i18n(
"Version %1", info.version()), i);
51int WhatsNewWidget::currentVersion()
const
53 return mWhatsNewInfo.
count() - 1;
56void WhatsNewWidget::updateInformations()
58 slotVersionChanged(currentVersion());
61QString WhatsNewWidget::generateStartEndHtml(
const QString &str)
const
63 const QString message = QStringLiteral(
"<qt>") + str + QStringLiteral(
"</qt>");
67void WhatsNewWidget::slotVersionChanged(
int type)
69 if (type == allVersion) {
71 for (
int i = mWhatsNewInfo.
count() - 1; i >= 0; i--) {
72 const WhatsNewInfo &info = mWhatsNewInfo.
at(i);
73 message += generateVersionHeader(i);
74 message += createVersionInformation(info);
76 mLabelInfo->
setHtml(generateStartEndHtml(message));
78 const QString message = generateStartEndHtml(createVersionInformation(mWhatsNewInfo.
at(type)));
83QString WhatsNewWidget::importantChangeStr()
const
85 return QStringLiteral(
"<b>") +
i18n(
"Important changes since last version:") + QStringLiteral(
"</b>");
88QString WhatsNewWidget::featuresChangeStr()
const
90 return QStringLiteral(
"<b>") +
i18n(
"Some of the new features in this release include:") + QStringLiteral(
"</b>");
93QString WhatsNewWidget::bugFixingChangeStr()
const
95 return QStringLiteral(
"<b>") +
i18n(
"Some bug fixing:") + QStringLiteral(
"</b>");
98QString WhatsNewWidget::createVersionInformation(
const WhatsNewInfo &info)
101 if (!info.changes().
isEmpty()) {
102 message += importantChangeStr();
103 message += QStringLiteral(
"<ul>");
104 for (
int i = 0, total = info.changes().
count(); i < total; ++i) {
105 message += QStringLiteral(
"<li>%1</li>").
arg(info.changes().
at(i));
107 message += QStringLiteral(
"</ul>");
110 if (!info.newFeatures().
isEmpty()) {
111 message += featuresChangeStr();
112 message += QStringLiteral(
"<ul>");
113 for (
int i = 0, total = info.newFeatures().
count(); i < total; ++i) {
114 message += QStringLiteral(
"<li>%1</li>").
arg(info.newFeatures().
at(i));
116 message += QStringLiteral(
"</ul>");
119 if (!info.bugFixings().
isEmpty()) {
120 message += bugFixingChangeStr();
121 message += QStringLiteral(
"<ul>");
122 for (
int i = 0, total = info.bugFixings().
count(); i < total; ++i) {
123 message += QStringLiteral(
"<li>%1</li>").
arg(info.bugFixings().
at(i));
125 message += QStringLiteral(
"</ul>");
130QString WhatsNewWidget::generateVersionHeader(
int type)
const
132 if (type != allVersion) {
133 return QStringLiteral(
"<h1><i> Version %1 </i></h1><hr/><br>").arg(mWhatsNewInfo.
at(type).version());
138#include "moc_whatsnewwidget.cpp"
QString i18n(const char *text, const TYPE &arg...)
const_reference at(qsizetype i) const const
qsizetype count() const const
bool isEmpty() const const
QString arg(Args &&... args) const const
void setHtml(const QString &text)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)