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-12-11 02:10:51 +03:00
|
|
|
import Nemo.Notifications 1.0
|
|
|
|
|
2018-10-22 23:53:14 +03:00
|
|
|
|
|
|
|
Page {
|
|
|
|
id: page
|
|
|
|
|
|
|
|
SilicaFlickable {
|
|
|
|
id: flickable
|
|
|
|
anchors.fill: parent
|
2018-12-13 01:10:45 +03:00
|
|
|
contentHeight: column.height + Theme.paddingLarge
|
2018-10-22 23:53:14 +03:00
|
|
|
|
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-12-07 02:30:18 +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-12-07 02:30:18 +03:00
|
|
|
id: accountRepeater
|
|
|
|
model: appSettings.accountIDs
|
|
|
|
|
2018-10-23 23:15:59 +03:00
|
|
|
delegate: ListItem {
|
2018-11-18 00:28:25 +03:00
|
|
|
id: accountListItem
|
2018-11-24 21:34:01 +03:00
|
|
|
contentHeight: accountTextSwitch.height
|
|
|
|
highlighted: accountTextSwitch.down
|
2018-11-15 00:13:47 +03:00
|
|
|
|
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 {
|
2018-11-24 21:34:01 +03:00
|
|
|
id: accountTextSwitch
|
2018-10-23 23:15:59 +03:00
|
|
|
automaticCheck: false
|
2018-12-07 02:30:18 +03:00
|
|
|
checked: modelData === api.uuid
|
|
|
|
onClicked: {
|
|
|
|
api.uuid = modelData
|
|
|
|
api.getNotes()
|
|
|
|
}
|
2018-11-18 00:28:25 +03:00
|
|
|
onPressAndHold: openMenu()
|
2018-10-22 23:53:14 +03:00
|
|
|
}
|
2018-10-23 23:15:59 +03:00
|
|
|
menu: ContextMenu {
|
|
|
|
MenuItem {
|
2018-11-18 00:28:25 +03:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|
2018-11-18 00:28:25 +03:00
|
|
|
MenuItem {
|
2018-10-23 23:15:59 +03:00
|
|
|
text: qsTr("Delete")
|
2018-11-15 00:13:47 +03:00
|
|
|
onClicked: {
|
2018-11-18 00:28:25 +03:00
|
|
|
accountListItem.remorseAction(qsTr("Deleting account"), function() {
|
2018-12-07 02:30:18 +03:00
|
|
|
console.log("Deleting " + modelData)
|
|
|
|
appSettings.removeAccount(modelData)
|
2018-11-18 00:28:25 +03:00
|
|
|
})
|
2018-11-15 00:13:47 +03:00
|
|
|
}
|
2018-11-18 00:28:25 +03:00
|
|
|
}
|
2018-10-22 23:53:14 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Button {
|
|
|
|
text: qsTr("Add account")
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
onClicked: {
|
2018-12-07 02:30:18 +03:00
|
|
|
var newAccountID = appSettings.addAccount()
|
2018-12-07 03:13:22 +03:00
|
|
|
var login = pageStack.replace(Qt.resolvedUrl("LoginDialog.qml"), { accountId: newAccountID, addingNew: true })
|
2018-10-22 23:53:14 +03:00
|
|
|
}
|
|
|
|
}
|
2018-11-24 21:34:01 +03:00
|
|
|
|
2018-12-04 13:44:06 +03:00
|
|
|
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]
|
2018-12-04 13:44:06 +03:00
|
|
|
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-04 13:44:06 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-12-11 02:10:51 +03:00
|
|
|
onCurrentIndexChanged: {
|
|
|
|
appSettings.autoSyncInterval = autoSyncIntervalRepeater.model[currentIndex]
|
|
|
|
if (autoSyncIntervalRepeater.model[currentIndex] === 42 && theAnswer.enabled) {
|
|
|
|
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
|
|
|
|
}
|
2018-12-04 13:44:06 +03:00
|
|
|
}
|
|
|
|
|
2018-11-24 21:34:01 +03:00
|
|
|
SectionHeader {
|
|
|
|
text: qsTr("Appearance")
|
|
|
|
}
|
|
|
|
ComboBox {
|
2018-11-25 16:08:00 +03:00
|
|
|
id: sortByComboBox
|
2018-12-04 17:22:57 +03:00
|
|
|
property var names: [qsTr("Last edited"), qsTr("Category"), qsTr("Title alphabetically")]
|
2018-11-25 22:39:03 +03:00
|
|
|
label: qsTr("Sort notes by")
|
2018-12-04 17:22:57 +03:00
|
|
|
description: qsTr("This will also change how the notes are grouped")
|
2018-11-24 21:34:01 +03:00
|
|
|
menu: ContextMenu {
|
|
|
|
Repeater {
|
2018-11-25 16:08:00 +03:00
|
|
|
id: sortByRepeater
|
|
|
|
model: ["date", "category", "title"]
|
2018-11-24 21:34:01 +03:00
|
|
|
MenuItem {
|
2018-11-25 16:08:00 +03:00
|
|
|
text: sortByComboBox.names[index]
|
|
|
|
//enabled: modelData !== "title"
|
2018-11-24 21:34:01 +03:00
|
|
|
Component.onCompleted: {
|
2018-11-25 16:08:00 +03:00
|
|
|
if (modelData === appSettings.sortBy) {
|
|
|
|
sortByComboBox.currentIndex = index
|
2018-11-24 21:34:01 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
onCurrentIndexChanged: {
|
2018-11-25 16:08:00 +03:00
|
|
|
appSettings.sortBy = sortByRepeater.model[currentIndex]
|
2018-11-24 21:34:01 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
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")
|
2018-11-24 21:34:01 +03:00
|
|
|
onSliderValueChanged: appSettings.previewLineCount = sliderValue
|
|
|
|
}
|
|
|
|
|
|
|
|
SectionHeader {
|
2018-12-04 13:44:06 +03:00
|
|
|
text: qsTr("Editing")
|
2018-11-24 21:34:01 +03:00
|
|
|
}
|
2018-12-04 13:44:06 +03:00
|
|
|
TextSwitch {
|
2018-12-04 17:22:57 +03:00
|
|
|
text: qsTr("Monospaced font")
|
2018-12-04 13:44:06 +03:00
|
|
|
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")
|
2018-12-04 13:44:06 +03:00
|
|
|
checked: appSettings.useCapitalX
|
|
|
|
onCheckedChanged: appSettings.useCapitalX = checked
|
2018-11-24 21:34:01 +03:00
|
|
|
}
|
2018-10-22 23:53:14 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
VerticalScrollDecorator {}
|
|
|
|
}
|
2018-12-04 19:24:45 +03:00
|
|
|
|
|
|
|
allowedOrientations: defaultAllowedOrientations
|
2018-10-22 23:53:14 +03:00
|
|
|
}
|