1
FalkonTutorials/qml/extensions/qml_tutorial_8/main.qml
Juraj Oravec 5e6b860531
QML: Use Pane as container in settings example
Using QtQuick.Controls Pane allows the resulting UI element to be styled
by system theme.
Using Rectangle forces some color, if not specified white is used.

Signed-off-by: Juraj Oravec <jurajoravec@mailo.com>
2022-07-14 10:33:45 +02:00

79 lines
2.0 KiB
QML

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: Pane {
width: 100;
height: 100;
}
}
settingsWindow: Pane {
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: i18n('Show in statusbar')
anchors.top: image.bottom
}
Button {
id: button
text: i18n('Save')
height: 50
anchors.top: checkStatusbar.bottom
anchors.left: parent.left
anchors.right: parent.right
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!')
}
}
}
}
}