import QtQuick 2.0
import Sailfish.Silica 1.0
import Sailfish.Pickers 1.0
import Nemo.Configuration 1.0
Page {
id: configPage
Component.onCompleted: console.log("COMPLETED")
allowedOrientations: defaultAllowedOrientations
property string backupDestination: config.value("backup_destination", "", String);
property string sshKeyPath: config.value("ssh_key", "~/.ssh/id_rsa", String);
Component.onDestruction: {
config.setValue("backup_destination", backupDestination)
config.setValue("ssh_key", sshKeyPath)
config.sync()
console.log("Configuration written to disk.")
}
ConfigurationGroup {
id: config
path: "/apps/harbour-restic"
}
SilicaFlickable {
anchors.fill: parent
contentHeight: configColumn.height + Theme.paddingLarge
flickableDirection: Flickable.VerticalFlick
VerticalScrollDecorator {}
Column {
id: configColumn
width: parent.width
PageHeader {
title: "Restic configuration"
}
TextField {
id: backupDestinationEntry
label: "Backup destination"
labelVisible: true
placeholderText: label + ": No path or URL set"
width: parent.width
text: configPage.backupDestination
inputMethodHints: Qt.ImhUrlCharactersOnly | Qt.ImhNoAutoUppercase | Qt.ImhNoPredictiveText
Binding { target: configPage; property: "backupDestination"; value: backupDestinationEntry.text }
}
ValueButton {
label: "SSH key"
value: configPage.sshKeyPath
onClicked: pageStack.push(sshKeyPicker)
visible: {
var patt = /^sftp:/;
return patt.test(configPage.backupDestination)
}
}
}
}
Component {
id: sshKeyPicker
FilePickerPage {
title: "Set path of SSH key"
onSelectedContentPropertiesChanged: {
configPage.sshKeyPath = selectedContentProperties.filePath
}
}
}
}
Nothing gets stored, I get “Configuration written to disk.” in the output.