UI: add decline page for the Terms and Conditions (#20919)

* add decline page

* change action + keep the same layout
old-commit-hash: d44ee69b24
commatwo_master
Maxime Desroches 4 years ago committed by GitHub
parent 47b1b6042b
commit 778f54057b
  1. 63
      selfdrive/ui/qt/offroad/onboarding.cc
  2. 19
      selfdrive/ui/qt/offroad/onboarding.h

@ -10,6 +10,8 @@
#include "selfdrive/common/params.h" #include "selfdrive/common/params.h"
#include "selfdrive/common/util.h" #include "selfdrive/common/util.h"
#include "selfdrive/ui/qt/home.h" #include "selfdrive/ui/qt/home.h"
#include "selfdrive/ui/qt/widgets/input.h"
void TrainingGuide::mouseReleaseEvent(QMouseEvent *e) { void TrainingGuide::mouseReleaseEvent(QMouseEvent *e) {
QPoint touch = QPoint(e->x(), e->y()) - imageCorner; QPoint touch = QPoint(e->x(), e->y()) - imageCorner;
@ -77,11 +79,13 @@ void TermsPage::showEvent(QShowEvent *event) {
QObject *obj = (QObject*)text->rootObject(); QObject *obj = (QObject*)text->rootObject();
QObject::connect(obj, SIGNAL(qmlSignal()), SLOT(enableAccept())); QObject::connect(obj, SIGNAL(qmlSignal()), SLOT(enableAccept()));
// TODO: add decline page
QHBoxLayout* buttons = new QHBoxLayout; QHBoxLayout* buttons = new QHBoxLayout;
main_layout->addLayout(buttons); main_layout->addLayout(buttons);
buttons->addWidget(new QPushButton("Decline")); decline_btn = new QPushButton("Decline");
buttons->addWidget(decline_btn);
QObject::connect(decline_btn, &QPushButton::released, this, &TermsPage::declinedTerms);
buttons->addSpacing(50); buttons->addSpacing(50);
accept_btn = new QPushButton("Scroll to accept"); accept_btn = new QPushButton("Scroll to accept");
@ -106,6 +110,50 @@ void TermsPage::enableAccept(){
return; return;
} }
void DeclinePage::showEvent(QShowEvent *event) {
if (layout()) {
return;
}
QVBoxLayout *main_layout = new QVBoxLayout;
main_layout->setMargin(40);
main_layout->setSpacing(40);
QLabel *text = new QLabel(this);
text->setText("You must accept the Terms and Conditions in order to use openpilot!");
text->setStyleSheet(R"(font-size: 50px;)");
main_layout->addWidget(text, 0, Qt::AlignCenter);
QHBoxLayout* buttons = new QHBoxLayout;
main_layout->addLayout(buttons);
back_btn = new QPushButton("Back");
buttons->addWidget(back_btn);
buttons->addSpacing(50);
QObject::connect(back_btn, &QPushButton::released, this, &DeclinePage::getBack);
uninstall_btn = new QPushButton("Decline, uninstall openpilot");
uninstall_btn->setStyleSheet("background-color: #E22C2C;");
buttons->addWidget(uninstall_btn);
QObject::connect(uninstall_btn, &QPushButton::released, [=](){
if (ConfirmationDialog::confirm("Are you sure you want to uninstall?", this)) {
Params().putBool("DoUninstall", true);
}
});
setLayout(main_layout);
setStyleSheet(R"(
QPushButton {
padding: 50px;
font-size: 50px;
border-radius: 10px;
background-color: #292929;
}
)");
}
void OnboardingWindow::updateActiveScreen() { void OnboardingWindow::updateActiveScreen() {
updateOnboardingStatus(); updateOnboardingStatus();
@ -138,6 +186,17 @@ OnboardingWindow::OnboardingWindow(QWidget *parent) : QStackedWidget(parent) {
}); });
addWidget(tr); addWidget(tr);
DeclinePage* declinePage = new DeclinePage(this);
addWidget(declinePage);
connect(terms, &TermsPage::declinedTerms, [=](){
setCurrentIndex(2);
});
connect(declinePage, &DeclinePage::getBack, [=](){
updateActiveScreen();
});
setStyleSheet(R"( setStyleSheet(R"(
* { * {
color: white; color: white;

@ -64,12 +64,31 @@ protected:
private: private:
QPushButton *accept_btn; QPushButton *accept_btn;
QPushButton *decline_btn;
public slots: public slots:
void enableAccept(); void enableAccept();
signals: signals:
void acceptedTerms(); void acceptedTerms();
void declinedTerms();
};
class DeclinePage : public QFrame {
Q_OBJECT
public:
explicit DeclinePage(QWidget *parent = 0) : QFrame(parent) {};
protected:
void showEvent(QShowEvent *event) override;
private:
QPushButton *back_btn;
QPushButton *uninstall_btn;
signals:
void getBack();
}; };
class OnboardingWindow : public QStackedWidget { class OnboardingWindow : public QStackedWidget {

Loading…
Cancel
Save