fix user profile crash

- 1st commit for fixing app crashes
This commit is contained in:
molan-git 2020-06-16 16:09:28 +02:00
parent 0446eda9d0
commit 674e96754b
14 changed files with 194 additions and 126 deletions

View file

Before

Width:  |  Height:  |  Size: 451 B

After

Width:  |  Height:  |  Size: 451 B

View file

@ -89,11 +89,11 @@ var tootParser = function(data){
ret.avatar_static = data.account.avatar_static ret.avatar_static = data.account.avatar_static
ret.favourited = data.favourited ? true : false ret.favourited = data.favourited ? true : false
ret.favourites_count = data.favourites_count ? data.favourites_count : 0 ret.status_favourites_count = data.favourites_count ? data.favourites_count : 0
ret.reblog = data.reblog ? true : false ret.reblog = data.reblog ? true : false
ret.reblogged = data.reblogged ? true : false ret.reblogged = data.reblogged ? true : false
ret.reblogs_count = data.reblogs_count ? data.reblogs_count : false ret.status_reblogs_count = data.reblogs_count ? data.reblogs_count : false
ret.muted = data.muted ? true : false ret.muted = data.muted ? true : false
ret.sensitive = data.sensitive ? true : false ret.sensitive = data.sensitive ? true : false

View file

@ -1,5 +1,8 @@
Qt.include("Mastodon.js") Qt.include("Mastodon.js")
var loadImages = true; var loadImages = true;
WorkerScript.onMessage = function(msg) { WorkerScript.onMessage = function(msg) {
console.log("Action > " + msg.action) console.log("Action > " + msg.action)
console.log("Model > " + msg.model) console.log("Model > " + msg.model)
@ -9,16 +12,17 @@ WorkerScript.onMessage = function(msg) {
// order notifications in ASC order // order notifications in ASC order
function orderNotifications(items){ function orderNotifications(items){
for (var i = items.length-1; i > 0; i--){ for (var i = items.length-1; i > 0; i--) {
if (items[i].id > 0 ) //msg.conf.notificationLastID) if (items[i].id > 0 ) //msg.conf.notificationLastID)
WorkerScript.sendMessage({ 'fireNotification': true, "data": items[i]}) WorkerScript.sendMessage({ 'fireNotification': true, "data": items[i]})
} }
} }
if (!msg.conf || !msg.conf.login){ if (!msg.conf || !msg.conf.login) {
console.log("Not loggedin") console.log("Not loggedin")
return; return;
} }
if (typeof msg.conf['loadImages'] !== "undefined") if (typeof msg.conf['loadImages'] !== "undefined")
loadImages = msg.conf['loadImages'] loadImages = msg.conf['loadImages']
@ -27,7 +31,7 @@ WorkerScript.onMessage = function(msg) {
API.post(msg.action, msg.params, function(data) { API.post(msg.action, msg.params, function(data) {
if (msg.bgAction){ if (msg.bgAction){
console.log(JSON.stringify(data)) console.log(JSON.stringify(data))
} else if (msg.action === "statuses"){ } else if (msg.action === "statuses") {
// status posted // status posted
if(msg.model){ if(msg.model){
var item = parseToot(data); var item = parseToot(data);
@ -59,7 +63,7 @@ WorkerScript.onMessage = function(msg) {
} else if(msg.action === "notifications") { } else if(msg.action === "notifications") {
// notification // notification
//console.log("Is notification... parsing...") // console.log("Is notification... parsing...")
console.log(JSON.stringify(data[i])) console.log(JSON.stringify(data[i]))
item = parseNotification(data[i]); item = parseNotification(data[i]);
items.push(item) items.push(item)
@ -90,14 +94,13 @@ WorkerScript.onMessage = function(msg) {
} }
addDataToModel (msg.model, "append", items); addDataToModel (msg.model, "append", items);
items = []; items = [];
} else if (data[i].hasOwnProperty("content")){ } else if (data[i].hasOwnProperty("content")){
//console.log("Is toot... parsing...") // console.log("Is toot... parsing...")
item = parseToot(data[i]); item = parseToot(data[i]);
item['id'] = item['status_id'] item['id'] = item['status_id']
items.push(item) items.push(item)
} else { } else {
WorkerScript.sendMessage({ 'action': msg.action, 'success': true, key: i, "data": data[i]}) WorkerScript.sendMessage({ 'action': msg.action, 'success': true, key: i, "data": data[i] })
} }
} }
} }
@ -108,39 +111,54 @@ WorkerScript.onMessage = function(msg) {
}); });
} }
//WorkerScript.sendMessage({ 'notifyNewItems': length - i }) //WorkerScript.sendMessage({ 'notifyNewItems': length - i })
function addDataToModel (model, mode, items){ function addDataToModel (model, mode, items) {
var length = items.length; var length = items.length;
console.log("Fetched > " +length) console.log("Fetched > " +length)
if (mode === "append") { if (mode === "append") {
model.append(items) model.append(items)
} else if (mode === "prepend") { } else if (mode === "prepend") {
for(var i = length-1; i >= 0 ; i--){ for(var i = length-1; i >= 0 ; i--) {
model.insert(0,items[i]) model.insert(0,items[i])
} }
} }
model.sync() model.sync()
} }
function parseAccounts(collection, prefix, data){
var res = collection;
// Get Account Data: Represents a user of Mastodon and their associated profile.
function parseAccounts(collection, prefix, data) {
var res = collection;
// Base attributes
res[prefix + 'account_id'] = data["id"] res[prefix + 'account_id'] = data["id"]
res[prefix + 'account_username'] = data["username"] res[prefix + 'account_username'] = data["username"]
res[prefix + 'account_acct'] = data["acct"] res[prefix + 'account_acct'] = data["acct"]
res[prefix + 'account_url'] = data["url"]
// Display attributes
res[prefix + 'account_display_name'] = data["display_name"] res[prefix + 'account_display_name'] = data["display_name"]
res[prefix + 'account_locked'] = data["locked"] res[prefix + 'account_note'] = data["note"]
res[prefix + 'account_created_at'] = data["created_at"]
res[prefix + 'account_avatar'] = data["avatar"] res[prefix + 'account_avatar'] = data["avatar"]
res[prefix + 'account_header'] = data["header"] res[prefix + 'account_header'] = data["header"]
res[prefix + 'account_locked'] = data["locked"]
//res[prefix + 'account_emojis'] = data["emojis"]
res[prefix + 'account_discoverable'] = data["discoverable"]
// Statistical attributes
res[prefix + 'account_created_at'] = data["created_at"]
res[prefix + 'account_statuses_count'] = data["statuses_count"]
res[prefix + 'account_followers_count'] = data["followers_count"]
res[prefix + 'account_following_count'] = data["following_count"]
// Optional attributes
//res[prefix + 'account_fields'] = data["fields"]
res[prefix + 'account_bot'] = data["bot"]
res[prefix + 'account_source'] = data["source"]
// console.log(JSON.stringify(res)) //console.log(JSON.stringify(res))
return (res); return (res);
} }
// Get Notification Data
function parseNotification(data){ function parseNotification(data){
//console.log(JSON.stringify(data)) //console.log(JSON.stringify(data))
var item = { var item = {
@ -153,29 +171,28 @@ function parseNotification(data){
if (!data.status) { if (!data.status) {
break; break;
} }
item = parseToot(data.status) item = parseToot(data.status)
item['typeIcon'] = "image://theme/icon-s-retweet" item['typeIcon'] = "image://theme/icon-s-retweet"
item['typeIcon'] = "image://theme/icon-s-alarm" item['typeIcon'] = "image://theme/icon-s-alarm"
item['type'] = "mention"; item['type'] = "mention"
break; break;
case "reblog": case "reblog":
if (!data.status) { if (!data.status) {
break; break;
} }
item = parseToot(data.status) item = parseToot(data.status)
item = parseAccounts(item, "reblog_", data["account"]) item = parseAccounts(item, "reblog_", data["account"])
item = parseAccounts(item, "", data["status"]["account"]) item = parseAccounts(item, "", data["status"]["account"])
item['status_reblog'] = true; item['status_reblog'] = true
item['type'] = "reblog"; item['type'] = "reblog"
item['typeIcon'] = "image://theme/icon-s-retweet" item['typeIcon'] = "image://theme/icon-s-retweet"
break; break;
case "favourite": case "favourite":
if (!data.status) { if (!data.status) {
break; break;
} }
item = parseToot(data.status) item = parseToot(data.status)
item = parseAccounts(item, "reblog_", data["account"]) item = parseAccounts(item, "reblog_", data["account"])
item = parseAccounts(item, "", data["status"]["account"]) item = parseAccounts(item, "", data["status"]["account"])
@ -184,15 +201,16 @@ function parseNotification(data){
item['type'] = "favourite"; item['type'] = "favourite";
//item['retweetScreenName'] = item['reblog_account_username']; //item['retweetScreenName'] = item['reblog_account_username'];
break; break;
case "follow": case "follow":
item['type'] = "follow"; item['type'] = "follow";
item = parseAccounts(item, "", data["account"]) item = parseAccounts(item, "", data["account"])
item = parseAccounts(item, "reblog_", data["account"]) item = parseAccounts(item, "reblog_", data["account"])
item['content'] = data['account']['note'] item['content'] = data['account']['note']
item['typeIcon'] = "../../images/icon-s-following.svg" item['typeIcon'] = "../../images/icon-s-follow.svg"
item['attachments'] = [] item['attachments'] = []
break; break;
default: default:
item['typeIcon'] = "image://theme/icon-s-sailfish" item['typeIcon'] = "image://theme/icon-s-sailfish"
} }
@ -215,41 +233,48 @@ function collect() {
} }
return ret; return ret;
} }
function getDate(dateStr){
function getDate(dateStr) {
var ts = new Date(dateStr); var ts = new Date(dateStr);
return new Date(ts.getFullYear(), ts.getMonth(), ts.getDate(), 0, 0, 0) return new Date(ts.getFullYear(), ts.getMonth(), ts.getDate(), 0, 0, 0)
} }
function parseToot (data){
// Get Status / Toot Data
function parseToot (data) {
var i = 0; var i = 0;
var item = {}; var item = {};
item['type'] = "toot" item['type'] = "toot"
item['highlight'] = false item['highlight'] = false
item['status_id'] = data["id"] item['status_id'] = data["id"]
item['status_uri'] = data["uri"] item['status_created_at'] = item['created_at'] = new Date(data["created_at"])
item['status_url'] = data["url"]
item['status_in_reply_to_id'] = data["in_reply_to_id"]
item['status_in_reply_to_account_id'] = data["in_reply_to_account_id"]
item['status_reblog'] = data["reblog"] ? true : false
item['status_content'] = data["content"]
item['status_created_at'] = item['created_at'] = new Date(data["created_at"]);
item['section'] = getDate(data["created_at"]);
item['reblogs_count'] = data["reblogs_count"]
item['favourites_count'] = data["favourites_count"]
item['reblogged'] = data["reblogged"]
item['favourited'] = data["favourited"]
item['bookmarked'] = data["bookmarked"]
item['status_sensitive'] = data["sensitive"] item['status_sensitive'] = data["sensitive"]
item['status_spoiler_text'] = data["spoiler_text"] item['status_spoiler_text'] = data["spoiler_text"]
item['status_visibility'] = data["visibility"] item['status_visibility'] = data["visibility"]
item['status_language'] = data["language"]
if(item['status_reblog']){ item['status_uri'] = data["uri"]
item['status_url'] = data["url"]
item['status_replies_count'] = data["replies_count"]
item['status_reblogs_count'] = data["reblogs_count"]
item['status_favourites_count'] = data["favourites_count"]
item['status_favourited'] = data["favourited"]
item['status_reblogged'] = data["reblogged"]
item['status_bookmarked'] = data["bookmarked"]
item['status_content'] = data["content"]
item['status_in_reply_to_id'] = data["in_reply_to_id"]
item['status_in_reply_to_account_id'] = data["in_reply_to_account_id"]
item['status_reblog'] = data["reblog"] ? true : false
item['section'] = getDate(data["created_at"])
// If Toot is a Reblog
if(item['status_reblog']) {
item['type'] = "reblog"; item['type'] = "reblog";
item['typeIcon'] = "image://theme/icon-s-retweet" item['typeIcon'] = "image://theme/icon-s-retweet"
item['status_id'] = data["reblog"]["id"]; item['status_id'] = data["reblog"]["id"];
item['status_spoiler_text'] = data["reblog"]["spoiler_text"] item['status_spoiler_text'] = data["reblog"]["spoiler_text"]
item['status_sensitive'] = data["reblog"]["sensitive"] item['status_sensitive'] = data["reblog"]["sensitive"]
item['emojis'] = data["reblog"]["emojis"];
item = parseAccounts(item, "", data['reblog']["account"]) item = parseAccounts(item, "", data['reblog']["account"])
item = parseAccounts(item, "reblog_", data["account"]) item = parseAccounts(item, "reblog_", data["account"])
} else { } else {
@ -262,14 +287,11 @@ function parseToot (data){
.replaceAll('class=""', ''); .replaceAll('class=""', '');
item['attachments'] = []; item['attachments'] = [];
// Media attachements in Toots
for(i = 0; i < data['media_attachments'].length ; i++) {
for(i = 0; i < data['media_attachments'].length ; i++){
var attachments = data['media_attachments'][i]; var attachments = data['media_attachments'][i];
item['content'] = item['content'].replaceAll(attachments['text_url'], '') item['content'] = item['content'].replaceAll(attachments['text_url'], '')
var tmp = { var tmp = {
id: attachments['id'],
id: attachments['id'], id: attachments['id'],
type: attachments['type'], type: attachments['type'],
url: attachments['remote_url'] && typeof attachments['remote_url'] == "string" ? attachments['remote_url'] : attachments['url'] , url: attachments['remote_url'] && typeof attachments['remote_url'] == "string" ? attachments['remote_url'] : attachments['url'] ,
@ -277,8 +299,10 @@ function parseToot (data){
} }
item['attachments'].push(tmp) item['attachments'].push(tmp)
} }
if(item['status_reblog']){
for(i = 0; i < data['reblog']['media_attachments'].length ; i++){ // Media attachements in Reblogs
if(item['status_reblog']) {
for(i = 0; i < data['reblog']['media_attachments'].length ; i++) {
var attachments = data['reblog']['media_attachments'][i]; var attachments = data['reblog']['media_attachments'][i];
item['content'] = item['content'].replaceAll(attachments['text_url'], '') item['content'] = item['content'].replaceAll(attachments['text_url'], '')
var tmp = { var tmp = {
@ -290,18 +314,20 @@ function parseToot (data){
item['attachments'].push(tmp) item['attachments'].push(tmp)
} }
} }
return addEmojis(item, data); return addEmojis(item, data);
} }
function addEmojis(item, data){ // Display function for custom Emojis in Toots
function addEmojis(item, data) {
var emoji, i; var emoji, i;
for (i = 0; i < data["emojis"].length; i++){ for (i = 0; i < data["emojis"].length; i++) {
emoji = data["emojis"][i]; emoji = data["emojis"][i];
item['content'] = item['content'].replaceAll(":"+emoji.shortcode+":", "<img src=\"" + emoji.static_url+"\" align=\"top\" width=\"50\" height=\"50\">") item['content'] = item['content'].replaceAll(":"+emoji.shortcode+":", "<img src=\"" + emoji.static_url+"\" align=\"top\" width=\"50\" height=\"50\">")
//console.log(JSON.stringify(data["emojis"][i])) //console.log(JSON.stringify(data["emojis"][i]))
} }
if (data["reblog"]) if (data["reblog"])
for (i = 0; i < data["reblog"]["emojis"].length; i++){ for (i = 0; i < data["reblog"]["emojis"].length; i++) {
emoji = data["reblog"]["emojis"][i]; emoji = data["reblog"]["emojis"][i];
item['content'] = item['content'].replaceAll(":"+emoji.shortcode+":", "<img src=\"" + emoji.static_url+"\" align=\"top\" width=\"50\" height=\"50\">") item['content'] = item['content'].replaceAll(":"+emoji.shortcode+":", "<img src=\"" + emoji.static_url+"\" align=\"top\" width=\"50\" height=\"50\">")
} }

View file

@ -173,10 +173,12 @@ Page {
} }
} }
onCountChanged: { onCountChanged: {
if (count > 0) {
positionViewAtBeginning(suggestedModel.count - 1, ListView.Beginning) positionViewAtBeginning(suggestedModel.count - 1, ListView.Beginning)
} }
} }
} }
}
DockedPanel { DockedPanel {
id: panel id: panel

View file

@ -175,7 +175,14 @@ Page {
"username": model.account_acct, "username": model.account_acct,
"user_id": model.account_id, "user_id": model.account_id,
"profileImage": model.account_avatar, "profileImage": model.account_avatar,
"profileBackground": model.account_header "profileBackground": model.account_header,
"note": model.account_note,
"url": model.account_url,
"followers_count": model.account_followers_count,
"following_count": model.account_following_count,
"statuses_count": model.account_statuses_count,
"locked": model.account_locked,
"bot": model.account_bot
}) })
} }
} }

