Change layout of location selector

This commit is contained in:
Angela Mazzurco 2017-07-22 15:32:17 +02:00
parent db0292f6e0
commit 962cda0947

View File

@ -34,14 +34,14 @@ Item
{ {
name: "selectLocation" name: "selectLocation"
PropertyChanges { target: locationsListView; visible: true } PropertyChanges { target: locationsListView; visible: true }
PropertyChanges { target: bottomButton; visible: true } PropertyChanges { target: createNewButton; visible: true }
PropertyChanges { target: loginView; visible: false } PropertyChanges { target: loginView; visible: false }
}, },
State State
{ {
name: "createLocation" name: "createLocation"
PropertyChanges { target: locationsListView; visible: false } PropertyChanges { target: locationsListView; visible: false }
PropertyChanges { target: bottomButton; visible: false } PropertyChanges { target: createNewButton; visible: false }
PropertyChanges PropertyChanges
{ {
target: loginView target: loginView
@ -59,8 +59,8 @@ Item
JSON.stringify(jsonData)) JSON.stringify(jsonData))
mainWindow.user_name = login mainWindow.user_name = login
locationView.state = "selectLocation" locationView.state = "selectLocation"
bottomButton.enabled = false createNewButton.enabled = false
bottomButton.text = "Creating profile..." createNewButton.text = "Creating profile..."
} }
} }
}, },
@ -68,7 +68,7 @@ Item
{ {
name: "login" name: "login"
PropertyChanges { target: locationsListView; visible: false } PropertyChanges { target: locationsListView; visible: false }
PropertyChanges { target: bottomButton; visible: false } PropertyChanges { target: createNewButton; visible: false }
PropertyChanges PropertyChanges
{ {
target: loginView target: loginView
@ -116,6 +116,15 @@ Item
onFocusChanged: focus && requestLocationsList() onFocusChanged: focus && requestLocationsList()
Component.onCompleted: requestLocationsList() Component.onCompleted: requestLocationsList()
Button
{
id: createNewButton
text: "Create new location"
anchors.top: parent.top
anchors.horizontalCenter: parent.horizontalCenter
onClicked: locationView.state = "createLocation"
}
JSONListModel JSONListModel
{ {
id: locationsModel id: locationsModel
@ -125,12 +134,17 @@ Item
{ {
id: locationsListView id: locationsListView
width: parent.width width: parent.width
anchors.top: parent.top height: parent.height - createNewButton.height
anchors.bottom: bottomButton.top anchors.top: createNewButton.bottom
anchors.topMargin: 10
anchors.bottom: parent.bottom
anchors.horizontalCenter: parent.horizontalCenter
model: locationsModel.model model: locationsModel.model
clip: true
delegate: Button delegate: Button
{ {
text: model.name text: model.name
anchors.horizontalCenter: parent.horizontalCenter
onClicked: onClicked:
{ {
loginView.login = text loginView.login = text
@ -142,15 +156,6 @@ Item
visible: false visible: false
} }
Button
{
id: bottomButton
text: "Create new location"
anchors.bottom: parent.bottom
anchors.horizontalCenter: parent.horizontalCenter
onClicked: locationView.state = "createLocation"
}
RsLoginPassView RsLoginPassView
{ {
id: loginView id: loginView
@ -192,8 +197,8 @@ Item
else else
{ {
// if Already logged in // if Already logged in
bottomButton.enabled = false createNewButton.enabled = false
bottomButton.text = "Unlocking location..." createNewButton.text = "Unlocking location..."
locationView.attemptLogin = false locationView.attemptLogin = false
locationView.state = "selectLocation" locationView.state = "selectLocation"
locationsListView.enabled = false locationsListView.enabled = false