wip
This commit is contained in:
110
selfdrive/ui/qt/text.cc
Executable file
110
selfdrive/ui/qt/text.cc
Executable file
@@ -0,0 +1,110 @@
|
||||
#include <QApplication>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QScrollBar>
|
||||
#include <QVBoxLayout>
|
||||
#include <QWidget>
|
||||
#include <QProcess>
|
||||
|
||||
#include "system/hardware/hw.h"
|
||||
#include "selfdrive/ui/qt/util.h"
|
||||
#include "selfdrive/ui/qt/qt_window.h"
|
||||
#include "selfdrive/ui/qt/widgets/scrollview.h"
|
||||
#include "selfdrive/ui/qt/network/wifi_manager.h"
|
||||
|
||||
// wifi connection screen
|
||||
// wifi = new QWidget;
|
||||
// {
|
||||
// QVBoxLayout *layout = new QVBoxLayout(wifi);
|
||||
// layout->setContentsMargins(100, 100, 100, 100);
|
||||
|
||||
// Networking *networking = new Networking(this, false);
|
||||
// networking->setStyleSheet("Networking { background-color: #292929; border-radius: 13px; }");
|
||||
// layout->addWidget(networking, 1);
|
||||
|
||||
// QPushButton *back = new QPushButton(tr("Back"));
|
||||
// back->setObjectName("navBtn");
|
||||
// back->setStyleSheet("padding-left: 60px; padding-right: 60px;");
|
||||
// QObject::connect(back, &QPushButton::clicked, [=]() {
|
||||
// setCurrentWidget(prompt);
|
||||
// });
|
||||
// layout->addWidget(back, 0, Qt::AlignLeft);
|
||||
// }
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
initApp(argc, argv);
|
||||
QApplication a(argc, argv);
|
||||
QWidget window;
|
||||
setMainWindow(&window);
|
||||
|
||||
QGridLayout *main_layout = new QGridLayout(&window);
|
||||
main_layout->setMargin(50);
|
||||
|
||||
QLabel *label = new QLabel(argv[1]);
|
||||
label->setWordWrap(true);
|
||||
label->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);
|
||||
ScrollView *scroll = new ScrollView(label);
|
||||
scroll->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||
main_layout->addWidget(scroll, 0, 0, Qt::AlignTop);
|
||||
|
||||
// Scroll to the bottom
|
||||
QObject::connect(scroll->verticalScrollBar(), &QAbstractSlider::rangeChanged, [=]() {
|
||||
scroll->verticalScrollBar()->setValue(scroll->verticalScrollBar()->maximum());
|
||||
});
|
||||
|
||||
|
||||
QPushButton *btnupdate = new QPushButton();
|
||||
#ifdef __aarch64__
|
||||
btnupdate->setText(QObject::tr("Update"));
|
||||
QObject::connect(btnupdate, &QPushButton::clicked, [=]() {
|
||||
QProcess process;
|
||||
label->setText("Attempting to connect to wifi");
|
||||
// TODO: make this work, then copy the compiled binary into git
|
||||
// wifi = new WifiManager(null);
|
||||
// connect(wifi, &WifiManager::refreshSignal, [=]() {
|
||||
// label->setText("Performing update");
|
||||
// process.setWorkingDirectory("/data/openpilot/");
|
||||
// process.start("/bin/bash", QStringList{"-c", "update.sh"});
|
||||
// process.waitForFinished();
|
||||
// label->setText("Rebooting");
|
||||
// Hardware::reboot();
|
||||
// });
|
||||
// wifi->start();
|
||||
});
|
||||
#else
|
||||
btnupdate->setText(QObject::tr("Exit"));
|
||||
QObject::connect(btnupdate, &QPushButton::clicked, &a, &QApplication::quit);
|
||||
#endif
|
||||
main_layout->addWidget(btnupdate, 0, 0, Qt::AlignLeft | Qt::AlignBottom);
|
||||
|
||||
QPushButton *btn = new QPushButton();
|
||||
#ifdef __aarch64__
|
||||
btn->setText(QObject::tr("Reboot"));
|
||||
QObject::connect(btn, &QPushButton::clicked, [=]() {
|
||||
Hardware::reboot(); // bbot this is the dreaded crash reboot button
|
||||
});
|
||||
#else
|
||||
btn->setText(QObject::tr("Exit"));
|
||||
QObject::connect(btn, &QPushButton::clicked, &a, &QApplication::quit);
|
||||
#endif
|
||||
main_layout->addWidget(btn, 0, 0, Qt::AlignRight | Qt::AlignBottom);
|
||||
|
||||
window.setStyleSheet(R"(
|
||||
* {
|
||||
outline: none;
|
||||
color: white;
|
||||
background-color: black;
|
||||
font-size: 60px;
|
||||
}
|
||||
QPushButton {
|
||||
padding: 50px;
|
||||
padding-right: 100px;
|
||||
padding-left: 100px;
|
||||
border: 2px solid white;
|
||||
border-radius: 20px;
|
||||
margin-right: 40px;
|
||||
}
|
||||
)");
|
||||
|
||||
return a.exec();
|
||||
}
|
||||
Reference in New Issue
Block a user