...
 
Commits (3)
cmake_minimum_required(VERSION 3.0)
project(ktrip VERSION 0.0.1)
set(QT_MIN_VERSION "5.12.0")
set(QT_MIN_VERSION "5.14.0")
set(KF5_MIN_VERSION "5.70.0")
find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE)
......
......@@ -25,10 +25,10 @@
#include <QTime>
#include <QVariant>
#include <KPublicTransport/StopoverRequest>
#include <KPublicTransport/JourneyRequest>
#include <KPublicTransport/Location>
#include <KPublicTransport/LocationRequest>
#include <KPublicTransport/StopoverRequest>
class Controller : public QObject
{
......
......@@ -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,16 +73,19 @@ 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());
QObject::connect(&manager, &KPublicTransport::Manager::configurationChanged, &settings, [&settings, &manager]{
QObject::connect(&manager, &KPublicTransport::Manager::configurationChanged, &settings, [&settings, &manager] {
settings.setEnabledBackends(manager.enabledBackends());
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()
}
}
......