Files
dragonpilot/selfdrive/ui/qt/text.cc
Dean Lee 7222d0f20d Cleanup selfdrive/ includes (#20822)
* cleanup include path

* continue

* format includes

* fix testraw.cc

* remove include path from SConstruct

* regroup

* rebase master

* almost done

* apply review

* rename FileReader.xx to filereader.xx

* rename Unlogger.x->unlogger.x

* rename FrameReader.xx -> framereader.xx

* apply reviews

* ui.h

* continue

* fix framebuffer.cc build error:mv util.h up

* full path to msm_media_info

* fix qcom2 camerad

Co-authored-by: Comma Device <device@comma.ai>
2021-05-08 22:15:17 -07:00

67 lines
1.7 KiB
C++

#include <QApplication>
#include <QLabel>
#include <QPushButton>
#include <QScrollBar>
#include <QVBoxLayout>
#include <QWidget>
#include "selfdrive/hardware/hw.h"
#include "selfdrive/ui/qt/qt_window.h"
#include "selfdrive/ui/qt/widgets/scrollview.h"
int main(int argc, char *argv[]) {
QApplication a(argc, argv);
QWidget window;
setMainWindow(&window);
Hardware::set_display_power(true);
Hardware::set_brightness(65);
QGridLayout *layout = new QGridLayout;
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);
layout->addWidget(scroll, 0, 0, Qt::AlignTop);
// Scroll to the bottom
QObject::connect(scroll->verticalScrollBar(), &QAbstractSlider::rangeChanged, [=](){
scroll->verticalScrollBar()->setValue(scroll->verticalScrollBar()->maximum());
});
QPushButton *btn = new QPushButton();
#ifdef __aarch64__
btn->setText("Reboot");
QObject::connect(btn, &QPushButton::released, [=]() {
Hardware::reboot();
});
#else
btn->setText("Exit");
QObject::connect(btn, &QPushButton::released, &a, &QApplication::quit);
#endif
layout->addWidget(btn, 0, 0, Qt::AlignRight | Qt::AlignBottom);
window.setLayout(layout);
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();
}