View file

@ -19,14 +19,11 @@ Page {
property int statuses_count property int statuses_count
property int following_count property int following_count
property int followers_count property int followers_count
property int favourites_count
property int reblogs_count
property int count_moments
property bool locked: false property bool locked: false
property bool bot: false property bool bot: false
property bool following: false property bool following: false
property bool requested: false
property bool followed_by: false property bool followed_by: false
property bool requested: false
property bool blocking: false property bool blocking: false
property bool muting: false property bool muting: false
property bool domain_blocking: false property bool domain_blocking: false
@ -57,12 +54,12 @@ Page {
if(messageObject.action === "accounts/relationships/"){ if(messageObject.action === "accounts/relationships/"){
console.log(JSON.stringify(messageObject)) console.log(JSON.stringify(messageObject))
following= messageObject.data.following following = messageObject.data.following
requested= messageObject.data.requested requested = messageObject.data.requested
followed_by= messageObject.data.followed_by followed_by = messageObject.data.followed_by
blocking= messageObject.data.blocking blocking = messageObject.data.blocking
muting= messageObject.data.muting muting = messageObject.data.muting
domain_blocking= messageObject.data.domain_blocking domain_blocking = messageObject.data.domain_blocking
} }
switch (messageObject.key) { switch (messageObject.key) {
case 'followers_count': case 'followers_count':
@ -119,15 +116,18 @@ Page {
if (user_id) { if (user_id) {
msg = { msg = {
'action' : "accounts/relationships/", 'action' : "accounts/relationships/",
'params' : [ {name: "id", data: user_id}], 'params' : [ {name: "id", data: user_id} ],
'conf' : Logic.conf 'conf' : Logic.conf
} }
worker.sendMessage(msg) worker.sendMessage(msg)
msg = {
// reason for crashes when opening ProfilePage.qml
/* msg = {
'action' : "accounts/"+user_id, 'action' : "accounts/"+user_id,
'conf' : Logic.conf 'conf' : Logic.conf
} }
worker.sendMessage(msg) worker.sendMessage(msg) */
} else { } else {
var instance = Logic.conf['instance'].split("//") var instance = Logic.conf['instance'].split("//")
msg = { msg = {
@ -249,7 +249,7 @@ Page {
Text { Text {
id: txtFollowers id: txtFollowers
visible: followers_count ? true : false visible: true //followers_count ? true : false
text: followers_count+" "+ text: followers_count+" "+
//: Will show as: "35 Followers" //: Will show as: "35 Followers"
qsTr("Followers") qsTr("Followers")
@ -260,7 +260,7 @@ Page {
Text { Text {
id: txtFollowing id: txtFollowing
visible: following_count ? true : false visible: true //following_count ? true : false
text: following_count+" "+ text: following_count+" "+
//: Will show as: "23 Following" //: Will show as: "23 Following"
qsTr("Following") qsTr("Following")
@ -271,7 +271,7 @@ Page {
Text { Text {
id: txtStatuses id: txtStatuses
visible: statuses_count ? true : false visible: true //statuses_count ? true : false
text: statuses_count+" "+ text: statuses_count+" "+
//: Will show as: "115 Statuses" //: Will show as: "115 Statuses"
qsTr("Statuses") qsTr("Statuses")
@ -279,17 +279,6 @@ Page {
color: Theme.highlightColor color: Theme.highlightColor
wrapMode: Text.Wrap wrapMode: Text.Wrap
} }
/*Text {
id: txtFavourites
visible: favourites_count ? true : false
text: favourites_count+" "+
//: Will show as: "56 Favourites"
qsTr("Favourites")
font.pixelSize: Theme.fontSizeExtraSmall
color: Theme.highlightColor
wrapMode: Text.Wrap
} */
} }
Item { // dummy item for spacing Item { // dummy item for spacing

View file

@ -18,6 +18,7 @@ BackgroundItem {
anchors.left: parent.left anchors.left: parent.left
anchors.leftMargin: Theme.horizontalPageMargin anchors.leftMargin: Theme.horizontalPageMargin
color: Theme.highlightDimmerColor color: Theme.highlightDimmerColor
Image { Image {
id: img id: img
opacity: status === Image.Ready ? 1.0 : 0.0 opacity: status === Image.Ready ? 1.0 : 0.0
@ -41,7 +42,14 @@ BackgroundItem {
"username": model.account_acct, "username": model.account_acct,
"user_id": model.account_id, "user_id": model.account_id,
"profileImage": model.account_avatar, "profileImage": model.account_avatar,
"profileBackground": model.account_header "profileBackground": model.account_header,
"note": model.account_note,
"url": model.account_url,
"followers_count": model.account_followers_count,
"following_count": model.account_following_count,
"statuses_count": model.account_statuses_count,
"locked": model.account_locked,
"bot": model.account_bot
}) })
} }
} }
@ -54,7 +62,7 @@ BackgroundItem {
Label { Label {
id: display_name id: display_name
text: if (model.account_display_name + " ") { text: if (model.account_display_name === "") {
model.account_username.split("@")[0] + " " model.account_username.split("@")[0] + " "
} else model.account_display_name } else model.account_display_name
color: !pressed ? Theme.primaryColor : Theme.highlightColor color: !pressed ? Theme.primaryColor : Theme.highlightColor
@ -75,7 +83,14 @@ BackgroundItem {
"username": model.account_acct, "username": model.account_acct,
"user_id": model.account_id, "user_id": model.account_id,
"profileImage": model.account_avatar, "profileImage": model.account_avatar,
"profileBackground": model.account_header "profileBackground": model.account_header,
"note": model.account_note,
"url": model.account_url,
"followers_count": model.account_followers_count,
"following_count": model.account_following_count,
"statuses_count": model.account_statuses_count,
"locked": model.account_locked,
"bot": model.account_bot
} ) } )
} }

View file

@ -23,12 +23,14 @@ Item {
if (model && model.count) if (model && model.count)
count = model.count count = model.count
switch(count){ switch(count){
case 1: case 1:
placeholder1.width = holder.width placeholder1.width = holder.width
placeholder1.height = placeholder1.width*hRatio placeholder1.height = placeholder1.width*hRatio
placeholder1.visible = true; placeholder1.visible = true;
holder.height = placeholder1.height holder.height = placeholder1.height
break; break;
case 2: case 2:
placeholder1.visible = true; placeholder1.visible = true;
placeholder2.visible = true; placeholder2.visible = true;
@ -39,6 +41,7 @@ Item {
placeholder2.x = placeholder1.width + placeholder2.x + Theme.paddingSmall placeholder2.x = placeholder1.width + placeholder2.x + Theme.paddingSmall
holder.height = placeholder1.height holder.height = placeholder1.height
break; break;
case 3: case 3:
placeholder1.visible = true; placeholder1.visible = true;
placeholder2.visible = true; placeholder2.visible = true;
@ -53,8 +56,8 @@ Item {
placeholder3.height = placeholder3.width = placeholder2.height = placeholder2.width placeholder3.height = placeholder3.width = placeholder2.height = placeholder2.width
placeholder3.x = placeholder2.x = placeholder1.x + placeholder1.width + Theme.paddingSmall; placeholder3.x = placeholder2.x = placeholder1.x + placeholder1.width + Theme.paddingSmall;
placeholder3.y = placeholder2.y + placeholder2.height + Theme.paddingSmall; placeholder3.y = placeholder2.y + placeholder2.height + Theme.paddingSmall;
break; break;
case 4: case 4:
placeholder1.visible = true; placeholder1.visible = true;
placeholder2.visible = true; placeholder2.visible = true;
@ -67,9 +70,9 @@ Item {
placeholder3.x = 2*(placeholder1.width)+ 2*Theme.paddingSmall; placeholder3.x = 2*(placeholder1.width)+ 2*Theme.paddingSmall;
placeholder4.x = 3*(placeholder1.width)+ 3*Theme.paddingSmall; placeholder4.x = 3*(placeholder1.width)+ 3*Theme.paddingSmall;
holder.height = placeholder1.height holder.height = placeholder1.height
break; break;
default: default:
holder.height = 0 holder.height = 0
placeholder1.visible = placeholder2.visible = placeholder3.visible = placeholder4.visible = false; placeholder1.visible = placeholder2.visible = placeholder3.visible = placeholder4.visible = false;
@ -86,7 +89,7 @@ Item {
type = model.get(0).type type = model.get(0).type
previewURL = model.get(0).preview_url previewURL = model.get(0).preview_url
mediaURL = model.get(0).url mediaURL = model.get(0).url
height = 200 height = Theme.itemSizeLarge
return true return true
} else { } else {
height = 0 height = 0
@ -105,7 +108,7 @@ Item {
type = model.get(1).type type = model.get(1).type
previewURL = model.get(1).preview_url previewURL = model.get(1).preview_url
mediaURL = model.get(1).url mediaURL = model.get(1).url
height = 200 height = Theme.itemSizeLarge
return true return true
} else { } else {
height = 0 height = 0
@ -124,7 +127,7 @@ Item {
type = model.get(2).type type = model.get(2).type
previewURL = model.get(2).preview_url previewURL = model.get(2).preview_url
mediaURL = model.get(2).url mediaURL = model.get(2).url
height = 200 height = Theme.itemSizeLarge
return true return true
} else { } else {
height = 0 height = 0
@ -143,7 +146,7 @@ Item {
type = model.get(3).type type = model.get(3).type
previewURL = model.get(3).preview_url previewURL = model.get(3).preview_url
mediaURL = model.get(3).url mediaURL = model.get(3).url
height = 200 height = Theme.itemSizeLarge
return true return true
} else { } else {
height = 0 height = 0

View file

@ -11,7 +11,7 @@ FullscreenContentPage {
property string mediaURL: "" property string mediaURL: ""
allowedOrientations: Orientation.All allowedOrientations: Orientation.All
Component.onCompleted: function(){ Component.onCompleted: function() {
console.log(type) console.log(type)
console.log(previewURL) console.log(previewURL)
console.log(mediaURL) console.log(mediaURL)
@ -44,7 +44,7 @@ FullscreenContentPage {
Video { Video {
id: video id: video
anchors.fill: parent anchors.fill: parent
onErrorStringChanged: function(){ onErrorStringChanged: function() {
videoError.visible = true videoError.visible = true
} }
onStatusChanged: { onStatusChanged: {
@ -60,7 +60,7 @@ FullscreenContentPage {
} }
onPlaybackStateChanged: { onPlaybackStateChanged: {
console.log(playbackState) console.log(playbackState)
switch (playbackState){ switch (playbackState) {
case MediaPlayer.PlayingState: case MediaPlayer.PlayingState:
playerIcon.icon.source = "image://theme/icon-m-pause" playerIcon.icon.source = "image://theme/icon-m-pause"
return; return;
@ -72,7 +72,7 @@ FullscreenContentPage {
return; return;
} }
} }
onPositionChanged: function(){ onPositionChanged: function() {
//console.log(duration) //console.log(duration)
//console.log(bufferProgress) //console.log(bufferProgress)
//console.log(position) //console.log(position)
@ -84,7 +84,7 @@ FullscreenContentPage {
} }
} }
onStopped: function() { onStopped: function() {
if (video.duration < 30000) if (type != 'video')
video.play() video.play()
else else
video.stop() video.stop()
@ -151,7 +151,6 @@ FullscreenContentPage {
anchors.centerIn: parent anchors.centerIn: parent
} }
} }
} }
} }
@ -288,7 +287,7 @@ FullscreenContentPage {
id: failedLoading id: failedLoading
Text { Text {
text: qsTr("Error loading") text: qsTr("Error loading")
font.pixelSize: Theme.fontSizeSmall; font.pixelSize: Theme.fontSizeSmall
color: Theme.highlightColor color: Theme.highlightColor
} }
} }
@ -315,11 +314,10 @@ FullscreenContentPage {
} }
icon.source: "image://theme/icon-m-cloud-download" icon.source: "image://theme/icon-m-cloud-download"
onClicked: { onClicked: {
var filename = mediaURL.split("/"); var filename = mediaURL.split("/")
FileDownloader.downloadFile(mediaURL, filename[filename.length-1]); FileDownloader.downloadFile(mediaURL, filename[filename.length-1])
} }
} }
VerticalScrollDecorator { flickable: imageFlickable } VerticalScrollDecorator { flickable: imageFlickable }
} }

View file

@ -26,13 +26,8 @@ Item {
Label { Label {
id: lblRtByName id: lblRtByName
visible: type.length visible: type.length
anchors {
left: icon.right
leftMargin: Theme.paddingMedium
verticalCenter: icon.verticalCenter
}
text: { text: {
var action = ""; var action = ""
switch(type){ switch(type){
case "reblog": case "reblog":
action = qsTr('boosted'); action = qsTr('boosted');
@ -47,9 +42,14 @@ Item {
miniStatus.visible = false miniStatus.visible = false
action = type; action = type;
} }
return typeof reblog_account_username !== "undefined" ? '@' + reblog_account_username + ' ' + action : '' return typeof reblog_account_username !== "undefined" ? "@" + reblog_account_username + " " + action : " "
} }
font.pixelSize: Theme.fontSizeExtraSmall font.pixelSize: Theme.fontSizeExtraSmall
color: Theme.highlightColor color: Theme.highlightColor
anchors {
left: icon.right
leftMargin: Theme.paddingMedium
verticalCenter: icon.verticalCenter
}
} }
} }

View file

@ -84,7 +84,7 @@ SilicaListView {
} }
} }
delegate: VisualContainer {} delegate: VisualContainer { }
add: Transition { add: Transition {
NumberAnimation { property: "opacity"; from: 0; to: 1.0; duration: 800 } NumberAnimation { property: "opacity"; from: 0; to: 1.0; duration: 800 }

View file

@ -83,7 +83,14 @@ BackgroundItem {
"username": model.account_acct, "username": model.account_acct,
"user_id": model.account_id, "user_id": model.account_id,
"profileImage": model.account_avatar, "profileImage": model.account_avatar,
"profileBackground": model.account_header "profileBackground": model.account_header,
"note": model.account_note,
"url": model.account_url,
"followers_count": model.account_followers_count,
"following_count": model.account_following_count,
"statuses_count": model.account_statuses_count,
"locked": model.account_locked,
"bot": model.account_bot
} ) } )
} }
} }
@ -146,6 +153,26 @@ BackgroundItem {
width: Theme.iconSizeSmall width: Theme.iconSizeSmall
height: width height: width
} }
MouseArea {
anchors.fill: parent
onClicked: {
pageStack.push(Qt.resolvedUrl("../ProfilePage.qml"), {
"display_name": model.reblog_account_display_name,
"username": model.reblog_account_acct,
"user_id": model.reblog_account_id,
"profileImage": model.reblog_account_avatar,
"profileBackground": model.account_header,
"note": model.reblog_account_note,
"url": model.reblog_account_url,
"followers_count": model.reblog_account_followers_count,
"following_count": model.reblog_account_following_count,
"statuses_count": model.reblog_account_statuses_count,
"locked": model.reblog_account_locked,
"bot": model.reblog_account_bot
} )
}
}
} }
} }
@ -253,7 +280,7 @@ BackgroundItem {
left: lblContent.left left: lblContent.left
right: lblContent.right right: lblContent.right
top: lblContent.bottom top: lblContent.bottom
topMargin: Theme.paddingSmall topMargin: Theme.paddingMedium
bottomMargin: Theme.paddingLarge bottomMargin: Theme.paddingLarge
} }
} }
@ -275,7 +302,7 @@ BackgroundItem {
"bgAction": true, "bgAction": true,
"action" : "statuses/"+model.status_id+"/" + (status ? "unreblog" : "reblog") "action" : "statuses/"+model.status_id+"/" + (status ? "unreblog" : "reblog")
}) })
model.reblogs_count = !status ? model.reblogs_count+1 : (model.reblogs_count > 0 ? model.reblogs_count-1 : model.reblogs_count); model.status_reblogs_count = !status ? model.status_reblogs_count+1 : (model.status_reblogs_count > 0 ? model.status_reblogs_count-1 : model.status_reblogs_count);
model.reblogged = !model.reblogged model.reblogged = !model.reblogged
} }
@ -292,7 +319,7 @@ BackgroundItem {
} }
Label { Label {
text: reblogs_count text: status_reblogs_count // from API.js
font.pixelSize: Theme.fontSizeExtraSmall font.pixelSize: Theme.fontSizeExtraSmall
color: !model.reblogged ? Theme.highlightColor : Theme.primaryColor color: !model.reblogged ? Theme.highlightColor : Theme.primaryColor
anchors { anchors {
@ -316,7 +343,7 @@ BackgroundItem {
"bgAction": true, "bgAction": true,
"action" : "statuses/"+model.status_id+"/" + (status ? "unfavourite" : "favourite") "action" : "statuses/"+model.status_id+"/" + (status ? "unfavourite" : "favourite")
}) })
model.favourites_count = !status ? model.favourites_count+1 : (model.favourites_count > 0 ? model.favourites_count-1 : model.favourites_count); model.status_favourites_count = !status ? model.status_favourites_count+1 : (model.status_favourites_count > 0 ? model.status_favourites_count-1 : model.status_favourites_count);
model.favourited = !model.favourited model.favourited = !model.favourited
} }
@ -333,7 +360,7 @@ BackgroundItem {
} }
Label { Label {
text: favourites_count text: status_favourites_count // from API.js
font.pixelSize: Theme.fontSizeExtraSmall font.pixelSize: Theme.fontSizeExtraSmall
color: !model.favourited ? Theme.highlightColor : Theme.primaryColor color: !model.favourited ? Theme.highlightColor : Theme.primaryColor
anchors { anchors {
@ -386,8 +413,9 @@ BackgroundItem {
} }
onPressAndHold: { onPressAndHold: {
console.log(JSON.stringify(mdl.get(index))) console.log(JSON.stringify(mdl.get(index)))
mnu.show(delegate) mnu.open(delegate)
} }
onDoubleClicked: { onDoubleClicked: {
console.log("double click") console.log("double click")
} }

View file

@ -14,7 +14,7 @@ Name: harbour-tooter
%{?qtc_builddir:%define _builddir %qtc_builddir} %{?qtc_builddir:%define _builddir %qtc_builddir}
Summary: Tooter Summary: Tooter
Version: 1.0.4 Version: 1.0.4
Release: 1 Release: 9
Group: Qt/Qt Group: Qt/Qt
License: LICENSE License: LICENSE
URL: http://example.org/ URL: http://example.org/

View file

@ -1,7 +1,7 @@
Name: harbour-tooter Name: harbour-tooter
Summary: Tooter Summary: Tooter
Version: 1.0.4 Version: 1.0.4
Release: 1 Release: 9
# The contents of the Group field should be one of the groups listed here: # The contents of the Group field should be one of the groups listed here:
# https://github.com/mer-tools/spectacle/blob/master/data/GROUPS # https://github.com/mer-tools/spectacle/blob/master/data/GROUPS
Group: Qt/Qt Group: Qt/Qt