From 03ed308bd93633466e7bde7852d7c21b9c3d5ed3 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 13 Dec 2019 14:31:42 +0100 Subject: [PATCH] [welcome] Add QML model for translations --- src/modules/welcome/qmlmain.cpp | 4 ++++ src/modules/welcome/welcome.qml | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/src/modules/welcome/qmlmain.cpp b/src/modules/welcome/qmlmain.cpp index 0aca1ddcd..9c160fc1d 100644 --- a/src/modules/welcome/qmlmain.cpp +++ b/src/modules/welcome/qmlmain.cpp @@ -15,6 +15,7 @@ #include +#include "locale/LabelModel.h" #include "utils/Logger.h" #include "Config.h" @@ -61,8 +62,11 @@ int main(int argc, char **argv) cnf.setHelpUrl( QUrl( argv[1] ) ); } + // TODO: this should put the one config object in the context, rather than adding a factory function to share it everywhere qmlRegisterSingletonType< Config >( "io.calamares.modules.welcome", 1, 0, "PotatoConfig", [](QQmlEngine*, QJSEngine*) -> QObject* { return theConfig(); }); + qmlRegisterSingletonType< CalamaresUtils::Locale::LabelModel >( "io.calamares.locale", 1, 0, "LocaleModel", [](QQmlEngine*, QJSEngine*) -> QObject* { return CalamaresUtils::Locale::availableTranslations(); } ); + qqw.setSource( QUrl::fromLocalFile("../src/modules/welcome/welcome.qml") ); return a.exec(); diff --git a/src/modules/welcome/welcome.qml b/src/modules/welcome/welcome.qml index ba28d660b..bdb7c4416 100644 --- a/src/modules/welcome/welcome.qml +++ b/src/modules/welcome/welcome.qml @@ -1,6 +1,7 @@ import QtQuick 2.0; import QtQuick.Controls 2.3; import io.calamares.modules.welcome 1.0; +import io.calamares.locale 1.0; Rectangle { width: 200; @@ -14,8 +15,15 @@ Rectangle { } Button { + id: thebutton; anchors.top: label.bottom; text: PotatoConfig.helpUrl; } + + ListView { + anchors.fill: parent; + model: LocaleModel; + delegate: Label { text: display } + } }