[ubuntu] Add Save action to images on long press
When a long press gesture is detected, popup a context menu. If the underlying item is an image, use the DownloadManager to download it and transfer to another app.
This commit is contained in:
parent
25f15ef7c9
commit
c9dad9174c
6 changed files with 120 additions and 7 deletions
44
qml/ttrss/ubuntu-touch/ContextMenu.qml
Normal file
44
qml/ttrss/ubuntu-touch/ContextMenu.qml
Normal 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,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
import QtQuick 2.0
|
||||
import Ubuntu.Components 1.1
|
||||
import Ubuntu.Components.Popups 1.0
|
||||
|
||||
Item {
|
||||
id: root
|
||||
|
|
@ -87,6 +88,7 @@ Item {
|
|||
rightMargin: Theme.paddingLarge
|
||||
}
|
||||
}
|
||||
|
||||
RescalingRichText {
|
||||
id: itemView
|
||||
width: parent.width
|
||||
|
|
@ -94,6 +96,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,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
47
qml/ttrss/ubuntu-touch/FileSaver.qml
Normal file
47
qml/ttrss/ubuntu-touch/FileSaver.qml
Normal 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
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
import QtQuick 2.0
|
||||
import Ubuntu.Components 0.1
|
||||
import Ubuntu.Components.ListItems 1.0 as ListItem
|
||||
import Ubuntu.Keyboard 0.1
|
||||
//import Ubuntu.Keyboard 0.1
|
||||
|
||||
Item {
|
||||
id: root
|
||||
|
|
@ -60,7 +60,7 @@ Item {
|
|||
inputMethodHints: Qt.ImhUrlCharactersOnly + Qt.ImhNoPredictiveText
|
||||
KeyNavigation.tab: username
|
||||
Keys.onReturnPressed: username.forceActiveFocus()
|
||||
InputMethod.extensions: { "enterKeyText": qsTr("Next") }
|
||||
//InputMethod.extensions: { "enterKeyText": qsTr("Next") }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -81,7 +81,7 @@ Item {
|
|||
KeyNavigation.tab: password
|
||||
KeyNavigation.backtab: server
|
||||
Keys.onReturnPressed: password.forceActiveFocus()
|
||||
InputMethod.extensions: { "enterKeyText": qsTr("Next") }
|
||||
//InputMethod.extensions: { "enterKeyText": qsTr("Next") }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -100,7 +100,7 @@ Item {
|
|||
enabled: !network.loading
|
||||
KeyNavigation.backtab: username
|
||||
Keys.onReturnPressed: root.submit()
|
||||
InputMethod.extensions: { "enterKeyText": qsTr("Login") }
|
||||
//InputMethod.extensions: { "enterKeyText": qsTr("Login") }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
{
|
||||
"policy_groups": [
|
||||
"content_exchange",
|
||||
"content_exchange_source",
|
||||
"networking"
|
||||
],
|
||||
"policy_version": 1.2
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue