1
FalkonTutorials/qml/extensions/qml_tutorial_9/main.qml
Juraj Oravec 0a22091f19
QML: Add WIP example extension for QML Windows
Signed-off-by: Juraj Oravec <jurajoravec@mailo.com>
2022-04-15 13:54:11 +02:00

110 lines
2.8 KiB
QML

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({
"id": window.id.toString()
})
})
console.log(Falkon.PluginInterface.LateInitState)
if (state == 1) {
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()
})
}
}
}
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 {
Component {
id: contactsDelegate
ColumnLayout {
id: wrapper
spacing: 2
CheckBox {
id: checkSelected
text: "Window " + id
}
}
}
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() {
;
}
}
Button {
id: button_remove
text: i18n('Remove Selected Windows')
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
onClicked: function() {
;
}
}
}
}
}