1

QML: Finish Falkon Windows example

Signed-off-by: Juraj Oravec <jurajoravec@mailo.com>
This commit is contained in:
Juraj Oravec 2022-04-23 01:17:53 +02:00
parent 0a22091f19
commit 6b460fae4d
Signed by: SGOrava
GPG Key ID: 13660A3F1D9F093B
3 changed files with 34 additions and 14 deletions

View File

@ -8,3 +8,4 @@
6. [Using clipboard](articles/6.Using_clipboard.md) - [Extension](extensions/qml_tutorial_6/) 6. [Using clipboard](articles/6.Using_clipboard.md) - [Extension](extensions/qml_tutorial_6/)
7. [Adding a sidebar](articles/7.Adding_a_sidebar.md) - [Extension](extensions/qml_tutorial_7/) 7. [Adding a sidebar](articles/7.Adding_a_sidebar.md) - [Extension](extensions/qml_tutorial_7/)
8. [Extension settings](articles/8.Extension_settings.md) - [Extension](extensions/qml_tutorial_8/) 8. [Extension settings](articles/8.Extension_settings.md) - [Extension](extensions/qml_tutorial_8/)
9. [Falkon windows](articles/9.Falkon_windows.md) - [Extension](extensions/qml_tutorial_9/)

View File

@ -77,7 +77,8 @@ More detailed information can be found in the
## Example ## Example
The example will create a sidebar in which will be a list of currently The example will create a sidebar in which will be a list of currently
open Falkon windows with information and few buttons. open Falkon windows with information and buttons to create and remove
windows.
![Windows list in the sidebar](../images/tutorial9/sidebar_windows_list.png) ![Windows list in the sidebar](../images/tutorial9/sidebar_windows_list.png)

View File

@ -15,22 +15,32 @@ Falkon.PluginInterface {
Falkon.Windows.created.connect(function(window) { Falkon.Windows.created.connect(function(window) {
objectTutorial9.windows.append({ objectTutorial9.windows.append({
"id": window.id.toString() "id": window.id.toString(),
"window": window,
"check": false
}) })
}) })
console.log(Falkon.PluginInterface.LateInitState) if (state == 1 /* LateInitState */) {
if (state == 1) {
var windowsAll = Falkon.Windows.getAll() var windowsAll = Falkon.Windows.getAll()
console.log("Creating windows") console.log("Creating windows")
for (var i = 0; i < windowsAll.length; ++i) { for (var i = 0; i < windowsAll.length; ++i) {
objectTutorial9.windows.append({ objectTutorial9.windows.append({
"id": windowsAll[i].id.toString() "id": windowsAll[i].id.toString(),
"window": window,
"check": false
}) })
} }
} }
Falkon.Windows.removed.connect(function(window) {
for (var i = 0; i < objectTutorial9.windows.count; ++i) {
if (objectTutorial9.windows.get(i)["window"] == window) {
objectTutorial9.windows.remove(i, 1)
}
}
})
} }
testPlugin: function() { testPlugin: function() {
@ -60,16 +70,18 @@ Falkon.PluginInterface {
ScrollBar.vertical.policy: ScrollBar.AlwaysOn ScrollBar.vertical.policy: ScrollBar.AlwaysOn
ListView { ListView {
id: listWindows
Component { Component {
id: contactsDelegate id: contactsDelegate
ColumnLayout {
id: wrapper
spacing: 2
CheckBox { CheckBox {
id: checkSelected id: checkSelected
text: "Window " + id checked: check
text: "Id: " + id + " Tabs: " + Falkon.Windows.get(id).tabs.length
onCheckStateChanged: {
objectTutorial9.windows.setProperty(id, "check", checked)
} }
} }
} }
@ -88,7 +100,9 @@ Falkon.PluginInterface {
anchors.bottom: button_remove.top anchors.bottom: button_remove.top
onClicked: function() { onClicked: function() {
; Falkon.Windows.create({
url: "falkon:start"
})
} }
} }
Button { Button {
@ -100,7 +114,11 @@ Falkon.PluginInterface {
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
onClicked: function() { onClicked: function() {
; for (var i = 0; i < objectTutorial9.windows.count; ++i) {
if (objectTutorial9.windows.get(i)["check"]) {
Falkon.Windows.remove(objectTutorial9.windows.get(i)["id"])
}
}
} }
} }
} }