|
|
@ -2,6 +2,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
#include <QPushButton> |
|
|
|
#include <QPushButton> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "selfdrive/ui/qt/util.h" |
|
|
|
#include "selfdrive/ui/qt/qt_window.h" |
|
|
|
#include "selfdrive/ui/qt/qt_window.h" |
|
|
|
#include "selfdrive/hardware/hw.h" |
|
|
|
#include "selfdrive/hardware/hw.h" |
|
|
|
|
|
|
|
|
|
|
@ -164,47 +165,56 @@ void InputDialog::setMinLength(int length) { |
|
|
|
|
|
|
|
|
|
|
|
ConfirmationDialog::ConfirmationDialog(const QString &prompt_text, const QString &confirm_text, const QString &cancel_text, |
|
|
|
ConfirmationDialog::ConfirmationDialog(const QString &prompt_text, const QString &confirm_text, const QString &cancel_text, |
|
|
|
QWidget *parent) : QDialogBase(parent) { |
|
|
|
QWidget *parent) : QDialogBase(parent) { |
|
|
|
setWindowFlags(Qt::Popup); |
|
|
|
QFrame *container = new QFrame(this); |
|
|
|
main_layout = new QVBoxLayout(this); |
|
|
|
QVBoxLayout *main_layout = new QVBoxLayout(container); |
|
|
|
main_layout->setMargin(25); |
|
|
|
main_layout->setContentsMargins(32, 120, 32, 32); |
|
|
|
|
|
|
|
|
|
|
|
prompt = new QLabel(prompt_text, this); |
|
|
|
QLabel *prompt = new QLabel(prompt_text, this); |
|
|
|
prompt->setWordWrap(true); |
|
|
|
prompt->setWordWrap(true); |
|
|
|
prompt->setAlignment(Qt::AlignHCenter); |
|
|
|
prompt->setAlignment(Qt::AlignHCenter); |
|
|
|
prompt->setStyleSheet("font-size: 55px; font-weight: 400;"); |
|
|
|
prompt->setStyleSheet("font-size: 70px; font-weight: bold; color: black;"); |
|
|
|
main_layout->addWidget(prompt, 1, Qt::AlignTop | Qt::AlignHCenter); |
|
|
|
main_layout->addWidget(prompt, 1, Qt::AlignTop | Qt::AlignHCenter); |
|
|
|
|
|
|
|
|
|
|
|
// cancel + confirm buttons
|
|
|
|
// cancel + confirm buttons
|
|
|
|
QHBoxLayout *btn_layout = new QHBoxLayout(); |
|
|
|
QHBoxLayout *btn_layout = new QHBoxLayout(); |
|
|
|
btn_layout->setSpacing(20); |
|
|
|
btn_layout->setSpacing(30); |
|
|
|
btn_layout->addStretch(1); |
|
|
|
|
|
|
|
main_layout->addLayout(btn_layout); |
|
|
|
main_layout->addLayout(btn_layout); |
|
|
|
|
|
|
|
|
|
|
|
if (cancel_text.length()) { |
|
|
|
if (cancel_text.length()) { |
|
|
|
QPushButton* cancel_btn = new QPushButton(cancel_text); |
|
|
|
QPushButton* cancel_btn = new QPushButton(cancel_text); |
|
|
|
btn_layout->addWidget(cancel_btn, 0, Qt::AlignRight); |
|
|
|
btn_layout->addWidget(cancel_btn); |
|
|
|
QObject::connect(cancel_btn, &QPushButton::released, this, &ConfirmationDialog::reject); |
|
|
|
QObject::connect(cancel_btn, &QPushButton::released, this, &ConfirmationDialog::reject); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (confirm_text.length()) { |
|
|
|
if (confirm_text.length()) { |
|
|
|
QPushButton* confirm_btn = new QPushButton(confirm_text); |
|
|
|
QPushButton* confirm_btn = new QPushButton(confirm_text); |
|
|
|
btn_layout->addWidget(confirm_btn, 0, Qt::AlignRight); |
|
|
|
btn_layout->addWidget(confirm_btn); |
|
|
|
QObject::connect(confirm_btn, &QPushButton::released, this, &ConfirmationDialog::accept); |
|
|
|
QObject::connect(confirm_btn, &QPushButton::released, this, &ConfirmationDialog::accept); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
setFixedSize(900, 350); |
|
|
|
QVBoxLayout *outer_layout = new QVBoxLayout(this); |
|
|
|
|
|
|
|
outer_layout->setContentsMargins(210, 170, 210, 170); |
|
|
|
|
|
|
|
outer_layout->addWidget(container); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setWindowFlags(Qt::Popup); |
|
|
|
setStyleSheet(R"( |
|
|
|
setStyleSheet(R"( |
|
|
|
* { |
|
|
|
ConfirmationDialog { |
|
|
|
color: black; |
|
|
|
background-color: black; |
|
|
|
background-color: white; |
|
|
|
} |
|
|
|
|
|
|
|
QFrame { |
|
|
|
|
|
|
|
border-radius: 0; |
|
|
|
|
|
|
|
background-color: #ECECEC; |
|
|
|
} |
|
|
|
} |
|
|
|
QPushButton { |
|
|
|
QPushButton { |
|
|
|
font-size: 40px; |
|
|
|
height: 160; |
|
|
|
padding: 30px; |
|
|
|
font-size: 55px; |
|
|
|
padding-right: 45px; |
|
|
|
font-weight: 400; |
|
|
|
padding-left: 45px; |
|
|
|
border-radius: 10px; |
|
|
|
border-radius: 7px; |
|
|
|
color: white; |
|
|
|
background-color: #44444400; |
|
|
|
background-color: #333333; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
QPushButton:pressed { |
|
|
|
|
|
|
|
background-color: #444444; |
|
|
|
} |
|
|
|
} |
|
|
|
)"); |
|
|
|
)"); |
|
|
|
} |
|
|
|
} |
|
|
@ -220,9 +230,6 @@ bool ConfirmationDialog::confirm(const QString &prompt_text, QWidget *parent) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int ConfirmationDialog::exec() { |
|
|
|
int ConfirmationDialog::exec() { |
|
|
|
// TODO: make this work without fullscreen
|
|
|
|
|
|
|
|
if (Hardware::TICI()) { |
|
|
|
|
|
|
|
setMainWindow(this); |
|
|
|
setMainWindow(this); |
|
|
|
} |
|
|
|
|
|
|
|
return QDialog::exec(); |
|
|
|
return QDialog::exec(); |
|
|
|
} |
|
|
|
} |
|
|
|