This commit is contained in:
Your Name
2024-05-10 02:52:28 -05:00
parent 719856d2df
commit 8a00434411

View File

@@ -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[]) { int main(int argc, char *argv[]) {
setenv("XDG_RUNTIME_DIR", "/var/tmp/weston", 1); setenv("XDG_RUNTIME_DIR", "/var/tmp/weston", 1);
@@ -49,10 +65,7 @@ int main(int argc, char *argv[]) {
} }
// Common init // Common init
QWidget window; MainWindow window;
window.setWindowTitle("Generic Window");
window.setStyleSheet("background-color: blue;");
window.showFullScreen();
auto windowHandle = window.windowHandle(); auto windowHandle = window.windowHandle();
if (!windowHandle) { if (!windowHandle) {
@@ -72,31 +85,31 @@ int main(int argc, char *argv[]) {
window.setFixedSize(2160, 1080); window.setFixedSize(2160, 1080);
QVBoxLayout *layout = new QVBoxLayout(&window); // QVBoxLayout *layout = new QVBoxLayout(&window);
layout->setSpacing(0); // layout->setSpacing(0);
layout->setContentsMargins(0, 0, 0, 0); // layout->setContentsMargins(0, 0, 0, 0);
QTextEdit *outputDisplay = new QTextEdit; // QTextEdit *outputDisplay = new QTextEdit;
outputDisplay->setFont(QFont("Consolas", 32)); // outputDisplay->setFont(QFont("Consolas", 32));
outputDisplay->setReadOnly(true); // outputDisplay->setReadOnly(true);
outputDisplay->setFixedSize(window.width(), window.height()); // outputDisplay->setFixedSize(window.width(), window.height());
outputDisplay->setStyleSheet("color: white; background-color: black;"); // outputDisplay->setStyleSheet("color: white; background-color: black;");
outputDisplay->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); // Hide the vertical scrollbar // outputDisplay->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); // Hide the vertical scrollbar
layout->addWidget(outputDisplay); // layout->addWidget(outputDisplay);
// QString url = args.first(); // QString url = args.first();
// web_view->load(QUrl(argv[1])); // web_view->load(QUrl(argv[1]));
// layout->addWidget(web_view); // layout->addWidget(web_view);
// Set a timer to change the background color and load the URL after 0.5 seconds // Set a timer to change the background color and load the URL after 0.5 seconds
QTimer::singleShot(2000, [&]() { // QTimer::singleShot(2000, [&]() {
WebViewFrame *webViewFrame = new WebViewFrame(this); // WebViewFrame *webViewFrame = new WebViewFrame(this);
layout->addWidget(webViewFrame); // layout->addWidget(webViewFrame);
// QWebEngineView *web_view = new QWebEngineView(); // // QWebEngineView *web_view = new QWebEngineView();
// web_view->load(QUrl(args.first())); // Load the URL // // web_view->load(QUrl(args.first())); // Load the URL
// layout->addWidget(web_view); // Add the web view to the layout // // layout->addWidget(web_view); // Add the web view to the layout
window.update(); // Refresh window to apply changes // window.update(); // Refresh window to apply changes
}); // });
// window.showFullScreen(); // window.showFullScreen();
window.show(); window.show();