Skip to content

Commit

Permalink
add small minimum time between taps to onboarding (#23212)
Browse files Browse the repository at this point in the history
Co-authored-by: Comma Device <device@comma.ai>
  • Loading branch information
adeebshihadeh and Comma Device authored Dec 14, 2021
1 parent f482354 commit df5b374
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions selfdrive/ui/qt/offroad/onboarding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ TrainingGuide::TrainingGuide(QWidget *parent) : QFrame(parent) {
}

void TrainingGuide::mouseReleaseEvent(QMouseEvent *e) {
if (click_timer.elapsed() < 250) {
return;
}
click_timer.restart();

if (boundingRect[currentIndex].contains(e->x(), e->y())) {
if (currentIndex == 9) {
const QRect yes = QRect(692, 842, 492, 148);
Expand All @@ -40,6 +45,7 @@ void TrainingGuide::showEvent(QShowEvent *event) {

currentIndex = 0;
image.load(img_path + "step0.png");
click_timer.start();
}

void TrainingGuide::paintEvent(QPaintEvent *event) {
Expand Down
2 changes: 2 additions & 0 deletions selfdrive/ui/qt/offroad/onboarding.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include <QElapsedTimer>
#include <QImage>
#include <QMouseEvent>
#include <QPushButton>
Expand Down Expand Up @@ -74,6 +75,7 @@ class TrainingGuide : public QFrame {

QString img_path;
QVector<QRect> boundingRect;
QElapsedTimer click_timer;

signals:
void completedTraining();
Expand Down

0 comments on commit df5b374

Please sign in to comment.