2018-10-22 23:53:14 +03:00
import QtQuick 2.0
import Sailfish . Silica 1.0
2018-11-15 00:13:47 +03:00
import Nemo . Configuration 1.0
2018-10-22 23:53:14 +03:00
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" ) )
}
}
2018-10-22 23:53:14 +03:00
Column {
id: column
width: parent . width
spacing: Theme . paddingMedium
PageHeader {
title: qsTr ( "Settings" )
}
SectionHeader {
text: qsTr ( "Accounts" )
}
Label {
id: noAccountsLabel
2018-11-15 00:13:47 +03:00
visible: appSettings . accountIDs . length <= 0
2018-10-22 23:53:14 +03:00
text: qsTr ( "No Nextcloud account yet" )
2018-10-23 23:15:59 +03:00
font.pixelSize: Theme . fontSizeLarge
2018-10-22 23:53:14 +03:00
color: Theme . secondaryHighlightColor
anchors.horizontalCenter: parent . horizontalCenter
}
Repeater {
2018-11-15 00:13:47 +03:00
model: appSettings . accountIDs . length
2018-10-23 23:15:59 +03:00
delegate: ListItem {
id: listItem
2018-11-15 00:13:47 +03:00
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
2018-11-15 00:13:47 +03:00
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-22 23:53:14 +03:00
}
2018-10-23 23:15:59 +03:00
menu: ContextMenu {
MenuItem {
2018-11-15 00:13:47 +03:00
text: qsTr ( "Configure" )
2018-10-23 23:15:59 +03:00
onClicked: {
2018-11-15 00:13:47 +03:00
var login = pageStack . push ( Qt . resolvedUrl ( "LoginDialog.qml" ) , { accountID: appSettings . accountIDs [ index ] } )
2018-10-23 23:15:59 +03:00
login . accepted . connect ( function ( ) {
2018-11-15 00:13:47 +03:00
update ( )
} )
login . rejected . connect ( function ( ) {
2018-10-23 23:15:59 +03:00
} )
}
}
2018-11-15 00:13:47 +03:00
/ * M e n u I t e m {
2018-10-23 23:15:59 +03:00
text: qsTr ( "Delete" )
2018-11-15 00:13:47 +03:00
onClicked: {
accounts . itemAt ( index ) . clear ( )
// TODO reorder items
}
} * /
2018-10-22 23:53:14 +03:00
}
}
}
Button {
text: qsTr ( "Add account" )
anchors.horizontalCenter: parent . horizontalCenter
onClicked: {
2018-11-15 00:13:47 +03:00
var login = pageStack . push ( Qt . resolvedUrl ( "LoginDialog.qml" ) , { accountID: accounts . add ( ) } )
2018-10-22 23:53:14 +03:00
login . accepted . connect ( function ( ) {
2018-11-15 00:13:47 +03:00
var tmpIDs = appSettings . accountIDs
tmpIDs . push ( login . accountID )
appSettings . accountIDs = tmpIDs
} )
login . rejected . connect ( function ( ) {
2018-10-22 23:53:14 +03:00
} )
}
}
}
VerticalScrollDecorator { }
}
}