Link to full-size media instead of the previews

This commit is contained in:
Christian Muehlhaeuser 2019-05-09 04:29:48 +02:00
parent c41ee5b1e7
commit f7f79907db
No known key found for this signature in database
GPG key ID: 3CF9FA45CA1EBB7E
7 changed files with 44 additions and 40 deletions

View file

@ -32,6 +32,11 @@ type Follow struct {
FollowedBy bool
}
type Media struct {
Preview string
URL string
}
// MessageEvent describes an incoming message event.
type MessageEvent struct {
Account string
@ -44,7 +49,7 @@ type MessageEvent struct {
Notification bool
Post Post
Follow Follow
Media []string
Media []Media
}
// ProfileEvent describes a profile event.

View file

@ -322,7 +322,10 @@ func (mod *Account) handleNotification(n *mastodon.Notification) {
}
for _, v := range n.Status.MediaAttachments {
ev.Media = append(ev.Media, v.PreviewURL)
ev.Media = append(ev.Media, accounts.Media{
Preview: v.PreviewURL,
URL: v.URL,
})
}
}
@ -419,14 +422,20 @@ func (mod *Account) handleStatus(s *mastodon.Status) accounts.MessageEvent {
}
for _, v := range s.MediaAttachments {
ev.Media = append(ev.Media, v.PreviewURL)
ev.Media = append(ev.Media, accounts.Media{
Preview: v.PreviewURL,
URL: v.URL,
})
}
if s.Reblog != nil {
ev.Forward = true
for _, v := range s.Reblog.MediaAttachments {
ev.Media = append(ev.Media, v.PreviewURL)
ev.Media = append(ev.Media, accounts.Media{
Preview: v.PreviewURL,
URL: v.URL,
})
}
ev.Post.URL = s.Reblog.URL

View file

@ -35,7 +35,8 @@ func messageFromEvent(event accounts.MessageEvent) *Message {
p.Liked = event.Post.Liked
p.Shared = event.Post.Shared
if len(event.Media) > 0 {
p.Media = event.Media[0]
p.MediaPreview = event.Media[0].Preview
p.MediaURL = event.Media[0].URL
}
if p.Followed {

View file

@ -34,7 +34,8 @@ const (
Followed
Following
FollowedBy
Media
MediaPreview
MediaURL
Editing
Liked
Shared
@ -79,7 +80,8 @@ type Message struct {
Followed bool
Following bool
FollowedBy bool
Media string
MediaPreview string
MediaURL string
Editing bool
Liked bool
Shared bool
@ -107,7 +109,8 @@ func (m *MessageModel) init() {
Followed: core.NewQByteArray2("followed", -1),
Following: core.NewQByteArray2("following", -1),
FollowedBy: core.NewQByteArray2("followedby", -1),
Media: core.NewQByteArray2("media", -1),
MediaPreview: core.NewQByteArray2("mediapreview", -1),
MediaURL: core.NewQByteArray2("mediaurl", -1),
Editing: core.NewQByteArray2("editing", -1),
Liked: core.NewQByteArray2("liked", -1),
Shared: core.NewQByteArray2("shared", -1),
@ -236,9 +239,13 @@ func (m *MessageModel) data(index *core.QModelIndex, role int) *core.QVariant {
{
return core.NewQVariant11(p.FollowedBy)
}
case Media:
case MediaPreview:
{
return core.NewQVariant14(p.Media)
return core.NewQVariant14(p.MediaPreview)
}
case MediaURL:
{
return core.NewQVariant14(p.MediaURL)
}
case Editing:
{

View file

@ -22,7 +22,8 @@ Popup {
property bool forward
property bool mention
property bool like
property string media
property string mediapreview
property string mediaurl
property bool liked
property bool shared
@ -59,7 +60,8 @@ Popup {
forward: popup.forward
mention: popup.mention
like: popup.like
media: popup.media
mediapreview: popup.mediapreview
mediaurl: popup.mediaurl
liked: popup.liked
shared: popup.shared
}

View file

@ -27,7 +27,8 @@ ColumnLayout {
property bool followed: model.followed
property bool following: model.following
property bool followedby: model.followedby
property string media: model.media
property string mediapreview: model.mediapreview
property string mediaurl: model.mediaurl
property bool liked: model.liked
property bool shared: model.shared
@ -198,21 +199,21 @@ ColumnLayout {
}
ImageButton {
visible: media != ""
visible: mediapreview != ""
Layout.topMargin: 4
Layout.fillWidth: true
// Layout.maximumWidth: sourceSize.width
Layout.maximumHeight: (accountBridge.username == author && (like || forward)) ?
Math.min(384 / 3, paintedHeight + 8) :
Math.min(384, paintedHeight + 8)
source: media
source: mediapreview
fillMode: Image.PreserveAspectFit
verticalAlignment: Image.AlignBottom
autoTransform: true
opacity: fadeMedia ? 0.2 : 1.0
onClicked: function() {
Qt.openUrlExternally(media)
Qt.openUrlExternally(mediaurl)
}
}
@ -262,6 +263,8 @@ ColumnLayout {
messagePopup.replytoauthor = replytoauthor
messagePopup.forward = forward
messagePopup.mention = mention
messagePopup.mediapreview = mediapreview
messagePopup.mediaurl = mediaurl
messagePopup.like = like
messagePopup.liked = liked
messagePopup.shared = shared

View file

@ -8,33 +8,21 @@ ListModel {
avatar: "https://pbs.twimg.com/profile_images/779041781413507072/TaqJsdzS_normal.jpg"
body: "This is a very, very long test post, that should probably get word-wrapped. But does it work?"
createdat: "now"
actor: ""
actorname: ""
reply: false
replytoid: ""
replytoauthor: ""
forward: false
mention: false
like: false
media: ""
}
ListElement {
name: ""
messageid: ""
author: ""
avatar: "https://pbs.twimg.com/profile_images/779041781413507072/TaqJsdzS_normal.jpg"
body: ""
createdat: "now"
actor: "afriend"
actorname: "Alex Friend"
reply: false
replytoid: ""
replytoauthor: ""
forward: false
mention: false
like: false
followed: true
media: ""
}
ListElement {
name: "Some Guy With A Really Really Long Name"
@ -43,8 +31,6 @@ ListModel {
avatar: "https://pbs.twimg.com/profile_images/707382834827120640/R-Eb9YZB_normal.jpg"
body: "This is a response"
createdat: "now"
actor: ""
actorname: ""
reply: true
replytoid: "901223685058703361"
replytoauthor: "mueslix"
@ -52,7 +38,6 @@ ListModel {
mention: false
like: false
liked: true
media: ""
}
ListElement {
name: "Dummy User"
@ -64,13 +49,11 @@ ListModel {
actor: "mueslix"
actorname: "Christian Muehlhaeuser"
reply: false
replytoid: ""
replytoauthor: ""
forward: true
mention: false
like: false
shared: true
media: "https://pbs.twimg.com/media/DIfdvcxXkAUXAvs.jpg"
mediapreview: "https://pbs.twimg.com/media/DIfdvcxXkAUXAvs.jpg"
}
ListElement {
name: "Another User"
@ -82,12 +65,9 @@ ListModel {
actor: "mueslix"
actorname: "Christian Muehlhaeuser"
reply: false
replytoid: ""
replytoauthor: ""
forward: false
mention: true
like: false
media: ""
}
ListElement {
name: "This Poster"
@ -99,11 +79,8 @@ ListModel {
actor: "mueslix"
actorname: "Christian Muehlhaeuser"
reply: false
replytoid: ""
replytoauthor: ""
forward: false
mention: false
like: true
media: ""
}
}