1
FalkonTutorials/qml/extensions/qml_tutorial_8/main.qml

75 lines
2.0 KiB
QML
Raw Normal View History

import org.kde.falkon 1.0 as Falkon
import QtQuick.Controls 2.3
import QtQuick 2.3
Falkon.PluginInterface {
Falkon.Settings {
id: settings
name: 'Tutorial8_settings'
}
init: function(state, settingsPath) {
console.log(i18n('"Tutorial8" plugin loaded'))
}
testPlugin: function() {
return true
}
unload: function() {
console.log(i18n('"Tutorial8" plugin unloaded'))
}
Falkon.BrowserAction {
name: 'QML Tutorial 8'
identity: 'qml-tutorial-8-id'
title: i18n('Qml Tutorial 8')
toolTip: i18n('My little button')
icon: 'falkon'
location: Falkon.BrowserAction.NavigationToolBar | (settings.value({key: 'statusbar', defaultValue: 1}) == 1 ? Falkon.BrowserAction.StatusBar : 0)
popup: Rectangle {
width: 100;
height: 100;
}
}
settingsWindow: Rectangle {
id: window
width: 256
height: 200
Image {
id: image
source: 'qrc:/icons/other/about.svg'
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
}
CheckBox {
id: checkStatusbar
checked: settings.value({key: 'statusbar', defaultValue: 1}) == 1
text: 'Show in statusbar'
anchors.top: image.bottom
}
Button {
id: button
text: i18n('Save')
width: 256
height: 50
anchors.top: checkStatusbar.bottom
onClicked: function() {
var res = settings.setValue({
key: 'statusbar',
value: checkStatusbar.checked ? 1 : 0
})
var sync = settings.sync()
if (res && sync) {
button.text = i18n('Saved!')
} else {
button.text = i18n('Error occurred, try again!')
}
}
}
}
}