Fav + Boost option init

This commit is contained in:
Dusko Angirevic 2017-07-04 01:07:39 +02:00
parent 5f387b7ab6
commit b2017bacb4
11 changed files with 174 additions and 33 deletions

2
.gitignore vendored
View file

@ -2,3 +2,5 @@
*.user
harbour-tooter.pro.user
harbour-tooter.pro.user
harbour-tooter.pro.user.2549760

View file

@ -31,6 +31,9 @@ OTHER_FILES += qml/harbour-tooter.qml \
rpm/harbour-tooter.spec \
rpm/harbour-tooter.yaml \
translations/*.ts \
qml/pages/components/VisualContainer.qml \
qml/pages/components/MiniStatus.qml \
qml/pages/components/MiniHeader.qml \
harbour-tooter.desktop
SAILFISHAPP_ICONS = 86x86 108x108 128x128 256x256
@ -58,7 +61,4 @@ DISTFILES += \
qml/images/verified.svg \
qml/lib/Mastodon.js \
qml/lib/Worker.js \
qml/images/boosted.svg \
qml/pages/components/VisualContainer.qml \
qml/pages/components/MiniStatus.qml \
qml/pages/components/MiniHeader.qml
qml/images/boosted.svg

View file

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.0.1, 2017-06-15T15:42:07. -->
<!-- Written by QtCreator 4.0.1, 2017-07-02T11:48:16. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
<value type="QByteArray">{25497605-1bff-4134-a878-76c1475dd8e3}</value>
<value type="QByteArray">{41ec03ca-9430-48f3-b421-990d428b2838}</value>
</data>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
@ -61,12 +61,12 @@
<valuemap type="QVariantMap">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">MerSDK-SailfishOS-i486</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">MerSDK-SailfishOS-i486</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{f49c1b5a-d715-401a-9a10-0e5fe9e5b72a}</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{fd18ca89-dfc9-4054-9c53-c67be7689951}</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">2</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:/Users/dysko/SF/build-harbour-tooter-MerSDK_SailfishOS_i486-Debug</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/Users/dysko/GIT/build-harbour-tooter-MerSDK_SailfishOS_i486-Debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
@ -138,7 +138,7 @@
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:/Users/dysko/SF/build-harbour-tooter-MerSDK_SailfishOS_i486-Release</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/Users/dysko/GIT/build-harbour-tooter-MerSDK_SailfishOS_i486-Release</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
@ -210,7 +210,7 @@
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:/Users/dysko/SF/build-harbour-tooter-MerSDK_SailfishOS_i486-Profile</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/Users/dysko/GIT/build-harbour-tooter-MerSDK_SailfishOS_i486-Profile</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
@ -396,7 +396,7 @@
<value type="int">13</value>
<value type="int">14</value>
</valuelist>
<value type="QString" key="MerRunConfiguration.QmlLiveBenchWorkspace">C:/Users/dysko/SF/harbour-tooter</value>
<value type="QString" key="MerRunConfiguration.QmlLiveBenchWorkspace">/Users/dysko/GIT/harbour-tooter</value>
<value type="bool" key="MerRunConfiguration.QmlLiveEnabled">false</value>
<value type="int" key="MerRunConfiguration.QmlLiveIpcPort">10234</value>
<value type="int" key="MerRunConfiguration.QmlLiveOptions">3</value>
@ -414,7 +414,7 @@
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseMultiProcess">true</value>
<value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
</valuemap>
@ -426,12 +426,12 @@
<valuemap type="QVariantMap">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">MerSDK-SailfishOS-armv7hl</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">MerSDK-SailfishOS-armv7hl</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{588087e2-ecc1-41aa-b652-86f16cba9351}</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{f895389d-b51a-4d4f-8b03-5ec64bda6f66}</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">2</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:/Users/dysko/SF/build-harbour-tooter-MerSDK_SailfishOS_armv7hl-Debug</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/Users/dysko/GIT/build-harbour-tooter-MerSDK_SailfishOS_armv7hl-Debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
@ -503,7 +503,7 @@
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:/Users/dysko/SF/build-harbour-tooter-MerSDK_SailfishOS_armv7hl-Release</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/Users/dysko/GIT/build-harbour-tooter-MerSDK_SailfishOS_armv7hl-Release</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
@ -575,7 +575,7 @@
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:/Users/dysko/SF/build-harbour-tooter-MerSDK_SailfishOS_armv7hl-Profile</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/Users/dysko/GIT/build-harbour-tooter-MerSDK_SailfishOS_armv7hl-Profile</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
@ -761,7 +761,7 @@
<value type="int">13</value>
<value type="int">14</value>
</valuelist>
<value type="QString" key="MerRunConfiguration.QmlLiveBenchWorkspace">C:/Users/dysko/SF/harbour-tooter</value>
<value type="QString" key="MerRunConfiguration.QmlLiveBenchWorkspace">/Users/dysko/GIT/harbour-tooter</value>
<value type="bool" key="MerRunConfiguration.QmlLiveEnabled">false</value>
<value type="int" key="MerRunConfiguration.QmlLiveIpcPort">10234</value>
<value type="int" key="MerRunConfiguration.QmlLiveOptions">3</value>
@ -779,7 +779,7 @@
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseMultiProcess">true</value>
<value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
</valuemap>

View file

@ -14,18 +14,20 @@ WorkerScript.onMessage = function(msg) {
}
}
if (!msg.conf.login){
if (!msg.conf || !msg.conf.login){
console.log("Not loggedin")
return;
}
var API = MastodonAPI({ instance: msg.conf.instance, api_user_token: msg.conf.api_user_token});
if (msg.method === "POST"){
API.post(msg.action, msg.params, function(data) {
if (msg.action === "statuses"){
if (msg.bgAction){
console.log(JSON.stringify(data))
} else if (msg.action === "statuses"){
// status posted
if(msg.model){
var item = parseToot(data);
msg.model.append(item)
var item = parseToot(data);
msg.model.append(item)
msg.model.sync();
}
@ -201,6 +203,7 @@ function getDate(dateStr){
function parseToot (data){
//console.log(JSON.stringify(data))
var item = {};
item['type'] = "toot"
item['highlight'] = false
item['status_id'] = data["id"]
item['status_uri'] = data["uri"]

View file

@ -45,10 +45,13 @@ Item {
placeholder1.width = holder.width - Theme.paddingSmall - Theme.itemSizeLarge;
placeholder1.height = Theme.itemSizeLarge*2+Theme.paddingSmall
holder.height = placeholder1.height
placeholder2.width = Theme.itemSizeLarge;
placeholder2.height = placeholder2.width
placeholder2.x = placeholder1.x + placeholder1.width + Theme.paddingSmall;
placeholder3.height = placeholder3.width = placeholder2.height = placeholder2.width
placeholder3.x = placeholder2.x = placeholder1.x + placeholder1.width + Theme.paddingSmall;
placeholder3.y = placeholder2.y + placeholder2.height + Theme.paddingSmall;
break;
case 4:
placeholder1.visible = true;
@ -67,6 +70,7 @@ Item {
break;
default:
holder.height = 0
placeholder1.visible = placeholder2.visible = placeholder3.visible = placeholder4.visible = false;
}
}

View file

@ -1,5 +1,6 @@
import QtQuick 2.2
import Sailfish.Silica 1.0
import "../../lib/API.js" as Logic
BackgroundItem {
@ -44,6 +45,19 @@ BackgroundItem {
})
}
}
Image {
id: iconTR
anchors {
top: avatar.bottom
topMargin: Theme.paddingMedium
left: avatar.left
}
visible: typeof status_reblogged !== "undefined" && status_reblogged
width: Theme.iconSizeExtraSmall
height: width
source: "image://theme/icon-s-retweet"
}
Rectangle {
color: Theme.highlightDimmerColor
@ -137,14 +151,37 @@ BackgroundItem {
}
ContextMenu {
id: mnu
MenuItem {
text: "Toggle bold font"
}
MenuItem {
text: "Remove"
onClicked: model.remove(model.index)
}
}
MenuItem {
visible: model.type === "retoot" || model.type === "toot"
text: typeof status_reblogged !== "undefined" && status_reblogged ? qsTr("Unboost") : qsTr("Boost")
onClicked: {
var reblogged = typeof status_reblogged !== "undefined" && status_reblogged
worker.sendMessage({
"conf" : Logic.conf,
"params" : [],
"method" : "POST",
//"bgAction": true,
"action" : "statuses/"+model.status_id+"/" + (reblogged ? "unreblog" : "reblog")
})
model['status_reblogged'] = !reblogged
}
}
MenuItem {
visible: model.type === "retoot" || model.type === "toot"
text: typeof status_favourited !== "undefined" && status_favourited ? qsTr("Unfavorite") : qsTr("Favorite")
onClicked: {
var favourited = typeof status_favourited !== "undefined" && status_favourited
worker.sendMessage({
"conf" : Logic.conf,
"params" : [],
"method" : "POST",
//"bgAction": true,
"action" : "statuses/"+model.status_id+"/" + (favourited ? "unfavourite" : "favourite")
})
model['status_favourited'] = !favourited
}
}
}
@ -162,7 +199,7 @@ BackgroundItem {
})
}
onPressAndHold: {
console.log(lblContent.text)
console.log(model['status_reblogged'])
mnu.show(delegate)
}
onDoubleClicked: {

View file

@ -191,4 +191,23 @@
<translation>te siguió</translation>
</message>
</context>
<context>
<name>VisualContainer</name>
<message>
<source>Unboost</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Boost</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unfavorite</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Favorite</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>

View file

@ -191,4 +191,23 @@
<translation>vous suit</translation>
</message>
</context>
<context>
<name>VisualContainer</name>
<message>
<source>Unboost</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Boost</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unfavorite</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Favorite</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>

View file

@ -191,4 +191,23 @@
<translation>volgde jou</translation>
</message>
</context>
<context>
<name>VisualContainer</name>
<message>
<source>Unboost</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Boost</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unfavorite</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Favorite</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>

View file

@ -191,4 +191,23 @@
<translation>vos sèc</translation>
</message>
</context>
<context>
<name>VisualContainer</name>
<message>
<source>Unboost</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Boost</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unfavorite</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Favorite</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>

View file

@ -191,4 +191,23 @@
<translation>followed you</translation>
</message>
</context>
<context>
<name>VisualContainer</name>
<message>
<source>Unboost</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Boost</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unfavorite</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Favorite</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>