Added Settings page

This commit is contained in:
Dusko Angirevic 2017-07-20 12:14:16 +02:00
parent eadfbf6985
commit 9975b54630
17 changed files with 481 additions and 62 deletions

View file

@ -63,7 +63,10 @@ DISTFILES += \
qml/images/tooter.svg \
qml/lib/Mastodon.js \
qml/lib/Worker.js \
qml/images/boosted.svg
qml/images/boosted.svg \
qml/pages/Settings.qml \
qml/pages/components/MediaBlock.qml \
qml/pages/components/MyImage.qml
HEADERS += \
src/imageuploader.h

View file

@ -51,6 +51,7 @@ ApplicationWindow
Logic.api = new Logic.MastodonAPI({ instance: Logic.conf['instance'], api_user_token: "" });
}
if (Logic.conf['login']) {
//Logic.conf['notificationLastID'] = 0
Logic.api.setConfig("api_user_token", Logic.conf['api_user_token'])
pageStack.push(Qt.resolvedUrl("./pages/MainPage.qml"), {})
//pageStack.push(Qt.resolvedUrl("./pages/Conversation.qml"), {})

View file

@ -162,7 +162,7 @@ var notifier = function(item){
msg = {
urgency: "low",
timestamp: item.created_at,
summary: (item.account_display_name !== "" ? item.account_display_name : '@'+item.account_username) + ' ' + qsTr("boosted"),
summary: (item.reblog_account_display_name !== "" ? item.reblog_account_display_name : '@'+item.reblog_account_username) + ' ' + qsTr("boosted"),
body: item.content
}
break;

View file

@ -1,4 +1,5 @@
Qt.include("Mastodon.js")
var loadImages = true;
WorkerScript.onMessage = function(msg) {
console.log("Action > " + msg.action)
console.log("Model > " + msg.model)
@ -18,6 +19,9 @@ WorkerScript.onMessage = function(msg) {
console.log("Not loggedin")
return;
}
if (typeof msg.conf['loadImages'] !== "undefined")
loadImages = msg.conf['loadImages']
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) {
@ -246,6 +250,8 @@ function parseToot (data){
item['content'] = item['content'].replaceAll('#'+tag, '<a href="#'+tag+'">'+tag+'</a>')
}*/
item['attachments'] = [];
console.log("Image "+loadImages)
for(var i = 0; i < data['media_attachments'].length ; i++){
var attachments = data['media_attachments'][i];
item['content'] = item['content'].replaceAll(attachments['text_url'], '')
@ -254,7 +260,7 @@ function parseToot (data){
id: attachments['id'],
type: attachments['type'],
url: attachments['remote_url'] !=="" ? attachments['remote_url'] : attachments['url'] ,
preview_url: attachments['preview_url']
preview_url: loadImages ? attachments['preview_url'] : ''
})
}
/*item['content'] = item['content'].split(" ")

View file

@ -12,6 +12,7 @@ Page {
property alias avatar: header.image
property int toot_id
property ListModel mdl;
allowedOrientations: Orientation.All
ListModel {
id: mediaModel
onCountChanged: {

View file

@ -37,6 +37,7 @@ import "./components/"
Page {
id: mainPage
property bool isFirstPage: true
property bool isTablet: true; //Screen.sizeCategory >= Screen.Large
// The effective value will be restricted by ApplicationWindow.allowedOrientations
allowedOrientations: Orientation.All
@ -63,8 +64,8 @@ Page {
title: qsTr("Home")
type: "timelines/home"
mdl: Logic.modelTLhome
width: parent.width
height: parent.height
width: parent.itemWidth
height: parent.itemHeight
onOpenDrawer: infoPanel.open = setDrawer
}
MyList{
@ -72,8 +73,8 @@ Page {
title: qsTr("Timeline")
type: "timelines/public"
mdl: Logic.modelTLpublic
width: parent.width
height: parent.height
width: parent.itemWidth
height: parent.itemHeight
onOpenDrawer: infoPanel.open = setDrawer
}
MyList{
@ -82,8 +83,8 @@ Page {
type: "notifications"
notifier: true
mdl: Logic.modelTLnotifications
width: parent.width
height: parent.height
width: parent.itemWidth
height: parent.itemHeight
onOpenDrawer: infoPanel.open = setDrawer
}
MyList{
@ -102,8 +103,8 @@ Page {
title: qsTr("Search")
type: ""
mdl: ListModel {}
width: parent.width
height: parent.height
width: parent.itemWidth
height: parent.itemHeight
onOpenDrawer: infoPanel.open = setDrawer
header: SearchField {
@ -130,7 +131,8 @@ Page {
id: slideshow
width: parent.width
height: parent.height
itemWidth: parent.width
itemWidth: isTablet ? Math.round(parent.width) : parent.width
itemHeight: height
clip: true
onCurrentIndexChanged: {
navigation.slideshowIndexChanged(currentIndex)
@ -148,6 +150,7 @@ Page {
Component.onCompleted: {
}
}
IconButton {
anchors {
right: (mainPage.isPortrait ? parent.right : infoPanel.left)

160
qml/pages/Settings.qml Normal file
View file

@ -0,0 +1,160 @@
import QtQuick 2.0
import Sailfish.Silica 1.0
import "../lib/API.js" as Logic
Page {
SilicaFlickable {
anchors.fill: parent
contentHeight: column.height + Theme.paddingLarge
contentWidth: parent.width
VerticalScrollDecorator {}
Column {
id: column
spacing: Theme.paddingSmall
width: parent.width
PageHeader {
title: qsTr("Settings")
}
Column {
// No spacing in this column
width: parent.width
IconTextSwitch {
text: Logic.conf['login'] ? qsTr("Remove Account"): qsTr("Add Account")
description: Logic.conf['login'] ? qsTr("Deauthorize this app and remove your account") : qsTr("Authorize this app to use your Mastodon account in your behalf")
icon.source: Logic.conf['login'] ? "image://theme/icon-m-people" : "image://theme/icon-m-add"
onClicked: {
if (Logic.conf['login']) {
Logic.conf['login'] = false
Logic.conf['instance'] = null;
Logic.conf['api_user_token'] = null;
}
pageStack.push(Qt.resolvedUrl("LoginPage.qml"))
}
}
IconTextSwitch {
//enabled: false
checked: typeof Logic.conf['loadImages'] !== "undefined" && Logic.conf['loadImages']
text: qsTr("Load images in toots")
description: qsTr("Disable this option if you want to preserve your data connection")
icon.source: "image://theme/icon-m-mobile-network"
onClicked: {
Logic.conf['loadImages'] = checked
}
}
IconTextSwitch {
text: qsTr("Translate")
description: qsTr("Use Transifex to help with app translation to your language")
icon.source: "image://theme/icon-m-presence"
onClicked: {
Qt.openUrlExternally("https://www.transifex.com/dysko/tooter/");
}
}
}
SectionHeader {
text: qsTr("Credits")
}
Column {
width: parent.width
anchors {
left: parent.left
right: parent.right
rightMargin: Theme.horizontalPageMargin
}
Repeater {
model: ListModel {
ListElement {
name: "Duško Angirević"
desc: qsTr("UI/UX design and development")
mastodon: "dysko@mastodon.social"
mail: ""
}
ListElement {
name: "Miodrag Nikolić"
desc: "visual identity"
mastodon: ""
mail: "micotakis@gmail.com"
}
ListElement {
name: "Quentin PAGÈS / Quenti ♏"
desc: "Occitan & French translation"
mastodon: "Quenti@framapiaf.org"
mail: ""
}
ListElement {
name: "André Koot"
desc: "Dutch translation"
mastodon: "meneer@mastodon.social"
mail: "https://twitter.com/meneer"
}
ListElement {
name: "Carlos Gonzalez / Caballlero"
desc: "Español translation"
mastodon: ""
mail: "carlosgonz@protonmail.com"
}
ListElement {
name: "Mohamed-Touhami MAHDI"
desc: "Added README file"
mastodon: "dragnucs@touha.me"
mail: "touhami@touha.me"
}
}
Item {
width: parent.width
height: Theme.itemSizeMedium
IconButton {
id: btn
anchors {
verticalCenter: parent.verticalCenter
right: parent.right
}
icon.source: "image://theme/" + (model.mastodon !== "" ? "icon-m-person" : "icon-m-mail") + "?" + (pressed
? Theme.highlightColor
: Theme.primaryColor)
onClicked: {
if (model.mastodon !== ""){
var m = Qt.createQmlObject('import QtQuick 2.0; ListModel { }', Qt.application, 'InternalQmlObject');
pageStack.push(Qt.resolvedUrl("Conversation.qml"), {
toot_id: 0,
title: model.name,
description: '@'+model.mastodon,
avatar: "",
mdl: m,
type: "reply"
})
} else {
Qt.openUrlExternally("mailto:"+model.mail);
}
}
}
Column {
anchors {
verticalCenter: parent.verticalCenter
left: parent.left
leftMargin: Theme.horizontalPageMargin
right: btn.left
rightMargin: Theme.paddingMedium
}
Label {
id: lblName
text: model.name
color: Theme.secondaryColor
font.pixelSize: Theme.fontSizeSmall
}
Label {
text: model.desc
color: Theme.secondaryHighlightColor
font.pixelSize: Theme.fontSizeExtraSmall
}
}
}
}
}
}
}
}

View file

@ -61,7 +61,7 @@ Item {
anchors {
right: parent.right
baseline: lblName.baseline
rightMargin: Theme.paddingLarge
rightMargin: Theme.horizontalPageMargin
}
}
}

View file

@ -6,6 +6,16 @@ Item {
property string type : ""
property string previewURL: ""
property string mediaURL: ""
Rectangle {
opacity: 0.2
anchors.fill: parent
color: Theme.highlightDimmerColor
}
Image {
anchors.centerIn: parent
source: "image://theme/icon-m-image"
}
Image {
id: img
anchors.fill: parent
@ -46,4 +56,5 @@ Item {
}
}
}
}

View file

@ -58,14 +58,9 @@ SilicaListView {
PullDownMenu {
MenuItem {
text: Logic.conf['login'] ? qsTr("Logout"): qsTr("Login")
text: qsTr("Settings")
onClicked: {
if (Logic.conf['login']) {
Logic.conf['login'] = false
Logic.conf['instance'] = null;
Logic.conf['api_user_token'] = null;
Logic.conf['dysko'] = null;
}
pageStack.push(Qt.resolvedUrl("../Settings.qml"), {})
}
}

View file

@ -34,6 +34,13 @@ BackgroundItem {
smooth: true
source: account_avatar
visible: true
onStatusChanged: {
if (avatar.status === Image.Error)
source = "image://theme/icon-m-person?" + (pressed
? Theme.highlightColor
: Theme.primaryColor)
}
MouseArea {
anchors.fill: parent
onClicked: {
@ -101,7 +108,7 @@ BackgroundItem {
topMargin: Theme.paddingSmall
bottomMargin: Theme.paddingLarge
}
height: content.length ? paintedHeight : 0
height: content.length ? (contentWarningLabel.paintedHeight > paintedHeight ? contentWarningLabel.paintedHeight : paintedHeight) : 0
onLinkActivated: {
var test = link.split("/")
console.log(link)
@ -138,11 +145,22 @@ BackgroundItem {
color: Theme.highlightDimmerColor
visible: status_spoiler_text.length > 0
Label {
id: contentWarningLabel
font.pixelSize: Theme.fontSizeExtraSmall
horizontalAlignment: Text.AlignHCenter
anchors.centerIn: parent
anchors {
topMargin: Theme.paddingSmall
left: parent.left
leftMargin: Theme.paddingMedium
centerIn: parent
right: parent.right
rightMargin: Theme.paddingMedium
bottomMargin: Theme.paddingSmall
}
width: parent.width
truncationMode: TruncationMode.Fade
color: Theme.highlightColor
wrapMode: Text.WordWrap
text: model.status_spoiler_text
}
MouseArea {

View file

@ -33,3 +33,9 @@
* Thu July 7 2017 Dusko Angirevic <dysko@me.com> 0.1.9-0
- Image Upload added [#9]
- Emoji pannel added
- ES lang update by Carlos Gonzales
* Thu July 20 2017 Dusko Angirevic <dysko@me.com> 0.2.0-0
- Better tablet displaying
- "boosted" notification bugfix
- ES lang update by Caballlero

View file

@ -133,12 +133,8 @@
<translation>Cargar más</translation>
</message>
<message>
<source>Logout</source>
<translation>Cerrar sesión</translation>
</message>
<message>
<source>Login</source>
<translation>Iniciar sesión</translation>
<source>Settings</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
@ -192,6 +188,53 @@
<translation>Seguidores</translation>
</message>
</context>
<context>
<name>Settings</name>
<message>
<source>Settings</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Remove Account</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Add Account</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Load images in toots</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Credits</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>UI/UX design and development</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Translate</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Deauthorize this app and remove your account</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Authorize this app to use your Mastodon account in your behalf</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Disable this option if you want to preserve your data connection</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Use Transifex to help with app translation to your language</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>Toot</name>
<message>

View file

@ -133,12 +133,8 @@
<translation>Charger plus</translation>
</message>
<message>
<source>Logout</source>
<translation>Déconnexion</translation>
</message>
<message>
<source>Login</source>
<translation>Connexion</translation>
<source>Settings</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
@ -192,6 +188,53 @@
<translation>Abonnés</translation>
</message>
</context>
<context>
<name>Settings</name>
<message>
<source>Settings</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Remove Account</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Add Account</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Load images in toots</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Credits</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>UI/UX design and development</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Translate</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Deauthorize this app and remove your account</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Authorize this app to use your Mastodon account in your behalf</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Disable this option if you want to preserve your data connection</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Use Transifex to help with app translation to your language</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>Toot</name>
<message>

View file

@ -133,11 +133,7 @@
<translation type="unfinished"></translation>
</message>
<message>
<source>Logout</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Login</source>
<source>Settings</source>
<translation type="unfinished"></translation>
</message>
</context>
@ -192,6 +188,53 @@
<translation>Volgers</translation>
</message>
</context>
<context>
<name>Settings</name>
<message>
<source>Settings</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Remove Account</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Add Account</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Load images in toots</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Credits</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>UI/UX design and development</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Translate</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Deauthorize this app and remove your account</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Authorize this app to use your Mastodon account in your behalf</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Disable this option if you want to preserve your data connection</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Use Transifex to help with app translation to your language</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>Toot</name>
<message>

View file

@ -133,12 +133,8 @@
<translation>Cargar mai</translation>
</message>
<message>
<source>Logout</source>
<translation>Desconnexion</translation>
</message>
<message>
<source>Login</source>
<translation>Connexion</translation>
<source>Settings</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
@ -192,6 +188,53 @@
<translation>Seguidors</translation>
</message>
</context>
<context>
<name>Settings</name>
<message>
<source>Settings</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Remove Account</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Add Account</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Load images in toots</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Credits</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>UI/UX design and development</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Translate</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Deauthorize this app and remove your account</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Authorize this app to use your Mastodon account in your behalf</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Disable this option if you want to preserve your data connection</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Use Transifex to help with app translation to your language</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>Toot</name>
<message>

View file

@ -39,46 +39,46 @@
<name>Conversation</name>
<message>
<source>Conversation</source>
<translation type="unfinished"></translation>
<translation>Conversation</translation>
</message>
<message>
<source>Content warning!</source>
<translation type="unfinished"></translation>
<translation>Content warning!</translation>
</message>
<message>
<source>public</source>
<translation type="unfinished"></translation>
<translation>public</translation>
</message>
<message>
<source>unlisted</source>
<translation type="unfinished"></translation>
<translation>unlisted</translation>
</message>
<message>
<source>followers only</source>
<translation type="unfinished"></translation>
<translation>followers only</translation>
</message>
<message>
<source>direct</source>
<translation type="unfinished"></translation>
<translation>direct</translation>
</message>
<message>
<source>Delete</source>
<translation type="unfinished"></translation>
<translation>Delete</translation>
</message>
<message>
<source>Emojis</source>
<translation type="unfinished"></translation>
<translation>Emojis</translation>
</message>
<message>
<source>Tap to insert</source>
<translation type="unfinished"></translation>
<translation>Tap to insert</translation>
</message>
</context>
<context>
<name>ImageUploader</name>
<message>
<source>The file %1 does not exists</source>
<translation>The file %1 does not exists</translation>
<translation></translation>
</message>
</context>
<context>
@ -133,12 +133,8 @@
<translation>Load more</translation>
</message>
<message>
<source>Logout</source>
<translation>Logout</translation>
</message>
<message>
<source>Login</source>
<translation>Login</translation>
<source>Settings</source>
<translation>Settings</translation>
</message>
</context>
<context>
@ -192,6 +188,53 @@
<translation>Followers</translation>
</message>
</context>
<context>
<name>Settings</name>
<message>
<source>Settings</source>
<translation>Settings</translation>
</message>
<message>
<source>Remove Account</source>
<translation>Remove Account</translation>
</message>
<message>
<source>Add Account</source>
<translation>Add Account</translation>
</message>
<message>
<source>Authorize this app to use your Mastodon account in your behalf</source>
<translation>Authorize this app to use your Mastodon account in your behalf</translation>
</message>
<message>
<source>Load images in toots</source>
<translation>Load images in toots</translation>
</message>
<message>
<source>Deauthorize this app and remove your account</source>
<translation>Deauthorize this app and remove your account</translation>
</message>
<message>
<source>Credits</source>
<translation>Credits</translation>
</message>
<message>
<source>Translate</source>
<translation>Translate</translation>
</message>
<message>
<source>Use Transifex to help with app translation to your language</source>
<translation>Use Transifex to help with app translation to your language</translation>
</message>
<message>
<source>Disable this option if you want to preserve your data connection</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>UI/UX design and development</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>Toot</name>
<message>