mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-07-16 13:02:27 +08:00
Merge branch 'master-new' into mads-new
This commit is contained in:
@@ -15,7 +15,7 @@ if arch == "Darwin":
|
||||
sp_widgets_src = []
|
||||
sp_qt_src = []
|
||||
if not GetOption('stock_ui'):
|
||||
SConscript(['../../sunnypilot/selfdrive/ui/SConscript'])
|
||||
SConscript(['sunnypilot/SConscript'])
|
||||
Import('sp_widgets_src', 'sp_qt_src')
|
||||
|
||||
# FIXME: remove this once we're on 5.15 (24.04)
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "selfdrive/ui/qt/window.h"
|
||||
|
||||
#ifdef SUNNYPILOT
|
||||
#include "../../sunnypilot/selfdrive/ui/qt/window.h"
|
||||
#include "selfdrive/ui/sunnypilot/qt/window.h"
|
||||
#define MainWindow MainWindowSP
|
||||
#else
|
||||
#include "selfdrive/ui/qt/qt_window.h"
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include "common/util.h"
|
||||
|
||||
#ifdef SUNNYPILOT
|
||||
#include "../../sunnypilot/selfdrive/ui/ui.h"
|
||||
#include "selfdrive/ui/sunnypilot/ui.h"
|
||||
#define UIState UIStateSP
|
||||
#else
|
||||
#include "selfdrive/ui/ui.h"
|
||||
|
||||
@@ -13,9 +13,9 @@
|
||||
#include "selfdrive/ui/ui.h"
|
||||
|
||||
#ifdef SUNNYPILOT
|
||||
#include "../../sunnypilot/selfdrive/ui/qt/widgets/controls.h"
|
||||
#include "../../sunnypilot/selfdrive/ui/qt/onroad/onroad_home.h"
|
||||
#include "../../sunnypilot/selfdrive/ui/qt/sidebar.h"
|
||||
#include "selfdrive/ui/sunnypilot/qt/widgets/controls.h"
|
||||
#include "selfdrive/ui/sunnypilot/qt/onroad/onroad_home.h"
|
||||
#include "selfdrive/ui/sunnypilot/qt/sidebar.h"
|
||||
#define OnroadWindow OnroadWindowSP
|
||||
#define LayoutWidget LayoutWidgetSP
|
||||
#define Sidebar SidebarSP
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
#include "selfdrive/ui/qt/util.h"
|
||||
|
||||
#ifdef SUNNYPILOT
|
||||
#include "../../sunnypilot/selfdrive/ui/qt/widgets/controls.h"
|
||||
#include "../../sunnypilot/selfdrive/ui/qt/widgets/scrollview.h"
|
||||
#include "selfdrive/ui/sunnypilot/qt/widgets/controls.h"
|
||||
#include "selfdrive/ui/sunnypilot/qt/widgets/scrollview.h"
|
||||
#else
|
||||
#include "selfdrive/ui/qt/widgets/controls.h"
|
||||
#include "selfdrive/ui/qt/widgets/scrollview.h"
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "selfdrive/ui/qt/widgets/toggle.h"
|
||||
|
||||
#ifdef SUNNYPILOT
|
||||
#include "../../sunnypilot/selfdrive/ui/qt/widgets/controls.h"
|
||||
#include "selfdrive/ui/sunnypilot/qt/widgets/controls.h"
|
||||
#define ButtonControl ButtonControlSP
|
||||
#define ElidedLabel ElidedLabelSP
|
||||
#define LabelControl LabelControlSP
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "common/util.h"
|
||||
|
||||
#ifdef SUNNYPILOT
|
||||
#include "../../sunnypilot/selfdrive/ui/qt/widgets/controls.h"
|
||||
#include "selfdrive/ui/sunnypilot/qt/widgets/controls.h"
|
||||
#else
|
||||
#include "selfdrive/ui/qt/widgets/controls.h"
|
||||
#endif
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef SUNNYPILOT
|
||||
#include "../../sunnypilot/selfdrive/ui/qt/offroad/settings/settings.h"
|
||||
#include "selfdrive/ui/sunnypilot/qt/offroad/settings/settings.h"
|
||||
#else
|
||||
#include "selfdrive/ui/qt/offroad/settings.h"
|
||||
#endif
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
#include "selfdrive/ui/qt/util.h"
|
||||
|
||||
#ifdef SUNNYPILOT
|
||||
#include "../../sunnypilot/selfdrive/ui/ui.h"
|
||||
#include "../../sunnypilot/selfdrive/ui/qt/widgets/controls.h"
|
||||
#include "selfdrive/ui/sunnypilot/ui.h"
|
||||
#include "selfdrive/ui/sunnypilot/qt/widgets/controls.h"
|
||||
#define ListWidget ListWidgetSP
|
||||
#define ParamControl ParamControlSP
|
||||
#define ButtonControl ButtonControlSP
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <QPushButton>
|
||||
|
||||
#ifdef SUNNYPILOT
|
||||
#include "../../sunnypilot/selfdrive/ui/ui.h"
|
||||
#include "selfdrive/ui/sunnypilot/ui.h"
|
||||
#else
|
||||
#include "selfdrive/ui/ui.h"
|
||||
#endif
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <QPolygonF>
|
||||
|
||||
#ifdef SUNNYPILOT
|
||||
#include "../../sunnypilot/selfdrive/ui/ui.h"
|
||||
#include "selfdrive/ui/sunnypilot/ui.h"
|
||||
#else
|
||||
#include "selfdrive/ui/ui.h"
|
||||
#endif
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "selfdrive/ui/qt/api.h"
|
||||
|
||||
#ifdef SUNNYPILOT
|
||||
#include "../../sunnypilot/selfdrive/ui/ui.h"
|
||||
#include "selfdrive/ui/sunnypilot/ui.h"
|
||||
#else
|
||||
#include "selfdrive/ui/ui.h"
|
||||
#endif
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "selfdrive/ui/qt/network/networking.h"
|
||||
|
||||
#ifdef SUNNYPILOT
|
||||
#include "../../sunnypilot/selfdrive/ui/ui.h"
|
||||
#include "selfdrive/ui/sunnypilot/ui.h"
|
||||
#else
|
||||
#include "selfdrive/ui/ui.h"
|
||||
#endif
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include "msgq/visionipc/visionipc_client.h"
|
||||
|
||||
#ifdef SUNNYPILOT
|
||||
#include "../../sunnypilot/selfdrive/ui/ui.h"
|
||||
#include "selfdrive/ui/sunnypilot/ui.h"
|
||||
#else
|
||||
#include "selfdrive/ui/ui.h"
|
||||
#endif
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "system/hardware/hw.h"
|
||||
|
||||
#ifdef SUNNYPILOT
|
||||
#include "../../sunnypilot/selfdrive/ui/qt/widgets/controls.h"
|
||||
#include "selfdrive/ui/sunnypilot/qt/widgets/controls.h"
|
||||
#define ButtonControl ButtonControlSP
|
||||
#define ToggleControl ToggleControlSP
|
||||
#else
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <QWidget>
|
||||
|
||||
#ifdef SUNNYPILOT
|
||||
#include "../../sunnypilot/selfdrive/ui/ui.h"
|
||||
#include "selfdrive/ui/sunnypilot/ui.h"
|
||||
#define UIState UIStateSP
|
||||
#else
|
||||
#include "selfdrive/ui/ui.h"
|
||||
|
||||
@@ -5,11 +5,10 @@
|
||||
#include "system/hardware/hw.h"
|
||||
|
||||
// We have this constructor so that we can provide custom implementations of the windows. By default (stock_ui) would receive them as nullptr, so they'll be instantiated with stock. Otherwise they'd be SP instances
|
||||
MainWindow::MainWindow(QWidget *parent, HomeWindow *hw, SettingsWindow *sw, OnboardingWindow *ow) :
|
||||
MainWindow::MainWindow(QWidget *parent, HomeWindow *hw, SettingsWindow *sw) :
|
||||
QWidget(parent),
|
||||
homeWindow(hw ? hw : new HomeWindow(this)),
|
||||
settingsWindow(sw ? sw : new SettingsWindow(this)),
|
||||
onboardingWindow(ow ? ow : new OnboardingWindow(this)) {
|
||||
settingsWindow(sw ? sw : new SettingsWindow(this)) {
|
||||
|
||||
main_layout = new QStackedLayout(this);
|
||||
main_layout->setMargin(0);
|
||||
@@ -25,6 +24,7 @@ MainWindow::MainWindow(QWidget *parent, HomeWindow *hw, SettingsWindow *sw, Onbo
|
||||
main_layout->setCurrentWidget(onboardingWindow);
|
||||
});
|
||||
|
||||
onboardingWindow = new OnboardingWindow(this);
|
||||
main_layout->addWidget(onboardingWindow);
|
||||
QObject::connect(onboardingWindow, &OnboardingWindow::onboardingDone, [=]() {
|
||||
main_layout->setCurrentWidget(homeWindow);
|
||||
|
||||
@@ -11,13 +11,12 @@ class MainWindow : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWindow(QWidget *parent = 0) : MainWindow(parent, nullptr, nullptr, nullptr) {}
|
||||
explicit MainWindow(QWidget *parent = 0) : MainWindow(parent, nullptr, nullptr) {}
|
||||
|
||||
protected:
|
||||
explicit MainWindow(QWidget *parent, HomeWindow *hw = nullptr, SettingsWindow *sw = nullptr, OnboardingWindow *ow = nullptr);
|
||||
explicit MainWindow(QWidget *parent, HomeWindow *hw = nullptr, SettingsWindow *sw = nullptr);
|
||||
HomeWindow *homeWindow;
|
||||
SettingsWindow *settingsWindow;
|
||||
OnboardingWindow *onboardingWindow;
|
||||
virtual void closeSettings();
|
||||
|
||||
private:
|
||||
@@ -25,4 +24,5 @@ private:
|
||||
void openSettings(int index = 0, const QString ¶m = "");
|
||||
|
||||
QStackedLayout *main_layout;
|
||||
OnboardingWindow *onboardingWindow;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
widgets_src = [
|
||||
"sunnypilot/qt/widgets/toggle.cc",
|
||||
"sunnypilot/qt/widgets/controls.cc",
|
||||
"sunnypilot/qt/widgets/scrollview.cc",
|
||||
]
|
||||
|
||||
qt_src = [
|
||||
"sunnypilot/ui.cc",
|
||||
"sunnypilot/qt/sidebar.cc",
|
||||
"sunnypilot/qt/window.cc",
|
||||
"sunnypilot/qt/home.cc",
|
||||
"sunnypilot/qt/offroad/settings/settings.cc",
|
||||
"sunnypilot/qt/onroad/onroad_home.cc",
|
||||
]
|
||||
|
||||
sp_widgets_src = widgets_src
|
||||
sp_qt_src = qt_src
|
||||
|
||||
Export('sp_widgets_src', 'sp_qt_src')
|
||||
@@ -5,7 +5,7 @@
|
||||
* See the LICENSE.md file in the root directory for more details.
|
||||
*/
|
||||
|
||||
#include "../../sunnypilot/selfdrive/ui/qt/home.h"
|
||||
#include "selfdrive/ui/sunnypilot/qt/home.h"
|
||||
|
||||
HomeWindowSP::HomeWindowSP(QWidget *parent) : HomeWindow(parent) {
|
||||
}
|
||||
@@ -13,11 +13,11 @@
|
||||
#include "common/params.h"
|
||||
#include "selfdrive/ui/qt/body.h"
|
||||
#include "selfdrive/ui/qt/widgets/offroad_alerts.h"
|
||||
#include "../../sunnypilot/selfdrive/ui/ui.h"
|
||||
#include "selfdrive/ui/sunnypilot/ui.h"
|
||||
#include "selfdrive/ui/qt/home.h"
|
||||
|
||||
#ifdef SUNNYPILOT
|
||||
#include "../../sunnypilot/selfdrive/ui/qt/sidebar.h"
|
||||
#include "selfdrive/ui/sunnypilot/qt/sidebar.h"
|
||||
#define OnroadWindow OnroadWindowSP
|
||||
#else
|
||||
#include "selfdrive/ui/qt/sidebar.h"
|
||||
+2
-2
@@ -5,10 +5,10 @@
|
||||
* See the LICENSE.md file in the root directory for more details.
|
||||
*/
|
||||
|
||||
#include "../../sunnypilot/selfdrive/ui/qt/offroad/settings/settings.h"
|
||||
#include "selfdrive/ui/sunnypilot/qt/offroad/settings/settings.h"
|
||||
|
||||
#include "selfdrive/ui/qt/network/networking.h"
|
||||
#include "../../sunnypilot/selfdrive/ui/qt/widgets/scrollview.h"
|
||||
#include "selfdrive/ui/sunnypilot/qt/widgets/scrollview.h"
|
||||
#include "selfdrive/ui/qt/offroad/developer_panel.h"
|
||||
|
||||
TogglesPanelSP::TogglesPanelSP(SettingsWindow *parent) : TogglesPanel(parent) {
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
* See the LICENSE.md file in the root directory for more details.
|
||||
*/
|
||||
|
||||
#include "../../sunnypilot/selfdrive/ui/qt/onroad/onroad_home.h"
|
||||
#include "selfdrive/ui/sunnypilot/qt/onroad/onroad_home.h"
|
||||
|
||||
#include "common/swaglog.h"
|
||||
#include "selfdrive/ui/qt/util.h"
|
||||
@@ -5,7 +5,7 @@
|
||||
* See the LICENSE.md file in the root directory for more details.
|
||||
*/
|
||||
|
||||
#include "../../sunnypilot/selfdrive/ui/qt/sidebar.h"
|
||||
#include "selfdrive/ui/sunnypilot/qt/sidebar.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <QMouseEvent>
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
#include "selfdrive/ui/qt/sidebar.h"
|
||||
|
||||
#include "../../sunnypilot/selfdrive/ui/ui.h"
|
||||
#include "selfdrive/ui/sunnypilot/ui.h"
|
||||
|
||||
class SidebarSP : public Sidebar {
|
||||
Q_OBJECT
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
* See the LICENSE.md file in the root directory for more details.
|
||||
*/
|
||||
|
||||
#include "../../sunnypilot/selfdrive/ui/qt/widgets/controls.h"
|
||||
#include "selfdrive/ui/sunnypilot/qt/widgets/controls.h"
|
||||
|
||||
#include <QPainter>
|
||||
#include <QStyleOption>
|
||||
+1
-1
@@ -15,7 +15,7 @@
|
||||
#include "common/params.h"
|
||||
#include "selfdrive/ui/qt/widgets/controls.h"
|
||||
#include "selfdrive/ui/qt/widgets/input.h"
|
||||
#include "../../sunnypilot/selfdrive/ui/qt/widgets/toggle.h"
|
||||
#include "selfdrive/ui/sunnypilot/qt/widgets/toggle.h"
|
||||
|
||||
QFrame *horizontal_line(QWidget *parent = nullptr);
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* Copyright (c) 2021-, Haibin Wen, sunnypilot, and a number of other contributors.
|
||||
*
|
||||
* This file is part of sunnypilot and is licensed under the MIT License.
|
||||
* See the LICENSE.md file in the root directory for more details.
|
||||
*/
|
||||
|
||||
#include "selfdrive/ui/sunnypilot/qt/widgets/scrollview.h"
|
||||
|
||||
#include <QScrollBar>
|
||||
|
||||
void ScrollViewSP::setLastScrollPosition() {
|
||||
lastScrollPosition = verticalScrollBar()->value();
|
||||
}
|
||||
|
||||
void ScrollViewSP::restoreScrollPosition() {
|
||||
verticalScrollBar()->setValue(lastScrollPosition);
|
||||
}
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
* See the LICENSE.md file in the root directory for more details.
|
||||
*/
|
||||
|
||||
#include "../../sunnypilot/selfdrive/ui/qt/widgets/toggle.h"
|
||||
#include "selfdrive/ui/sunnypilot/qt/widgets/toggle.h"
|
||||
|
||||
#include <QPainter>
|
||||
|
||||
@@ -5,14 +5,13 @@
|
||||
* See the LICENSE.md file in the root directory for more details.
|
||||
*/
|
||||
|
||||
#include "../../sunnypilot/selfdrive/ui/qt/window.h"
|
||||
#include "selfdrive/ui/sunnypilot/qt/window.h"
|
||||
|
||||
MainWindowSP::MainWindowSP(QWidget *parent)
|
||||
: MainWindow(parent, new HomeWindowSP(parent), new SettingsWindowSP(parent), new OnboardingWindowSP(parent)) {
|
||||
: MainWindow(parent, new HomeWindowSP(parent), new SettingsWindowSP(parent)) {
|
||||
|
||||
homeWindow = dynamic_cast<HomeWindowSP *>(MainWindow::homeWindow);
|
||||
settingsWindow = dynamic_cast<SettingsWindowSP *>(MainWindow::settingsWindow);
|
||||
onboardingWindow = dynamic_cast<OnboardingWindowSP *>(MainWindow::onboardingWindow);
|
||||
}
|
||||
|
||||
void MainWindowSP::closeSettings() {
|
||||
@@ -8,9 +8,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "selfdrive/ui/qt/window.h"
|
||||
#include "../../sunnypilot/selfdrive/ui/qt/home.h"
|
||||
#include "../../sunnypilot/selfdrive/ui/qt/offroad/settings/settings.h"
|
||||
#include "offroad/settings/onboarding.h"
|
||||
#include "selfdrive/ui/sunnypilot/qt/home.h"
|
||||
#include "selfdrive/ui/sunnypilot/qt/offroad/settings/settings.h"
|
||||
|
||||
class MainWindowSP : public MainWindow {
|
||||
Q_OBJECT
|
||||
@@ -21,6 +20,5 @@ public:
|
||||
private:
|
||||
HomeWindowSP *homeWindow;
|
||||
SettingsWindowSP *settingsWindow;
|
||||
OnboardingWindowSP *onboardingWindow;
|
||||
void closeSettings() override;
|
||||
};
|
||||
@@ -5,7 +5,7 @@
|
||||
* See the LICENSE.md file in the root directory for more details.
|
||||
*/
|
||||
|
||||
#include "../../sunnypilot/selfdrive/ui/ui.h"
|
||||
#include "selfdrive/ui/sunnypilot/ui.h"
|
||||
|
||||
#include "common/watchdog.h"
|
||||
|
||||
@@ -500,6 +500,17 @@
|
||||
<translation>إلغاء</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ParamControlSP</name>
|
||||
<message>
|
||||
<source>Enable</source>
|
||||
<translation>تمكين</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Cancel</source>
|
||||
<translation>إلغاء</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>PrimeAdWidget</name>
|
||||
<message>
|
||||
@@ -662,6 +673,37 @@ This may take up to a minute.</source>
|
||||
<translation>المطور</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>SettingsWindowSP</name>
|
||||
<message>
|
||||
<source>×</source>
|
||||
<translation>×</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Device</source>
|
||||
<translation>الجهاز</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Network</source>
|
||||
<translation>الشبكة</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Toggles</source>
|
||||
<translation>المثبتتات</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Software</source>
|
||||
<translation>البرنامج</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Developer</source>
|
||||
<translation>المطور</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>sunnypilot</source>
|
||||
<translation>sunnypilot</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Setup</name>
|
||||
<message>
|
||||
|
||||
@@ -495,6 +495,17 @@
|
||||
<translation>Aktivieren</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ParamControlSP</name>
|
||||
<message>
|
||||
<source>Cancel</source>
|
||||
<translation>Abbrechen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Enable</source>
|
||||
<translation>Aktivieren</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>PrimeAdWidget</name>
|
||||
<message>
|
||||
@@ -644,6 +655,37 @@ This may take up to a minute.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>SettingsWindowSP</name>
|
||||
<message>
|
||||
<source>×</source>
|
||||
<translation>x</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Device</source>
|
||||
<translation>Gerät</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Network</source>
|
||||
<translation>Netzwerk</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Toggles</source>
|
||||
<translation>Schalter</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Software</source>
|
||||
<translation>Software</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Developer</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>sunnypilot</source>
|
||||
<translation>sunnypilot</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Setup</name>
|
||||
<message>
|
||||
|
||||
@@ -496,6 +496,17 @@
|
||||
<translation>Cancelar</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ParamControlSP</name>
|
||||
<message>
|
||||
<source>Enable</source>
|
||||
<translation>Activar</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Cancel</source>
|
||||
<translation>Cancelar</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>PrimeAdWidget</name>
|
||||
<message>
|
||||
@@ -646,6 +657,37 @@ Esto puede tardar un minuto.</translation>
|
||||
<translation>Desarrollador</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>SettingsWindowSP</name>
|
||||
<message>
|
||||
<source>×</source>
|
||||
<translation>×</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Device</source>
|
||||
<translation>Dispositivo</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Network</source>
|
||||
<translation>Red</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Toggles</source>
|
||||
<translation>Ajustes</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Software</source>
|
||||
<translation>Software</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Developer</source>
|
||||
<translation>Desarrollador</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>sunnypilot</source>
|
||||
<translation>sunnypilot</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Setup</name>
|
||||
<message>
|
||||
|
||||
@@ -496,6 +496,17 @@
|
||||
<translation>Annuler</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ParamControlSP</name>
|
||||
<message>
|
||||
<source>Enable</source>
|
||||
<translation>Activer</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Cancel</source>
|
||||
<translation>Annuler</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>PrimeAdWidget</name>
|
||||
<message>
|
||||
@@ -646,6 +657,37 @@ Cela peut prendre jusqu'à une minute.</translation>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>SettingsWindowSP</name>
|
||||
<message>
|
||||
<source>×</source>
|
||||
<translation>×</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Device</source>
|
||||
<translation>Appareil</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Network</source>
|
||||
<translation>Réseau</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Toggles</source>
|
||||
<translation>Options</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Software</source>
|
||||
<translation>Logiciel</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Developer</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>sunnypilot</source>
|
||||
<translation>sunnypilot</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Setup</name>
|
||||
<message>
|
||||
|
||||
@@ -494,6 +494,17 @@
|
||||
<translation>を有効化</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ParamControlSP</name>
|
||||
<message>
|
||||
<source>Cancel</source>
|
||||
<translation>キャンセル</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Enable</source>
|
||||
<translation>を有効化</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>PrimeAdWidget</name>
|
||||
<message>
|
||||
@@ -640,6 +651,37 @@ This may take up to a minute.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>SettingsWindowSP</name>
|
||||
<message>
|
||||
<source>×</source>
|
||||
<translation>×</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Device</source>
|
||||
<translation>デバイス</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Network</source>
|
||||
<translation>ネットワーク</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Toggles</source>
|
||||
<translation>機能設定</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Software</source>
|
||||
<translation>ソフトウェア</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Developer</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>sunnypilot</source>
|
||||
<translation>sunnypilot</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Setup</name>
|
||||
<message>
|
||||
|
||||
@@ -495,6 +495,17 @@
|
||||
<translation>활성화</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ParamControlSP</name>
|
||||
<message>
|
||||
<source>Cancel</source>
|
||||
<translation>취소</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Enable</source>
|
||||
<translation>활성화</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>PrimeAdWidget</name>
|
||||
<message>
|
||||
@@ -642,6 +653,37 @@ This may take up to a minute.</source>
|
||||
<translation>개발자</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>SettingsWindowSP</name>
|
||||
<message>
|
||||
<source>×</source>
|
||||
<translation>×</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Device</source>
|
||||
<translation>장치</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Network</source>
|
||||
<translation>네트워크</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Toggles</source>
|
||||
<translation>토글</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Software</source>
|
||||
<translation>소프트웨어</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Developer</source>
|
||||
<translation>개발자</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>sunnypilot</source>
|
||||
<translation>sunnypilot</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Setup</name>
|
||||
<message>
|
||||
|
||||
@@ -496,6 +496,17 @@
|
||||
<translation>Ativar</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ParamControlSP</name>
|
||||
<message>
|
||||
<source>Cancel</source>
|
||||
<translation>Cancelar</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Enable</source>
|
||||
<translation>Ativar</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>PrimeAdWidget</name>
|
||||
<message>
|
||||
@@ -646,6 +657,37 @@ Isso pode levar até um minuto.</translation>
|
||||
<translation>Desenvdor</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>SettingsWindowSP</name>
|
||||
<message>
|
||||
<source>×</source>
|
||||
<translation>×</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Device</source>
|
||||
<translation>Dispositivo</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Network</source>
|
||||
<translation>Rede</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Toggles</source>
|
||||
<translation>Ajustes</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Software</source>
|
||||
<translation>Software</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Developer</source>
|
||||
<translation>Desenvdor</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>sunnypilot</source>
|
||||
<translation>sunnypilot</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Setup</name>
|
||||
<message>
|
||||
|
||||
@@ -495,6 +495,17 @@
|
||||
<translation>ยกเลิก</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ParamControlSP</name>
|
||||
<message>
|
||||
<source>Enable</source>
|
||||
<translation>เปิดใช้งาน</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Cancel</source>
|
||||
<translation>ยกเลิก</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>PrimeAdWidget</name>
|
||||
<message>
|
||||
@@ -642,6 +653,37 @@ This may take up to a minute.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>SettingsWindowSP</name>
|
||||
<message>
|
||||
<source>×</source>
|
||||
<translation>×</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Device</source>
|
||||
<translation>อุปกรณ์</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Network</source>
|
||||
<translation>เครือข่าย</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Toggles</source>
|
||||
<translation>ตัวเลือก</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Software</source>
|
||||
<translation>ซอฟต์แวร์</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Developer</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>sunnypilot</source>
|
||||
<translation>sunnypilot</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Setup</name>
|
||||
<message>
|
||||
|
||||
@@ -494,6 +494,17 @@
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ParamControlSP</name>
|
||||
<message>
|
||||
<source>Enable</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Cancel</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>PrimeAdWidget</name>
|
||||
<message>
|
||||
@@ -640,6 +651,37 @@ This may take up to a minute.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>SettingsWindowSP</name>
|
||||
<message>
|
||||
<source>×</source>
|
||||
<translation>x</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Device</source>
|
||||
<translation>Cihaz</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Network</source>
|
||||
<translation>Ağ</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Toggles</source>
|
||||
<translation>Değiştirme</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Software</source>
|
||||
<translation>Yazılım</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Developer</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>sunnypilot</source>
|
||||
<translation>sunnypilot</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Setup</name>
|
||||
<message>
|
||||
|
||||
@@ -495,6 +495,17 @@
|
||||
<translation>启用</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ParamControlSP</name>
|
||||
<message>
|
||||
<source>Cancel</source>
|
||||
<translation>取消</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Enable</source>
|
||||
<translation>启用</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>PrimeAdWidget</name>
|
||||
<message>
|
||||
@@ -642,6 +653,37 @@ This may take up to a minute.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>SettingsWindowSP</name>
|
||||
<message>
|
||||
<source>×</source>
|
||||
<translation>×</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Device</source>
|
||||
<translation>设备</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Network</source>
|
||||
<translation>网络</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Toggles</source>
|
||||
<translation>设定</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Software</source>
|
||||
<translation>软件</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Developer</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>sunnypilot</source>
|
||||
<translation>sunnypilot</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Setup</name>
|
||||
<message>
|
||||
|
||||
@@ -495,6 +495,17 @@
|
||||
<translation>啟用</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ParamControlSP</name>
|
||||
<message>
|
||||
<source>Cancel</source>
|
||||
<translation>取消</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Enable</source>
|
||||
<translation>啟用</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>PrimeAdWidget</name>
|
||||
<message>
|
||||
@@ -642,6 +653,37 @@ This may take up to a minute.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>SettingsWindowSP</name>
|
||||
<message>
|
||||
<source>×</source>
|
||||
<translation>×</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Device</source>
|
||||
<translation>裝置</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Network</source>
|
||||
<translation>網路</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Toggles</source>
|
||||
<translation>設定</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Software</source>
|
||||
<translation>軟體</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Developer</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>sunnypilot</source>
|
||||
<translation>sunnypilot</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Setup</name>
|
||||
<message>
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
moc_*
|
||||
*.moc
|
||||
@@ -1,21 +0,0 @@
|
||||
widgets_src = [
|
||||
"../../sunnypilot/selfdrive/ui/ui.cc",
|
||||
"../../sunnypilot/selfdrive/ui/qt/window.cc",
|
||||
"../../sunnypilot/selfdrive/ui/qt/widgets/controls.cc",
|
||||
"../../sunnypilot/selfdrive/ui/qt/widgets/drive_stats.cc",
|
||||
"../../sunnypilot/selfdrive/ui/qt/widgets/scrollview.cc",
|
||||
"../../sunnypilot/selfdrive/ui/qt/widgets/toggle.cc",
|
||||
]
|
||||
|
||||
qt_src = [
|
||||
"../../sunnypilot/selfdrive/ui/qt/home.cc",
|
||||
"../../sunnypilot/selfdrive/ui/qt/sidebar.cc",
|
||||
"../../sunnypilot/selfdrive/ui/qt/offroad/settings/onboarding.cc",
|
||||
"../../sunnypilot/selfdrive/ui/qt/offroad/settings/settings.cc",
|
||||
"../../sunnypilot/selfdrive/ui/qt/onroad/onroad_home.cc",
|
||||
]
|
||||
|
||||
sp_widgets_src = widgets_src
|
||||
sp_qt_src = qt_src
|
||||
|
||||
Export('sp_widgets_src', 'sp_qt_src')
|
||||
@@ -1,102 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2021-, Haibin Wen, sunnypilot, and a number of other contributors.
|
||||
*
|
||||
* This file is part of sunnypilot and is licensed under the MIT License.
|
||||
* See the LICENSE.md file in the root directory for more details.
|
||||
*/
|
||||
|
||||
#include "../../sunnypilot/selfdrive/ui/qt/offroad/settings/onboarding.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <QScrollBar>
|
||||
#include <common/swaglog.h>
|
||||
|
||||
#include "common/util.h"
|
||||
#include "common/params.h"
|
||||
#include "selfdrive/ui/qt/util.h"
|
||||
#include "selfdrive/ui/qt/widgets/input.h"
|
||||
#include "selfdrive/ui/qt/widgets/scrollview.h"
|
||||
|
||||
void TermsPageSP::showEvent(QShowEvent *event) {
|
||||
// late init, building QML widget takes 200ms
|
||||
if (layout()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QVBoxLayout *main_layout = new QVBoxLayout(this);
|
||||
main_layout->setContentsMargins(45, 35, 45, 45);
|
||||
main_layout->setSpacing(0);
|
||||
|
||||
QLabel *title = new QLabel(tr("Terms & Conditions"));
|
||||
title->setStyleSheet("font-size: 90px; font-weight: 600;");
|
||||
main_layout->addWidget(title);
|
||||
|
||||
QLabel *text = new QLabel(this);
|
||||
text->setTextFormat(Qt::RichText);
|
||||
text->setWordWrap(true);
|
||||
std::string tc_text = sunnypilot_tc ? "../assets/offroad/sp_tc.html" : "../assets/offroad/tc.html";
|
||||
text->setText(QString::fromStdString(util::read_file(tc_text)));
|
||||
text->setStyleSheet("font-size:50px; font-weight: 200; color: #C9C9C9; background-color:#1B1B1B; padding:50px 50px;");
|
||||
ScrollView *scroll = new ScrollView(text, this);
|
||||
|
||||
main_layout->addSpacing(30);
|
||||
main_layout->addWidget(scroll);
|
||||
main_layout->addSpacing(50);
|
||||
|
||||
QHBoxLayout *buttons = new QHBoxLayout;
|
||||
buttons->setMargin(0);
|
||||
buttons->setSpacing(45);
|
||||
main_layout->addLayout(buttons);
|
||||
|
||||
QPushButton *decline_btn = new QPushButton(tr("Decline"));
|
||||
buttons->addWidget(decline_btn);
|
||||
QObject::connect(decline_btn, &QPushButton::clicked, this, &TermsPage::declinedTerms);
|
||||
|
||||
accept_btn = new QPushButton(tr("Scroll to accept"));
|
||||
accept_btn->setEnabled(false);
|
||||
accept_btn->setStyleSheet(R"(
|
||||
QPushButton {
|
||||
background-color: #465BEA;
|
||||
}
|
||||
QPushButton:pressed {
|
||||
background-color: #3049F4;
|
||||
}
|
||||
QPushButton:disabled {
|
||||
background-color: #4F4F4F;
|
||||
}
|
||||
)");
|
||||
buttons->addWidget(accept_btn);
|
||||
QObject::connect(accept_btn, &QPushButton::clicked, this, &TermsPage::acceptedTerms);
|
||||
QScrollBar *scroll_bar = scroll->verticalScrollBar();
|
||||
connect(scroll_bar, &QScrollBar::valueChanged, this, [this, scroll_bar](int value) {
|
||||
if (value == scroll_bar->maximum()) {
|
||||
enableAccept();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void OnboardingWindowSP::updateActiveScreen() {
|
||||
if (accepted_terms && training_done && !accepted_terms_sp) {
|
||||
setCurrentIndex(3);
|
||||
} else {
|
||||
OnboardingWindow::updateActiveScreen();
|
||||
}
|
||||
}
|
||||
|
||||
OnboardingWindowSP::OnboardingWindowSP(QWidget *parent) : OnboardingWindow(parent) {
|
||||
std::string current_terms_version_sp = params.get("TermsVersionSunnypilot");
|
||||
accepted_terms_sp = params.get("HasAcceptedTermsSP") == current_terms_version_sp;
|
||||
LOGD("accepted_terms_sp: %s", params.get("HasAcceptedTermsSP").c_str());
|
||||
|
||||
auto *terms_sp = new TermsPageSP(true, parent);
|
||||
addWidget(terms_sp); // index = 3
|
||||
connect(terms_sp, &TermsPageSP::acceptedTerms, [=]() {
|
||||
params.put("HasAcceptedTermsSP", current_terms_version_sp);
|
||||
accepted_terms_sp = true;
|
||||
updateActiveScreen();
|
||||
});
|
||||
connect(terms_sp, &TermsPageSP::declinedTerms, [=]() { setCurrentIndex(2); });
|
||||
|
||||
OnboardingWindowSP::updateActiveScreen();
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2021-, Haibin Wen, sunnypilot, and a number of other contributors.
|
||||
*
|
||||
* This file is part of sunnypilot and is licensed under the MIT License.
|
||||
* See the LICENSE.md file in the root directory for more details.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "selfdrive/ui/qt/offroad/onboarding.h"
|
||||
|
||||
#include "selfdrive/ui/qt/qt_window.h"
|
||||
|
||||
class TermsPageSP : public TermsPage {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TermsPageSP(bool sunnypilot = false, QWidget *parent = 0) : TermsPage(parent), sunnypilot_tc(sunnypilot) {}
|
||||
|
||||
private:
|
||||
bool sunnypilot_tc = false;
|
||||
void showEvent(QShowEvent *event) override;
|
||||
};
|
||||
|
||||
class OnboardingWindowSP : public OnboardingWindow {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit OnboardingWindowSP(QWidget *parent = 0);
|
||||
inline bool completed() const override { return accepted_terms && accepted_terms_sp && training_done; }
|
||||
|
||||
private:
|
||||
bool accepted_terms_sp = false;
|
||||
void updateActiveScreen() override;
|
||||
};
|
||||
@@ -1,103 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2021-, Haibin Wen, sunnypilot, and a number of other contributors.
|
||||
*
|
||||
* This file is part of sunnypilot and is licensed under the MIT License.
|
||||
* See the LICENSE.md file in the root directory for more details.
|
||||
*/
|
||||
|
||||
#include "../../sunnypilot/selfdrive/ui/qt/widgets/drive_stats.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QGridLayout>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "common/params.h"
|
||||
#include "selfdrive/ui/qt/request_repeater.h"
|
||||
#include "selfdrive/ui/qt/util.h"
|
||||
|
||||
static QLabel* newLabel(const QString& text, const QString &type) {
|
||||
QLabel* label = new QLabel(text);
|
||||
label->setProperty("type", type);
|
||||
return label;
|
||||
}
|
||||
|
||||
DriveStats::DriveStats(QWidget* parent) : QFrame(parent) {
|
||||
metric_ = Params().getBool("IsMetric");
|
||||
|
||||
QVBoxLayout* main_layout = new QVBoxLayout(this);
|
||||
main_layout->setContentsMargins(50, 50, 50, 60);
|
||||
|
||||
auto add_stats_layouts = [=](const QString &title, StatsLabels& labels) {
|
||||
QGridLayout* grid_layout = new QGridLayout;
|
||||
grid_layout->setVerticalSpacing(10);
|
||||
grid_layout->setContentsMargins(0, 10, 0, 10);
|
||||
|
||||
int row = 0;
|
||||
grid_layout->addWidget(newLabel(title, "title"), row++, 0, 1, 3);
|
||||
grid_layout->addItem(new QSpacerItem(0, 50), row++, 0, 1, 1);
|
||||
|
||||
grid_layout->addWidget(labels.routes = newLabel("0", "number"), row, 0, Qt::AlignLeft);
|
||||
grid_layout->addWidget(labels.distance = newLabel("0", "number"), row, 1, Qt::AlignLeft);
|
||||
grid_layout->addWidget(labels.hours = newLabel("0", "number"), row, 2, Qt::AlignLeft);
|
||||
|
||||
grid_layout->addWidget(newLabel((tr("Drives")), "unit"), row + 1, 0, Qt::AlignLeft);
|
||||
grid_layout->addWidget(labels.distance_unit = newLabel(getDistanceUnit(), "unit"), row + 1, 1, Qt::AlignLeft);
|
||||
grid_layout->addWidget(newLabel(tr("Hours"), "unit"), row + 1, 2, Qt::AlignLeft);
|
||||
|
||||
main_layout->addLayout(grid_layout);
|
||||
};
|
||||
|
||||
add_stats_layouts(tr("ALL TIME"), all_);
|
||||
main_layout->addStretch();
|
||||
add_stats_layouts(tr("PAST WEEK"), week_);
|
||||
|
||||
if (auto dongleId = getDongleId()) {
|
||||
QString url = CommaApi::BASE_URL + "/v1.1/devices/" + *dongleId + "/stats";
|
||||
RequestRepeater* repeater = new RequestRepeater(this, url, "ApiCache_DriveStats", 30);
|
||||
QObject::connect(repeater, &RequestRepeater::requestDone, this, &DriveStats::parseResponse);
|
||||
}
|
||||
|
||||
setStyleSheet(R"(
|
||||
DriveStats {
|
||||
background-color: #333333;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
QLabel[type="title"] { font-size: 51px; font-weight: 500; }
|
||||
QLabel[type="number"] { font-size: 78px; font-weight: 500; }
|
||||
QLabel[type="unit"] { font-size: 51px; font-weight: 300; color: #A0A0A0; }
|
||||
)");
|
||||
}
|
||||
|
||||
void DriveStats::updateStats() {
|
||||
auto update = [=](const QJsonObject& obj, StatsLabels& labels) {
|
||||
labels.routes->setText(QString::number((int)obj["routes"].toDouble()));
|
||||
labels.distance->setText(QString::number(int(obj["distance"].toDouble() * (metric_ ? MILE_TO_KM : 1))));
|
||||
labels.distance_unit->setText(getDistanceUnit());
|
||||
labels.hours->setText(QString::number((int)(obj["minutes"].toDouble() / 60)));
|
||||
};
|
||||
|
||||
QJsonObject json = stats_.object();
|
||||
update(json["all"].toObject(), all_);
|
||||
update(json["week"].toObject(), week_);
|
||||
}
|
||||
|
||||
void DriveStats::parseResponse(const QString& response, bool success) {
|
||||
if (!success) return;
|
||||
|
||||
QJsonDocument doc = QJsonDocument::fromJson(response.trimmed().toUtf8());
|
||||
if (doc.isNull()) {
|
||||
qDebug() << "JSON Parse failed on getting past drives statistics";
|
||||
return;
|
||||
}
|
||||
stats_ = doc;
|
||||
updateStats();
|
||||
}
|
||||
|
||||
void DriveStats::showEvent(QShowEvent* event) {
|
||||
bool metric = Params().getBool("IsMetric");
|
||||
if (metric_ != metric) {
|
||||
metric_ = metric;
|
||||
updateStats();
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2021-, Haibin Wen, sunnypilot, and a number of other contributors.
|
||||
*
|
||||
* This file is part of sunnypilot and is licensed under the MIT License.
|
||||
* See the LICENSE.md file in the root directory for more details.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <QLabel>
|
||||
|
||||
class DriveStats : public QFrame {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DriveStats(QWidget* parent = 0);
|
||||
|
||||
private:
|
||||
void showEvent(QShowEvent *event) override;
|
||||
void updateStats();
|
||||
inline QString getDistanceUnit() const { return metric_ ? tr("KM") : tr("Miles"); }
|
||||
|
||||
bool metric_;
|
||||
QJsonDocument stats_;
|
||||
struct StatsLabels {
|
||||
QLabel *routes, *distance, *distance_unit, *hours;
|
||||
} all_, week_;
|
||||
|
||||
private slots:
|
||||
void parseResponse(const QString &response, bool success);
|
||||
};
|
||||
@@ -1,37 +0,0 @@
|
||||
/**
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright (c) 2021-, Haibin Wen, sunnypilot, and a number of other contributors.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* Last updated: July 29, 2024
|
||||
*/
|
||||
|
||||
#include "../../sunnypilot/selfdrive/ui/qt/widgets/scrollview.h"
|
||||
|
||||
#include <QScrollBar>
|
||||
|
||||
void ScrollViewSP::setLastScrollPosition() {
|
||||
lastScrollPosition = verticalScrollBar()->value();
|
||||
}
|
||||
|
||||
void ScrollViewSP::restoreScrollPosition() {
|
||||
verticalScrollBar()->setValue(lastScrollPosition);
|
||||
}
|
||||
Reference in New Issue
Block a user