harbour-nextcloudnotes/qml/pages/SettingsPage.qml

101 lines
3.7 KiB
QML
Raw Normal View History

import QtQuick 2.0
import Sailfish.Silica 1.0
import Nemo.Configuration 1.0
Page {
id: page
SilicaFlickable {
id: flickable
anchors.fill: parent
contentHeight: column.height
2018-10-23 23:15:59 +03:00
PullDownMenu {
MenuItem {
text: qsTr("About")
onClicked: pageStack.push(Qt.resolvedUrl("AboutPage.qml"))
}
}
Column {
id: column
width: parent.width
spacing: Theme.paddingMedium
PageHeader {
title: qsTr("Settings")
}
SectionHeader {
text: qsTr("Accounts")
}
Label {
id: noAccountsLabel
visible: appSettings.accountIDs.length <= 0
text: qsTr("No Nextcloud account yet")
2018-10-23 23:15:59 +03:00
font.pixelSize: Theme.fontSizeLarge
color: Theme.secondaryHighlightColor
anchors.horizontalCenter: parent.horizontalCenter
}
Repeater {
model: appSettings.accountIDs.length
2018-10-23 23:15:59 +03:00
delegate: ListItem {
id: listItem
ConfigurationGroup {
id: account
path: "/apps/harbour-nextcloudnotes/accounts/" + appSettings.accountIDs[index]
}
2018-10-23 23:15:59 +03:00
TextSwitch {
anchors.verticalCenter: parent.verticalCenter
automaticCheck: false
checked: index === appSettings.currentAccount
text: account.value("name", qsTr("Account") + " " + (index+1), String)
//enabled: account.value("valid", false, Boolean)
description: account.value("valid", false, Boolean) ? account.value("username", qsTr("user"), String) + "@" + account.value("server", qsTr("server"), String) : qsTr("Press and hold to configure")
onClicked: if (account.value("valid", false, Boolean)) appSettings.currentAccount = index
2018-10-23 23:15:59 +03:00
onPressAndHold: listItem.openMenu()
}
2018-10-23 23:15:59 +03:00
menu: ContextMenu {
MenuItem {
text: qsTr("Configure")
2018-10-23 23:15:59 +03:00
onClicked: {
var login = pageStack.push(Qt.resolvedUrl("LoginDialog.qml"), { accountID: appSettings.accountIDs[index] })
2018-10-23 23:15:59 +03:00
login.accepted.connect(function() {
update()
})
login.rejected.connect(function() {
2018-10-23 23:15:59 +03:00
})
}
}
/*MenuItem {
2018-10-23 23:15:59 +03:00
text: qsTr("Delete")
onClicked: {
accounts.itemAt(index).clear()
// TODO reorder items
}
}*/
}
}
}
Button {
text: qsTr("Add account")
anchors.horizontalCenter: parent.horizontalCenter
onClicked: {
var login = pageStack.push(Qt.resolvedUrl("LoginDialog.qml"), { accountID: accounts.add() })
login.accepted.connect(function() {
var tmpIDs = appSettings.accountIDs
tmpIDs.push(login.accountID)
appSettings.accountIDs = tmpIDs
})
login.rejected.connect(function() {
})
}
}
}
VerticalScrollDecorator {}
}
}