diff --git a/qml/README.md b/qml/README.md index fcb6f53..8cb7b83 100644 --- a/qml/README.md +++ b/qml/README.md @@ -8,3 +8,4 @@ 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/) 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/) diff --git a/qml/articles/9.Falkon_windows.md b/qml/articles/9.Falkon_windows.md index 4c3e700..2e246a5 100644 --- a/qml/articles/9.Falkon_windows.md +++ b/qml/articles/9.Falkon_windows.md @@ -77,7 +77,8 @@ More detailed information can be found in the ## Example 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) diff --git a/qml/extensions/qml_tutorial_9/main.qml b/qml/extensions/qml_tutorial_9/main.qml index 115ae41..8a5f426 100644 --- a/qml/extensions/qml_tutorial_9/main.qml +++ b/qml/extensions/qml_tutorial_9/main.qml @@ -15,22 +15,32 @@ Falkon.PluginInterface { Falkon.Windows.created.connect(function(window) { objectTutorial9.windows.append({ - "id": window.id.toString() + "id": window.id.toString(), + "window": window, + "check": false }) }) - console.log(Falkon.PluginInterface.LateInitState) - - if (state == 1) { + if (state == 1 /* LateInitState */) { var windowsAll = Falkon.Windows.getAll() console.log("Creating windows") for (var i = 0; i < windowsAll.length; ++i) { 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() { @@ -60,16 +70,18 @@ Falkon.PluginInterface { ScrollBar.vertical.policy: ScrollBar.AlwaysOn ListView { + id: listWindows + Component { id: contactsDelegate - ColumnLayout { - id: wrapper - spacing: 2 + CheckBox { + id: checkSelected + checked: check + text: "Id: " + id + " Tabs: " + Falkon.Windows.get(id).tabs.length - CheckBox { - id: checkSelected - text: "Window " + id + onCheckStateChanged: { + objectTutorial9.windows.setProperty(id, "check", checked) } } } @@ -88,7 +100,9 @@ Falkon.PluginInterface { anchors.bottom: button_remove.top onClicked: function() { - ; + Falkon.Windows.create({ + url: "falkon:start" + }) } } Button { @@ -100,7 +114,11 @@ Falkon.PluginInterface { anchors.bottom: parent.bottom 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"]) + } + } } } }