From b3ffb418c0beec61165c995c2a3e1f96303818de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Mon, 3 Nov 2014 11:32:10 +0200 Subject: [PATCH 1/2] Add initial webengine support. --- webengine/webengine.cpp | 6 ++++++ webengine/webengine.go | 20 ++++++++++++++++++++ webengine/webengine.h | 14 ++++++++++++++ 3 files changed, 40 insertions(+) create mode 100644 webengine/webengine.cpp create mode 100644 webengine/webengine.go create mode 100644 webengine/webengine.h diff --git a/webengine/webengine.cpp b/webengine/webengine.cpp new file mode 100644 index 00000000..118b451e --- /dev/null +++ b/webengine/webengine.cpp @@ -0,0 +1,6 @@ +#include +#include "webengine.h" + +void webengineInitialize() { + QtWebEngine::initialize(); +} diff --git a/webengine/webengine.go b/webengine/webengine.go new file mode 100644 index 00000000..6eac42f9 --- /dev/null +++ b/webengine/webengine.go @@ -0,0 +1,20 @@ +package webengine + +// #cgo CPPFLAGS: -I./ +// #cgo CXXFLAGS: -std=c++0x -pedantic-errors -Wall -fno-strict-aliasing +// #cgo LDFLAGS: -lstdc++ +// #cgo pkg-config: Qt5WebEngine +// +// #include "webengine.h" +import "C" + +import ( + "gopkg.in/qml.v1" +) + +// Initializes the WebEngine extension. +func Initialize() { + qml.RunMain(func() { + C.webengineInitialize() + }) +} diff --git a/webengine/webengine.h b/webengine/webengine.h new file mode 100644 index 00000000..9c3b13bf --- /dev/null +++ b/webengine/webengine.h @@ -0,0 +1,14 @@ +#ifndef WEBENGINE_H +#define WEBENGINE_H + +#ifdef __cplusplus +extern "C" { +#endif + +void webengineInitialize(); + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // WEBENGINE_H From dc1162e671f8c99dc80e19d6ab12f95aa3470a24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Mon, 3 Nov 2014 11:38:32 +0200 Subject: [PATCH 2/2] Add some usage examples for the webengine module. --- examples/webengine/webengine.go | 27 +++++++++++++++++++++++++++ examples/webengine/webengine.qml | 14 ++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 examples/webengine/webengine.go create mode 100644 examples/webengine/webengine.qml diff --git a/examples/webengine/webengine.go b/examples/webengine/webengine.go new file mode 100644 index 00000000..33fb7a78 --- /dev/null +++ b/examples/webengine/webengine.go @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "os" + + "gopkg.in/qml.v1" + "gopkg.in/qml.v1/webengine" +) + +func main() { + fmt.Println(qml.Run(func() error { + webengine.Initialize() + + engine := qml.NewEngine() + engine.On("quit", func() { os.Exit(0) }) + + component, err := engine.LoadFile("webengine.qml") + if err != nil { + return err + } + win := component.CreateWindow(nil) + win.Show() + win.Wait() + return nil + })) +} diff --git a/examples/webengine/webengine.qml b/examples/webengine/webengine.qml new file mode 100644 index 00000000..7beefa32 --- /dev/null +++ b/examples/webengine/webengine.qml @@ -0,0 +1,14 @@ +import QtQuick 2.1 +import QtWebEngine 1.0 +import QtQuick.Controls 1.0 + +ApplicationWindow { + id: root + width: 1024 + height: 768 + + WebEngineView { + anchors.fill: parent + url: "http://codingame.com" + } +}