Commit 939550bf authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Make it compile against qt6

parent 2e482c3c
Pipeline #131085 passed with stage
in 35 seconds
......@@ -14,6 +14,7 @@
#include <KActionMenu>
#include <KConfigGroup>
#include <KSharedConfig>
#include <QActionGroup>
class GrantleeThemeManagerTest : public QObject
{
......
......@@ -7,8 +7,10 @@
#include "grantleethemetest.h"
#include "grantleetheme.h"
#include <QFile>
#include <QPalette>
#include <QProcess>
#include <QRegularExpression>
#include <QStandardPaths>
#include <qtest.h>
......@@ -94,7 +96,7 @@ bool GrantleeThemeTest::validateHtml(const QString &themePath, const QString &na
const QString htmlFileName = themePath + QStringLiteral("/%1.out.html").arg(name);
QFile outFile(outFileName);
if (!outFile.open(QIODevice::WriteOnly)) {
qDebug() << "impossible to open " << outFile;
qDebug() << "impossible to open " << outFile.fileName();
return false;
}
outFile.write(html.toUtf8());
......@@ -122,7 +124,7 @@ bool GrantleeThemeTest::compareHtml(const QString &generatedTheme, const QString
}
QString content = QString::fromUtf8(f.readAll());
f.close();
content.replace(QRegExp(QLatin1String("\"file:[^\"]*[/(?:%2F)]([^\"/(?:%2F)]*)\"")), QStringLiteral("\"file:\\1\""));
content.replace(QRegularExpression(QLatin1String("\"file:[^\"]*[/(?:%2F)]([^\"/(?:%2F)]*)\"")), QStringLiteral("\"file:\\1\""));
if (!f.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
return false;
}
......
......@@ -56,10 +56,17 @@ QString GrantleeKi18nLocalizer::processArguments(const KLocalizedString &kstr, c
str = str.subs(iter->toDouble());
break;
case QVariant::UserType:
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
if (iter->canConvert<Grantlee::SafeString>()) {
str = str.subs(iter->value<Grantlee::SafeString>().get());
break;
}
#else
if (iter->canConvert<KTextTemplate::SafeString>()) {
str = str.subs(iter->value<KTextTemplate::SafeString>().get());
break;
}
#endif
// fall-through
default:
qCWarning(GRANTLEETHEME_LOG) << "Unknown type" << iter->typeName() << "(" << iter->type() << ")";
......
......@@ -45,8 +45,11 @@ static QString rgbaString(const QColor &c)
if (property == QLatin1String(#name)) { \
return object.name(); \
}
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
GRANTLEE_BEGIN_LOOKUP(QColor)
#else
KTEXTTEMPLATE_BEGIN_LOOKUP(QColor)
#endif
COLOR_PROP(red)
COLOR_PROP(green)
COLOR_PROP(blue)
......@@ -58,11 +61,18 @@ if (property == QLatin1String("cssRgba")) {
return rgbaString(object);
}
return {};
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
GRANTLEE_END_LOOKUP
#else
KTEXTTEMPLATE_END_LOOKUP
#endif
void Color::registerMetaType()
{
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
Grantlee::registerMetaType<QColor>();
#else
KTextTemplate::registerMetaType<QColor>();
#endif
}
QVariant ColorHexRgbFilter::doFilter(const QVariant &input, const QVariant &arg, bool autoescape) const
......
......@@ -21,8 +21,11 @@
#define BACKGROUND_PROP(PROP) PROP_IMPL(PROP, background)
#define FOREGROUND_PROP(PROP) PROP_IMPL(PROP, foreground)
#define DECORATION_PROP(PROP) PROP_IMPL(PROP, decoration)
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
GRANTLEE_BEGIN_LOOKUP(KColorScheme)
#else
KTEXTTEMPLATE_BEGIN_LOOKUP(KColorScheme)
#endif
BACKGROUND_PROP(NormalBackground)
BACKGROUND_PROP(AlternateBackground)
BACKGROUND_PROP(ActiveBackground)
......@@ -45,7 +48,11 @@ DECORATION_PROP(FocusColor)
DECORATION_PROP(HoverColor)
return {};
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
GRANTLEE_END_LOOKUP
#else
KTEXTTEMPLATE_END_LOOKUP
#endif
void ColorScheme::registerMetaType()
{
......
......@@ -27,8 +27,11 @@ static const struct {
ROLE(HighlightedText), ROLE(Light), ROLE(Link), ROLE(LinkVisited), ROLE(Mid), ROLE(Midlight), ROLE(PlaceholderText),
ROLE(Shadow), ROLE(Text), ROLE(ToolTipBase), ROLE(ToolTipText), ROLE(Window), ROLE(WindowText),
};
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
GRANTLEE_BEGIN_LOOKUP(QPalette)
#else
KTEXTTEMPLATE_BEGIN_LOOKUP(QPalette)
#endif
auto group = QPalette::Inactive;
auto roleName = property;
......@@ -49,7 +52,11 @@ for (const auto &role : color_roles) {
}
}
return {};
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
GRANTLEE_END_LOOKUP
#else
KTEXTTEMPLATE_END_LOOKUP
#endif
void Palette::registerMetaType()
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment