wip
This commit is contained in:
66
system/clearpilot/tools/webview.cc
Normal file
66
system/clearpilot/tools/webview.cc
Normal file
@@ -0,0 +1,66 @@
|
||||
#include <QCommandLineParser>
|
||||
#include <QApplication>
|
||||
#include <QWidget>
|
||||
#include <QTextEdit>
|
||||
#include <QLabel>
|
||||
#include <QProcess>
|
||||
#include <QVBoxLayout>
|
||||
#include <QFont>
|
||||
#include <QScreen>
|
||||
#include <QScrollBar>
|
||||
#include <QGuiApplication>
|
||||
#include <qpa/qplatformnativeinterface.h>
|
||||
#include <wayland-client-protocol.h>
|
||||
|
||||
#include <QWebEngineView>
|
||||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
QApplication app(argc, argv);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
// Common init
|
||||
QWidget window;
|
||||
window.setWindowTitle("Webview");
|
||||
window.setStyleSheet("background-color: black;");
|
||||
window.showFullScreen();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
wl_surface_set_buffer_transform(s, WL_OUTPUT_TRANSFORM_270);
|
||||
wl_surface_commit(s);
|
||||
|
||||
window.setFixedSize(2160, 1080);
|
||||
|
||||
QVBoxLayout *layout = new QVBoxLayout(&window);
|
||||
layout->setSpacing(0);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
QString url = args.first();
|
||||
QWebEngineView *web_view = new QWebEngineView();
|
||||
web_view->load(QUrl(url));
|
||||
center_layout->addWidget(web_view);
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
Reference in New Issue
Block a user