Merge remote-tracking branch 'mardy/master'

This commit is contained in:
Hauke Schade 2015-09-13 19:39:43 +02:00
commit 9c40239db2
14 changed files with 174 additions and 168 deletions

View file

@ -16,6 +16,8 @@ Page {
id: categoriesPage
title: qsTr("Tiny Tiny RSS Reader")
property var categories
head {
actions: [
Action {

View file

@ -0,0 +1,44 @@
//Copyright Alberto Mardegan, 2015
//
//This file is part of TTRss.
//
//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 (on a Maemo/Meego system there is a copy
//in /usr/share/common-licenses. If not, see http://www.gnu.org/licenses/.
import QtQuick 2.0
import Ubuntu.Components 1.1
import Ubuntu.Components.ListItems 1.0 as ListItem
import Ubuntu.Components.Popups 1.0
import Ubuntu.Content 1.1
ActionSelectionPopover {
id: root
property bool isImage: false
property string url: ""
grabDismissAreaEvents: true
delegate: ListItem.Standard {
text: action.text
onTriggered: root.hide()
}
actions: ActionList {
Action {
text: qsTr("Open in Web Browser")
onTriggered: Qt.openUrlExternally(root.url)
}
Action {
text: qsTr("Save image")
visible: isImage
onTriggered: pageStack.push(Qt.resolvedUrl("FileSaver.qml"), {
"url": url,
"contentType": ContentType.Pictures,
})
}
}
}

View file

@ -11,6 +11,7 @@
import QtQuick 2.0
import Ubuntu.Components 1.1
import Ubuntu.Components.Popups 1.0
Item {
id: root
@ -31,6 +32,8 @@ Item {
anchors.fill: parent
contentHeight: content.height
interactive: true
flickableDirection: Flickable.VerticalFlick
topMargin: pageStack.currentPage.header.height
clip: true
/* TODO
@ -65,7 +68,7 @@ Item {
Column {
id: content
width: parent.width
anchors { left: parent.left; right: parent.right; margins: units.gu(1) }
spacing: 2
Label {
@ -87,6 +90,7 @@ Item {
rightMargin: Theme.paddingLarge
}
}
RescalingRichText {
id: itemView
width: parent.width
@ -94,6 +98,15 @@ Item {
fontSize: settings.webviewFontSize
color: Theme.palette.selected.baseText
onLinkActivated: Qt.openUrlExternally(link)
onPressAndHold: {
var url = link ? link : root.url
var isImage = (/jpe?g$/i.test(url) || /png$/i.test(url))
PopupUtils.open(Qt.resolvedUrl("ContextMenu.qml"), root, {
"isImage": isImage,
"url": url,
"target": itemView,
})
}
}
}
}

View file

@ -16,10 +16,8 @@ import Ubuntu.Components.ListItems 0.1 as ListItem
ListItem.Empty {
id: listItem
onClicked: root.clicked()
SubtitledLabel {
anchors { leftMargin: units.gu(1); rightMargin: units.gu(1) }
text: model.title
subText: model.subtitle
iconSource: (settings.displayIcons && feed.isCat) ? model.icon : ''

View file

@ -28,13 +28,13 @@ Page {
Action {
iconSource: "../resources/ic_star_"+(currentItem.marked?"enabled":"disabled")+".png"
onTriggered: {
feedItems.toggleStar()
model.toggleStar()
}
},
Action {
iconSource: "../resources/ic_"+(currentItem.unread?"unread":"read")+".png"
onTriggered: {
feedItems.toggleRead()
model.toggleRead()
}
}
]
@ -63,10 +63,10 @@ Page {
}
onCurrentIndexChanged: {
feedItems.selectedIndex = currentIndex
model.selectedIndex = currentIndex
if (currentItem && settings.autoMarkRead && currentItem.unread) {
console.log("marking item as read")
feedItems.toggleRead()
model.toggleRead()
}
panel.close()
}

View file

@ -20,13 +20,12 @@ Page {
title: feed.title
Component.onCompleted: {
feedItems.feed = feeditemsPage.feed
feedItems.hasMoreItems = false
feedItems.continuation = 0
feedItems.clear()
feedItemModel.feed = feeditemsPage.feed
feedItemModel.hasMoreItems = false
feedItemModel.continuation = 0
var ttrss = rootWindow.getTTRSS()
ttrss.setShowAll(settings.showAll)
feedItems.update()
feedItemModel.update()
// FIXME workaround for https://bugs.launchpad.net/bugs/1404884
pullToRefresh.enabled = true
}
@ -41,58 +40,35 @@ Page {
if (showAll != settings.showAll) {
ttrss.setShowAll(showAll)
settings.showAll = showAll
feedItems.continuation = 0
feedItems.hasMoreItems = false
feedItems.clear()
feedItems.update()
feedItemModel.continuation = 0
feedItemModel.hasMoreItems = false
feedItemModel.clear()
feedItemModel.update()
}
}
}
actions: [
Action {
text: qsTr('Mark all read')
iconName: "tick"
onTriggered: feedItemModel.catchUp()
}
]
}
ListView {
id: listView
anchors.fill: parent
model: feedItems
model: feedItemModel
PullToRefresh {
id: pullToRefresh
enabled: false
onRefresh: feedItems.update()
onRefresh: feedItemModel.update()
refreshing: network.loading
}
/* TODO
PullDownMenu {
// AboutItem {}
// SettingsItem {}
MenuItem {
text: qsTr("Update")
enabled: !network.loading
onClicked: {
feedItems.continuation = 0
feedItems.hasMoreItems = false
feedItems.clear()
feedItems.update()
}
}
ToggleShowAllItem {
onUpdateView: {
feedItems.continuation = 0
feedItems.hasMoreItems = false
feedItems.clear()
feedItems.update()
}
}
MenuItem {
text: qsTr('Mark all read')
onClicked: {
feedItems.catchUp()
}
}
}
*/
section {
property: 'date'
@ -103,9 +79,9 @@ Page {
delegate: FeedItemDelegate {
onClicked: {
feedItems.selectedIndex = index
feedItemModel.selectedIndex = index
pageStack.push(Qt.resolvedUrl("FeedItemSwipe.qml"), {
model: feedItems,
model: feedItemModel,
currentIndex: index,
isCat: feed.isCat
})

View file

@ -14,16 +14,16 @@ import Ubuntu.Components 1.1
Page {
id: feedsPage
property variant category
property var category
title: category.title
Component.onCompleted: {
feeds.category = feedsPage.category
feeds.clear()
feedModel.category = feedsPage.category
feedModel.clear()
var ttrss = rootWindow.getTTRSS()
ttrss.setShowAll(settings.showAll)
feeds.update()
feedModel.update()
// FIXME workaround for https://bugs.launchpad.net/bugs/1404884
pullToRefresh.enabled = true
}
@ -45,7 +45,7 @@ Page {
if (showAll != settings.showAll) {
ttrss.setShowAll(showAll)
settings.showAll = showAll
feeds.update()
feedModel.update()
}
}
}
@ -54,12 +54,12 @@ Page {
ListView {
id: listView
anchors.fill: parent
model: feeds
model: feedModel
PullToRefresh {
id: pullToRefresh
enabled: false
onRefresh: feeds.update()
onRefresh: feedModel.update()
refreshing: network.loading
}
@ -84,7 +84,7 @@ Page {
break
case 1:
//notification.show(qsTr('Feed added'))
feeds.update()
feedModel.update()
categories.update()
break
case 2:
@ -120,12 +120,12 @@ Page {
text: qsTr("Update")
enabled: !network.loading
onClicked: {
feeds.update()
feedModel.update()
}
}
ToggleShowAllItem {
onUpdateView: {
feeds.update()
feedModel.update()
}
}
}
@ -133,7 +133,7 @@ Page {
delegate: FeedDelegate {
onClicked: {
feeds.selectedIndex = index
feedModel.selectedIndex = index
showFeed(model)
}
}
@ -151,6 +151,7 @@ Page {
function showFeed(feedModel) {
if (feedModel != null) {
feedItemModel.clear()
pageStack.push(Qt.resolvedUrl("FeedItems.qml"), {
feed: feedModel
})

View file

@ -0,0 +1,47 @@
//Copyright Alberto Mardegan, 2015
//
//This file is part of TTRss.
//
//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 (on a Maemo/Meego system there is a copy
//in /usr/share/common-licenses. If not, see http://www.gnu.org/licenses/.
import QtQuick 2.0
import Ubuntu.Components 1.1
import Ubuntu.Content 1.1
import Ubuntu.DownloadManager 0.1
Page {
id: root
property string url: ""
property alias contentType: picker.contentType
property var __activeTransfer: null
title: qsTr("Save to")
visible: false
onUrlChanged: singleDownload.download(url)
ContentPeerPicker {
id: picker
showTitle: false
handler: ContentHandler.Destination
onPeerSelected: {
console.log("Peer selected")
__activeTransfer = peer.request()
__activeTransfer.downloadId = singleDownload.downloadId
__activeTransfer.state = ContentTransfer.Downloading
pageStack.pop()
}
}
SingleDownload {
id: singleDownload
autoStart: false
}
}

View file

@ -219,7 +219,7 @@ Item {
// loginErrorDialog.open();
return
}
categories.update()
categoryModel.update()
pageStack.clear()
//Now show the categories View
if (settings.useAllFeedsOnStartup) {
@ -229,11 +229,14 @@ Item {
categoryId: ttrss.constants['categories']['ALL'],
title: constant.allFeeds,
unreadcount: 0
}
},
})
}
else {
pageStack.push(Qt.resolvedUrl('Categories.qml'), {
categories: categoryModel,
})
}
else
pageStack.push(Qt.resolvedUrl('Categories.qml'))
}
Component.onCompleted: {

View file

@ -18,7 +18,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import QtQuick 2.0
import QtQuick 2.3
/* Pretty fancy element for displaying rich text fitting the width.
*
@ -40,6 +40,7 @@ Item {
property real scaling: 1
signal linkActivated(string link)
signal pressAndHold(string link)
height: contentText.height * scaling
clip: true
@ -78,8 +79,16 @@ Item {
// text: _RICHTEXT_STYLESHEET_PREAMBLE + parent.text + _RICHTEXT_STYLESHEET_APPENDIX
onLinkActivated: {
root.linkActivated(link)
MouseArea {
anchors.fill: parent
onClicked: {
var url = contentText.linkAt(mouse.x, mouse.y)
if (url) root.linkActivated(url)
}
onPressAndHold: {
var url = contentText.linkAt(mouse.x, mouse.y)
root.pressAndHold(url)
}
}
}

View file

@ -9,7 +9,7 @@ import "../models" 1.0
MainView {
id: rootWindow
applicationName: "ttrss"
applicationName: Qt.application.name
/* Disabled until QTBUG-43555 is fixed
automaticOrientation: true
*/
@ -36,104 +36,14 @@ MainView {
Constants{ id: constant }
CategoryModel {
id: categories
id: categoryModel
}
FeedModel {
id: feeds
onFeedUnreadChanged: {
var op = function(x) { return x - oldAmount + feed.unreadcount }
categories.updateUnreadCountForId(feed.categoryId, op)
//console.log("updating category with id: " + feed.categoryId + " op is " + op(0))
// update the 'All Feeds' Category
categories.updateUnreadCountForId(TTRss.constants['categories']['ALL'], op)
//console.log("updating special cat with id: " + TTRss.constants['categories']['ALL'] + " op is " + op(0))
// if there is an 'all feed items' update that aswell
if (feeds.count > 1) {
var m = feeds.get(0)
if (m.isCat) { // just check to be sure
if (feed.isCat && m.feedId == feed.feedId && feed.unreadcount == 0) {
// we can not determine where to substract, but when all is 0, we can update accordingly
for (var i = 1; i < feeds.count; i++) {
feeds.setProperty(i, "unreadcount", 0)
}
}
else {
feeds.setProperty(0, "unreadcount", op(m.unreadcount))
}
}
}
}
id: feedModel
categories: categoryModel
}
FeedItemModel {
id: feedItems
onItemUnreadChanged: {
var op = item.unread ?
function(x) { return x + 1 } :
function(x) { return x - 1 }
// update the feed's category
feeds.updateUnreadCountForId(item.feedId, op)
//console.log("updating feed with id: " + item.feedId + " op is " + op(0))
// update special for all feeditems category
categories.updateUnreadCountForId(
TTRss.constants['categories']['SPECIAL'],
op)
//console.log("updating special cat with id: " + TTRss.constants['categories']['SPECIAL'] + " op is " + op(0))
// if the item is new, update 'special feeds' for 'fresh articles'
// TODO
if (item.unread && false)
categories.updateUnreadCountForId(
TTRss.constants['categories']['SPECIAL'],
op)
// if item was is starred/published, update special feeds aswell
if (item.rss)
categories.updateUnreadCountForId(
TTRss.constants['categories']['SPECIAL'],
op)
if (item.marked)
categories.updateUnreadCountForId(
TTRss.constants['categories']['SPECIAL'],
op)
// maybe check if currently viewing special feeds and update published
// not nesseccary because this is updated by mark unread
}
onItemPublishedChanged: {
var op = item.rss ?
function(x) { return x + 1 } :
function(x) { return x - 1 }
// if the item is unread, update 'special feeds'
if (item.unread)
categories.updateUnreadCountForId(
TTRss.constants['categories']['SPECIAL'],
op)
// maybe check if currently viewing special feeds and update published
// not nesseccary because this is updated by mark unread
}
onItemStarChanged: {
var op = item.marked ?
function(x) { return x + 1 } :
function(x) { return x - 1 }
// if the item is unread, update 'special feeds'
if (item.unread)
categories.updateUnreadCountForId(
TTRss.constants['categories']['SPECIAL'],
op)
// maybe check if currently viewing special feeds and update starred
// not nesseccary because this is updated by mark unread
}
id: feedItemModel
categories: categoryModel
}
}

View file

@ -1,4 +1,5 @@
VERSION = 0.5.1
VERSION = 0.5.2
UBUNTU_REVISION = 1
DEFINES += APP_VERSION=\\\"$$VERSION\\\"
DEFINES += Q_OS_UBUNTU_TOUCH

View file

@ -11,5 +11,5 @@
\"maintainer\": \"Alberto Mardegan <info@mardy.it>\",
\"name\": \"it.mardy.ttrss\",
\"title\": \"Tiny Tiny RSS\",
\"version\": \"$${VERSION}-0\"
\"version\": \"$${VERSION}-$${UBUNTU_REVISION}\"
}

View file

@ -1,5 +1,7 @@
{
"policy_groups": [
"content_exchange",
"content_exchange_source",
"networking"
],
"policy_version": 1.2