From 6a9afd8460d31eb1a265dbee28bbfda64a6fdc97 Mon Sep 17 00:00:00 2001 From: iejMac <61431446+iejMac@users.noreply.github.com> Date: Sat, 20 Mar 2021 21:26:05 -0700 Subject: [PATCH] terms fixups (#20392) * accept * accept at end + env variables * better * testing some settings * bottom margin * nothing * doesnt work * don't need anymore * clean up * fix * unused * more prime widget cleanup * Revert "more prime widget cleanup" This reverts commit d44651ee8c501be61099dc4cd40fa0467bc315a3. Co-authored-by: Comma Device Co-authored-by: Adeeb Shihadeh --- launch_chffrplus.sh | 4 +++ selfdrive/ui/qt/offroad/onboarding.cc | 37 +++++++++++++------------- selfdrive/ui/qt/offroad/onboarding.hpp | 3 +++ 3 files changed, 26 insertions(+), 18 deletions(-) diff --git a/launch_chffrplus.sh b/launch_chffrplus.sh index 8a91bb4e5b..cc6e8f4973 100755 --- a/launch_chffrplus.sh +++ b/launch_chffrplus.sh @@ -9,6 +9,10 @@ source "$BASEDIR/launch_env.sh" DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" function two_init { + + export QT_QPA_EGLFS_PHYSICAL_WIDTH=151 + export QT_QPA_EGLFS_PHYSICAL_HEIGHT=74 + # Wifi scan wpa_cli IFNAME=wlan0 SCAN diff --git a/selfdrive/ui/qt/offroad/onboarding.cc b/selfdrive/ui/qt/offroad/onboarding.cc index c3c89131c5..1f95eb0db6 100644 --- a/selfdrive/ui/qt/offroad/onboarding.cc +++ b/selfdrive/ui/qt/offroad/onboarding.cc @@ -7,29 +7,34 @@ #include #include #include + #include "common/params.h" #include "onboarding.hpp" #include "home.hpp" #include "util.h" + void TrainingGuide::mouseReleaseEvent(QMouseEvent *e) { int leftOffset = (geometry().width()-1620)/2; int mousex = e->x()-leftOffset; 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) { @@ -51,7 +56,7 @@ void TrainingGuide::paintEvent(QPaintEvent *event) { QWidget* OnboardingWindow::terms_screen() { QVBoxLayout *main_layout = new QVBoxLayout; - main_layout->setContentsMargins(40, 20, 40, 0); + main_layout->setContentsMargins(40, 20, 40, 20); QString terms_html = QString::fromStdString(util::read_file("../assets/offroad/tc.html")); terms_text = new QTextEdit(); @@ -95,8 +100,12 @@ QWidget* OnboardingWindow::terms_screen() { QScroller::grabGesture(terms_text, QScroller::TouchGesture); terms_text->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); #endif + QObject::connect(sb, &QScrollBar::valueChanged, [sb, accept_btn]() { - accept_btn->setEnabled(accept_btn->isEnabled() || (sb->value() == sb->maximum())); + if (sb->value() == sb->maximum()){ + accept_btn->setText("Accept"); + accept_btn->setEnabled(true); + } }); QWidget *widget = new QWidget; @@ -116,10 +125,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) { @@ -130,16 +138,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; - - // Don't initialize widgets unless neccesary. - if (accepted_terms && training_done) { - return; - } addWidget(terms_screen()); diff --git a/selfdrive/ui/qt/offroad/onboarding.hpp b/selfdrive/ui/qt/offroad/onboarding.hpp index 55a1ab9514..e307bb63a5 100644 --- a/selfdrive/ui/qt/offroad/onboarding.hpp +++ b/selfdrive/ui/qt/offroad/onboarding.hpp @@ -6,6 +6,8 @@ #include #include +#include "selfdrive/common/params.h" + class TrainingGuide : public QFrame { Q_OBJECT @@ -35,6 +37,7 @@ public: explicit OnboardingWindow(QWidget *parent = 0); private: + Params params; std::string current_terms_version; std::string current_training_version;