From c16edbc50f119c9705ca4339e07b3efab3a61ac7 Mon Sep 17 00:00:00 2001 From: Miquel Lionel Date: Mon, 18 Oct 2021 22:15:58 +0100 Subject: Add "Change avatar" button to settings page --- qml/SettingsPage.qml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'qml') 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 -- cgit v1.2.3-70-g09d2