Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove libuv dependency #116

Merged
merged 9 commits into from
Apr 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
strategy:
matrix:
version:
- '1.4'
- '1.6'
- 'nightly'
steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-win-mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
fail-fast: false
matrix:
version:
- '1.4'
- '1.6'
- 'nightly'
os:
- macOS-latest
Expand Down
11 changes: 5 additions & 6 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
name = "QML"
uuid = "2db162a6-7e43-52c3-8d84-290c1c42d82a"
authors = ["Bart Janssens <[email protected]>"]
version = "0.6.1"
version = "0.7.0"

[deps]
ColorTypes = "3da002f7-5984-5a60-b8a6-cbb66c0b333f"
CxxWrap = "1f15a43c-97ca-5a2a-ae31-89f07a497df4"
FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
Mesa_jll = "78dcde23-ec64-5e07-a917-6fe22bbc0f45"
Expand All @@ -17,18 +16,18 @@ jlqml_jll = "6b5019fb-a83d-5b4e-a9f7-678a36c28df7"
[compat]
ColorTypes = "0.10"
CxxWrap = "0.11"
FileIO = "~1.3"
MacroTools = "0.5"
Observables = "0.3"
Requires = "1.0"
jlqml_jll = "0.1.3"
julia = "1.3"
jlqml_jll = "0.2"
julia = "1.6"

[extras]
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
Qt5QuickControls_jll = "e4aecf45-a397-53cc-864f-87db395e0248"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Documenter", "Plots", "Test", "BenchmarkTools"]
test = ["Documenter", "Plots", "Test", "BenchmarkTools", "Qt5QuickControls_jll"]
1 change: 1 addition & 0 deletions example/board.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using QML
using Qt5QuickControls_jll

# Represents the state related to a single emoji
mutable struct EmojiState
Expand Down
1 change: 1 addition & 0 deletions example/canvas.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
ENV["QSG_RENDER_LOOP"] = "basic"

using QML
using Qt5QuickControls_jll
using Observables
using ColorTypes
import CxxWrap # for safe_cfunction
Expand Down
1 change: 1 addition & 0 deletions example/canvas_alpha.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
ENV["QSG_RENDER_LOOP"] = "basic"

using QML
using Qt5QuickControls2_jll
using Observables
using ColorTypes
import CxxWrap # for safe_cfunction
Expand Down
1 change: 1 addition & 0 deletions example/canvas_and_gr.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
ENV["QSG_RENDER_LOOP"] = "basic" # multithreading in Qt must be off

using QML
using Qt5QuickControls2_jll
using Observables
using Plots
using ColorTypes
Expand Down
1 change: 1 addition & 0 deletions example/canvas_twice.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
ENV["QSG_RENDER_LOOP"] = "basic"

using QML
using Qt5QuickControls_jll
using Observables
using ColorTypes
import CxxWrap # for safe_cfunction
Expand Down
1 change: 1 addition & 0 deletions example/checkboxes.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using QML
using Qt5QuickControls_jll
#=
A simple gui. A set of diagrams can be selected with check boxes.
They should be displayed, when the button "Plot" is clicked.
Expand Down
1 change: 1 addition & 0 deletions example/colors.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using QML
using Qt5QuickControls_jll

loadqml(joinpath(dirname(Base.source_path()), "qml", "tutorial.qml"))
exec()
Expand Down
1 change: 1 addition & 0 deletions example/drag.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using QML
using Qt5QuickControls_jll

@qmlfunction println
loadqml(joinpath(dirname(@__FILE__), "qml", "drag.qml"))
Expand Down
1 change: 1 addition & 0 deletions example/filedialog.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using QML
using Qt5QuickControls_jll

