From dcb3c44b1a1d8c6b3c9353343b1c8ab619430562 Mon Sep 17 00:00:00 2001 From: Juraj Oravec Date: Sat, 9 Apr 2022 18:00:31 +0200 Subject: [PATCH] QML: Add windows tutorial Signed-off-by: Juraj Oravec --- qml/articles/9.Falkon_windows.md | 86 ++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 qml/articles/9.Falkon_windows.md diff --git a/qml/articles/9.Falkon_windows.md b/qml/articles/9.Falkon_windows.md new file mode 100644 index 0000000..4c3e700 --- /dev/null +++ b/qml/articles/9.Falkon_windows.md @@ -0,0 +1,86 @@ +# Falkon QML Tutorial - 9. Falkon windows + +Hello, in this chapter I will show you how to get work with windows. + +## Access windows api +The windows API can be accessed through code. +```qml +Falkon.Windows +``` +More information can be found in the +[documentation](http://falkon.sgorava.xyz/docs/class_qml_windows.html). + +### Get windows +To get to the windows we can use three methods `get(windowId)`, +`getCurrent()` and `getAll()`. These methods return a window or array of +windows of type `Window` (see +[documentation](http://falkon.sgorava.xyz/docs/class_qml_window.html) +) which van be manipulated further. + +Example: +```qml +/* Get a specific window with known ID */ +var window = Falkon.Windows.get(0) + +/* Get current window */ +var currentWindow = Falkon.Windows.getCurrent() + +/* Get all windows */ +var allWindows = Falkon.Windows.getAll() +``` + +### Create a new window +To create a new window we have to supply it with URL and window type. +The `type` is optional and by default the `NewWindow` will be used. + +```qml +Falkon.Windows.create({ + url: 'https://falkon.org/' + type: Falkon.Enums.WindowType.NewWindow +}) +``` + +### Remove an existing window +To remove an existing window we need to first know its ID in current +session and than we can use the `remove` method. + +```qml +Falkon.Windows.remove(WINDOW_ID) +``` + +### Available signals +#### created(Window) +Triggered when new window was created with the new window in parameter. + +#### removed(Window) +Triggered when window was removed (closed) with the window as a +parameter. + +## Window properties +Each window has some properties which can be read, we can also get to +all tabs which belong to that window. + +```qml +window.id +window.incognito +window.title +window.state +window.type +window.tabs +window.focussed +window.height +window.width +``` + +More detailed information can be found in the +[documentation](http://falkon.sgorava.xyz/docs/class_qml_window.html). + +## Example +The example will create a sidebar in which will be a list of currently +open Falkon windows with information and few buttons. + +![Windows list in the sidebar](../images/tutorial9/sidebar_windows_list.png) + +### Code +The code for this example can be found at +[extensions/qml_tutorial_9](../extensions/qml_tutorial_9)