From be58961db8c4e8a1a8a3688855258e5268267335 Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 10 May 2024 01:25:01 -0500 Subject: [PATCH] wip --- selfdrive/ui/SConscript | 3 +- system/clearpilot/tools/qt_webview2.cc | 125 +++++++++++++++++++++++++ 2 files changed, 127 insertions(+), 1 deletion(-) create mode 100644 system/clearpilot/tools/qt_webview2.cc diff --git a/selfdrive/ui/SConscript b/selfdrive/ui/SConscript index 98f17ac..938dd8b 100644 --- a/selfdrive/ui/SConscript +++ b/selfdrive/ui/SConscript @@ -92,7 +92,8 @@ qt_webengine_libs = qt_libs + ['Qt5WebEngineWidgets'] # Create clearpilot tools qt_env.Program("/data/openpilot/system/clearpilot/tools/qt_shell", ["/data/openpilot/system/clearpilot/tools/qt_shell.cc"], LIBS=qt_libs) -qt_env.Program("/data/openpilot/system/clearpilot/tools/qt_webview", ["/data/openpilot/system/clearpilot/tools/qt_webview.cc"], LIBS=qt_webengine_libs) +# qt_env.Program("/data/openpilot/system/clearpilot/tools/qt_webview", ["/data/openpilot/system/clearpilot/tools/qt_webview.cc"], LIBS=qt_webengine_libs) +qt_env.Program("/data/openpilot/system/clearpilot/tools/qt_webview2", ["/data/openpilot/system/clearpilot/tools/qt_webview2.cc"], LIBS=qt_webengine_libs) # build main UI qt_env.Program("ui", qt_src + [asset_obj], LIBS=qt_webengine_libs) diff --git a/system/clearpilot/tools/qt_webview2.cc b/system/clearpilot/tools/qt_webview2.cc new file mode 100644 index 0000000..e7cd465 --- /dev/null +++ b/system/clearpilot/tools/qt_webview2.cc @@ -0,0 +1,125 @@ +#include + +#include +#include + +#include "/data/openpilot/system/hardware/hw.h" +#include "/data/openpilot/selfdrive/ui/qt/qt_window.h" +#include "/data/openpilot/selfdrive/ui/qt/util.h" +#include "/data/openpilot/selfdrive/ui/qt/window.h" + +// class OffroadHome : public QFrame { +// Q_OBJECT + +// public: +// explicit OffroadHome(QWidget* parent = 0); + +// signals: +// void openSettings(int index = 0, const QString ¶m = ""); + +// 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 ¶m = ""); +// 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(); +}