Commit 8694fa8d authored by Sandro Andrade's avatar Sandro Andrade
Browse files

Fix clang-tidy and klazy issues

parent b693dfcd
......@@ -32,18 +32,17 @@
namespace Minuet
{
Core::~Core()
{
}
bool Core::initialize()
{
if (m_self)
if (m_self) {
return true;
}
qRegisterMetaType<Minuet::ISoundController::State>("State");
qmlRegisterInterface<Minuet::ISoundController>("ISoundController", 1);
qmlRegisterUncreatableType<Minuet::ISoundController>("org.kde.minuet.isoundcontroller", 1, 0, "ISoundController", "ISoundController cannot be instantiated");
qmlRegisterInterface<Minuet::ISoundController>("ISoundController");
qmlRegisterUncreatableType<Minuet::ISoundController>(
"org.kde.minuet.isoundcontroller", 1, 0, "ISoundController",
QStringLiteral("ISoundController cannot be instantiated"));
m_self = new Core;
......@@ -78,9 +77,7 @@ void Core::setSoundController(ISoundController *soundController)
}
}
Core::Core(QObject *parent)
: ICore(parent)
, m_soundController(0)
Core::Core(QObject *parent) : ICore(parent), m_soundController(nullptr)
{
m_pluginController = new PluginController(this);
if (!((PluginController *)m_pluginController)->initialize(this)) {
......
......@@ -32,7 +32,7 @@ class Core : public ICore
Q_OBJECT
public:
virtual ~Core() override;
virtual ~Core() override = default;
static bool initialize();
......
......@@ -38,15 +38,10 @@
namespace Minuet
{
ExerciseController::ExerciseController(QObject *parent)
: IExerciseController(parent)
, m_chosenRootNote(0)
{
m_exercises["exercises"] = QJsonArray();
m_definitions["definitions"] = QJsonArray();
}
ExerciseController::~ExerciseController()
: IExerciseController(parent), m_chosenRootNote(0)
{
m_exercises[QStringLiteral("exercises")] = QJsonArray();
m_definitions[QStringLiteral("definitions")] = QJsonArray();
}
bool ExerciseController::initialize(Core *core)
......@@ -54,8 +49,9 @@ bool ExerciseController::initialize(Core *core)
Q_UNUSED(core)
m_errorString.clear();
bool definitionsMerge = mergeJsonFiles("definitions", m_definitions);
bool exercisesMerge = mergeJsonFiles("exercises", m_exercises, true, "name", "children");
bool definitionsMerge = mergeJsonFiles(QStringLiteral("definitions"), m_definitions);
bool exercisesMerge = mergeJsonFiles(QStringLiteral("exercises"), m_exercises, true,
QStringLiteral("name"), QStringLiteral("children"));
// QFile file("merged-exercises.json");
// file.open(QIODevice::WriteOnly);
......@@ -72,43 +68,52 @@ QString ExerciseController::errorString() const
void ExerciseController::randomlySelectExerciseOptions()
{
while (!m_selectedExerciseOptions.isEmpty())
while (!m_selectedExerciseOptions.isEmpty()) {
m_selectedExerciseOptions.removeFirst();
}
int minNote = INT_MAX;
int maxNote = INT_MIN;
auto *generator = QRandomGenerator::global();
quint8 numberOfSelectedOptions = m_currentExercise[QStringLiteral("numberOfSelectedOptions")].toInt();
quint8 numberOfSelectedOptions
= m_currentExercise[QStringLiteral("numberOfSelectedOptions")].toInt();
for (quint8 i = 0; i < numberOfSelectedOptions; ++i) {
QJsonArray exerciseOptions = QJsonObject::fromVariantMap(m_currentExercise)[QStringLiteral("options")].toArray();
QJsonArray exerciseOptions
= QJsonObject::fromVariantMap(m_currentExercise)[QStringLiteral("options")].toArray();
quint8 chosenExerciseOption = generator->bounded(exerciseOptions.size());
QString sequence = exerciseOptions[chosenExerciseOption].toObject()[QStringLiteral("sequence")].toString();
QString sequence = exerciseOptions[chosenExerciseOption]
.toObject()[QStringLiteral("sequence")]
.toString();
foreach (const QString &additionalNote, sequence.split(' ')) {
int note = additionalNote.toInt();
if (note > maxNote)
if (note > maxNote) {
maxNote = note;
if (note < minNote)
}
if (note < minNote) {
minNote = note;
}
}
if (m_currentExercise["playMode"].toString() != "rhythm") {
QStringList exerciseRoots = m_currentExercise["root"].toString().split('.');
if (m_currentExercise[QStringLiteral("playMode")].toString() != QLatin1String("rhythm")) {
QStringList exerciseRoots
= m_currentExercise[QStringLiteral("root")].toString().split('.');
quint8 exerciseMinRoot = exerciseRoots.first().toInt();
quint8 exerciseMaxRoot = exerciseRoots.last().toInt();
do
m_chosenRootNote = exerciseMinRoot + generator->bounded(exerciseMaxRoot - exerciseMinRoot);
while (m_chosenRootNote + maxNote > 108 || m_chosenRootNote + minNote < 21);
do {
m_chosenRootNote
= exerciseMinRoot + generator->bounded(exerciseMaxRoot - exerciseMinRoot);
} while (m_chosenRootNote + maxNote > 108 || m_chosenRootNote + minNote < 21);
}
QJsonObject jsonObject = exerciseOptions[chosenExerciseOption].toObject();
jsonObject["rootNote"] = QString::number(m_chosenRootNote);
jsonObject[QStringLiteral("rootNote")] = QString::number(m_chosenRootNote);
exerciseOptions[chosenExerciseOption] = jsonObject;
m_selectedExerciseOptions.append(exerciseOptions[chosenExerciseOption]);
}
emit selectedExerciseOptionsChanged(m_selectedExerciseOptions);
}
unsigned int ExerciseController::chosenRootNote()
unsigned int ExerciseController::chosenRootNote() const
{
return m_chosenRootNote;
}
......@@ -118,20 +123,26 @@ QJsonArray ExerciseController::exercises() const
return m_exercises[QStringLiteral("exercises")].toArray();
}
bool ExerciseController::mergeJsonFiles(const QString directoryName, QJsonObject &targetObject, bool applyDefinitionsFlag, QString commonKey, QString mergeKey)
bool ExerciseController::mergeJsonFiles(const QString directoryName, QJsonObject &targetObject,
bool applyDefinitionsFlag, QString commonKey,
QString mergeKey)
{
QStringList jsonDirs;
#if defined(Q_OS_ANDROID)
jsonDirs << "assets:/data/" + directoryName;
#elif defined(Q_OS_WIN)
jsonDirs = QStandardPaths::locateAll(QStandardPaths::AppDataLocation, QStringLiteral("minuet/") + directoryName, QStandardPaths::LocateDirectory);
jsonDirs = QStandardPaths::locateAll(QStandardPaths::AppDataLocation,
QStringLiteral("minuet/") + directoryName,
QStandardPaths::LocateDirectory);
#else
jsonDirs = QStandardPaths::locateAll(QStandardPaths::AppDataLocation, directoryName, QStandardPaths::LocateDirectory);
jsonDirs = QStandardPaths::locateAll(QStandardPaths::AppDataLocation, directoryName,
QStandardPaths::LocateDirectory);
#ifdef Q_OS_MACOS
if (jsonDirs.isEmpty()) {
const QStringList xdgDataDirs = Utils::getXdgDataDirs();
for (const auto &dirPath : xdgDataDirs) {
const QDir testDir(QDir(dirPath).absoluteFilePath(QStringLiteral("minuet/") + directoryName));
const QDir testDir(
QDir(dirPath).absoluteFilePath(QStringLiteral("minuet/") + directoryName));
if (testDir.exists()) {
jsonDirs << testDir.absolutePath();
}
......@@ -142,14 +153,17 @@ bool ExerciseController::mergeJsonFiles(const QString directoryName, QJsonObject
foreach (const QString &jsonDirString, jsonDirs) {
QDir jsonDir(jsonDirString);
foreach (const QString &json, jsonDir.entryList(QDir::Files)) {
if (!json.endsWith(QLatin1String(".json")))
if (!json.endsWith(QLatin1String(".json"))) {
break;
}
QFile jsonFile(jsonDir.absoluteFilePath(json));
if (!jsonFile.open(QIODevice::ReadOnly)) {
#if !defined(Q_OS_ANDROID)
m_errorString = i18n("Could not open JSON file \"%1\".", jsonDir.absoluteFilePath(json));
m_errorString
= i18n("Could not open JSON file \"%1\".", jsonDir.absoluteFilePath(json));
#else
m_errorString = QStringLiteral("Couldn't open json file \"%1\".").arg(jsonDir.absoluteFilePath(json));
m_errorString = QStringLiteral("Couldn't open json file \"%1\".")
.arg(jsonDir.absoluteFilePath(json));
#endif
return false;
}
......@@ -157,23 +171,29 @@ bool ExerciseController::mergeJsonFiles(const QString directoryName, QJsonObject
QJsonDocument jsonDocument = QJsonDocument::fromJson(jsonFile.readAll(), &error);
if (error.error != QJsonParseError::NoError) {
m_errorString += QStringLiteral("Error when parsing JSON file '%1'. ").arg(jsonDir.absoluteFilePath(json));
m_errorString += QStringLiteral("Error when parsing JSON file '%1'. ")
.arg(jsonDir.absoluteFilePath(json));
jsonFile.close();
return false;
} else {
QJsonObject jsonObject = jsonDocument.object();
if (applyDefinitionsFlag)
jsonObject[directoryName] = applyDefinitions(jsonObject[directoryName].toArray(), m_definitions[QStringLiteral("definitions")].toArray());
targetObject[directoryName] = mergeJsonArrays(targetObject[directoryName].toArray(), jsonObject[directoryName].toArray(), commonKey, mergeKey);
}
QJsonObject jsonObject = jsonDocument.object();
if (applyDefinitionsFlag) {
jsonObject[directoryName]
= applyDefinitions(jsonObject[directoryName].toArray(),
m_definitions[QStringLiteral("definitions")].toArray());
}
targetObject[directoryName]
= mergeJsonArrays(targetObject[directoryName].toArray(),
jsonObject[directoryName].toArray(), commonKey, mergeKey);
jsonFile.close();
}
}
return true;
}
QJsonArray ExerciseController::applyDefinitions(QJsonArray exercises, QJsonArray definitions, QJsonObject collectedProperties)
QJsonArray ExerciseController::applyDefinitions(QJsonArray exercises, QJsonArray definitions,
QJsonObject collectedProperties)
{
QJsonArray::const_iterator exercisesBegin = exercises.constBegin();
QJsonArray::const_iterator exercisesEnd = exercises.constEnd();
......@@ -182,22 +202,33 @@ QJsonArray ExerciseController::applyDefinitions(QJsonArray exercises, QJsonArray
QJsonObject exerciseObject = i1->toObject();
QJsonArray filteredDefinitions = definitions;
QStringList exerciseObjectKeys = exerciseObject.keys();
if (exerciseObjectKeys.contains(QStringLiteral("and-tags")) && exerciseObject[QStringLiteral("and-tags")].isArray())
filterDefinitions(filteredDefinitions, exerciseObject, "and-tags", AndFiltering);
if (exerciseObjectKeys.contains(QStringLiteral("or-tags")) && exerciseObject[QStringLiteral("or-tags")].isArray())
filterDefinitions(filteredDefinitions, exerciseObject, "or-tags", OrFiltering);
if (exerciseObjectKeys.contains(QStringLiteral("and-tags"))
&& exerciseObject[QStringLiteral("and-tags")].isArray()) {
filterDefinitions(filteredDefinitions, exerciseObject, QStringLiteral("and-tags"),
AndFiltering);
}
if (exerciseObjectKeys.contains(QStringLiteral("or-tags"))
&& exerciseObject[QStringLiteral("or-tags")].isArray()) {
filterDefinitions(filteredDefinitions, exerciseObject, QStringLiteral("or-tags"),
OrFiltering);
}
if (exerciseObjectKeys.contains(QStringLiteral("children"))) {
foreach (const QString &key, exerciseObjectKeys)
if (key != "name" && key != "children" && key != "and-tags" && key != "or-tags" && !key.startsWith('_')) {
if (key != QLatin1String("name") && key != QLatin1String("children")
&& key != QLatin1String("and-tags") && key != QLatin1String("or-tags")
&& !key.startsWith('_')) {
collectedProperties.insert(key, exerciseObject[key]);
exerciseObject.remove(key);
}
exerciseObject[QStringLiteral("children")] = applyDefinitions(exerciseObject[QStringLiteral("children")].toArray(), filteredDefinitions, collectedProperties);
exerciseObject[QStringLiteral("children")]
= applyDefinitions(exerciseObject[QStringLiteral("children")].toArray(),
filteredDefinitions, collectedProperties);
} else {
foreach (const QString &key, collectedProperties.keys())
if (!exerciseObject.contains(key))
if (!exerciseObject.contains(key)) {
exerciseObject.insert(key, collectedProperties[key]);
exerciseObject.insert("options", filteredDefinitions);
}
exerciseObject.insert(QStringLiteral("options"), filteredDefinitions);
}
exercises[i1 - exercisesBegin] = exerciseObject;
}
......@@ -205,21 +236,24 @@ QJsonArray ExerciseController::applyDefinitions(QJsonArray exercises, QJsonArray
return exercises;
}
void ExerciseController::filterDefinitions(QJsonArray &definitions, QJsonObject &exerciseObject, const QString &filterTagsKey, DefinitionFilteringMode definitionFilteringMode)
void ExerciseController::filterDefinitions(QJsonArray &definitions, QJsonObject &exerciseObject,
const QString &filterTagsKey,
DefinitionFilteringMode definitionFilteringMode)
{
QJsonArray filterTags = exerciseObject[filterTagsKey].toArray();
exerciseObject.remove(filterTagsKey);
for (QJsonArray::Iterator i2 = definitions.begin(); i2 < definitions.end(); ++i2) {
bool remove = (definitionFilteringMode == AndFiltering) ? false : true;
bool remove = definitionFilteringMode != AndFiltering;
QJsonArray::const_iterator filterTagsEnd = filterTags.constEnd();
for (QJsonArray::ConstIterator i3 = filterTags.constBegin(); i3 < filterTagsEnd; ++i3) {
QJsonArray tagArray = i2->toObject()["tags"].toArray();
QJsonArray tagArray = i2->toObject()[QStringLiteral("tags")].toArray();
if (definitionFilteringMode == AndFiltering && !tagArray.contains(*i3)) {
remove = true;
break;
}
if (definitionFilteringMode == OrFiltering && tagArray.contains(*i3))
if (definitionFilteringMode == OrFiltering && tagArray.contains(*i3)) {
remove = false;
}
}
if (remove) {
i2 = definitions.erase(i2);
......@@ -228,7 +262,8 @@ void ExerciseController::filterDefinitions(QJsonArray &definitions, QJsonObject
}
}
QJsonArray ExerciseController::mergeJsonArrays(QJsonArray oldFile, QJsonArray newFile, QString commonKey, QString mergeKey)
QJsonArray ExerciseController::mergeJsonArrays(QJsonArray oldFile, QJsonArray newFile,
QString commonKey, QString mergeKey)
{
QJsonArray::const_iterator newFileEnd = newFile.constEnd();
;
......@@ -239,15 +274,19 @@ QJsonArray ExerciseController::mergeJsonArrays(QJsonArray oldFile, QJsonArray ne
for (i2 = oldFile.constBegin(); i2 < oldFileEnd; ++i2) {
QJsonObject newFileObject = i1->toObject();
QJsonObject oldFileObject = i2->toObject();
if (i2->isObject() && i1->isObject() && !commonKey.isEmpty() && oldFileObject[commonKey] == newFileObject[commonKey]) {
if (i2->isObject() && i1->isObject() && !commonKey.isEmpty()
&& oldFileObject[commonKey] == newFileObject[commonKey]) {
QJsonObject jsonObject = oldFile[i2 - oldFile.constBegin()].toObject();
jsonObject[mergeKey] = mergeJsonArrays(oldFileObject[mergeKey].toArray(), newFileObject[mergeKey].toArray(), commonKey, mergeKey);
jsonObject[mergeKey]
= mergeJsonArrays(oldFileObject[mergeKey].toArray(),
newFileObject[mergeKey].toArray(), commonKey, mergeKey);
oldFile[i2 - oldFile.constBegin()] = jsonObject;
break;
}
}
if (i2 == oldFile.constEnd())
if (i2 == oldFile.constEnd()) {
oldFile.append(*i1);
}
}
}
return oldFile;
......
......@@ -38,12 +38,12 @@ class ExerciseController : public IExerciseController
public:
explicit ExerciseController(QObject *parent = 0);
virtual ~ExerciseController();
virtual ~ExerciseController() = default;
bool initialize(Core *core);
virtual QString errorString() const override;
Q_INVOKABLE unsigned int chosenRootNote();
Q_INVOKABLE unsigned int chosenRootNote() const;
virtual QJsonArray exercises() const override;
......@@ -51,11 +51,17 @@ public Q_SLOTS:
virtual void randomlySelectExerciseOptions() override;
private:
bool mergeJsonFiles(const QString directoryName, QJsonObject &targetObject, bool applyDefinitionsFlag = false, QString commonKey = "", QString mergeKey = "");
QJsonArray applyDefinitions(QJsonArray exercises, QJsonArray definitions, QJsonObject collectedProperties = QJsonObject());
bool mergeJsonFiles(const QString directoryName, QJsonObject &targetObject,
bool applyDefinitionsFlag = false, QString commonKey = nullptr,
QString mergeKey = nullptr);
QJsonArray applyDefinitions(QJsonArray exercises, QJsonArray definitions,
QJsonObject collectedProperties = QJsonObject());
enum DefinitionFilteringMode { AndFiltering = 0, OrFiltering };
void filterDefinitions(QJsonArray &definitions, QJsonObject &exerciseObject, const QString &filterTagsKey, DefinitionFilteringMode definitionFilteringMode);
QJsonArray mergeJsonArrays(QJsonArray oldFile, QJsonArray newFile, QString commonKey = "", QString mergeKey = "");
static void filterDefinitions(QJsonArray &definitions, QJsonObject &exerciseObject,
const QString &filterTagsKey,
DefinitionFilteringMode definitionFilteringMode);
QJsonArray mergeJsonArrays(QJsonArray oldFile, QJsonArray newFile, QString commonKey = nullptr,
QString mergeKey = nullptr);
QJsonObject m_exercises;
QJsonObject m_definitions;
......@@ -65,4 +71,4 @@ private:
}
#endif // MINUET_EXERCISECONTROLLER_H
#endif // MINUET_EXERCISECONTROLLER_H
......@@ -47,13 +47,19 @@ int main(int argc, char *argv[])
KLocalizedString::setApplicationDomain("minuet");
KAboutData aboutData(QStringLiteral("minuet"), i18n("Minuet"), QStringLiteral(MINUET_VERSION_STRING), i18n("A KDE application for music education"), KAboutLicense::GPL, i18n("(c) 2016, Sandro S. Andrade (sandroandrade@kde.org)"));
aboutData.addAuthor("Sandro S. Andrade", i18n("Developer"), QStringLiteral("sandroandrade@kde.org"));
aboutData.addAuthor("Ayush Shah", i18n("Developer"), QStringLiteral("1595ayush@gmail.com"));
aboutData.addAuthor("Alessandro Longo", i18n("Minuet Icon Designer"), QStringLiteral("alessandro.longo@kdemail.net"));
KAboutData aboutData(QStringLiteral("minuet"), i18n("Minuet"),
QStringLiteral(MINUET_VERSION_STRING),
i18n("A KDE application for music education"), KAboutLicense::GPL,
i18n("(c) 2016, Sandro S. Andrade (sandroandrade@kde.org)"));
aboutData.addAuthor(QStringLiteral("Sandro S. Andrade"), i18n("Developer"),
QStringLiteral("sandroandrade@kde.org"));
aboutData.addAuthor(QStringLiteral("Ayush Shah"), i18n("Developer"),
QStringLiteral("1595ayush@gmail.com"));
aboutData.addAuthor(QStringLiteral("Alessandro Longo"), i18n("Minuet Icon Designer"),
QStringLiteral("alessandro.longo@kdemail.net"));
#endif
application.setWindowIcon(QIcon(QStringLiteral(":/minuet.png")));
QGuiApplication::setWindowIcon(QIcon(QStringLiteral(":/minuet.png")));
QCommandLineParser parser;
#if !defined(Q_OS_ANDROID)
......@@ -70,11 +76,14 @@ int main(int argc, char *argv[])
#if defined(Q_OS_ANDROID)
if (!QFile("/data/data/org.kde.minuet/files/sf_GMbank.sf2").exists()) {
if (QFile("assets:/share/sf_GMbank.sf2").copy("/data/data/org.kde.minuet/files/sf_GMbank.sf2"))
qDebug() << "COPIED " << QFileInfo("/data/data/org.kde.minuet/files/sf_GMbank.sf2").size() << "b soundfound file to /data/data/org.kde.minuet/files/sf_GMbank.sf2";
if (QFile("assets:/share/sf_GMbank.sf2")
.copy("/data/data/org.kde.minuet/files/sf_GMbank.sf2"))
qDebug() << "COPIED "
<< QFileInfo("/data/data/org.kde.minuet/files/sf_GMbank.sf2").size()
<< "b soundfound file to /data/data/org.kde.minuet/files/sf_GMbank.sf2";
}
#endif
Minuet::Core::initialize();
return application.exec();
return QGuiApplication::exec();
}
......@@ -39,15 +39,16 @@
namespace Minuet
{
PluginController::PluginController(QObject *parent)
: IPluginController(parent)
PluginController::PluginController(QObject *parent) : IPluginController(parent)
{
#if !defined(Q_OS_ANDROID)
m_plugins = KPluginLoader::findPlugins(QStringLiteral("minuet"), [&](const KPluginMetaData &meta) {
m_plugins = KPluginLoader::findPlugins(QStringLiteral("minuet"), [&](const KPluginMetaData
&meta) {
if (!meta.serviceTypes().contains(QStringLiteral("Minuet/Plugin"))) {
qWarning() << "Plugin" << meta.fileName()
<< "is installed into the minuet plugin directory, but does not have"
" \"Minuet/Plugin\" set as the service type. This plugin will not be loaded.";
qWarning()
<< "Plugin" << meta.fileName()
<< "is installed into the minuet plugin directory, but does not have"
" \"Minuet/Plugin\" set as the service type. This plugin will not be loaded.";
return false;
}
return true;
......@@ -58,7 +59,8 @@ PluginController::PluginController(QObject *parent)
PluginController::~PluginController()
{
#if !defined(Q_OS_ANDROID)
qDeleteAll(m_loadedPlugins.values().begin(), m_loadedPlugins.values().end());
const auto &loadedPlugins = m_loadedPlugins.values();
qDeleteAll(loadedPlugins.begin(), loadedPlugins.end());
m_loadedPlugins.clear();
#endif
}
......@@ -67,17 +69,20 @@ bool PluginController::initialize(Core *core)
{
m_errorString.clear();
#if !defined(Q_OS_ANDROID)
ISoundController *soundController = 0;
ISoundController *soundController = nullptr;
foreach (const KPluginMetaData &pluginMetaData, m_plugins) {
if (m_loadedPlugins.value(pluginMetaData))
if (m_loadedPlugins.value(pluginMetaData)) {
continue;
}
KPluginLoader loader(pluginMetaData.fileName());
IPlugin *plugin = qobject_cast<IPlugin *>(loader.instance());
if (plugin) {
m_loadedPlugins.insert(pluginMetaData, plugin);
if (!core->soundController() && (soundController = qobject_cast<ISoundController *>(plugin))) {
qInfo() << "Setting soundcontroller to" << soundController->metaObject()->className();
if (!core->soundController()
&& (soundController = qobject_cast<ISoundController *>(plugin))) {
qInfo() << "Setting soundcontroller to"
<< soundController->metaObject()->className();
core->setSoundController(soundController);
}
}
......
......@@ -471,10 +471,10 @@ Item {
}
Connections {
target: core.exerciseController
onSelectedExerciseOptionsChanged: pianoView.clearAllMarks()
function onSelectedExerciseOptionsChanged() { pianoView.clearAllMarks() }
}
Connections {
target: core.exerciseController
onSelectedExerciseOptionsChanged: sheetMusicView.clearAllMarks()
function onSelectedExerciseOptionsChanged() { sheetMusicView.clearAllMarks() }
}
}
......@@ -35,19 +35,12 @@
namespace Minuet
{
UiController::UiController(QObject *parent)
: IUiController(parent)
{
}
UiController::~UiController()
{
}
UiController::UiController(QObject *parent) : IUiController(parent) {}
bool UiController::initialize(Core *core)
{
m_errorString.clear();
QQmlApplicationEngine *engine = new QQmlApplicationEngine(this);
auto *engine = new QQmlApplicationEngine(this);
QQmlContext *rootContext = engine->rootContext();
rootContext->setContextProperty(QStringLiteral("core"), core);
#ifndef Q_OS_ANDROID
......@@ -55,7 +48,7 @@ bool UiController::initialize(Core *core)
#else
rootContext->setContextObject(new DummyAndroidLocalizer(engine));
#endif
engine->load(QUrl("qrc:/Main.qml"));
engine->load(QUrl(QStringLiteral("qrc:/Main.qml")));
return true;
}
......
......@@ -33,36 +33,23 @@ class DummyAndroidLocalizer : public QObject
Q_OBJECT
public:
explicit DummyAndroidLocalizer(QObject *parent = 0)
: QObject(parent)
{
}
explicit DummyAndroidLocalizer(QObject *parent = 0) : QObject(parent) {}
Q_INVOKABLE QString i18n(const QString &message,
const QVariant &p1 = QVariant(),
const QVariant &p2 = QVariant(),
const QVariant &p3 = QVariant(),
const QVariant &p4 = QVariant(),
const QVariant &p5 = QVariant(),
const QVariant &p6 = QVariant(),
const QVariant &p7 = QVariant(),
const QVariant &p8 = QVariant(),
const QVariant &p9 = QVariant(),
Q_INVOKABLE QString i18n(const QString &message, const QVariant &p1 = QVariant(),
const QVariant &p2 = QVariant(), const QVariant &p3 = QVariant(),
const QVariant &p4 = QVariant(), const QVariant &p5 = QVariant(),
const QVariant &p6 = QVariant(), const QVariant &p7 = QVariant(),
const QVariant &p8 = QVariant(), const QVariant &p9 = QVariant(),
const QVariant &p10 = QVariant()) const
{
return message;
}
Q_INVOKABLE QString i18nc(const QString &context,
const QString &message,
const QVariant &p1 = QVariant(),
const QVariant &p2 = QVariant(),
const QVariant &p3 = QVariant(),
const QVariant &p4 = QVariant(),
const QVariant &p5 = QVariant(),
const QVariant &p6 = QVariant(),
const QVariant &p7 = QVariant(),
const QVariant &p8 = QVariant(),
Q_INVOKABLE QString i18nc(const QString &context, const QString &message,
const QVariant &p1 = QVariant(), const QVariant &p2 = QVariant(),
const QVariant &p3 = QVariant(), const QVariant &p4 = QVariant(),
const QVariant &p5 = QVariant(), const QVariant &p6 = QVariant(),
const QVariant &p7 = QVariant(), const QVariant &p8 = QVariant(),
const QVariant &p9 = QVariant(),
const QVariant &p10 = QVariant()) const
{
......@@ -81,7 +68,7 @@ class UiController : public IUiController
public:
explicit UiController(QObject *parent = 0);
~UiController() override;
~UiController() override = default;
bool initialize(Core *core);
virtual QString errorString() const override;
......
......@@ -24,11 +24,11 @@
namespace Minuet
{
ICore *ICore::m_self = 0;
ICore *ICore::m_self = nullptr;
ICore::~ICore()
{
m_self = 0;
m_self = nullptr;
}
ICore *ICore::self()
......@@ -36,10 +36,9 @@ ICore *ICore::self()