This commit is contained in:
Your Name
2024-05-10 04:14:00 -05:00
parent ad3a0476e9
commit bc2a4e2266
12 changed files with 136 additions and 203 deletions

View File

@@ -1,127 +1,127 @@
#include <QCommandLineParser>
#include <QApplication>
#include <QWidget>
#include <QTextEdit>
#include <QLabel>
#include <QTimer>
#include <QProcess>
#include <QVBoxLayout>
#include <QFont>
#include <QScreen>
#include <QScrollBar>
#include <QGuiApplication>
#include <qpa/qplatformnativeinterface.h>
#include <wayland-client-protocol.h>
#include <cstdlib>
// #include <QCommandLineParser>
// #include <QApplication>
// #include <QWidget>
// #include <QTextEdit>
// #include <QLabel>
// #include <QTimer>
// #include <QProcess>
// #include <QVBoxLayout>
// #include <QFont>
// #include <QScreen>
// #include <QScrollBar>
// #include <QGuiApplication>
// #include <qpa/qplatformnativeinterface.h>
// #include <wayland-client-protocol.h>
// #include <cstdlib>
#include <QWebEngineView>
// #include <QWebEngineView>
class WebViewFrame : public QFrame {
Q_OBJECT
public:
explicit WebViewFrame(QWidget *parent = nullptr) : QFrame(parent) {
QVBoxLayout *layout = new QVBoxLayout(this);
QWebEngineView *web_view = new QWebEngineView();
web_view->load(QUrl("http://example.com")); // Change URL as needed
layout->addWidget(web_view);
}
};
// class WebViewFrame : public QFrame {
// Q_OBJECT
// public:
// explicit WebViewFrame(QWidget *parent = nullptr) : QFrame(parent) {
// QVBoxLayout *layout = new QVBoxLayout(this);
// QWebEngineView *web_view = new QWebEngineView();
// web_view->load(QUrl("http://example.com")); // Change URL as needed
// layout->addWidget(web_view);
// }
// };
class MainWindow : public QWidget {
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = nullptr) {
this->setWindowTitle("Webview in Frame");
this->setStyleSheet("background-color: black;");
this->showFullScreen();
// class MainWindow : public QWidget {
// Q_OBJECT
// public:
// explicit MainWindow(QWidget *parent = nullptr) {
// this->setWindowTitle("Webview in Frame");
// this->setStyleSheet("background-color: black;");
// this->showFullScreen();
QVBoxLayout *mainLayout = new QVBoxLayout(this);
this->setLayout(mainLayout);
// QVBoxLayout *mainLayout = new QVBoxLayout(this);
// this->setLayout(mainLayout);
WebViewFrame *webViewFrame = nullptr; // Declare pointer but do not initialize
// WebViewFrame *webViewFrame = nullptr; // Declare pointer but do not initialize
QTimer::singleShot(2000, this, [=, &webViewFrame]() mutable {
webViewFrame = new WebViewFrame(this); // Initialize here
mainLayout->addWidget(webViewFrame);
});
// QTimer::singleShot(2000, this, [=, &webViewFrame]() mutable {
// webViewFrame = new WebViewFrame(this); // Initialize here
// mainLayout->addWidget(webViewFrame);
// });
this->show();
// this->show();
}
};
// }
// };
int main(int argc, char *argv[]) {
setenv("XDG_RUNTIME_DIR", "/var/tmp/weston", 1);
setenv("WAYLAND_DISPLAY", "wayland-0", 1);
setenv("QT_QPA_PLATFORM", "wayland", 1);
setenv("QT_WAYLAND_SHELL_INTEGRATION", "wl-shell", 1);
// int main(int argc, char *argv[]) {
// setenv("XDG_RUNTIME_DIR", "/var/tmp/weston", 1);
// setenv("WAYLAND_DISPLAY", "wayland-0", 1);
// setenv("QT_QPA_PLATFORM", "wayland", 1);
// setenv("QT_WAYLAND_SHELL_INTEGRATION", "wl-shell", 1);
QApplication app(argc, argv);
// QApplication app(argc, argv);
QCommandLineParser parser;
parser.addHelpOption();
parser.addPositionalArgument("command", "The URL to open.");
parser.process(app);
// QCommandLineParser parser;
// parser.addHelpOption();
// parser.addPositionalArgument("command", "The URL to open.");
// parser.process(app);
QStringList args = parser.positionalArguments();
if (args.isEmpty()) {
fprintf(stderr, "Usage: %s '<command>'\n", argv[0]);
return 1;
}
// QStringList args = parser.positionalArguments();
// if (args.isEmpty()) {
// fprintf(stderr, "Usage: %s '<command>'\n", argv[0]);
// return 1;
// }
// Common init
MainWindow window;
// // Common init
// MainWindow window;
auto windowHandle = window.windowHandle();
if (!windowHandle) {
fprintf(stderr, "Error: Unable to obtain window handle.\n");
return 1;
}
// auto windowHandle = window.windowHandle();
// if (!windowHandle) {
// fprintf(stderr, "Error: Unable to obtain window handle.\n");
// return 1;
// }
QPlatformNativeInterface *native = QGuiApplication::platformNativeInterface();
auto *s = static_cast<wl_surface*>(native->nativeResourceForWindow("surface", windowHandle));
if (!s) {
fprintf(stderr, "Error: Unable to obtain native Wayland surface.\n");
return 1;
}
// QPlatformNativeInterface *native = QGuiApplication::platformNativeInterface();
// auto *s = static_cast<wl_surface*>(native->nativeResourceForWindow("surface", windowHandle));
// if (!s) {
// fprintf(stderr, "Error: Unable to obtain native Wayland surface.\n");
// return 1;
// }
wl_surface_set_buffer_transform(s, WL_OUTPUT_TRANSFORM_270);
wl_surface_commit(s);
// wl_surface_set_buffer_transform(s, WL_OUTPUT_TRANSFORM_270);
// wl_surface_commit(s);
window.setFixedSize(2160, 1080);
// window.setFixedSize(2160, 1080);
// QVBoxLayout *layout = new QVBoxLayout(&window);
// layout->setSpacing(0);
// layout->setContentsMargins(0, 0, 0, 0);
// // QVBoxLayout *layout = new QVBoxLayout(&window);
// // layout->setSpacing(0);
// // layout->setContentsMargins(0, 0, 0, 0);
// QTextEdit *outputDisplay = new QTextEdit;
// outputDisplay->setFont(QFont("Consolas", 32));
// outputDisplay->setReadOnly(true);
// outputDisplay->setFixedSize(window.width(), window.height());
// outputDisplay->setStyleSheet("color: white; background-color: black;");
// outputDisplay->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); // Hide the vertical scrollbar
// layout->addWidget(outputDisplay);
// // QTextEdit *outputDisplay = new QTextEdit;
// // outputDisplay->setFont(QFont("Consolas", 32));
// // outputDisplay->setReadOnly(true);
// // outputDisplay->setFixedSize(window.width(), window.height());
// // outputDisplay->setStyleSheet("color: white; background-color: black;");
// // outputDisplay->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); // Hide the vertical scrollbar
// // layout->addWidget(outputDisplay);
// QString url = args.first();
// web_view->load(QUrl(argv[1]));
// layout->addWidget(web_view);
// // QString url = args.first();
// // web_view->load(QUrl(argv[1]));
// // layout->addWidget(web_view);
// Set a timer to change the background color and load the URL after 0.5 seconds
// QTimer::singleShot(2000, [&]() {
// WebViewFrame *webViewFrame = new WebViewFrame(this);
// layout->addWidget(webViewFrame);
// // QWebEngineView *web_view = new QWebEngineView();
// // web_view->load(QUrl(args.first())); // Load the URL
// // layout->addWidget(web_view); // Add the web view to the layout
// window.update(); // Refresh window to apply changes
// });
// // Set a timer to change the background color and load the URL after 0.5 seconds
// // QTimer::singleShot(2000, [&]() {
// // WebViewFrame *webViewFrame = new WebViewFrame(this);
// // layout->addWidget(webViewFrame);
// // // QWebEngineView *web_view = new QWebEngineView();
// // // web_view->load(QUrl(args.first())); // Load the URL
// // // layout->addWidget(web_view); // Add the web view to the layout
// // window.update(); // Refresh window to apply changes
// // });
// window.showFullScreen();
window.show();
// // window.showFullScreen();
// window.show();
return app.exec();
}
// return app.exec();
// }
#include "qt_webview.moc"
// #include "qt_webview.moc"