function singlefile(uri)
uri_s = QString(uri)
Expand Down
1 change: 1 addition & 0 deletions example/fizzbuzz.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using QML
using Qt5QuickControls_jll
using Observables
"""
Translation of the FizzBuzz example from http://seanchas116.github.io/ruby-qml/
Expand Down
1 change: 1 addition & 0 deletions example/gltriangle.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ ENV["QSG_RENDER_LOOP"] = "basic"

using CxxWrap
using QML
using Qt5QuickControls2_jll
using ModernGL, GeometryTypes

mutable struct Corner
Expand Down
1 change: 1 addition & 0 deletions example/gr.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
ENV["QSG_RENDER_LOOP"] = "basic" # multithreading in Qt must be off
using CxxWrap # for safe_cfunction
using QML
using Qt5QuickControls_jll
using Observables

# Set up plots with GR so QPainter can be used directly
Expand Down
1 change: 1 addition & 0 deletions example/grid.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using QML
using Qt5QuickControls_jll

# Represents the state related to a single emoji
mutable struct EmojiState
Expand Down
1 change: 1 addition & 0 deletions example/gui.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Test
using QML
using Qt5QuickControls_jll
using Observables

hello() = "Hello from Julia"
Expand Down
1 change: 1 addition & 0 deletions example/image.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Test
using QML
using Qt5QuickControls_jll
using Images # for show of png
using TestImages

Expand Down
1 change: 1 addition & 0 deletions example/makie.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ ENV["QSG_RENDER_LOOP"] = "basic"
using CxxWrap
using Observables
using QML
using Qt5QuickControls_jll
using Makie

const catangle = Observable(0.0)
Expand Down
1 change: 1 addition & 0 deletions example/observable.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using QML
using Qt5QuickControls_jll
using Observables

qml_file = joinpath(dirname(@__FILE__), "qml", "observable.qml")
Expand Down
1 change: 1 addition & 0 deletions example/plot.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Test
using QML
using Qt5QuickControls_jll
using Plots

# No Python gui:
Expand Down
1 change: 1 addition & 0 deletions example/progressbar.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# This example show how to update the GUI during a long-running simulation
using Test
using QML
using Qt5QuickControls2_jll
using Observables
using ResumableFunctions
using Statistics
Expand Down
1 change: 1 addition & 0 deletions example/repl-background.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using QML
using Qt5QuickControls_jll

qml_file = joinpath(dirname(@__FILE__), "qml", "repl-background.qml")

Expand Down
1 change: 1 addition & 0 deletions example/sketch.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using QML
using Qt5QuickControls2_jll
using Observables

const x = Observable(0.0)
Expand Down
1 change: 1 addition & 0 deletions example/tableview.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Test
using QML
using Qt5QuickControls_jll
using Observables

struct Nuclide
Expand Down
1 change: 1 addition & 0 deletions example/text.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using QML
using Qt5QuickControls_jll

qmlfile = joinpath(dirname(Base.source_path()), "qml", "text.qml")

Expand Down
48 changes: 40 additions & 8 deletions src/QML.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export QQmlContext, root_context, loadqml, qt_prefix_path, set_source, engine, Q
export JuliaPropertyMap
export QStringList, QVariantList
export QPainter, device, width, height, logicalDpiX, logicalDpiY, QQuickWindow, effectiveDevicePixelRatio, window, JuliaPaintedItem
export @emit, @qmlfunction, qmlfunction, load, QQmlPropertyMap
export @emit, @qmlfunction, qmlfunction, QQmlPropertyMap
export set_context_property
export QUrlFromLocalFile
export qputenv, qgetenv, qunsetenv
Expand All @@ -17,7 +17,6 @@ using jlqml_jll

using CxxWrap
using Observables
using FileIO
import Libdl
using Requires
using ColorTypes
Expand Down Expand Up @@ -63,25 +62,40 @@ function loadqml(qmlfilename; kwargs...)
return load_qml(qmlfilename, qml_engine)
end

function FileIO.load(f::FileIO.File{format"QML"}; kwargs...)
Base.depwarn("load(qmlfile;...) is deprecated, please use loadqml(qmlfile;...)", :load)
return loadqml(filename(f); kwargs...)
end

@static if Sys.iswindows()
using Mesa_jll
end

const _loaded_qml_modules = Module[]

function loadqmljll(m::Module)
if m ∈ _loaded_qml_modules
return
end
push!(_loaded_qml_modules, m)
qmlpath(mod) = joinpath(mod.artifact_dir, "qml")
separator = Sys.iswindows() ? ';' : ':'
new_import_paths = join(qmlpath.(_loaded_qml_modules), separator)
ENV["QML2_IMPORT_PATH"] = new_import_paths
@static if Sys.iswindows() # ENV doesn't work on Windows for Qt, for reasons I forgot but that are explained on StackOverflow
qputenv("QML2_IMPORT_PATH", QByteArray(new_import_paths))
end
end


function __init__()
@initcxx
FileIO.add_format(format"QML", (), ".qml")

@require Makie="ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a" include(joinpath(@__DIR__, "makie_support.jl"))

# Make sure Qt can find the Mesa dll if it doesn't find a compatible OpenGL implementation
@static if Sys.iswindows()
qputenv("PATH", QByteArray(ENV["PATH"] * ";" * dirname(Mesa_jll.opengl32sw)))
end

loadqmljll(jlqml_jll.Qt5Declarative_jll)
@require Qt5QuickControls_jll="e4aecf45-a397-53cc-864f-87db395e0248" @eval loadqmljll(Qt5QuickControls_jll)
@require Qt5QuickControls2_jll="bf3ac11c-603e-589e-b4b7-e696ac65aa4a" @eval loadqmljll(Qt5QuickControls2_jll)
end

# QString
Expand Down Expand Up @@ -825,6 +839,24 @@ function force_model_update(lm::ListModel)
emit_data_changed(lm, 0, length(lm), StdVector{Int32}())
end

global _async_timer

# Stop the async loop (called on quit from C++)
function _stoptimer()
if !isdefined(QML, :_async_timer)
return
end
global _async_timer
if isopen(_async_timer)
close(_async_timer)
end
end

function exec_async()
global _async_timer = Timer((t) -> process_events(), 0.015; interval=0.015)
return
end

include("docs.jl")

end
1 change: 1 addition & 0 deletions test/badqml.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using QML
using Qt5QuickControls_jll
using Test

qmlfile = joinpath(dirname(@__FILE__), "qml", "badqml.qml")
Expand Down
1 change: 1 addition & 0 deletions test/julia_arrays.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Test
using QML
using Qt5QuickControls_jll
using Observables

# absolute path in case working dir is overridden
Expand Down
1 change: 1 addition & 0 deletions test/listviews.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Test
using QML
using Qt5QuickControls_jll

# absolute path in case working dir is overridden
qml_file = joinpath(dirname(@__FILE__), "qml", "listviews.qml")
Expand Down
1 change: 1 addition & 0 deletions test/qqmlcomponent.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Test
using Qt5QuickControls_jll
using QML

# absolute path in case working dir is overridden
Expand Down