Commit 7d24456d authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

run git clang-format

parent c1f2d8cb
......@@ -6,14 +6,14 @@
#include "grantleethememanager.h"
#include <qtest.h>
#include <QStandardPaths>
#include <QMenu>
#include <QStandardPaths>
#include <qtest.h>
#include <KConfigGroup>
#include <KSharedConfig>
#include <KActionCollection>
#include <KActionMenu>
#include <KConfigGroup>
#include <KSharedConfig>
class GrantleeThemeManagerTest : public QObject
{
......@@ -43,7 +43,8 @@ void GrantleeThemeManagerTest::initTestCase()
void GrantleeThemeManagerTest::updateActionList()
{
KActionCollection coll(this);
GrantleeTheme::ThemeManager *manager(new GrantleeTheme::ThemeManager(QStringLiteral("Stuff"), QStringLiteral("filename.testdesktop"), &coll, QStringLiteral("themes")));
GrantleeTheme::ThemeManager *manager(
new GrantleeTheme::ThemeManager(QStringLiteral("Stuff"), QStringLiteral("filename.testdesktop"), &coll, QStringLiteral("themes")));
QCOMPARE(manager->themes().count(), 2);
QVERIFY(!manager->actionForTheme()); // Bug? No "default" theme.
......@@ -67,7 +68,8 @@ void GrantleeThemeManagerTest::updateActionList()
void GrantleeThemeManagerTest::destructionOrderTest()
{
KActionCollection coll(this);
GrantleeTheme::ThemeManager *manager(new GrantleeTheme::ThemeManager(QStringLiteral("Stuff"), QStringLiteral("filename.testdesktop"), &coll, QStringLiteral("themes")));
GrantleeTheme::ThemeManager *manager(
new GrantleeTheme::ThemeManager(QStringLiteral("Stuff"), QStringLiteral("filename.testdesktop"), &coll, QStringLiteral("themes")));
QCOMPARE(manager->themes().count(), 2);
QVERIFY(!manager->actionForTheme()); // Bug? No "default" theme.
......
......@@ -7,10 +7,10 @@
#include "grantleethemetest.h"
#include "grantleetheme.h"
#include <qtest.h>
#include <QPalette>
#include <QProcess>
#include <QStandardPaths>
#include <qtest.h>
#include <KColorScheme>
#include <KConfigGroup>
......@@ -69,11 +69,12 @@ void GrantleeThemeTest::shouldLoadTheme_data()
QTest::addColumn<bool>("isvalid");
QTest::addColumn<QStringList>("displayExtraVariables");
QTest::newRow("valid theme") << QStringLiteral("valid") << QStringLiteral("filename.testdesktop") << true << QStringList();
QTest::newRow("not existing theme") << QStringLiteral("notvalid") << QStringLiteral("filename.testdesktop") << false << QStringList();
QTest::newRow("valid theme") << QStringLiteral("valid") << QStringLiteral("filename.testdesktop") << true << QStringList();
QTest::newRow("not existing theme") << QStringLiteral("notvalid") << QStringLiteral("filename.testdesktop") << false << QStringList();
QStringList extraVariables;
extraVariables << QStringLiteral("foo") << QStringLiteral("bla");
QTest::newRow("valid with extra variable") << QStringLiteral("valid-with-extravariables") << QStringLiteral("filename.testdesktop") << true << extraVariables;
QTest::newRow("valid with extra variable") << QStringLiteral("valid-with-extravariables") << QStringLiteral("filename.testdesktop") << true
<< extraVariables;
}
void GrantleeThemeTest::shouldLoadTheme()
......@@ -83,7 +84,7 @@ void GrantleeThemeTest::shouldLoadTheme()
QFETCH(bool, isvalid);
QFETCH(QStringList, displayExtraVariables);
GrantleeTheme::Theme theme(QStringLiteral(GRANTLEETHEME_DATA_DIR "/themes/") + dirname, dirname, filename);
GrantleeTheme::Theme theme(QStringLiteral(GRANTLEETHEME_DATA_DIR "/themes/") + dirname, dirname, filename);
QCOMPARE(theme.isValid(), isvalid);
QCOMPARE(theme.displayExtraVariables(), displayExtraVariables);
QCOMPARE(theme.dirName(), dirname);
......@@ -102,14 +103,8 @@ bool GrantleeThemeTest::validateHtml(const QString &themePath, const QString &na
// validate xml and pretty-print for comparisson
// TODO add proper cmake check for xmllint and diff
const QStringList args = {
QStringLiteral("--format"),
QStringLiteral("--encode"),
QStringLiteral("UTF8"),
QStringLiteral("--output"),
htmlFileName,
outFileName
};
const QStringList args =
{QStringLiteral("--format"), QStringLiteral("--encode"), QStringLiteral("UTF8"), QStringLiteral("--output"), htmlFileName, outFileName};
const int result = QProcess::execute(QStringLiteral("xmllint"), args);
return result == 0;
......@@ -137,11 +132,7 @@ bool GrantleeThemeTest::compareHtml(const QString &themePath, const QString &nam
}
// compare to reference file
const QStringList args = {
QStringLiteral("-u"),
referenceFileName,
htmlFileName
};
const QStringList args = {QStringLiteral("-u"), referenceFileName, htmlFileName};
QProcess proc;
proc.setProcessChannelMode(QProcess::ForwardedChannels);
......
......@@ -5,8 +5,8 @@
*/
#include "genericformatter.h"
#include "grantleethemeengine.h"
#include "grantleeki18nlocalizer.h"
#include "grantleethemeengine.h"
using namespace GrantleeTheme;
......
......@@ -15,7 +15,8 @@
class QString;
namespace GrantleeTheme {
namespace GrantleeTheme
{
class GenericFormatterPrivate;
/** Convenience class for using a Grantlee theme. */
......
......@@ -64,7 +64,8 @@ QString GrantleeKi18nLocalizer::processArguments(const KLocalizedString &kstr, c
// Return localized in the currenctly active locale
const QString translatedStr = str.toString(mApplicationDomain.isEmpty() ? str.applicationDomain().constData() : mApplicationDomain.constData());
//qDebug() << " translatedStr"<< translatedStr << " domain :" << str.applicationDomain() << " currentLocale() "<< currentLocale() << " Specific applicationDomain" << mApplicationDomain;
// qDebug() << " translatedStr"<< translatedStr << " domain :" << str.applicationDomain() << " currentLocale() "<< currentLocale() << " Specific
// applicationDomain" << mApplicationDomain;
return translatedStr;
}
......@@ -80,7 +81,10 @@ QString GrantleeKi18nLocalizer::localizeString(const QString &string, const QVar
return processArguments(str, arguments);
}
QString GrantleeKi18nLocalizer::localizePluralContextString(const QString &string, const QString &pluralForm, const QString &context, const QVariantList &arguments) const
QString GrantleeKi18nLocalizer::localizePluralContextString(const QString &string,
const QString &pluralForm,
const QString &context,
const QVariantList &arguments) const
{
const KLocalizedString str = ki18ncp(qPrintable(context), qPrintable(string), qPrintable(pluralForm));
return processArguments(str, arguments);
......
......@@ -15,7 +15,8 @@
#include <QVariantHash>
class KLocalizedString;
namespace GrantleeTheme {
namespace GrantleeTheme
{
/**
* @brief The GrantleeKi18nLocalizer class
*/
......@@ -29,7 +30,10 @@ public:
// tr(), the remaining methods use QLocale internally, so we can reuse them
Q_REQUIRED_RESULT QString localizeContextString(const QString &string, const QString &context, const QVariantList &arguments) const override;
Q_REQUIRED_RESULT QString localizeString(const QString &string, const QVariantList &arguments) const override;
Q_REQUIRED_RESULT QString localizePluralContextString(const QString &string, const QString &pluralForm, const QString &context, const QVariantList &arguments) const override;
Q_REQUIRED_RESULT QString localizePluralContextString(const QString &string,
const QString &pluralForm,
const QString &context,
const QVariantList &arguments) const override;
Q_REQUIRED_RESULT QString localizePluralString(const QString &string, const QString &pluralForm, const QVariantList &arguments) const override;
// Only exception, Grantlee's implementation is not using QLocale for this
......@@ -39,6 +43,7 @@ public:
Q_REQUIRED_RESULT QString currentLocale() const override;
void setApplicationDomain(const QByteArray &domain);
private:
QString processArguments(const KLocalizedString &str, const QVariantList &arguments) const;
QByteArray mApplicationDomain;
......
......@@ -5,11 +5,11 @@
*/
#include "grantleetheme.h"
#include "grantleetheme_p.h"
#include "grantleetheme_debug.h"
#include "grantleetheme_p.h"
#include "grantleethemeengine.h"
#include <config-grantleetheme.h>
#include "qtresourcetemplateloader.h"
#include <config-grantleetheme.h>
#include <KConfig>
#include <KConfigGroup>
......@@ -85,19 +85,16 @@ Grantlee::Context ThemePrivate::createContext(const QVariantHash &data, const QB
QString ThemePrivate::errorTemplate(const QString &reason, const QString &origTemplateName, const Grantlee::Template &failedTemplate)
{
Grantlee::Template tpl = sEngine->newTemplate(
QStringLiteral("<h1>{{ error }}</h1>\n"
"<b>%1:</b> {{ templateName }}<br>\n"
"<b>%2:</b> {{ errorMessage }}")
.arg(i18n("Template"), i18n("Error message")),
QStringLiteral("TemplateError"));
Grantlee::Template tpl = sEngine->newTemplate(QStringLiteral("<h1>{{ error }}</h1>\n"
"<b>%1:</b> {{ templateName }}<br>\n"
"<b>%2:</b> {{ errorMessage }}")
.arg(i18n("Template"), i18n("Error message")),
QStringLiteral("TemplateError"));
Grantlee::Context ctx = createContext();
ctx.insert(QStringLiteral("error"), reason);
ctx.insert(QStringLiteral("templateName"), origTemplateName);
const QString errorString = failedTemplate
? failedTemplate->errorString()
: i18n("(null template)");
const QString errorString = failedTemplate ? failedTemplate->errorString() : i18n("(null template)");
ctx.insert(QStringLiteral("errorMessage"), errorString);
return tpl->render(&ctx);
}
......@@ -207,7 +204,8 @@ QString Theme::render(const QString &templateName, const QVariantHash &data, con
Q_ASSERT(d->loader);
if (!d->loader->canLoadTemplate(templateName)) {
qCWarning(GRANTLEETHEME_LOG) << "Cannot load template" << templateName << ", please check your installation. Tried in these dirs:" << d->loader->templateDirs();
qCWarning(GRANTLEETHEME_LOG) << "Cannot load template" << templateName
<< ", please check your installation. Tried in these dirs:" << d->loader->templateDirs();
return QString();
}
......
......@@ -8,14 +8,15 @@
#include "grantleetheme_export.h"
#include <QSharedDataPointer>
#include <QString>
#include <QStringList>
#include <QVariantHash>
#include <QSharedDataPointer>
class GrantleeThemeTest;
namespace GrantleeTheme {
namespace GrantleeTheme
{
class ThemeManager;
class ThemePrivate;
/**
......
......@@ -7,14 +7,15 @@
#ifndef GRANTLEE_THEME_P_H
#define GRANTLEE_THEME_P_H
#include "grantleetheme.h"
#include "grantleeki18nlocalizer.h"
#include "grantleetheme.h"
#include <grantlee/engine.h>
#include <grantlee/template.h>
#include <grantlee/templateloader.h>
#include <grantlee/engine.h>
namespace GrantleeTheme {
namespace GrantleeTheme
{
class GRANTLEETHEME_NO_EXPORT ThemePrivate : public QSharedData
{
public:
......
......@@ -7,12 +7,13 @@
#ifndef GRANTLEETHEMEENGINE_H
#define GRANTLEETHEMEENGINE_H
#include <grantlee/engine.h>
#include <QSharedPointer>
#include <grantlee/engine.h>
#include "grantleetheme_export.h"
namespace GrantleeTheme {
namespace GrantleeTheme
{
class GrantleeKi18nLocalizer;
class EnginePrivate;
/**
......
......@@ -7,22 +7,22 @@
#include "grantleethememanager.h"
#include "grantleetheme_p.h"
#include <KDirWatch>
#include <KSharedConfig>
#include <KConfigGroup>
#include <KActionCollection>
#include <KToggleAction>
#include <KActionMenu>
#include <KAuthorized>
#include <KConfigGroup>
#include <KDirWatch>
#include <KLocalizedString>
#include <KNS3/DownloadDialog>
#include <KAuthorized>
#include <KActionMenu>
#include <KSharedConfig>
#include <KToggleAction>
#include <QAction>
#include <QIcon>
#include <QPointer>
#include <QActionGroup>
#include <QDir>
#include <QDirIterator>
#include <QActionGroup>
#include <QStandardPaths>
using namespace GrantleeTheme;
......@@ -197,7 +197,7 @@ public:
}
if (!themeActivatedFound) {
if (!themesActionList.isEmpty() && !themeActivated.isEmpty()) {
//Activate first item if we removed theme.
// Activate first item if we removed theme.
KToggleAction *act = themesActionList.at(0);
act->setChecked(true);
selectTheme(act);
......@@ -271,7 +271,11 @@ public:
ThemeManager *const q;
};
ThemeManager::ThemeManager(const QString &applicationType, const QString &defaultDesktopFileName, KActionCollection *actionCollection, const QString &path, QObject *parent)
ThemeManager::ThemeManager(const QString &applicationType,
const QString &defaultDesktopFileName,
KActionCollection *actionCollection,
const QString &path,
QObject *parent)
: QObject(parent)
, d(new Private(applicationType, defaultDesktopFileName, actionCollection, path, this))
{
......@@ -337,7 +341,7 @@ QString ThemeManager::pathFromThemes(const QString &themesRelativePath, const QS
if (!themesRelativePath.isEmpty()) {
themesDirectories = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, themesRelativePath, QStandardPaths::LocateDirectory);
if (themesDirectories.count() < 2) {
//Make sure to add local directory
// Make sure to add local directory
const QString localDirectory = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1Char('/') + themesRelativePath;
if (!themesDirectories.contains(localDirectory)) {
themesDirectories.append(localDirectory);
......
......@@ -9,14 +9,15 @@
#include "grantleetheme.h"
#include "grantleetheme_export.h"
#include <QObject>
#include <QMap>
#include <QObject>
class QActionGroup;
class KActionCollection;
class KToggleAction;
class KActionMenu;
namespace GrantleeTheme {
namespace GrantleeTheme
{
/**
* @brief The ThemeManager class
* @author Laurent montel <montel@kde.org>
......@@ -25,7 +26,11 @@ class GRANTLEETHEME_EXPORT ThemeManager : public QObject
{
Q_OBJECT
public:
explicit ThemeManager(const QString &themeType, const QString &defaultDesktopFileName, KActionCollection *actionCollection = nullptr, const QString &path = QString(), QObject *parent = nullptr);
explicit ThemeManager(const QString &themeType,
const QString &defaultDesktopFileName,
KActionCollection *actionCollection = nullptr,
const QString &path = QString(),
QObject *parent = nullptr);
~ThemeManager();
Q_REQUIRED_RESULT QMap<QString, GrantleeTheme::Theme> themes() const;
......
......@@ -24,14 +24,14 @@ static QColor inputToColor(const QVariant &v)
static QString rgbaString(const QColor &c)
{
return QLatin1String("rgba(")
+ QString::number(c.red()) + QLatin1String(", ")
+ QString::number(c.green()) + QLatin1String(", ")
+ QString::number(c.blue()) + QLatin1String(", ")
+ QString::number(c.alphaF()) + QLatin1Char(')');
return QLatin1String("rgba(") + QString::number(c.red()) + QLatin1String(", ") + QString::number(c.green()) + QLatin1String(", ")
+ QString::number(c.blue()) + QLatin1String(", ") + QString::number(c.alphaF()) + QLatin1Char(')');
}
#define COLOR_PROP(name) if (property == QLatin1String(#name)) { return object.name(); }
#define COLOR_PROP(name) \
if (property == QLatin1String(#name)) { \
return object.name(); \
}
GRANTLEE_BEGIN_LOOKUP(QColor)
COLOR_PROP(red)
......
......@@ -120,7 +120,8 @@ private:
double m_ratio;
};
namespace Color {
namespace Color
{
void registerMetaType();
}
......
......@@ -10,8 +10,10 @@
#include <KColorScheme>
#define PROP_IMPL(PROP, METHOD) if (QString::compare(property, QLatin1String(#PROP), Qt::CaseInsensitive) == 0) \
{ return object.METHOD(KColorScheme::PROP).color(); }
#define PROP_IMPL(PROP, METHOD) \
if (QString::compare(property, QLatin1String(#PROP), Qt::CaseInsensitive) == 0) { \
return object.METHOD(KColorScheme::PROP).color(); \
}
#define BACKGROUND_PROP(PROP) PROP_IMPL(PROP, background)
#define FOREGROUND_PROP(PROP) PROP_IMPL(PROP, foreground)
#define DECORATION_PROP(PROP) PROP_IMPL(PROP, decoration)
......
......@@ -7,7 +7,8 @@
#ifndef GRANTLEETHEME_COLORSCHEME_H
#define GRANTLEETHEME_COLORSCHEME_H
namespace ColorScheme {
namespace ColorScheme
{
void registerMetaType();
}
......
......@@ -26,19 +26,18 @@ Grantlee::Node *IconTag::getNode(const QString &tagContent, Grantlee::Parser *p)
{
Q_UNUSED(p)
static QHash<QString, int> sizeOrGroupLookup
= { { QStringLiteral("desktop"), KIconLoader::Desktop },
{ QStringLiteral("toolbar"), KIconLoader::Toolbar },
{ QStringLiteral("maintoolbar"), KIconLoader::MainToolbar },
{ QStringLiteral("small"), KIconLoader::Small },
{ QStringLiteral("panel"), KIconLoader::Panel },
{ QStringLiteral("dialog"), KIconLoader::Dialog },
{ QStringLiteral("sizesmall"), KIconLoader::SizeSmall },
{ QStringLiteral("sizesmallmedium"), KIconLoader::SizeSmallMedium },
{ QStringLiteral("sizemedium"), KIconLoader::SizeMedium },
{ QStringLiteral("sizelarge"), KIconLoader::SizeLarge },
{ QStringLiteral("sizehuge"), KIconLoader::SizeHuge },
{ QStringLiteral("sizeenormous"), KIconLoader::SizeEnormous }};
static QHash<QString, int> sizeOrGroupLookup = {{QStringLiteral("desktop"), KIconLoader::Desktop},
{QStringLiteral("toolbar"), KIconLoader::Toolbar},
{QStringLiteral("maintoolbar"), KIconLoader::MainToolbar},
{QStringLiteral("small"), KIconLoader::Small},
{QStringLiteral("panel"), KIconLoader::Panel},
{QStringLiteral("dialog"), KIconLoader::Dialog},
{QStringLiteral("sizesmall"), KIconLoader::SizeSmall},
{QStringLiteral("sizesmallmedium"), KIconLoader::SizeSmallMedium},
{QStringLiteral("sizemedium"), KIconLoader::SizeMedium},
{QStringLiteral("sizelarge"), KIconLoader::SizeLarge},
{QStringLiteral("sizehuge"), KIconLoader::SizeHuge},
{QStringLiteral("sizeenormous"), KIconLoader::SizeEnormous}};
const QStringList parts = smartSplit(tagContent);
const int partsSize = parts.size();
......@@ -123,11 +122,10 @@ void IconNode::render(Grantlee::OutputStream *stream, Grantlee::Context *c) cons
}
}
const QString html = QStringLiteral("<img src=\"file://%1\" align=\"top\" height=\"%2\" width=\"%2\" alt=\"%3\" title=\"%4\" />")
.arg(KIconLoader::global()->iconPath(iconName, mSizeOrGroup < KIconLoader::LastGroup ? mSizeOrGroup : -mSizeOrGroup))
.arg(mSizeOrGroup < KIconLoader::LastGroup
? KIconLoader::global()->currentSize(static_cast<KIconLoader::Group>(mSizeOrGroup))
: mSizeOrGroup)
.arg(altText.isEmpty() ? iconName : altText, altText); // title is intentionally blank if no alt is provided
const QString html =
QStringLiteral("<img src=\"file://%1\" align=\"top\" height=\"%2\" width=\"%2\" alt=\"%3\" title=\"%4\" />")
.arg(KIconLoader::global()->iconPath(iconName, mSizeOrGroup < KIconLoader::LastGroup ? mSizeOrGroup : -mSizeOrGroup))
.arg(mSizeOrGroup < KIconLoader::LastGroup ? KIconLoader::global()->currentSize(static_cast<KIconLoader::Group>(mSizeOrGroup)) : mSizeOrGroup)
.arg(altText.isEmpty() ? iconName : altText, altText); // title is intentionally blank if no alt is provided
(*stream) << Grantlee::SafeString(html, Grantlee::SafeString::IsSafe);
}
......@@ -10,32 +10,18 @@
#include <QPalette>
#define ROLE(R) { #R, QPalette::R }
#define ROLE(R) \
{ \
#R, QPalette::R \
}
static const struct {
const char *name;
QPalette::ColorRole role;
} color_roles[] = {
ROLE(AlternateBase),
ROLE(Base),
ROLE(BrightText),
ROLE(Button),
ROLE(ButtonText),
ROLE(Dark),
ROLE(Highlight),
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),
ROLE(AlternateBase), ROLE(Base), ROLE(BrightText), ROLE(Button), ROLE(ButtonText), ROLE(Dark), ROLE(Highlight),
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),
};
GRANTLEE_BEGIN_LOOKUP(QPalette)
......
......@@ -7,7 +7,8 @@
#ifndef GRANTLEETHEME_PALETTE_H
#define GRANTLEETHEME_PALETTE_H
namespace Palette {
namespace Palette
{
void registerMetaType();
}
......
......@@ -10,7 +10,7 @@
#include <QFile>
#include <QTextStream>
#include <grantlee/engine.h>
//TODO: remove this class when Grantlee support it
// TODO: remove this class when Grantlee support it
using namespace GrantleeTheme;
QtResourceTemplateLoader::QtResourceTemplateLoader(const QSharedPointer<Grantlee::AbstractLocalizer> localizer)
......
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