View File

@@ -1,71 +0,0 @@
#include <sys/resource.h>
#include <cstdlib>
// #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 <QCommandLineParser>
// #include <QApplication>
// #include <QWidget>
// #include <QTextEdit>
// #include <QLabel>
// #include <QProcess>
// #include <QVBoxLayout>
// #include <QFont>
// #include <QScreen>
// #include <QScrollBar>
// #include <QGuiApplication>
// #include <QWebEngineView>
// #include <QStackedLayout>
#include <QApplication>
#include <QFrame>
#include <QVBoxLayout>
#include <QWebEngineView>
#include <QWidget>
class WebViewFrame : public QFrame {
Q_OBJECT
public:
explicit WebViewFrame(QWidget *parent = nullptr) : QFrame(parent) {
QVBoxLayout *layout = new QVBoxLayout(this);
QWebEngineView *web_view = new QWebEngineView();
web_view->load(QUrl("http://example.com")); // Change URL as needed
layout->addWidget(web_view);
}
};
class MainWindow : public QWidget {
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = nullptr) {
this->setWindowTitle("Webview in Frame");
this->setStyleSheet("background-color: black;");
WebViewFrame *webViewFrame = new WebViewFrame(this);
QVBoxLayout *mainLayout = new QVBoxLayout(this);
mainLayout->addWidget(webViewFrame);
this->setLayout(mainLayout);
this->show();
}
};
int main(int argc, char *argv[]) {
setenv("XDG_RUNTIME_DIR", "/var/tmp/weston", 1);
setenv("WAYLAND_DISPLAY", "wayland-0", 1);
setenv("QT_QPA_PLATFORM", "wayland", 1);
setenv("QT_WAYLAND_SHELL_INTEGRATION", "wl-shell", 1);
setpriority(PRIO_PROCESS, 0, -20);
initApp(argc, argv);
QApplication app(argc, argv);
MainWindow mainWindow;
setMainWindow(&mainWindow);
return app.exec();
}
#include "qt_webview2.moc"