85 anchors.centerIn: parent |
86 anchors.centerIn: parent |
86 z: 22; |
87 z: 22; |
87 |
88 |
88 Behavior on width { |
89 Behavior on width { |
89 NumberAnimation {} |
90 NumberAnimation {} |
90 enabled: initialWidth != 0 |
91 enabled: nameInputDialog.initialWidth != 0 |
91 } |
92 } |
92 |
93 |
|
94 onOpened: nameInputText.focus = true; |
|
95 onClosed: { |
|
96 nameInputText.focus = false; |
|
97 if (nameInputText.text != "") |
|
98 Logic.saveHighScore(nameInputText.text); |
|
99 } |
93 Text { |
100 Text { |
94 id: dialogText |
101 id: dialogText |
95 anchors { left: nameInputDialog.left; leftMargin: 20; verticalCenter: parent.verticalCenter } |
102 anchors { left: nameInputDialog.left; leftMargin: 20; verticalCenter: parent.verticalCenter } |
96 text: "You won! Please enter your name: " |
103 text: "You won! Please enter your name: " |
97 } |
104 } |
|
105 MouseArea { |
|
106 anchors.fill: parent |
|
107 onClicked: { |
|
108 if (nameInputText.text == "") |
|
109 nameInputText.openSoftwareInputPanel(); |
|
110 else |
|
111 nameInputDialog.forceClose(); |
|
112 } |
|
113 } |
98 |
114 |
99 TextInput { |
115 TextInput { |
100 id: nameInputText |
116 id: nameInputText |
101 anchors { verticalCenter: parent.verticalCenter; left: dialogText.right } |
117 anchors { verticalCenter: parent.verticalCenter; left: dialogText.right } |
102 focus: true |
118 focus: false |
103 |
119 autoScroll: false |
|
120 maximumLength: 24 |
104 onTextChanged: { |
121 onTextChanged: { |
105 var newWidth = nameInputText.width + dialogText.width + 40; |
122 var newWidth = nameInputText.width + dialogText.width + 40; |
106 if ( (newWidth > nameInputDialog.width && newWidth < screen.width) |
123 if ( (newWidth > nameInputDialog.width && newWidth < screen.width) |
107 || (nameInputDialog.width > nameInputDialog.initialWidth) ) |
124 || (nameInputDialog.width > nameInputDialog.initialWidth) ) |
108 nameInputDialog.width = newWidth; |
125 nameInputDialog.width = newWidth; |
109 } |
126 } |
110 onAccepted: { |
127 onAccepted: { |
111 if (nameInputDialog.opacity == 1 && nameInputText.text != "") |
|
112 Logic.saveHighScore(nameInputText.text); |
|
113 nameInputDialog.forceClose(); |
128 nameInputDialog.forceClose(); |
114 } |
129 } |
115 } |
130 } |
116 } |
131 } |
117 |
132 |