2020-01-14 16:47:42 +03:00
|
|
|
import QtQuick 2.2
|
2018-10-16 18:50:58 +03:00
|
|
|
import Sailfish.Silica 1.0
|
2021-06-20 22:02:10 +03:00
|
|
|
import harbour.nextcloudapi 1.0
|
2021-06-21 01:17:10 +03:00
|
|
|
import harbour.nextcloudapi.notes 1.0
|
2018-10-16 18:50:58 +03:00
|
|
|
|
|
|
|
Page {
|
|
|
|
id: page
|
|
|
|
|
2018-11-18 00:28:25 +03:00
|
|
|
onStatusChanged: {
|
2020-04-15 09:31:04 +03:00
|
|
|
if (status === PageStatus.Activating) {
|
2021-06-21 01:17:10 +03:00
|
|
|
if (appSettings.accountList.length <= 0) {
|
2018-12-07 02:30:18 +03:00
|
|
|
addAccountHint.restart()
|
2018-11-18 00:28:25 +03:00
|
|
|
}
|
|
|
|
else {
|
2018-12-07 02:30:18 +03:00
|
|
|
autoSyncTimer.restart()
|
2018-11-18 00:28:25 +03:00
|
|
|
}
|
|
|
|
}
|
2020-04-15 09:31:04 +03:00
|
|
|
else if (status === PageStatus.Deactivating) {
|
|
|
|
autoSyncTimer.stop()
|
|
|
|
}
|
2018-11-18 00:28:25 +03:00
|
|
|
}
|
|
|
|
|
2018-10-16 18:50:58 +03:00
|
|
|
SilicaListView {
|
|
|
|
id: notesList
|
|
|
|
anchors.fill: parent
|
2018-12-13 01:10:45 +03:00
|
|
|
spacing: Theme.paddingLarge
|
2018-10-16 18:50:58 +03:00
|
|
|
|
|
|
|
PullDownMenu {
|
2021-06-20 22:02:10 +03:00
|
|
|
busy: Nextcloud.busy
|
2018-10-22 23:53:14 +03:00
|
|
|
|
2018-10-16 18:50:58 +03:00
|
|
|
MenuItem {
|
|
|
|
text: qsTr("Settings")
|
2018-10-22 23:53:14 +03:00
|
|
|
onClicked: pageStack.push(Qt.resolvedUrl("SettingsPage.qml"))
|
2018-10-16 18:50:58 +03:00
|
|
|
}
|
|
|
|
MenuItem {
|
|
|
|
text: qsTr("Add note")
|
2021-06-20 22:02:10 +03:00
|
|
|
visible: appSettings.currentAccount !== ""
|
|
|
|
enabled: Nextcloud.networkAccessible
|
2021-06-21 01:17:10 +03:00
|
|
|
onClicked: Notes.createNote( { 'content': "", 'modified': new Date().valueOf() / 1000 } )
|
2018-10-16 18:50:58 +03:00
|
|
|
}
|
2018-11-15 00:13:47 +03:00
|
|
|
MenuItem {
|
2021-06-20 22:02:10 +03:00
|
|
|
text: Nextcloud.networkAccessible && !Nextcloud.busy ? qsTr("Reload") : qsTr("Updating...")
|
|
|
|
visible: appSettings.currentAccount !== ""
|
|
|
|
enabled: Nextcloud.networkAccessible && !Nextcloud.busy
|
2021-06-21 01:17:10 +03:00
|
|
|
onClicked: Notes.getAllNotes()
|
2018-11-15 00:13:47 +03:00
|
|
|
}
|
|
|
|
MenuLabel {
|
2021-06-20 22:02:10 +03:00
|
|
|
visible: appSettings.currentAccount !== ""
|
2018-12-07 02:30:18 +03:00
|
|
|
text: qsTr("Last update") + ": " + (
|
2018-12-27 22:38:14 +03:00
|
|
|
new Date(account.update).valueOf() !== 0 ?
|
|
|
|
new Date(account.update).toLocaleString(Qt.locale(), Locale.ShortFormat) :
|
2018-12-07 02:30:18 +03:00
|
|
|
qsTr("never"))
|
2018-11-15 00:13:47 +03:00
|
|
|
}
|
2018-10-16 18:50:58 +03:00
|
|
|
}
|
|
|
|
|
2018-11-18 13:25:28 +03:00
|
|
|
header: PageHeader {
|
2018-12-04 18:31:28 +03:00
|
|
|
height: searchField.height + description.height
|
2018-12-03 22:33:37 +03:00
|
|
|
SearchField {
|
|
|
|
id: searchField
|
|
|
|
width: parent.width
|
2019-06-21 18:49:54 +03:00
|
|
|
enabled: !busyIndicator.running && !noLoginPlaceholder.enabled && !errorPlaceholder.enabled && !noNotesPlaceholder.enabled
|
2021-06-20 22:02:10 +03:00
|
|
|
placeholderText: Nextcloud.statusProductName.length > 0 ? Nextcloud.statusProductName : account.name.length > 0 ? account.name : qsTr("Nextcloud Notes")
|
2018-12-03 22:33:37 +03:00
|
|
|
EnterKey.iconSource: "image://theme/icon-m-enter-close"
|
|
|
|
EnterKey.onClicked: focus = false
|
2020-03-29 19:03:05 +03:00
|
|
|
onTextChanged: {
|
2021-06-20 22:02:10 +03:00
|
|
|
Notes.model.searchFilter = text
|
2020-03-29 19:03:05 +03:00
|
|
|
}
|
2018-11-25 16:08:00 +03:00
|
|
|
}
|
2018-12-04 18:31:28 +03:00
|
|
|
Label {
|
|
|
|
id: description
|
|
|
|
x: Theme.horizontalPageMargin
|
|
|
|
width: parent.width - 2*x
|
2018-12-27 22:38:14 +03:00
|
|
|
visible: text.length > 1
|
2018-12-04 18:31:28 +03:00
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
anchors.bottomMargin: Theme.paddingMedium
|
|
|
|
color: Theme.secondaryHighlightColor
|
|
|
|
font.pixelSize: Theme.fontSizeSmall
|
2021-06-20 22:02:10 +03:00
|
|
|
text: Nextcloud.username + "@" + Nextcloud.host
|
2018-12-05 19:06:06 +03:00
|
|
|
}
|
|
|
|
BusyIndicator {
|
|
|
|
anchors.verticalCenter: searchField.verticalCenter
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: Theme.horizontalPageMargin
|
|
|
|
size: BusyIndicatorSize.Medium
|
2021-06-20 22:02:10 +03:00
|
|
|
running: Nextcloud.busy && !busyIndicator.running
|
2018-12-04 18:31:28 +03:00
|
|
|
}
|
2018-10-16 18:50:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
currentIndex: -1
|
|
|
|
|
2021-04-12 19:58:39 +03:00
|
|
|
model: notesModel
|
2018-10-16 18:50:58 +03:00
|
|
|
|
2019-01-29 01:15:53 +03:00
|
|
|
delegate: BackgroundItem {
|
|
|
|
id: note
|
|
|
|
|
|
|
|
contentHeight: titleLabel.height + previewLabel.height + 2*Theme.paddingSmall
|
|
|
|
height: contentHeight + menu.height
|
|
|
|
width: parent.width
|
|
|
|
highlighted: down || menu.active
|
|
|
|
ListView.onAdd: AddAnimation {
|
|
|
|
target: note //searchText !== "" ? null : note
|
|
|
|
}
|
|
|
|
ListView.onRemove: RemoveAnimation {
|
|
|
|
target: note //searchText !== "" ? null : note
|
|
|
|
}
|
|
|
|
RemorseItem {
|
|
|
|
id: remorse
|
|
|
|
}
|
|
|
|
|
2020-05-03 19:30:39 +03:00
|
|
|
onClicked: pageStack.push(Qt.resolvedUrl("NotePage.qml"), { id: id } )
|
2019-01-29 01:15:53 +03:00
|
|
|
onPressAndHold: menu.open(note)
|
|
|
|
|
|
|
|
Separator {
|
|
|
|
width: parent.width
|
|
|
|
color: Theme.primaryColor
|
|
|
|
anchors.top: titleLabel.top
|
|
|
|
visible: appSettings.showSeparator && index !== 0
|
|
|
|
}
|
|
|
|
|
|
|
|
IconButton {
|
|
|
|
id: isFavoriteIcon
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.top: parent.top
|
|
|
|
icon.source: (favorite ? "image://theme/icon-m-favorite-selected?" : "image://theme/icon-m-favorite?") +
|
|
|
|
(note.highlighted ? Theme.secondaryHighlightColor : Theme.secondaryColor)
|
|
|
|
onClicked: {
|
2021-06-20 22:02:10 +03:00
|
|
|
Notes.model.setNote({ 'favorite': !favorite })
|
2019-01-29 01:15:53 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Label {
|
|
|
|
id: titleLabel
|
|
|
|
anchors.left: isFavoriteIcon.right
|
|
|
|
anchors.leftMargin: Theme.paddingSmall
|
|
|
|
anchors.right: categoryRectangle.visible ? categoryRectangle.left : parent.right
|
|
|
|
anchors.top: parent.top
|
|
|
|
text: title
|
|
|
|
truncationMode: TruncationMode.Fade
|
|
|
|
color: note.highlighted ? Theme.highlightColor : Theme.primaryColor
|
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
id: categoryRectangle
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: Theme.horizontalPageMargin
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: Theme.paddingSmall
|
|
|
|
width: categoryLabel.width + Theme.paddingLarge
|
|
|
|
height: categoryLabel.height + Theme.paddingSmall
|
|
|
|
color: "transparent"
|
|
|
|
border.color: Theme.highlightColor
|
|
|
|
radius: height / 4
|
|
|
|
visible: appSettings.sortBy !== "category" && categoryLabel.text.length > 0
|
|
|
|
Label {
|
|
|
|
id: categoryLabel
|
|
|
|
anchors.centerIn: parent
|
2020-04-19 20:01:03 +03:00
|
|
|
text: categoryLabel.text.length > 0 ? category : ""
|
2019-01-29 01:15:53 +03:00
|
|
|
color: note.highlighted ? Theme.secondaryHighlightColor : Theme.secondaryColor
|
|
|
|
font.pixelSize: Theme.fontSizeExtraSmall
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Label {
|
|
|
|
id: previewLabel
|
|
|
|
anchors.left: isFavoriteIcon.right
|
|
|
|
anchors.leftMargin: Theme.paddingSmall
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: Theme.horizontalPageMargin
|
|
|
|
anchors.top: titleLabel.bottom
|
|
|
|
text: parseText(content)
|
|
|
|
font.pixelSize: Theme.fontSizeExtraSmall
|
|
|
|
textFormat: Text.PlainText
|
|
|
|
wrapMode: Text.Wrap
|
|
|
|
elide: Text.ElideRight
|
|
|
|
maximumLineCount: appSettings.previewLineCount > 0 ? appSettings.previewLineCount : 1
|
|
|
|
visible: appSettings.previewLineCount > 0
|
|
|
|
color: note.highlighted ? Theme.secondaryHighlightColor : Theme.secondaryColor
|
|
|
|
function parseText (preText) {
|
|
|
|
var lines = preText.split('\n')
|
|
|
|
lines.splice(0,1);
|
|
|
|
var newText = lines.join('\n');
|
|
|
|
return newText.replace(/^\s*$(?:\r\n?|\n)/gm, "")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ContextMenu {
|
|
|
|
id: menu
|
|
|
|
MenuLabel {
|
|
|
|
id: modifiedLabel
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
text: qsTr("Modified") + ": " + new Date(modified * 1000).toLocaleString(Qt.locale(), Locale.ShortFormat)
|
|
|
|
}
|
|
|
|
MenuItem {
|
|
|
|
text: qsTr("Delete")
|
|
|
|
onClicked: {
|
|
|
|
remorse.execute(note, qsTr("Deleting note"), function() {
|
2021-06-20 22:02:10 +03:00
|
|
|
Notes.model.deleteNote(id)
|
2019-01-29 01:15:53 +03:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-25 16:08:00 +03:00
|
|
|
section.property: appSettings.sortBy
|
|
|
|
section.criteria: appSettings.sortBy === "title" ? ViewSection.FirstCharacter : ViewSection.FullString
|
2018-12-20 20:53:29 +03:00
|
|
|
section.labelPositioning: appSettings.sortBy === "title" ? ViewSection.CurrentLabelAtStart | ViewSection.NextLabelAtEnd : ViewSection.InlineLabels
|
2018-10-16 18:50:58 +03:00
|
|
|
section.delegate: SectionHeader {
|
2019-11-14 02:47:38 +03:00
|
|
|
text: section
|
2018-10-16 18:50:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
BusyIndicator {
|
|
|
|
id: busyIndicator
|
|
|
|
anchors.centerIn: parent
|
|
|
|
size: BusyIndicatorSize.Large
|
2021-06-20 22:02:10 +03:00
|
|
|
running: notesList.count === 0 && Nextcloud.busy
|
2018-10-16 18:50:58 +03:00
|
|
|
}
|
2019-06-21 18:49:54 +03:00
|
|
|
Label {
|
|
|
|
id: busyLabel
|
|
|
|
anchors.top: busyIndicator.bottom
|
|
|
|
anchors.topMargin: Theme.paddingMedium
|
|
|
|
visible: busyIndicator.running
|
|
|
|
width: parent.width
|
|
|
|
color: Theme.highlightColor
|
|
|
|
font.pixelSize: Theme.fontSizeExtraLarge
|
|
|
|
horizontalAlignment: Qt.AlignHCenter
|
|
|
|
text: qsTr("Loading notes...")
|
|
|
|
}
|
2019-11-11 01:04:42 +03:00
|
|
|
|
2018-10-21 02:44:23 +03:00
|
|
|
ViewPlaceholder {
|
2018-11-24 21:34:01 +03:00
|
|
|
id: noLoginPlaceholder
|
2021-06-21 01:17:10 +03:00
|
|
|
enabled: appSettings.accountList.length <= 0
|
2018-11-24 21:34:01 +03:00
|
|
|
text: qsTr("No account yet")
|
|
|
|
hintText: qsTr("Got to the settings to add an account")
|
|
|
|
}
|
|
|
|
|
|
|
|
ViewPlaceholder {
|
|
|
|
id: noNotesPlaceholder
|
2021-06-20 22:02:10 +03:00
|
|
|
enabled: Nextcloud.status === 204 && !busyIndicator.running && !noLoginPlaceholder.enabled
|
2018-10-22 23:53:14 +03:00
|
|
|
text: qsTr("No notes yet")
|
|
|
|
hintText: qsTr("Pull down to add a note")
|
2018-10-21 02:44:23 +03:00
|
|
|
}
|
|
|
|
|
2018-12-03 22:33:37 +03:00
|
|
|
ViewPlaceholder {
|
|
|
|
id: noSearchPlaceholder
|
2021-06-20 22:02:10 +03:00
|
|
|
enabled: notesList.count === 0 && notesModel.searchFilter !== "" //Notes.model.filterRegExp !== ""
|
2018-12-03 22:33:37 +03:00
|
|
|
text: qsTr("No result")
|
|
|
|
hintText: qsTr("Try another query")
|
|
|
|
}
|
|
|
|
|
2018-11-15 00:13:47 +03:00
|
|
|
ViewPlaceholder {
|
2018-11-24 21:34:01 +03:00
|
|
|
id: errorPlaceholder
|
2018-12-03 22:33:37 +03:00
|
|
|
enabled: notesList.count === 0 && !busyIndicator.running && !noSearchPlaceholder.enabled && !noNotesPlaceholder.enabled && !noLoginPlaceholder.enabled
|
2018-11-24 21:34:01 +03:00
|
|
|
text: qsTr("An error occurred")
|
2021-06-20 22:02:10 +03:00
|
|
|
//hintText: Nextcloud.statusText
|
2018-11-15 00:13:47 +03:00
|
|
|
}
|
2019-11-11 01:04:42 +03:00
|
|
|
|
2018-11-15 00:13:47 +03:00
|
|
|
TouchInteractionHint {
|
|
|
|
id: addAccountHint
|
|
|
|
interactionMode: TouchInteraction.Pull
|
|
|
|
direction: TouchInteraction.Down
|
|
|
|
}
|
|
|
|
InteractionHintLabel {
|
|
|
|
anchors.fill: parent
|
|
|
|
text: qsTr("Open the settings to configure your Nextcloud accounts")
|
|
|
|
opacity: addAccountHint.running ? 1.0 : 0.0
|
|
|
|
Behavior on opacity { FadeAnimation {} }
|
|
|
|
width: parent.width
|
|
|
|
}
|
2018-10-22 23:53:14 +03:00
|
|
|
|
2018-11-15 00:13:47 +03:00
|
|
|
VerticalScrollDecorator { flickable: notesList }
|
|
|
|
}
|
2018-12-04 19:24:45 +03:00
|
|
|
|
2021-04-12 19:58:39 +03:00
|
|
|
allowedOrientations: appWindow.allowedOrientations
|
2018-10-16 18:50:58 +03:00
|
|
|
}
|