pull/20392/head
Comma Device 4 years ago
parent 63e17c91c1
commit 3e64b5d14c
  1. 33
      selfdrive/ui/qt/offroad/onboarding.cc
  2. 5
      selfdrive/ui/qt/offroad/onboarding.hpp

@ -7,6 +7,7 @@
#include <QVBoxLayout>
#include <QDesktopWidget>
#include <QPainter>
#include "common/params.h"
#include "onboarding.hpp"
#include "home.hpp"
@ -20,18 +21,21 @@ void TrainingGuide::mouseReleaseEvent(QMouseEvent *e) {
int mousey = e->y();
// Check for restart
if (currentIndex == (boundingBox.size() - 1) && 1050 <= mousex && mousex <= 1500 && 773 <= mousey && mousey <= 954) {
if (currentIndex == (boundingBox.size() - 1) && 1050 <= mousex && mousex <= 1500 &&
773 <= mousey && mousey <= 954) {
currentIndex = 0;
} else if (boundingBox[currentIndex][0] <= mousex && mousex <= boundingBox[currentIndex][1] && boundingBox[currentIndex][2] <= mousey && mousey <= boundingBox[currentIndex][3]) {
++currentIndex;
} else if (boundingBox[currentIndex][0] <= mousex && mousex <= boundingBox[currentIndex][1] &&
boundingBox[currentIndex][2] <= mousey && mousey <= boundingBox[currentIndex][3]) {
currentIndex += 1;
}
if (currentIndex >= boundingBox.size()) {
emit completedTraining();
return;
} else {
image.load("../assets/training/step" + QString::number(currentIndex) + ".jpg");
update();
}
image.load("../assets/training/step" + QString::number(currentIndex) + ".jpg");
repaint();
}
TrainingGuide::TrainingGuide(QWidget* parent) {
@ -79,16 +83,6 @@ QWidget* OnboardingWindow::terms_screen() {
// TODO: tune the scrolling
auto sb = terms_text->verticalScrollBar();
QScrollerProperties sp;
sp.setScrollMetric(QScrollerProperties::DragStartDistance, 0.001);
sp.setScrollMetric(QScrollerProperties::DecelerationFactor, 0.4);
sp.setScrollMetric(QScrollerProperties::DragVelocitySmoothingFactor, 0.5);
sp.setScrollMetric(QScrollerProperties::MaximumVelocity, 1.0);
scroller = QScroller::scroller(terms_text);
scroller->setScrollerProperties(sp);
#ifdef QCOM2
sb->setStyleSheet(R"(
QScrollBar {
@ -133,10 +127,9 @@ QWidget* OnboardingWindow::terms_screen() {
}
void OnboardingWindow::updateActiveScreen() {
Params params = Params();
bool accepted_terms = params.get("HasAcceptedTerms", false).compare(current_terms_version) == 0;
bool training_done = params.get("CompletedTrainingVersion", false).compare(current_training_version) == 0;
if (!accepted_terms) {
setCurrentIndex(0);
} else if (!training_done) {
@ -147,11 +140,9 @@ void OnboardingWindow::updateActiveScreen() {
}
OnboardingWindow::OnboardingWindow(QWidget *parent) : QStackedWidget(parent) {
Params params = Params();
params = Params();
current_terms_version = params.get("TermsVersion", false);
current_training_version = params.get("TrainingVersion", false);
bool accepted_terms = params.get("HasAcceptedTerms", false).compare(current_terms_version) == 0;
bool training_done = params.get("CompletedTrainingVersion", false).compare(current_training_version) == 0;
addWidget(terms_screen());

@ -1,12 +1,13 @@
#pragma once
#include <QWidget>
#include <QScroller>
#include <QStackedWidget>
#include <QTextEdit>
#include <QMouseEvent>
#include <QImage>
#include "selfdrive/common/params.h"
class TrainingGuide : public QFrame {
Q_OBJECT
@ -36,13 +37,13 @@ public:
explicit OnboardingWindow(QWidget *parent = 0);
private:
Params params;
std::string current_terms_version;
std::string current_training_version;
QTextEdit *terms_text;
QWidget *terms_screen();
QWidget *training_screen();
QScroller *scroller;
signals:
void onboardingDone();

Loading…
Cancel
Save