1

QML: Add windows tutorial

Signed-off-by: Juraj Oravec <jurajoravec@mailo.com>
This commit is contained in:
Juraj Oravec 2022-04-09 18:00:31 +02:00
parent 42c6991a8f
commit dcb3c44b1a
Signed by: SGOrava
GPG Key ID: 13660A3F1D9F093B

View File

@ -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)