2020-01-14 16:47:42 +03:00
|
|
|
import QtQuick 2.2
|
2018-10-22 23:53:14 +03:00
|
|
|
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
|
2021-01-03 21:07:47 +03:00
|
|
|
visible: appSettings.accounts.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
|
2021-01-02 14:34:31 +03:00
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
width: parent.width
|
|
|
|
wrapMode: Text.Wrap
|
2018-10-22 23:53:14 +03:00
|
|
|
}
|
|
|
|
Repeater {
|
2018-12-07 02:30:18 +03:00
|
|
|
id: accountRepeater
|
2021-01-03 21:07:47 +03:00
|
|
|
model: appSettings.accounts
|
2018-12-07 02:30:18 +03:00
|
|
|
|
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: {
|
2020-03-29 19:03:05 +03:00
|
|
|
accountTextSwitch.text = account.value("username", qsTr("unknown"), String) + " @ " + value("name", qsTr("Unnamed account"), String)
|
|
|
|
accountTextSwitch.description =account.value("server", qsTr("unknown"), String)
|
2018-12-07 02:30:18 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
2019-03-10 22:20:41 +03:00
|
|
|
checked: modelData === appSettings.currentAccount
|
2018-12-07 02:30:18 +03:00
|
|
|
onClicked: {
|
2019-03-10 22:20:41 +03:00
|
|
|
appSettings.currentAccount = modelData
|
2018-12-07 02:30:18 +03:00
|
|
|
}
|
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: {
|
2020-03-29 19:03:05 +03:00
|
|
|
var login = pageStack.push(Qt.resolvedUrl("LoginPage.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: {
|
2021-01-03 21:07:47 +03:00
|
|
|
var login = pageStack.push(Qt.resolvedUrl("LoginPage.qml"), { accountId: "" })
|
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) {
|
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
|
|
|
|
}
|
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
|
2019-11-12 01:23:41 +03:00
|
|
|
property var criteria: [
|
2020-01-11 15:32:26 +03:00
|
|
|
{ role: "modifiedString", text: qsTr("Last edited") },
|
2019-11-12 01:23:41 +03:00
|
|
|
{ role: "category", text: qsTr("Category") },
|
|
|
|
{ role: "title", text: qsTr("Title alphabetically") },
|
|
|
|
{ role: "none", text: qsTr("No sorting") }
|
|
|
|
]
|
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
|
2019-11-12 01:23:41 +03:00
|
|
|
model: sortByComboBox.criteria
|
2018-11-24 21:34:01 +03:00
|
|
|
MenuItem {
|
2019-11-12 01:23:41 +03:00
|
|
|
text: modelData.text
|
2018-11-24 21:34:01 +03:00
|
|
|
Component.onCompleted: {
|
2019-11-12 01:23:41 +03:00
|
|
|
if (modelData.role === appSettings.sortBy) {
|
2018-11-25 16:08:00 +03:00
|
|
|
sortByComboBox.currentIndex = index
|
2018-11-24 21:34:01 +03:00
|
|
|
}
|
|
|
|
}
|
2019-11-12 01:23:41 +03:00
|
|
|
onClicked: appSettings.sortBy = modelData.role
|
2018-11-24 21:34:01 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-03-10 22:20:41 +03:00
|
|
|
/*onCurrentIndexChanged: {
|
2018-11-25 16:08:00 +03:00
|
|
|
appSettings.sortBy = sortByRepeater.model[currentIndex]
|
2019-03-10 22:20:41 +03:00
|
|
|
}*/
|
2018-11-24 21:34:01 +03:00
|
|
|
}
|
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
|
|
|
|
}
|
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
|
|
|
}
|
2020-08-22 16:48:35 +03:00
|
|
|
|
|
|
|
SectionHeader {
|
|
|
|
text: qsTr("Reset")
|
|
|
|
}
|
|
|
|
Button {
|
|
|
|
text: qsTr("Reset app settings")
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
RemorseItem { id: resetRemorse }
|
|
|
|
ConfigurationGroup {
|
|
|
|
id: appConfig
|
|
|
|
path: "/apps/harbour-nextcloudnotes"
|
|
|
|
}
|
|
|
|
onClicked: resetRemorse.execute(this, "Reset app", appConfig.clear())
|
|
|
|
}
|
|
|
|
LinkedLabel {
|
|
|
|
text: qsTr("Resetting the app wipes all application data from the device! This includes offline synced notes, app settings and accounts.")
|
|
|
|
x: Theme.horizontalPageMargin
|
|
|
|
width: parent.width - 2*x
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|