[harmattan] added a UI for editing notes, closes #139 and therefore also #106

This commit is contained in:
Hauke Schade 2014-12-16 22:52:27 +01:00
parent 9a81409556
commit 7cef5e302e
2 changed files with 110 additions and 3 deletions

View file

@ -27,10 +27,11 @@ import "../components" 1.0
Page {
id: root
tools: itemTools
property string pageTitle: ""
property alias pageTitle: pageHeader.text
property string subTitle: ""
property string url: ""
property string date: ""
property string note: ""
property bool marked: false
property bool unread: true
property bool rss: false
@ -94,7 +95,19 @@ Page {
Qt.openUrlExternally(link);
}
}
color: theme.inverted ? MyTheme.primaryColorInverted: MyTheme.primaryColor
color: theme.inverted ? MyTheme.primaryColorInverted : MyTheme.primaryColor
}
Text {
id: noteView
width: parent.width
text: qsTr("Note: %1").arg(note)
color: theme.inverted ? MyTheme.primaryColorInverted : MyTheme.primaryColor
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
textFormat: Text.PlainText
font.weight: Font.Light
font.italic: true
font.pixelSize: MyTheme.fontSizeTiny
visible: note != ""
}
}
}
@ -180,6 +193,7 @@ Page {
subTitle = data.feedTitle
date = data.date
root.labels = data.labels
note = data.note !== undefined ? data.note : ""
marked = data.marked
unread = data.unread
rss = data.rss
@ -197,13 +211,22 @@ Page {
}
}
function updateNote(note) {
feedItems.updateNote(note, function(successful, errorMessage) {
if (successful) {
root.note = note
}
// TODO make use of errorMessage
})
}
Component.onCompleted: {
showFeedItem();
}
PageHeader {
id: pageHeader
text: pageTitle
subtext: root.isCat ? root.subTitle : ""
}
@ -290,8 +313,21 @@ Page {
enabled: url && (url != "")
onClicked: QMLUtils.share(url, pageTitle);
}
MenuItem {
text: qsTr("Edit Note")
enabled: !network.loading
onClicked: {
noteEditor.previousNote = root.note
noteEditor.feedItemPage = root
noteEditor.open()
}
}
SettingsItem {}
AboutItem {}
}
}
NoteEditor {
id: noteEditor
}
}

View file

@ -0,0 +1,71 @@
/*
* This file is part of TTRss, a Tiny Tiny RSS Reader App
* for MeeGo Harmattan and Sailfish OS.
* Copyright (C) 20122014 Hauke Schade
*
* TTRss is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* TTRss is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with TTRss; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or see
* http://www.gnu.org/licenses/.
*/
import QtQuick 1.1
import com.nokia.meego 1.0
Sheet {
id: page
property string previousNote
property variant feedItemPage
acceptButtonText: canAccept ? qsTr("Save Note") : ""
rejectButtonText: qsTr("Cancel")
property bool canAccept: false
content: Flickable {
contentHeight: area.height + Theme.paddingMedium + header.height
contentWidth: parent.width
anchors.fill: parent
Column {
width: parent.width
spacing: MyTheme.paddingMedium
Label {
id: header
width: parent.width
text: qsTr("Edit Note")
}
TextArea {
id: area
width: parent.width
height: 80
focus: true
text: page.previousNote
Component.onCompleted: {
// We don't want to change page.canAccept during initialization.
area.textChanged.connect(function() {
if (page.previousNote != text)
page.canAccept = true
})
}
}
}
}
onAccepted: {
feedItemPage.updateNote(area.text)
}
}