2022-04-09 18:00:31 +02:00
|
|
|
# Falkon QML Tutorial - 9. Falkon windows
|
|
|
|
|
2022-04-26 19:33:59 +02:00
|
|
|
Hello, in this chapter I will show you how to work with windows.
|
2022-04-09 18:00:31 +02:00
|
|
|
|
|
|
|
## 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
|
2022-04-25 22:08:40 +02:00
|
|
|
parameter.
|
|
|
|
The `Window.id` property provided by this signal is `-1` and because of
|
|
|
|
this I recommend to use `window` itself as a backup identifier.
|
2022-04-09 18:00:31 +02:00
|
|
|
|
|
|
|
## 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
|
2022-04-23 01:17:53 +02:00
|
|
|
open Falkon windows with information and buttons to create and remove
|
|
|
|
windows.
|
2022-04-09 18:00:31 +02:00
|
|
|
|
2022-04-27 22:49:06 +02:00
|
|
|
![Windows list in the sidebar](../images/qml_tutorial9/sidebar_windows_list.png)
|
2022-04-09 18:00:31 +02:00
|
|
|
|
|
|
|
### Code
|
|
|
|
The code for this example can be found at
|
|
|
|
[extensions/qml_tutorial_9](../extensions/qml_tutorial_9)
|