- translations/: harbour-hermes-it/fr/de.ts (78 stringhe ciascuna, 100% tradotte) + caricamento in main.cpp in base alla lingua di sistema - .pro: CONFIG += sailfishapp_i18n + TRANSLATIONS (pattern ufficiale Sailfish: .qm generati in build e installati in /usr/share/harbour-hermes/translations) - stringhe visibili del core in tr(): ApiClient, ChatModel, Recorder (VoiceRecorder era gia' ok); plurali dei messaggi corretti (1 message / %1 messages) in SessionsPage e CoverPage - spec: BuildRequires qt5-qttools-linguist + %files translations - README/BUILD: sezione Localization + workflow lupdate/lrelease Verificato: lupdate 78/78 per it/fr/de, lrelease OK, e test runtime di caricamento .qm (tutte le traduzioni risolte nei contesti corretti).
128 lines
3.5 KiB
QML
128 lines
3.5 KiB
QML
import QtQuick 2.0
|
|
import Sailfish.Silica 1.0
|
|
|
|
// Lista delle sessioni della Web UI di Hermes (sidebar).
|
|
Page {
|
|
id: page
|
|
|
|
// true solo quando e' questa pagina a chiedere una nuova sessione:
|
|
// serve a distinguere la creazione dall'apertura di una sessione esistente.
|
|
property bool expectNewSession: false
|
|
|
|
SilicaListView {
|
|
id: list
|
|
anchors.fill: parent
|
|
model: api.sessions
|
|
spacing: Theme.paddingSmall
|
|
|
|
header: PageHeader { title: qsTr("Sessions") }
|
|
|
|
PullDownMenu {
|
|
MenuItem {
|
|
text: qsTr("New session")
|
|
onClicked: page.createSession()
|
|
}
|
|
MenuItem {
|
|
text: qsTr("Refresh")
|
|
onClicked: page.refresh()
|
|
}
|
|
MenuItem {
|
|
text: qsTr("Settings")
|
|
onClicked: page.openSettings()
|
|
}
|
|
MenuItem {
|
|
text: qsTr("Sign out")
|
|
onClicked: page.signOut()
|
|
}
|
|
}
|
|
|
|
delegate: ListItem {
|
|
id: item
|
|
contentHeight: col.height + Theme.paddingMedium
|
|
|
|
Column {
|
|
id: col
|
|
x: Theme.horizontalPageMargin
|
|
width: parent.width - 2 * Theme.horizontalPageMargin
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
spacing: Theme.paddingSmall / 2
|
|
|
|
Label {
|
|
width: parent.width
|
|
truncationMode: TruncationMode.Fade
|
|
color: item.highlighted ? Theme.highlightColor : Theme.primaryColor
|
|
text: model.title ? model.title : model.session_id
|
|
}
|
|
|
|
Label {
|
|
width: parent.width
|
|
font.pixelSize: Theme.fontSizeExtraSmall
|
|
color: Theme.secondaryColor
|
|
text: page.describe(model.message_count, model.updated_at)
|
|
}
|
|
}
|
|
|
|
onClicked: page.openSession(model.session_id)
|
|
}
|
|
|
|
ViewPlaceholder {
|
|
enabled: api.sessionsCount === 0 && !api.busy
|
|
text: qsTr("No sessions")
|
|
hintText: qsTr("Pull down to create a new session")
|
|
}
|
|
|
|
VerticalScrollDecorator {}
|
|
}
|
|
|
|
BusyIndicator {
|
|
anchors.centerIn: parent
|
|
size: BusyIndicatorSize.Large
|
|
running: api.busy
|
|
}
|
|
|
|
Connections {
|
|
target: api
|
|
onLoggedInChanged: {
|
|
if (!api.loggedIn)
|
|
pageStack.replace(Qt.resolvedUrl("LoginPage.qml"))
|
|
}
|
|
onSessionOpened: {
|
|
if (page.expectNewSession) {
|
|
page.expectNewSession = false
|
|
pageStack.push(Qt.resolvedUrl("ChatPage.qml"),
|
|
{ sessionId: api.session.session_id })
|
|
}
|
|
}
|
|
}
|
|
|
|
Component.onCompleted: api.refreshSessions()
|
|
|
|
function refresh() {
|
|
api.refreshSessions()
|
|
}
|
|
|
|
function openSettings() {
|
|
pageStack.push(Qt.resolvedUrl("SettingsPage.qml"))
|
|
}
|
|
|
|
function signOut() {
|
|
api.logout()
|
|
}
|
|
|
|
function openSession(id) {
|
|
expectNewSession = false
|
|
pageStack.push(Qt.resolvedUrl("ChatPage.qml"), { sessionId: id })
|
|
}
|
|
|
|
function createSession() {
|
|
expectNewSession = true
|
|
chat.newSession()
|
|
}
|
|
|
|
function describe(n, u) {
|
|
var c = n ? n : 0
|
|
var d = new Date((u ? u : 0) * 1000)
|
|
return (c === 1 ? qsTr("1 message") : qsTr("%1 messages").arg(c)) + " · " + Qt.formatDateTime(d, "dd/MM HH:mm")
|
|
}
|
|
}
|