-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 8c4d34f
Showing
53 changed files
with
58,214 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
.DS_Store | ||
deploy/* | ||
vendor/* | ||
rcc* | ||
moc* | ||
*.qmlc | ||
|
||
build/* | ||
.packages | ||
.dart_tool | ||
pubspec.lock | ||
|
||
*flutter_engine.* | ||
FlutterEmbedder.framework |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
[BINARIES](https://github.com/therecipe/flutter/releases/tag/v0.0.0) | ||
|
||
--- | ||
|
||
Introduction | ||
------------ | ||
|
||
TBD | ||
|
||
Status | ||
------ | ||
|
||
Almost all Qt functions and classes are accessible from Dart and you should be able to find everything you need to build fully featured Qt applications in Dart, the feature-set shown represents only a small portion of all the features available. | ||
|
||
However this is still very much experimental, and there are memory leaks and enums aren't support yet. | ||
|
||
Another caveat is that the flutter embedder currently only supports debug builds and the interop api isn't working on windows yet. | ||
It's also planned to make the custom flutter embedder optional and support plain dart projects as well. | ||
|
||
Also, the interop api isn't frozen yet and might change in the future. | ||
|
||
Info | ||
---- | ||
|
||
For general information about `therecipe/qt`, checkout: https://github.com/therecipe/qt | ||
|
||
The Qt API Docs can be found here: https://doc.qt.io/qt-5/classes.html | ||
|
||
If you have questions, join our Slack channel [#qt-binding](https://gophers.slack.com/messages/qt-binding/details) ([invite yourself here](https://invite.slack.golangbridge.org)\) | ||
|
||
Usage | ||
----- | ||
|
||
Setup `therecipe/qt` and install Flutter: https://flutter.dev/docs/get-started/install | ||
After adding the `flutter/bin` dir to your PATH, you can use `qtdeploy` to build the showcase. | ||
If you just want to rebuild the flutter code, you can use `flutter build bundle`. | ||
To enabled hot reloading, you can use something like: `flutter attach --debug-uri=http://127.0.0.1:60123/xyzxyzxyz/` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
set -ev | ||
|
||
OPWD=$PWD | ||
NAME=flutter | ||
|
||
qtdeploy -docker build linux && rm -rf rcc* moc* vendor && git clean -f && git reset --hard && docker rmi therecipe/qt:linux | ||
cd $OPWD/deploy/linux && zip -q -9 -r ../${NAME}_linux_amd64_shared.zip * && cd $OPWD && rm -rf $OPWD/deploy/linux | ||
|
||
qtdeploy -docker build linux_static && rm -rf rcc* moc* vendor && git clean -f && git reset --hard && docker rmi therecipe/qt:linux_static | ||
cd $OPWD/deploy/linux && zip -q -9 -r ../${NAME}_linux_amd64.zip * && cd $OPWD && rm -rf $OPWD/deploy/linux | ||
|
||
|
||
qtdeploy -docker build windows_64_shared_wine && rm -rf rcc* moc* vendor && git clean -f && git reset --hard && docker rmi therecipe/qt:windows_64_shared_wine | ||
cd $OPWD/deploy/windows && zip -q -9 -r ../${NAME}_windows_amd64_shared.zip * && cd $OPWD && rm -rf $OPWD/deploy/windows | ||
|
||
|
||
cd $(go env GOPATH)/src/github.com/therecipe/qt/internal/docker/darwin && ./build.sh && cd $OPWD | ||
qtdeploy -docker build darwin && rm -rf rcc* moc* vendor && git clean -f && git reset --hard && docker rmi therecipe/qt:darwin | ||
cd $OPWD/deploy/darwin && zip -q -9 -r ../${NAME}_darwin_amd64_shared.zip * && cd $OPWD && rm -rf $OPWD/deploy/darwin | ||
|
||
cd $(go env GOPATH)/src/github.com/therecipe/qt/internal/docker/darwin && ./build_static.sh && cd $OPWD | ||
qtdeploy -docker build darwin_static && rm -rf rcc* moc* vendor && git clean -f && git reset --hard && docker rmi therecipe/qt:darwin_static | ||
cd $OPWD/deploy/darwin && zip -q -9 -r ../${NAME}_darwin_amd64.zip * && cd $OPWD && rm -rf $OPWD/deploy/darwin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'dart:io'; | ||
|
||
/* | ||
this is needed atm to let qtdeploy/qtminimal know that this file needs to be analysed | ||
import ( | ||
"github.com/therecipe/qt/core" | ||
"github.com/therecipe/qt/quick" | ||
"github.com/therecipe/qt/quickcontrols2" | ||
) | ||
*/ | ||
|
||
import 'qt/interop.dart' as interop; | ||
import 'qt/core.dart' as core; | ||
import 'qt/quick.dart' as quick; | ||
import 'qt/quickcontrols2.dart' as quickcontrols2; | ||
|
||
final interopEngine = (!Platform.isWindows) ? interop.PseudoQJSEngine_qjsEngine(null) : null; | ||
final quickWidget = (!Platform.isWindows) ? quick.NewQQuickWidget(null) : null; | ||
|
||
void main() { | ||
|
||
if (!Platform.isWindows) { | ||
interopEngine.GlobalObject().SetProperty("dartFunction", interopEngine.NewGoType((String s) { print(s); })); | ||
|
||
// setup qml widget | ||
|
||
quickcontrols2.QQuickStyle_SetStyle("Material"); | ||
|
||
quickWidget.Engine().GlobalObject().SetProperty("dartFunction", quickWidget.Engine().NewGoType((String s) { print(s); })); | ||
quickWidget.Engine().GlobalObject().SetProperty("qml", quickWidget.Engine().NewObject()); //create an empty object here, so we can write to it later from withing Qml since we can't directly add properties to the globalObject from within qml | ||
quickWidget.SetMinimumSize(core.NewQSize2(400, 300)); | ||
quickWidget.SetResizeMode(1); //TODO: quick.QQuickWidget__SizeRootObjectToView | ||
quickWidget.SetSource(core.NewQUrl3("qrc:/qml/main.qml", 0)); | ||
|
||
// call into go and let it finish the layout setup | ||
|
||
interopEngine.GlobalObject().SetProperty("quickWidget", interopEngine.NewGoType(quickWidget)); | ||
interopEngine.GlobalObject().Property("goSetupFunction").Call(null); | ||
} | ||
|
||
runApp(MyApp()); | ||
} | ||
|
||
/// This Widget is the main application widget. | ||
class MyApp extends StatelessWidget { | ||
static const String _title = 'Dart-Go-Qml Interop'; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return MaterialApp( | ||
title: _title, | ||
home: Scaffold( | ||
appBar: AppBar(title: const Text(_title)), | ||
body: MyStatelessWidget(), | ||
), | ||
); | ||
} | ||
} | ||
|
||
/// This is the stateless widget that the main application instantiates. | ||
class MyStatelessWidget extends StatelessWidget { | ||
MyStatelessWidget({Key key}) : super(key: key); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Center( | ||
child: Column( | ||
mainAxisSize: MainAxisSize.min, | ||
children: <Widget>[ | ||
RaisedButton( | ||
onPressed: () { | ||
if (!Platform.isWindows) { | ||
interopEngine.GlobalObject().Property("goFunction").Call([interopEngine.NewGoType("Hello from Dart")]); | ||
} | ||
}, | ||
child: const Text('Dart calls Go', style: TextStyle(fontSize: 20)), | ||
), | ||
const SizedBox(height: 30), | ||
RaisedButton( | ||
onPressed: () { | ||
if (!Platform.isWindows) { | ||
quickWidget.Engine().GlobalObject().Property("qml").Property("qmlFunction").Call([quickWidget.Engine().NewGoType("Hello from Dart")]); | ||
} | ||
}, | ||
child: const Text('Dart calls Qml', style: TextStyle(fontSize: 20)), | ||
), | ||
], | ||
), | ||
); | ||
} | ||
} |
Oops, something went wrong.