From 0dc89f87fb8547a1ee5f25965f51ab59a4b9111b Mon Sep 17 00:00:00 2001 From: Morgan McMillian Date: Sat, 14 Apr 2018 13:19:51 -0700 Subject: [PATCH] add settings toggle for hiding long posts in the timeline --- assets/PostItem.qml | 11 ++++++++- assets/SettingsPage.qml | 49 ++++++++++++++++++++++++++++++++++++----- assets/StreamTab.qml | 7 ++++++ assets/ThreadPage.qml | 7 ++++++ translations/Goober.ts | 44 ++++++++++++++++++++++-------------- 5 files changed, 95 insertions(+), 23 deletions(-) diff --git a/assets/PostItem.qml b/assets/PostItem.qml index 0269eed..f7f3efa 100644 --- a/assets/PostItem.qml +++ b/assets/PostItem.qml @@ -158,7 +158,16 @@ Container { Container { // long post body topMargin: ui.sdu(2.0) bottomMargin: ui.sdu(2.0) - visible: (typeof ListItemData.longpost_body !== "undefined") + visible: { + if (postitem.ListItem.view.hideLongPosts()) { + return false + } else { + if (typeof ListItemData.longpost_body !== "undefined") { + return true + } + } + return false + } Divider { } Label { diff --git a/assets/SettingsPage.qml b/assets/SettingsPage.qml index b078d56..abb6d74 100644 --- a/assets/SettingsPage.qml +++ b/assets/SettingsPage.qml @@ -34,7 +34,7 @@ Page { Container { topPadding: ui.sdu(2) } - Container { + Container { // Unified home layout: DockLayout {} horizontalAlignment: HorizontalAlignment.Fill verticalAlignment: VerticalAlignment.Fill @@ -71,7 +71,7 @@ Page { } } Divider {} - Container { + Container { // CC setting layout: DockLayout {} horizontalAlignment: HorizontalAlignment.Fill verticalAlignment: VerticalAlignment.Fill @@ -110,7 +110,7 @@ Page { } } Divider {} - Container { + Container { // Hide photos setting layout: DockLayout {} horizontalAlignment: HorizontalAlignment.Fill verticalAlignment: VerticalAlignment.Fill @@ -149,7 +149,7 @@ Page { } } Divider {} - Container { + Container { // Hide avatar setting layout: DockLayout {} horizontalAlignment: HorizontalAlignment.Fill verticalAlignment: VerticalAlignment.Fill @@ -188,7 +188,46 @@ Page { } } Divider {} - Container { + Container { // Hide longposts setting + layout: DockLayout {} + horizontalAlignment: HorizontalAlignment.Fill + verticalAlignment: VerticalAlignment.Fill + Container { + verticalAlignment: VerticalAlignment.Center + leftPadding: ui.sdu(3) + Label { + text: qsTr("Hide long posts") + textStyle.fontSize: FontSize.Medium + textStyle.fontWeight: FontWeight.Bold + } + Label { + text: qsTr("Hide long posts in timeline") + textStyle.fontSize: FontSize.Small + multiline: true + } + } + Container { + id: longposttoggle + rightPadding: ui.sdu(3) + horizontalAlignment: HorizontalAlignment.Right + verticalAlignment: VerticalAlignment.Center + ToggleButton { + checked: _app.setting("hidelongp") + onCheckedChanged: { + if (checked) { + _app.setSetting("hidelongp", true) + reload() + } else { + _app.setSetting("hidelongp", false) + reload() + } + } + accessibility.name: "longposts" + } + } + } + Divider {} + Container { // Theme Setting leftPadding: ui.sdu(3) rightPadding: ui.sdu(3) DropDown { diff --git a/assets/StreamTab.qml b/assets/StreamTab.qml index 2c1a49a..6ca80e2 100644 --- a/assets/StreamTab.qml +++ b/assets/StreamTab.qml @@ -134,6 +134,13 @@ NavigationPane { return false } } + function hideLongPosts() { + if (_app.setting("hidelongp") === "true") { + return true + } else { + return false + } + } function copyText(text) { _app.copyText(text) } diff --git a/assets/ThreadPage.qml b/assets/ThreadPage.qml index ecc2a55..0b64f2a 100644 --- a/assets/ThreadPage.qml +++ b/assets/ThreadPage.qml @@ -81,6 +81,13 @@ Page { return false } } + function hideLongPosts() { + if (_app.setting("hidelongp") === "true") { + return true + } else { + return false + } + } function showImage(filename) { _app.showImage(filename) } diff --git a/translations/Goober.ts b/translations/Goober.ts index 37e0890..bb96a17 100644 --- a/translations/Goober.ts +++ b/translations/Goober.ts @@ -43,52 +43,52 @@ PostItem - + Reply - + Reply All - + Delete Bookmark - + Add Bookmark - + Delete Repost - + Repost - + Quote - + View Profile - + Copy text - + Delete @@ -205,17 +205,27 @@ - + + Hide long posts + + + + + Hide long posts in timeline + + + + Theme - + Bright - + Dark @@ -223,22 +233,22 @@ StreamTab - + New Post - + To Top - + To Bottom - + Reload