harbour-nextcloudnotes/qml/pages/SettingsPage.qml

217 lines
8.7 KiB
QML
Raw Normal View History

import QtQuick 2.0
import Sailfish.Silica 1.0
import Nemo.Configuration 1.0
2018-12-11 02:10:51 +03:00
import Nemo.Notifications 1.0
Page {
id: page
SilicaFlickable {
id: flickable
anchors.fill: parent
2018-12-13 01:10:45 +03:00
contentHeight: column.height + Theme.paddingLarge
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
2018-12-07 02:30:18 +03:00
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 {
2018-12-07 02:30:18 +03:00
id: accountRepeater
model: appSettings.accountIDs
2018-10-23 23:15:59 +03:00
delegate: ListItem {
id: accountListItem
contentHeight: accountTextSwitch.height
highlighted: accountTextSwitch.down
2018-12-07 02:30:18 +03:00
ConfigurationGroup {
id: account
path: "/apps/harbour-nextcloudnotes/accounts/" + modelData
Component.onCompleted: {
accountTextSwitch.text = value("name", qsTr("Unnamed account"), String)
accountTextSwitch.description = account.value("username", qsTr("unknown"), String) + "@" + account.value("server", qsTr("unknown"), String)
}
}
2018-10-23 23:15:59 +03:00
TextSwitch {
id: accountTextSwitch
2018-10-23 23:15:59 +03:00
automaticCheck: false
checked: modelData === appSettings.currentAccount
2018-12-07 02:30:18 +03:00
onClicked: {
appSettings.currentAccount = modelData
2018-12-07 02:30:18 +03:00
}
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: {
2018-12-07 02:30:18 +03:00
var login = pageStack.replace(Qt.resolvedUrl("LoginDialog.qml"), { accountId: modelData })
2018-10-23 23:15:59 +03:00
}
}
MenuItem {
2018-10-23 23:15:59 +03:00
text: qsTr("Delete")
onClicked: {
accountListItem.remorseAction(qsTr("Deleting account"), function() {
2018-12-07 02:30:18 +03:00
console.log("Deleting " + modelData)
appSettings.removeAccount(modelData)
})
}
}
}
}
}
Button {
text: qsTr("Add account")
anchors.horizontalCenter: parent.horizontalCenter
onClicked: {
2018-12-07 02:30:18 +03:00
var newAccountID = appSettings.addAccount()
var login = pageStack.replace(Qt.resolvedUrl("LoginDialog.qml"), { accountId: newAccountID, addingNew: true })
}
}
SectionHeader {
text: qsTr("Synchronization")
}
ComboBox {
id: autoSyncComboBox
label: qsTr("Auto-Sync")
description: qsTr("Periodically pull notes from the server")
menu: ContextMenu {
Repeater {
id: autoSyncIntervalRepeater
2018-12-11 02:10:51 +03:00
model: [0, 3, 5, 10, 20, 30, 42, 60, 120, 300, 600]
MenuItem {
text: modelData === 0 ?
qsTr("Disabled") : (qsTr("every") + " " +
(parseInt(modelData / 60) ?
(parseInt(modelData / 60) + " " + qsTr("Minutes")) :
(modelData + " " + qsTr("Seconds"))))
Component.onCompleted: {
if (modelData === appSettings.autoSyncInterval) {
autoSyncComboBox.currentIndex = index
2018-12-11 02:10:51 +03:00
theAnswer.enabled = true
}
}
}
}
}
2018-12-11 02:10:51 +03:00
onCurrentIndexChanged: {
appSettings.autoSyncInterval = autoSyncIntervalRepeater.model[currentIndex]
if (autoSyncIntervalRepeater.model[currentIndex] === 42 && theAnswer.enabled) {
2019-04-07 13:28:38 +03:00
console.log(theAnswer.body)
2018-12-11 02:10:51 +03:00
theAnswer.publish()
}
}
Notification {
id: theAnswer
property bool enabled: false
icon: "image://theme/icon-lock-information"
summary: qsTr("The Answer is 42")
body: qsTr("Congratulation you found the Answer to the Ultimate Question of Life, The Universe, and Everything!")
previewSummary: summary
category: "Easter Egg"
urgency: Notification.Low
}
}
SectionHeader {
text: qsTr("Appearance")
}
ComboBox {
2018-11-25 16:08:00 +03:00
id: sortByComboBox
property var names: { "date" : qsTr("Last edited"),
"category" : qsTr("Category"),
"title" : qsTr("Title alphabetically"),
"none" : qsTr("No sorting") }
label: qsTr("Sort notes by")
2018-12-04 17:22:57 +03:00
description: qsTr("This will also change how the notes are grouped")
menu: ContextMenu {
Repeater {
2018-11-25 16:08:00 +03:00
id: sortByRepeater
model: noteListModel.sortingCriteria()
MenuItem {
text: sortByComboBox.names[modelData]
Component.onCompleted: {
2018-11-25 16:08:00 +03:00
if (modelData === appSettings.sortBy) {
sortByComboBox.currentIndex = index
}
}
onClicked: appSettings.sortBy = modelData
}
}
}
/*onCurrentIndexChanged: {
2018-11-25 16:08:00 +03:00
appSettings.sortBy = sortByRepeater.model[currentIndex]
}*/
}
2018-12-27 22:38:14 +03:00
TextSwitch {
text: qsTr("Favorites on top")
description: qsTr("Show notes marked as favorite above the others")
checked: appSettings.favoritesOnTop
onCheckedChanged: appSettings.favoritesOnTop = checked
}
TextSwitch {
text: qsTr("Show separator")
description: qsTr("Show a separator line between the notes")
checked: appSettings.showSeparator
onCheckedChanged: appSettings.showSeparator = checked
}
Slider {
width: parent.width
minimumValue: 0
maximumValue: 20
stepSize: 1
value: appSettings.previewLineCount
valueText: sliderValue + " " + qsTr("lines")
2018-12-04 17:22:57 +03:00
label: qsTr("Number of lines in the preview")
onSliderValueChanged: appSettings.previewLineCount = sliderValue
}
SectionHeader {
text: qsTr("Editing")
}
TextSwitch {
2018-12-04 17:22:57 +03:00
text: qsTr("Monospaced font")
description: qsTr("Use a monospeced font to edit a note")
checked: appSettings.useMonoFont
onCheckedChanged: appSettings.useMonoFont = checked
}
TextSwitch {
2018-12-04 17:22:57 +03:00
text: qsTr("Capital 'X' in checkboxes")
description: qsTr("For interoperability with other apps such as Joplin")
checked: appSettings.useCapitalX
onCheckedChanged: appSettings.useCapitalX = checked
}
}
VerticalScrollDecorator {}
}
2018-12-04 19:24:45 +03:00
allowedOrientations: defaultAllowedOrientations
}