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 <device@comma.ai>
Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
albatross
iejMac 2021-03-20 21:26:05 -07:00 committed by GitHub
parent 0b16ed9dc9
commit 6a9afd8460
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 18 deletions

View File

@ -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

View File

@ -7,29 +7,34 @@
#include <QVBoxLayout>
#include <QDesktopWidget>
#include <QPainter>
#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());

View File

@ -6,6 +6,8 @@
#include <QMouseEvent>
#include <QImage>
#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;