2021-05-09 13:15:17 +08:00
|
|
|
#include <QApplication>
|
2020-11-06 12:05:24 -08:00
|
|
|
#include <QLabel>
|
|
|
|
|
#include <QPushButton>
|
2021-05-09 13:15:17 +08:00
|
|
|
#include <QScrollBar>
|
2020-11-06 12:05:24 -08:00
|
|
|
#include <QVBoxLayout>
|
2021-05-09 13:15:17 +08:00
|
|
|
#include <QWidget>
|
2020-11-06 12:05:24 -08:00
|
|
|
|
2022-06-11 16:38:24 -07:00
|
|
|
#include "system/hardware/hw.h"
|
2021-07-08 12:19:56 +08:00
|
|
|
#include "selfdrive/ui/qt/util.h"
|
2021-05-09 13:15:17 +08:00
|
|
|
#include "selfdrive/ui/qt/qt_window.h"
|
|
|
|
|
#include "selfdrive/ui/qt/widgets/scrollview.h"
|
2020-11-06 12:05:24 -08:00
|
|
|
|
|
|
|
|
int main(int argc, char *argv[]) {
|
2022-02-25 14:36:27 +01:00
|
|
|
initApp(argc, argv);
|
2020-11-06 12:05:24 -08:00
|
|
|
QApplication a(argc, argv);
|
2020-11-24 23:30:36 -08:00
|
|
|
QWidget window;
|
|
|
|
|
setMainWindow(&window);
|
2020-11-06 12:05:24 -08:00
|
|
|
|
2021-06-13 12:28:17 +08:00
|
|
|
QGridLayout *main_layout = new QGridLayout(&window);
|
|
|
|
|
main_layout->setMargin(50);
|
2020-11-06 12:05:24 -08:00
|
|
|
|
2021-04-03 01:18:26 -07:00
|
|
|
QLabel *label = new QLabel(argv[1]);
|
|
|
|
|
label->setWordWrap(true);
|
|
|
|
|
label->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);
|
|
|
|
|
ScrollView *scroll = new ScrollView(label);
|
|
|
|
|
scroll->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
2021-06-13 12:28:17 +08:00
|
|
|
main_layout->addWidget(scroll, 0, 0, Qt::AlignTop);
|
2020-11-06 12:05:24 -08:00
|
|
|
|
2021-04-05 14:27:14 -07:00
|
|
|
// Scroll to the bottom
|
2021-06-11 16:17:52 +08:00
|
|
|
QObject::connect(scroll->verticalScrollBar(), &QAbstractSlider::rangeChanged, [=]() {
|
2021-04-05 14:27:14 -07:00
|
|
|
scroll->verticalScrollBar()->setValue(scroll->verticalScrollBar()->maximum());
|
|
|
|
|
});
|
|
|
|
|
|
2020-11-06 12:05:24 -08:00
|
|
|
QPushButton *btn = new QPushButton();
|
|
|
|
|
#ifdef __aarch64__
|
2022-06-29 14:47:46 -07:00
|
|
|
btn->setText(QObject::tr("Reboot"));
|
2021-07-17 13:58:09 -07:00
|
|
|
QObject::connect(btn, &QPushButton::clicked, [=]() {
|
2021-03-24 14:30:41 -07:00
|
|
|
Hardware::reboot();
|
2020-11-06 12:05:24 -08:00
|
|
|
});
|
|
|
|
|
#else
|
2022-06-29 14:47:46 -07:00
|
|
|
btn->setText(QObject::tr("Exit"));
|
2021-07-17 13:58:09 -07:00
|
|
|
QObject::connect(btn, &QPushButton::clicked, &a, &QApplication::quit);
|
2020-11-06 12:05:24 -08:00
|
|
|
#endif
|
2021-06-13 12:28:17 +08:00
|
|
|
main_layout->addWidget(btn, 0, 0, Qt::AlignRight | Qt::AlignBottom);
|
2020-11-06 12:05:24 -08:00
|
|
|
|
2020-11-24 23:30:36 -08:00
|
|
|
window.setStyleSheet(R"(
|
|
|
|
|
* {
|
2021-03-24 14:30:41 -07:00
|
|
|
outline: none;
|
2020-11-06 12:05:24 -08:00
|
|
|
color: white;
|
2020-11-24 23:30:36 -08:00
|
|
|
background-color: black;
|
2020-11-06 12:05:24 -08:00
|
|
|
font-size: 60px;
|
|
|
|
|
}
|
|
|
|
|
QPushButton {
|
2020-11-24 23:30:36 -08:00
|
|
|
padding: 50px;
|
|
|
|
|
padding-right: 100px;
|
|
|
|
|
padding-left: 100px;
|
|
|
|
|
border: 2px solid white;
|
2020-11-06 12:05:24 -08:00
|
|
|
border-radius: 20px;
|
2021-04-03 01:18:26 -07:00
|
|
|
margin-right: 40px;
|
2020-11-06 12:05:24 -08:00
|
|
|
}
|
|
|
|
|
)");
|
|
|
|
|
|
|
|
|
|
return a.exec();
|
|
|
|
|
}
|