summary refs log tree commit diff
path: root/resources
diff options
context:
space:
mode:
authorJedi18 <targetakhil@gmail.com>2021-01-29 12:06:38 +0530
committerJedi18 <targetakhil@gmail.com>2021-01-29 12:06:38 +0530
commite09e587796373d4cb2093689c82f9912e5f84c52 (patch)
tree4eabfbd9acb5d7ddc8d30c7aebca12d37e248056 /resources
parentmade requeste changes (diff)
downloadnheko-e09e587796373d4cb2093689c82f9912e5f84c52.tar.xz
shifted isUsernameEditingAllowed to qml from c++
Diffstat (limited to 'resources')
-rw-r--r--resources/qml/UserProfile.qml17
1 files changed, 12 insertions, 5 deletions
diff --git a/resources/qml/UserProfile.qml b/resources/qml/UserProfile.qml
index 79e2b665..4442c97d 100644
--- a/resources/qml/UserProfile.qml
+++ b/resources/qml/UserProfile.qml
@@ -36,7 +36,10 @@ ApplicationWindow {
 
         TextInput {
             id: displayUsername
-            readOnly: !profile.isUsernameEditingAllowed
+
+            property bool isUsernameEditingAllowed
+
+            readOnly: !isUsernameEditingAllowed
             text: profile.displayName
             font.pixelSize: 20
             color: TimelineManager.userColor(profile.userid, colors.window)
@@ -44,20 +47,24 @@ ApplicationWindow {
             Layout.alignment: Qt.AlignHCenter
             selectByMouse: true
 
-            onAccepted: profile.changeUsername(displayUsername.text)
+            onAccepted: {
+                profile.changeUsername(displayUsername.text)
+                displayUsername.isUsernameEditingAllowed = false
+            }
 
             ImageButton {
                 visible: profile.isSelf
                 anchors.leftMargin: 5
                 anchors.left: displayUsername.right
                 anchors.verticalCenter: displayUsername.verticalCenter
-                image: profile.isUsernameEditingAllowed ? ":/icons/icons/ui/checkmark.png" : ":/icons/icons/ui/edit.png"
+                image: displayUsername.isUsernameEditingAllowed ? ":/icons/icons/ui/checkmark.png" : ":/icons/icons/ui/edit.png"
 
                 onClicked: {
-                    if (profile.isUsernameEditingAllowed) {
+                    if (displayUsername.isUsernameEditingAllowed) {
                         profile.changeUsername(displayUsername.text)
+                        displayUsername.isUsernameEditingAllowed = false
                     } else {
-                        profile.allowUsernameEditing(true)
+                        displayUsername.isUsernameEditingAllowed = true
                     }
                 }
             }