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

* add decline page

* change action + keep the same layout
pull/20977/head
Maxime Desroches 2021-05-20 09:59:56 -04:00 committed by GitHub
parent 7a8c7505d0
commit d44ee69b24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 80 additions and 2 deletions

View File

@ -10,6 +10,8 @@
#include "selfdrive/common/params.h"
#include "selfdrive/common/util.h"
#include "selfdrive/ui/qt/home.h"
#include "selfdrive/ui/qt/widgets/input.h"
void TrainingGuide::mouseReleaseEvent(QMouseEvent *e) {
QPoint touch = QPoint(e->x(), e->y()) - imageCorner;
@ -77,11 +79,13 @@ void TermsPage::showEvent(QShowEvent *event) {
QObject *obj = (QObject*)text->rootObject();
QObject::connect(obj, SIGNAL(qmlSignal()), SLOT(enableAccept()));
// TODO: add decline page
QHBoxLayout* buttons = new QHBoxLayout;
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);
accept_btn = new QPushButton("Scroll to accept");
@ -106,6 +110,50 @@ void TermsPage::enableAccept(){
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() {
updateOnboardingStatus();
@ -138,6 +186,17 @@ OnboardingWindow::OnboardingWindow(QWidget *parent) : QStackedWidget(parent) {
});
addWidget(tr);
DeclinePage* declinePage = new DeclinePage(this);
addWidget(declinePage);
connect(terms, &TermsPage::declinedTerms, [=](){
setCurrentIndex(2);
});
connect(declinePage, &DeclinePage::getBack, [=](){
updateActiveScreen();
});
setStyleSheet(R"(
* {
color: white;

View File

@ -64,12 +64,31 @@ protected:
private:
QPushButton *accept_btn;
QPushButton *decline_btn;
public slots:
void enableAccept();
signals:
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 {