hsqml-0.2.0.1: Haskell binding for Qt Quick

Safe HaskellNone

Graphics.QML.Engine

Contents

Description

Functions for starting QML engines, displaying content in a window.

Synopsis

Engines

data InitialWindowState

Specifies the intial state of the display window.

Constructors

ShowWindow

A visible window should be created for the initial document with a default title.

ShowWindowWithTitle String

A visible window should be created for the initial document with the given title.

HideWindow

A window should be created for the initial document, but it will remain hidden until made visible by the QML script.

data EngineConfig

Holds parameters for configuring a QML runtime engine.

Constructors

EngineConfig 

Fields

initialURL :: URI

URL for the first QML document to be loaded.

initialWindowState :: InitialWindowState

Window state for the initial QML document.

contextObject :: Maybe AnyObjRef

Context Object made available to QML script code.

defaultEngineConfig :: EngineConfig

Default engine configuration. Loads "main.qml" from the current working directory into a visible window with no context object.

data Engine

Represents a QML engine.

runEngine :: EngineConfig -> RunQML ()

Starts a new QML engine using the supplied configuration and blocks until the engine has terminated.

runEngineWith :: EngineConfig -> (Engine -> RunQML a) -> RunQML a

Starts a new QML engine using the supplied configuration. The 'with' function is executed once the engine has been started and after it returns this function blocks until the engine has terminated.

runEngineAsync :: EngineConfig -> RunQML Engine

Starts a new QML engine using the supplied configuration and returns immediately without blocking.

runEngineLoop :: EngineConfig -> IO ()

Conveniance function that both runs the event loop and starts a new QML engine. It blocks keeping the event loop running until the engine has terminated.

Event Loop

data RunQML a

Wrapper around the IO monad for running actions which depend on the Qt event loop.

runEventLoop :: RunQML a -> IO a

This function enters the Qt event loop and executes the supplied function in the RunQML monad on a new unbound thread. The event loop will continue to run until all functions in the RunQML monad have completed. This includes both the RunQML function launched by this call and any launched asynchronously via requireEventLoop. When the event loop exits, all engines will be terminated.

It's recommended that applications run the event loop on their primordial thread as some platforms mandate this. Once the event loop has finished, it can be started again, but only on the same operating system thread as before. If the event loop fails to start then an EventLoopException will be thrown.

requireEventLoop :: RunQML a -> IO a

Executes a function in the RunQML monad asynchronously to the event loop. Callers must apply their own sychronisation to ensure that the event loop is currently running when this function is called, otherwise an EventLoopException will be thrown. The event loop will not exit until the supplied function has completed.

data EventLoopException

Exception type used to report errors pertaining to the event loop.

Utilities

filePathToURI :: FilePath -> URI

Convenience function for converting local file paths into URIs.