Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 1f6d9e75 authored by Nicolas Fella's avatar Nicolas Fella

Almost port away from context properties

parent 19a763fa
......@@ -20,9 +20,9 @@
#include <QObject>
class Localizer
class Localizer : public QObject
{
Q_GADGET
Q_OBJECT
public:
Q_INVOKABLE QString countryName(const QString &isoCode) const;
/** Emoji representation of @p isoCode.
......
......@@ -73,7 +73,8 @@ int main(int argc, char *argv[])
KPublicTransport::Manager manager;
manager.setAllowInsecureBackends(true);
manager.setBackendsEnabledByDefault(false);
engine.rootContext()->setContextProperty(QStringLiteral("_manager"), &manager);
qmlRegisterSingletonInstance<KPublicTransport::Manager>("org.kde.ktrip", 1, 0, "Manager", &manager);
KTripSettings settings;
manager.setEnabledBackends(settings.enabledBackends());
......@@ -83,6 +84,8 @@ int main(int argc, char *argv[])
settings.save();
});
qmlRegisterSingletonInstance<KTripSettings>("org.kde.ktrip", 1, 0, "Settings", &settings);
KAboutData about(QStringLiteral("ktrip"), i18n("KTrip"), QStringLiteral("0.1"), i18n("Public transport assistant"), KAboutLicense::GPL, i18n("© 2019 KDE Community"));
about.addAuthor(i18n("Nicolas Fella"), QString(), QStringLiteral("nicolas.fella@gmx.de"));
about.setProgramLogo(QImage(QStringLiteral(":/ktrip.svg")));
......@@ -90,10 +93,8 @@ int main(int argc, char *argv[])
engine.rootContext()->setContextProperty(QStringLiteral("_aboutData"), QVariant::fromValue(about));
engine.rootContext()->setContextProperty(QStringLiteral("_settings"), &settings);
Formatter formatter;
engine.rootContext()->setContextProperty(QStringLiteral("_formatter"), &formatter);
qmlRegisterSingletonInstance<Formatter>("org.kde.ktrip", 1, 0, "Formatter", &formatter);
#ifdef Q_OS_ANDROID
engine.rootContext()->setContextProperty(QStringLiteral("_isAndroid"), true);
......@@ -102,12 +103,11 @@ int main(int argc, char *argv[])
engine.rootContext()->setContextProperty(QStringLiteral("_isAndroid"), false);
#endif
qmlRegisterSingletonType("org.kde.ktrip", 1, 0, "Localizer", [](QQmlEngine *, QJSEngine *engine) -> QJSValue { return engine->toScriptValue(Localizer()); });
Localizer localizer;
qmlRegisterSingletonInstance<Localizer>("org.kde.ktrip", 1, 0, "Localizer", &localizer);
qmlRegisterSingletonType<Controller>("org.kde.ktrip", 1, 0, "Controller", [](QQmlEngine *, QJSEngine *engine) -> QObject * {
Q_UNUSED(engine);
return new Controller;
});
Controller controller;
qmlRegisterSingletonInstance<Controller>("org.kde.ktrip", 1, 0, "Controller", &controller);
engine.load(QUrl(QStringLiteral("qrc:/qml/main.qml")));
......
......@@ -39,7 +39,7 @@ Kirigami.ScrollablePage {
KPublicTransport.BackendModel {
id: backendModel
manager: _manager
manager: Manager
}
Component {
......
......@@ -34,7 +34,7 @@ Row {
Kirigami.Heading {
id: durationHeading
level: 2
text: _formatter.formatDuration(root.journey.duration)
text: Formatter.formatDuration(root.journey.duration)
font.strikeout: root.journey.disruptionEffect == KPT.Disruption.NoService
}
......
......@@ -42,7 +42,7 @@ Kirigami.ScrollablePage
model: KPT.JourneyQueryModel {
id: theModel
request: Controller.createJourneyRequest()
manager: _manager
manager: Manager
}
header: ToolButton {
......
......@@ -40,13 +40,13 @@ Kirigami.ScrollablePage
model: KPT.DepartureQueryModel {
id: theModel
request: Controller.createStopoverRequest()
manager: _manager
manager: Manager
}
delegate: Kirigami.AbstractListItem {
RowLayout {
Label {
text: i18n("%3 %1 (%2)", departure.route.line.name, departure.route.direction, _formatter.formatTime(departure.scheduledDepartureTime))
text: i18n("%3 %1 (%2)", departure.route.line.name, departure.route.direction, Formatter.formatTime(departure.scheduledDepartureTime))
Layout.fillWidth: true
}
Label {
......
......@@ -67,7 +67,7 @@ Kirigami.ScrollablePage
KPT.LocationQueryModel {
id: queryModel
manager: _manager
manager: Manager
}
LocationCacheModel {
......
......@@ -21,6 +21,7 @@
import QtQuick 2.2
import QtQuick.Controls 2.4
import org.kde.kirigami 2.6 as Kirigami
import org.kde.ktrip 1.0
Kirigami.ApplicationWindow
{
......@@ -31,10 +32,10 @@ Kirigami.ApplicationWindow
pageStack.initialPage: Qt.resolvedUrl("QueryPage.qml")
Component.onCompleted: {
if (_settings.firstRun) {
if (Settings.firstRun) {
window.pageStack.push(Qt.resolvedUrl("BackendPage.qml"))
_settings.firstRun = false
_settings.save()
Settings.firstRun = false
Settings.save()
}
}
......
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