Nemo.Configuration ConfigurationGroup doesn't store my config

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.

declare properties inside ConfigurationGroup and assign it

1 Like

So I declare property string ssh_key in ConfigGroup.
And then I can just run setValue?
Would be super nice if you provide an example.

Then you just work with given property, it will automatically read initial value and write changes

1 Like

Would you mind to also share the working code example, would be great for reference!

1 Like

Ok, I added it the two properties,

ConfigurationGroup {
        id: config
        path: "/apps/harbour-restic"

        property string backup_destination
        property string ssh_key;
    }

But reading the values somehow still doesn’t work for me:

signal time=1614765748.157417 sender=:1.12 -> destination=(null destination) serial=69 path=/ca/desrt/dconf/Writer/user; interface=ca.desrt.dconf.Writer; member=Notify
   string "/apps/harbour-restic/ssh_key"
   array [
      string ""
   ]

I can find values in the dconf file but they never get read. Any ideas?