2022-04-15 13:54:11 +02:00
|
|
|
import org.kde.falkon 1.0 as Falkon
|
|
|
|
import QtQuick.Controls 2.3
|
|
|
|
import QtQuick.Layouts 1.0
|
|
|
|
import QtQuick 2.3
|
|
|
|
|
|
|
|
Falkon.PluginInterface {
|
|
|
|
|
|
|
|
QtObject {
|
|
|
|
id: objectTutorial9
|
|
|
|
property ListModel windows: ListModel {}
|
|
|
|
}
|
|
|
|
|
|
|
|
init: function(state, settingsPath) {
|
|
|
|
console.log(i18n('"Tutorial9" plugin loaded'))
|
|
|
|
|
|
|
|
Falkon.Windows.created.connect(function(window) {
|
|
|
|
objectTutorial9.windows.append({
|
2022-04-23 01:17:53 +02:00
|
|
|
"id": window.id.toString(),
|
|
|
|
"window": window,
|
|
|
|
"check": false
|
2022-04-15 13:54:11 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2022-04-23 01:17:53 +02:00
|
|
|
if (state == 1 /* LateInitState */) {
|
2022-04-15 13:54:11 +02:00
|
|
|
var windowsAll = Falkon.Windows.getAll()
|
|
|
|
console.log("Creating windows")
|
|
|
|
|
|
|
|
for (var i = 0; i < windowsAll.length; ++i) {
|
|
|
|
objectTutorial9.windows.append({
|
2022-04-23 01:17:53 +02:00
|
|
|
"id": windowsAll[i].id.toString(),
|
|
|
|
"window": window,
|
|
|
|
"check": false
|
2022-04-15 13:54:11 +02:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2022-04-23 01:17:53 +02:00
|
|
|
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
2022-04-15 13:54:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
testPlugin: function() {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
unload: function() {
|
|
|
|
console.log(i18n('"Tutorial9" plugin unloaded'))
|
|
|
|
}
|
|
|
|
|
|
|
|
Falkon.SideBar {
|
|
|
|
name: 'qml-tutorial9-sidebar'
|
|
|
|
title: i18n('Tutorial 9 - QML SideBar')
|
|
|
|
icon: 'falkon'
|
|
|
|
checkable: true
|
|
|
|
shortcut: 'Ctrl+Shift+Alt+W'
|
|
|
|
Rectangle {
|
|
|
|
ScrollView {
|
|
|
|
id: scroll_windows
|
|
|
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.bottom: button_add.top
|
|
|
|
|
|
|
|
ScrollBar.horizontal.policy: ScrollBar.AlwaysOn
|
|
|
|
ScrollBar.vertical.policy: ScrollBar.AlwaysOn
|
|
|
|
|
|
|
|
ListView {
|
2022-04-23 01:17:53 +02:00
|
|
|
id: listWindows
|
|
|
|
|
2022-04-15 13:54:11 +02:00
|
|
|
Component {
|
|
|
|
id: contactsDelegate
|
|
|
|
|
2022-04-23 01:17:53 +02:00
|
|
|
CheckBox {
|
|
|
|
id: checkSelected
|
|
|
|
checked: check
|
|
|
|
text: "Id: " + id + " Tabs: " + Falkon.Windows.get(id).tabs.length
|
2022-04-15 13:54:11 +02:00
|
|
|
|
2022-04-23 01:17:53 +02:00
|
|
|
onCheckStateChanged: {
|
|
|
|
objectTutorial9.windows.setProperty(id, "check", checked)
|
2022-04-15 13:54:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
model: objectTutorial9.windows
|
|
|
|
delegate: contactsDelegate
|
|
|
|
focus: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Button {
|
|
|
|
id: button_add
|
|
|
|
text: i18n('Add Window')
|
|
|
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.bottom: button_remove.top
|
|
|
|
|
|
|
|
onClicked: function() {
|
2022-04-23 01:17:53 +02:00
|
|
|
Falkon.Windows.create({
|
|
|
|
url: "falkon:start"
|
|
|
|
})
|
2022-04-15 13:54:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
Button {
|
|
|
|
id: button_remove
|
|
|
|
text: i18n('Remove Selected Windows')
|
|
|
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
|
|
|
|
onClicked: function() {
|
2022-04-23 01:17:53 +02:00
|
|
|
for (var i = 0; i < objectTutorial9.windows.count; ++i) {
|
|
|
|
if (objectTutorial9.windows.get(i)["check"]) {
|
|
|
|
Falkon.Windows.remove(objectTutorial9.windows.get(i)["id"])
|
|
|
|
}
|
|
|
|
}
|
2022-04-15 13:54:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|