harbour-nextcloudnotes/qml/pages/SettingsPage.qml

240 lines
9.5 KiB
QML
Raw Normal View History

import QtQuick 2.2
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
visible: appSettings.accounts.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
2021-01-02 14:34:31 +03:00
horizontalAlignment: Text.AlignHCenter
width: parent.width
wrapMode: Text.Wrap
}
Repeater {
2018-12-07 02:30:18 +03:00
id: accountRepeater
model: appSettings.accounts
2018-12-07 02:30:18 +03:00
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: {
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 {
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: {
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
}
}
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: {
var login = pageStack.push(Qt.resolvedUrl("LoginPage.qml"), { accountId: "" })
}
}
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
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") }
]
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
2019-11-12 01:23:41 +03:00
model: sortByComboBox.criteria
MenuItem {
2019-11-12 01:23:41 +03:00
text: modelData.text
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
}
}
2019-11-12 01:23:41 +03:00
onClicked: appSettings.sortBy = modelData.role
}
}
}
/*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
}
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
}
}
VerticalScrollDecorator {}
}
2018-12-04 19:24:45 +03:00
allowedOrientations: defaultAllowedOrientations
}