openpilot/selfdrive/ui/qt/text.cc

52 lines
1.1 KiB
C++
Raw Normal View History

#include <QLabel>
#include <QWidget>
#include <QPushButton>
#include <QVBoxLayout>
#include <QApplication>
#include "qt_window.hpp"
#include "selfdrive/hardware/hw.h"
int main(int argc, char *argv[]) {
QApplication a(argc, argv);
2020-11-25 00:30:36 -07:00
QWidget window;
setMainWindow(&window);
2020-11-25 00:30:36 -07:00
QVBoxLayout *layout = new QVBoxLayout();
2020-11-30 17:55:56 -07:00
layout->setContentsMargins(125, 125, 125, 125);
2020-11-25 00:30:36 -07:00
// TODO: make this scroll
layout->addWidget(new QLabel(argv[1]), 0, Qt::AlignTop);
QPushButton *btn = new QPushButton();
#ifdef __aarch64__
btn->setText("Reboot");
QObject::connect(btn, &QPushButton::released, [=]() {
Hardware::reboot();
});
#else
btn->setText("Exit");
QObject::connect(btn, SIGNAL(released()), &a, SLOT(quit()));
#endif
2020-11-25 00:30:36 -07:00
layout->addWidget(btn, 0, Qt::AlignRight);
2020-11-25 00:30:36 -07:00
window.setLayout(layout);
window.setStyleSheet(R"(
* {
outline: none;
color: white;
2020-11-25 00:30:36 -07:00
background-color: black;
font-size: 60px;
}
QPushButton {
2020-11-25 00:30:36 -07:00
padding: 50px;
padding-right: 100px;
padding-left: 100px;
border: 2px solid white;
border-radius: 20px;
}
)");
return a.exec();
}