Add all view
This commit is contained in:
1 parent
186cff1d73
commit
49d8524597
18 files changed
+1007
-98
No files matched your search
@@ -0,0 +1,102 @@
|
||||
import QtQuick 2.5
|
||||
import "../Components"
|
||||
|
||||
// Écran 3 : choix de l'utilisateur parmi les comptes publics du serveur.
|
||||
Page {
|
||||
id: page
|
||||
|
||||
property var users: page.session ? page.session.publicUsers() : []
|
||||
property bool busy: false
|
||||
property string error: ""
|
||||
|
||||
title: "Qui regarde ?"
|
||||
subtitle: page.session && page.session.currentServer
|
||||
? page.session.currentServer.name + " · " + page.session.currentServer.address
|
||||
: ""
|
||||
initialFocus: userList
|
||||
|
||||
function openUser(index) {
|
||||
if (busy)
|
||||
return;
|
||||
// Dernière carte : « Ajouter un compte » → identifiant libre.
|
||||
if (index >= users.length) {
|
||||
page.navigator.push("Login");
|
||||
return;
|
||||
}
|
||||
var user = users[index];
|
||||
if (user.hasPassword) {
|
||||
page.navigator.push("Login", { username: user.name });
|
||||
return;
|
||||
}
|
||||
// Compte sans mot de passe : connexion directe, comme sur Android TV.
|
||||
error = "";
|
||||
busy = true;
|
||||
page.session.authenticate(user.name, "", function (err) {
|
||||
page.busy = false;
|
||||
if (err) {
|
||||
page.error = err;
|
||||
return;
|
||||
}
|
||||
page.navigator.reset("Home");
|
||||
});
|
||||
}
|
||||
|
||||
Component.onDestruction: if (page.session) page.session.cancel()
|
||||
|
||||
ListView {
|
||||
id: userList
|
||||
anchors {
|
||||
top: parent.top
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
}
|
||||
height: 220
|
||||
orientation: ListView.Horizontal
|
||||
spacing: Theme.spacingL
|
||||
model: page.users.concat([{ name: "Ajouter un compte", add: true }])
|
||||
|
||||
delegate: UserCard {
|
||||
name: modelData.name
|
||||
addCard: modelData.add === true
|
||||
highlighted: ListView.isCurrentItem && userList.activeFocus
|
||||
onClicked: {
|
||||
userList.currentIndex = index;
|
||||
page.openUser(index);
|
||||
}
|
||||
}
|
||||
|
||||
Keys.onPressed: {
|
||||
if (Remote.isAccept(event.key) && currentIndex >= 0) {
|
||||
event.accepted = true;
|
||||
page.openUser(currentIndex);
|
||||
}
|
||||
}
|
||||
KeyNavigation.priority: KeyNavigation.AfterItem
|
||||
KeyNavigation.down: changeServerButton
|
||||
}
|
||||
|
||||
Text {
|
||||
id: statusText
|
||||
anchors {
|
||||
top: userList.bottom
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
}
|
||||
visible: text !== ""
|
||||
text: page.busy ? "Connexion…" : page.error
|
||||
color: page.busy ? Theme.textMuted : Theme.error
|
||||
font.pixelSize: Theme.fontBody
|
||||
wrapMode: Text.WordWrap
|
||||
}
|
||||
|
||||
FocusButton {
|
||||
id: changeServerButton
|
||||
anchors {
|
||||
left: parent.left
|
||||
bottom: parent.bottom
|
||||
}
|
||||
text: "Changer de serveur"
|
||||
KeyNavigation.up: userList
|
||||
onClicked: page.navigator.pop()
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user