Files
clearpilot/system/clearpilot/tools/qt_webview2.cc
Your Name 62a8fa9967 wip
2024-05-10 01:29:09 -05:00

125 lines
3.2 KiB
C++

#include <sys/resource.h>
#include <QApplication>
#include <QTranslator>
#include "/data/openpilot/system/hardware/hw.h"
#include "/data/openpilot/selfdrive/ui/qt/qt_window.h"
#include "/data/openpilot/selfdrive/ui/qt/util.h"
// class OffroadHome : public QFrame {
// Q_OBJECT
// public:
// explicit OffroadHome(QWidget* parent = 0);
// signals:
// void openSettings(int index = 0, const QString &param = "");
// private:
// void showEvent(QShowEvent *event) override;
// void hideEvent(QHideEvent *event) override;
// void refresh();
// Params params;
// QTimer* timer;
// ElidedLabel* version;
// QStackedLayout* center_layout;
// UpdateAlert *update_widget;
// OffroadAlert* alerts_widget;
// QPushButton* alert_notif;
// QPushButton* update_notif;
// // FrogPilot variables
// ElidedLabel* date;
// };
// OffroadHome::OffroadHome(QWidget* parent) : QFrame(parent) {
// QVBoxLayout* main_layout = new QVBoxLayout(this);
// main_layout->setContentsMargins(40, 40, 40, 40);
// main_layout->addLayout(header_layout);
// center_layout = new QStackedLayout();
// QWidget *home_widget = new QWidget(this);
// {
// QHBoxLayout *home_layout = new QHBoxLayout(home_widget);
// home_layout->setContentsMargins(0, 0, 0, 0);
// home_layout->setSpacing(30);
// // // Create a QWebEngineView
// QWebEngineView *web_view = new QWebEngineView();
// web_view->load(QUrl("http://fark.com"));
// // Add the QWebEngineView to the layout
// home_layout->addWidget(web_view);
// }
// center_layout->addWidget(home_widget);
// main_layout->addLayout(center_layout, 1);
// }
class MainWindow : public QWidget {
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
private:
// bool eventFilter(QObject *obj, QEvent *event) override;
// void openSettings(int index = 0, const QString &param = "");
// void closeSettings();
QStackedLayout *main_layout;
// OffroadHome *offroadhome;
// FrogPilot variables
// Params params;
};
MainWindow::MainWindow(QWidget *parent) : QWidget(parent) {
main_layout = new QStackedLayout(this);
main_layout->setMargin(0);
// Create a QWebEngineView
QWebEngineView *web_view = new QWebEngineView();
web_view->load(QUrl("http://fark.com"));
// Add the QWebEngineView to the layout
main_layout->addWidget(web_view);
setAttribute(Qt::WA_NoSystemBackground);
}
bool MainWindow::eventFilter(QObject *obj, QEvent *event) {
bool ignore = false;
switch (event->type()) {
case QEvent::TouchBegin:
case QEvent::TouchUpdate:
case QEvent::TouchEnd:
case QEvent::MouseButtonPress:
case QEvent::MouseMove: {
// ignore events when device is awakened by resetInteractiveTimeout
ignore = !device()->isAwake();
device()->resetInteractiveTimeout(uiState()->scene.screen_timeout, uiState()->scene.screen_timeout_onroad);
break;
}
default:
break;
}
return ignore;
}
int main(int argc, char *argv[]) {
setpriority(PRIO_PROCESS, 0, -20);
initApp(argc, argv);
QApplication a(argc, argv);
MainWindow w;
setMainWindow(&w);
a.installEventFilter(&w);
return a.exec();
}