diff --git a/src/Browser.qml b/src/Browser.qml
new file mode 100644
index 000000000..ac933bae7
--- /dev/null
+++ b/src/Browser.qml
@@ -0,0 +1,61 @@
+import QtQuick 2.7
+import QtQuick.Layouts 1.3
+import QtQuick.Controls 2.15
+import QtQuick.Controls.Material 2.0
+import Qt.labs.settings 1.0
+import QtWebView 1.1
+
+Item {
+ id: column1
+
+ signal browser_peloton_time_to_complete(string time_to_complete)
+ signal browser_peloton_time_to_start(string time_to_start)
+
+ Settings {
+ id: settings
+ }
+
+ WebView {
+ id: webView
+ property var rr;
+ anchors.top: parent.top
+ anchors.bottom: parent.bottom
+ anchors.horizontalCenter: parent.horizontalCenter
+ width: parent.width
+
+ url: "https://onepeloton.com"
+ visible: true
+ onLoadingChanged: {
+ if (loadRequest.errorString)
+ console.error(loadRequest.errorString);
+ if (loadRequest.status == WebView.LoadSucceededStatus) {
+ console.error("Procedo");
+ let loadScr = `
+ var findAndDisplayElement = function() {
+ var p = document.querySelector('p[data-test-id="time-to-complete"]');
+ if (p) {
+ browser_peloton_time_to_complete(p.innerText);
+ console.log(p.innerText);
+ } else {
+ console.log("Element not found");
+ }
+
+ p = document.querySelector('p[data-test-id="time-to-start"]');
+ if (p) {
+ browser_peloton_time_to_start(p.innerText);
+ console.log(p.innerText);
+ } else {
+ console.log("Element not found");
+ }
+ };
+
+ findAndDisplayElement(); // Run immediately on first load
+ setInterval(findAndDisplayElement, 1000); // Then run every 1000 milliseconds (1 second)
+ `;
+ console.error(loadScr);
+ webView.runJavaScript(loadScr, function(res) {
+ });
+ }
+ }
+ }
+}
diff --git a/src/homeform.cpp b/src/homeform.cpp
index aa3de6b81..b9e81b55b 100644
--- a/src/homeform.cpp
+++ b/src/homeform.cpp
@@ -499,6 +499,8 @@ homeform::homeform(QQmlApplicationEngine *engine, bluetooth *bl) {
QObject::connect(stack, SIGNAL(keyMediaNext()), this, SLOT(keyMediaNext()));
QObject::connect(stack, SIGNAL(floatingOpen()), this, SLOT(floatingOpen()));
QObject::connect(stack, SIGNAL(openFloatingWindowBrowser()), this, SLOT(openFloatingWindowBrowser()));
+ QObject::connect(stack, SIGNAL(browser_peloton_time_to_complete(QString)), this, SLOT(browser_peloton_time_to_complete(QString)));
+ QObject::connect(stack, SIGNAL(browser_peloton_time_to_start(QString)), this, SLOT(browser_peloton_time_to_start(QString)));
#if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS)
QObject::connect(engine, &QQmlApplicationEngine::quit, &QGuiApplication::quit);
@@ -5211,6 +5213,18 @@ bool homeform::getLap() {
return true;
}
+void homeform::browser_peloton_time_to_complete(const QString time_to_complete) {
+ qDebug() << QStringLiteral("browser_peloton_time_to_complete") << time_to_complete << trainProgram;
+ if(trainProgram)
+ trainProgram->pelotonOCRcomputeTime(time_to_complete);
+}
+
+void homeform::browser_peloton_time_to_start(const QString time_to_start) {
+ qDebug() << QStringLiteral("browser_peloton_time_to_start") << time_to_start << trainProgram;
+ if(trainProgram)
+ trainProgram->pelotonOCRcomputeTime("INTRO");
+}
+
void homeform::copyAndroidContentsURI(QFile* file, QString subfolder) {
#ifdef Q_OS_ANDROID
QString filename = file->fileName();
diff --git a/src/homeform.h b/src/homeform.h
index e44b07f7f..59d669c48 100644
--- a/src/homeform.h
+++ b/src/homeform.h
@@ -759,6 +759,8 @@ class homeform : public QObject {
void deviceFound(const QString &name);
void deviceConnected(QBluetoothDeviceInfo b);
void ftmsAccessoryConnected(smartspin2k *d);
+ void browser_peloton_time_to_complete(const QString time_to_complete);
+ void browser_peloton_time_to_start(const QString time_to_start);
void trainprogram_open_clicked(const QUrl &fileName);
void profile_open_clicked(const QUrl &fileName);
void trainprogram_preview(const QUrl &fileName);
diff --git a/src/main.qml b/src/main.qml
index bd750d059..fa9c70221 100644
--- a/src/main.qml
+++ b/src/main.qml
@@ -692,12 +692,11 @@ ApplicationWindow {
ItemDelegate {
id: gpx_save
- text: qsTr("Save GPX")
+ text: qsTr("Open Browser")
width: parent.width
onClicked: {
- gpx_save_clicked()
drawer.close()
- popupSaveFile.open()
+ stackView.push("Browser.qml")
}
}
ItemDelegate {
diff --git a/src/qml.qrc b/src/qml.qrc
index 1193f956b..ff808c150 100644
--- a/src/qml.qrc
+++ b/src/qml.qrc
@@ -107,5 +107,6 @@
ChartFooter.qml
ChartFooterInnerJS.qml
ChartFooterInnerNoJS.qml
+ Browser.qml
diff --git a/src/trainprogram.h b/src/trainprogram.h
index a6d1a4410..d48e44508 100644
--- a/src/trainprogram.h
+++ b/src/trainprogram.h
@@ -90,6 +90,8 @@ class trainprogram : public QObject {
}
return false;
}
+
+ void pelotonOCRcomputeTime(QString t);
QList rows;
QList loadedRows; // rows as loaded
@@ -153,8 +155,7 @@ private slots:
double lastCurrentStepDistance = 0.0;
QTime lastCurrentStepTime = QTime(0, 0, 0);
- QUdpSocket* pelotonOCRsocket = nullptr;
- void pelotonOCRcomputeTime(QString t);
+ QUdpSocket* pelotonOCRsocket = nullptr;
};
#endif // TRAINPROGRAM_H