harbour-nextcloudnotes/qml/pages/SettingsPage.qml

105 lines
3.8 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: nextcloudAccounts.count <= 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: nextcloudAccounts.count
2018-10-23 23:15:59 +03:00
delegate: ListItem {
id: accountListItem
contentHeight: textSwitch.height
highlighted: textSwitch.down
2018-10-23 23:15:59 +03:00
TextSwitch {
id: textSwitch
2018-10-23 23:15:59 +03:00
automaticCheck: false
checked: index === appSettings.currentAccount
text: nextcloudAccounts.itemAt(index).name.length <= 0 ? qsTr("Unnamed account") : nextcloudAccounts.itemAt(index).name
description: nextcloudAccounts.itemAt(index).username + "@" + nextcloudAccounts.itemAt(index).server// : qsTr("Press and hold to configure")
onClicked: appSettings.currentAccount = index
onPressAndHold: openMenu()
}
2018-10-23 23:15:59 +03:00
menu: ContextMenu {
MenuItem {
text: qsTr("Edit")
2018-10-23 23:15:59 +03:00
onClicked: {
var login = pageStack.push(Qt.resolvedUrl("LoginDialog.qml"), { account: index })
2018-10-23 23:15:59 +03:00
login.accepted.connect(function() {
})
login.rejected.connect(function() {
2018-10-23 23:15:59 +03:00
})
}
}
MenuItem {
visible: index === nextcloudAccounts.count-1
2018-10-23 23:15:59 +03:00
text: qsTr("Delete")
onClicked: {
accountListItem.remorseAction(qsTr("Deleting account"), function() {
nextcloudAccounts.itemAt(index).clear()
nextcloudAccounts.pop()
})
}
}
}
}
}
Button {
text: qsTr("Add account")
anchors.horizontalCenter: parent.horizontalCenter
onClicked: {
nextcloudAccounts.add()
var login = pageStack.push(Qt.resolvedUrl("LoginDialog.qml"), { account:nextcloudAccounts.count-1 })
login.accepted.connect(function() {
console.log("Adding account " + nextcloudAccounts.itemAt(login.account).name)
if (appSettings.currentAccount < 0)
appSettings.currentAccount = nextcloudUUIDs.value.length-1
appWindow.update()
})
login.rejected.connect(function() {
nextcloudAccounts.pop()
})
}
}
}
VerticalScrollDecorator {}
}
}