mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-06-21 22:12:05 +08:00
@@ -247,7 +247,7 @@ void WifiUI::refresh() {
|
||||
QPushButton *forgetBtn = new QPushButton("FORGET");
|
||||
forgetBtn->setObjectName("forgetBtn");
|
||||
QObject::connect(forgetBtn, &QPushButton::released, [=]() {
|
||||
if (ConfirmationDialog::confirm("Are you sure you want to forget " + QString::fromUtf8(network.ssid) + "?", this)) {
|
||||
if (ConfirmationDialog::confirm("Forget WiFi Network \"" + QString::fromUtf8(network.ssid) + "\"?", this)) {
|
||||
wifi->forgetConnection(network.ssid);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <QPushButton>
|
||||
|
||||
#include "selfdrive/ui/qt/util.h"
|
||||
#include "selfdrive/ui/qt/qt_window.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,
|
||||
QWidget *parent) : QDialogBase(parent) {
|
||||
setWindowFlags(Qt::Popup);
|
||||
main_layout = new QVBoxLayout(this);
|
||||
main_layout->setMargin(25);
|
||||
QFrame *container = new QFrame(this);
|
||||
QVBoxLayout *main_layout = new QVBoxLayout(container);
|
||||
main_layout->setContentsMargins(32, 120, 32, 32);
|
||||
|
||||
prompt = new QLabel(prompt_text, this);
|
||||
QLabel *prompt = new QLabel(prompt_text, this);
|
||||
prompt->setWordWrap(true);
|
||||
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);
|
||||
|
||||
// cancel + confirm buttons
|
||||
QHBoxLayout *btn_layout = new QHBoxLayout();
|
||||
btn_layout->setSpacing(20);
|
||||
btn_layout->addStretch(1);
|
||||
btn_layout->setSpacing(30);
|
||||
main_layout->addLayout(btn_layout);
|
||||
|
||||
if (cancel_text.length()) {
|
||||
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);
|
||||
}
|
||||
|
||||
if (confirm_text.length()) {
|
||||
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);
|
||||
}
|
||||
|
||||
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"(
|
||||
* {
|
||||
color: black;
|
||||
background-color: white;
|
||||
ConfirmationDialog {
|
||||
background-color: black;
|
||||
}
|
||||
QFrame {
|
||||
border-radius: 0;
|
||||
background-color: #ECECEC;
|
||||
}
|
||||
QPushButton {
|
||||
font-size: 40px;
|
||||
padding: 30px;
|
||||
padding-right: 45px;
|
||||
padding-left: 45px;
|
||||
border-radius: 7px;
|
||||
background-color: #44444400;
|
||||
height: 160;
|
||||
font-size: 55px;
|
||||
font-weight: 400;
|
||||
border-radius: 10px;
|
||||
color: white;
|
||||
background-color: #333333;
|
||||
}
|
||||
QPushButton:pressed {
|
||||
background-color: #444444;
|
||||
}
|
||||
)");
|
||||
}
|
||||
@@ -220,9 +230,6 @@ bool ConfirmationDialog::confirm(const QString &prompt_text, QWidget *parent) {
|
||||
}
|
||||
|
||||
int ConfirmationDialog::exec() {
|
||||
// TODO: make this work without fullscreen
|
||||
if (Hardware::TICI()) {
|
||||
setMainWindow(this);
|
||||
}
|
||||
setMainWindow(this);
|
||||
return QDialog::exec();
|
||||
}
|
||||
|
||||
@@ -59,10 +59,6 @@ public:
|
||||
static bool alert(const QString &prompt_text, QWidget *parent);
|
||||
static bool confirm(const QString &prompt_text, QWidget *parent);
|
||||
|
||||
private:
|
||||
QLabel *prompt;
|
||||
QVBoxLayout *main_layout;
|
||||
|
||||
public slots:
|
||||
int exec() override;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user