wip
This commit is contained in:
@@ -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)
|
||||
|
||||
125
system/clearpilot/tools/qt_webview2.cc
Normal file
125
system/clearpilot/tools/qt_webview2.cc
Normal file
@@ -0,0 +1,125 @@
|
||||
#include </data/openpilot/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"
|
||||
#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();
|
||||
}
|
||||
Reference in New Issue
Block a user