[welcome] Add QML model for translations

This commit is contained in:
Adriaan de Groot 2019-12-13 14:31:42 +01:00
parent d41d8df2a5
commit 03ed308bd9
2 changed files with 12 additions and 0 deletions

View File

@ -15,6 +15,7 @@
#include <KAboutData>
#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();

View File

@ -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 }
}
}