From 8a004344111ea530231b5f71e947252b0d5f0e22 Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 10 May 2024 02:52:28 -0500 Subject: [PATCH] wip --- system/clearpilot/tools/qt_webview.cc | 57 ++++++++++++++++----------- 1 file changed, 35 insertions(+), 22 deletions(-) diff --git a/system/clearpilot/tools/qt_webview.cc b/system/clearpilot/tools/qt_webview.cc index 573527b..6834866 100644 --- a/system/clearpilot/tools/qt_webview.cc +++ b/system/clearpilot/tools/qt_webview.cc @@ -28,6 +28,22 @@ public: }; +class MainWindow : public QWidget { + Q_OBJECT +public: + explicit MainWindow(QWidget *parent = nullptr) { + this->setWindowTitle("Webview in Frame"); + this->setStyleSheet("background-color: black;"); + window.showFullScreen(); + + 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); @@ -49,10 +65,7 @@ int main(int argc, char *argv[]) { } // Common init - QWidget window; - window.setWindowTitle("Generic Window"); - window.setStyleSheet("background-color: blue;"); - window.showFullScreen(); + MainWindow window; auto windowHandle = window.windowHandle(); if (!windowHandle) { @@ -72,31 +85,31 @@ int main(int argc, char *argv[]) { 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); // 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 - }); + // 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();