1
FalkonTutorials/qml/articles/9.Falkon_windows.md
Juraj Oravec 2f762366d3
QML: Mention broken window id inremoved signal
Signed-off-by: Juraj Oravec <jurajoravec@mailo.com>
2022-04-25 22:08:40 +02:00

2.3 KiB

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.

Falkon.Windows

More information can be found in the documentation.

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 ) which van be manipulated further.

Example:

/* 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.

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.

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.
The Window.id property provided by this signal is -1 and because of this I recommend to use window itself as a backup identifier.

Window properties

Each window has some properties which can be read, we can also get to all tabs which belong to that window.

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.

Example

The example will create a sidebar in which will be a list of currently open Falkon windows with information and buttons to create and remove windows.

Windows list in the sidebar

Code

The code for this example can be found at extensions/qml_tutorial_9