diff options
author | Miquel Lionel <lionel@les-miquelots.net> | 2021-10-18 22:15:58 +0100 |
---|---|---|
committer | link2xt <link2xt@testrun.org> | 2021-10-24 14:02:06 +0300 |
commit | c16edbc50f119c9705ca4339e07b3efab3a61ac7 (patch) | |
tree | 4a2895c4f472b2ff13b9ae249155ba1b83ccd6ee | |
parent | bb6244f9fa200d8442b9256fc25d1c1bc9578d26 (diff) | |
download | kdeltachat-c16edbc50f119c9705ca4339e07b3efab3a61ac7.tar.gz kdeltachat-c16edbc50f119c9705ca4339e07b3efab3a61ac7.zip |
Add "Change avatar" button to settings page
-rw-r--r-- | qml/SettingsPage.qml | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/qml/SettingsPage.qml b/qml/SettingsPage.qml index 138fe71..d0f8065 100644 --- a/qml/SettingsPage.qml +++ b/qml/SettingsPage.qml @@ -1,6 +1,7 @@ import DeltaChat 1.0 import QtQuick 2.12 import QtQuick.Controls 2.12 +import QtQuick.Dialogs 1.3 import QtQuick.Layouts 1.12 import org.kde.kirigami 2.12 as Kirigami @@ -13,10 +14,35 @@ Kirigami.ScrollablePage { Kirigami.FormLayout { Image { + id: pfp Kirigami.FormData.label: "Avatar: " source: "file:" + root.context.getConfig("selfavatar") } + FileDialog{ + id: changePfpDialog + folder: shortcuts.pictures + nameFilters: [ "Image files (*.jpg *.png *.gif)" ] + onAccepted: { + var url = changePfpDialog.fileUrl.toString(); + if (url.startsWith("file://") && url.length > 0) { + var filename = url.substring(7); + console.log("Set avatar to : " + filename) + root.context.setConfig("selfavatar", filename) + pfp.source = "file:" + root.context.getConfig("selfavatar") + } + } + + } + + Button { + id: changePfpBtn + text: "Change avatar" + icon.name: "avatar-default" + hoverEnabled: true + onClicked: changePfpDialog.open() + } + TextField { id: displayNameField |