diff options
Diffstat (limited to 'eventsview-plugins/eventsview-plugin-mastodon/MastodonFeedItem.qml')
| -rw-r--r-- | eventsview-plugins/eventsview-plugin-mastodon/MastodonFeedItem.qml | 71 |
1 files changed, 55 insertions, 16 deletions
diff --git a/eventsview-plugins/eventsview-plugin-mastodon/MastodonFeedItem.qml b/eventsview-plugins/eventsview-plugin-mastodon/MastodonFeedItem.qml index c003950..63b9556 100644 --- a/eventsview-plugins/eventsview-plugin-mastodon/MastodonFeedItem.qml +++ b/eventsview-plugins/eventsview-plugin-mastodon/MastodonFeedItem.qml @@ -1,11 +1,12 @@ -/**************************************************************************** - ** - ** Copyright (C) 2013-2026 Jolla Ltd. - ** - ****************************************************************************/ +/* + * SPDX-FileCopyrightText: 2013 - 2026 Jolla Ltd. + * + * SPDX-License-Identifier: BSD-3-Clause + */ import QtQuick 2.0 import Sailfish.Silica 1.0 +import Sailfish.Share 1.0 import Sailfish.TextLinking 1.0 import org.nemomobile.lipstick 0.1 import "shared" @@ -35,10 +36,19 @@ SocialMediaFeedItem { property var _actionMenu property real _contextMenuHeight: (_contextMenuOpen && _actionMenu) ? _actionMenu.height : 0 - property string _booster: item.stringValue("boostedBy", "rebloggedBy", "retweeter") - property string _displayName: item.stringValue("name", "displayName", "display_name") - property string _accountName: item.stringValue("accountName", "acct", "screenName", "username") - property string _bodyText: item.stringValue("body", "content", "text") + property string _booster: model && model.boostedBy ? model.boostedBy.toString() : "" + property string _displayName: model && model.name ? model.name.toString() : "" + property string _accountName: model && model.accountName ? model.accountName.toString() : "" + property string _bodyText: model && model.body ? model.body.toString() : "" + //: Action label shown in Mastodon interaction menu. + //% "Share" + readonly property string _shareActionText: qsTrId("lipstick-jolla-home-la-mastodon_share") + //: Link title used when sharing a Mastodon post. + //% "Post from Mastodon" + readonly property string _shareLinkTitle: qsTrId("lipstick-jolla-home-la-mastodon_share_link_title") + property var _shareAction: ShareAction { + title: item._shareActionText + } timestamp: model.timestamp onRefreshTimeCountChanged: formattedTime = Format.formatDate(model.timestamp, Format.TimeElapsed) @@ -257,6 +267,10 @@ SocialMediaFeedItem { return isNaN(parsed) ? -1 : parsed } + function shareStatusUrl() { + return item.stringValue("url", "link", "uri") + } + function topLevelParent() { var p = item while (p && p.parent) { @@ -354,12 +368,12 @@ SocialMediaFeedItem { width: parent.width height: Theme.itemSizeMedium - onXPosChanged: hoveredIndex = xPos < width / 2 ? 0 : 1 + onXPosChanged: hoveredIndex = Math.max(0, Math.min(2, Math.floor((xPos * 3) / Math.max(1, width)))) onDownChanged: if (!down) hoveredIndex = -1 onClicked: { xPos = _contentColumn.mapFromItem(actionMenu, actionMenu.mouseX, actionMenu.mouseY).x - var index = hoveredIndex >= 0 ? hoveredIndex : (xPos < width / 2 ? 0 : 1) + var index = hoveredIndex >= 0 ? hoveredIndex : Math.max(0, Math.min(2, Math.floor((xPos * 3) / Math.max(1, width)))) if (!actionEnabled) { return } @@ -371,19 +385,30 @@ SocialMediaFeedItem { } else { item.postActions.favourite(accountId, postId) } - } else { + } else if (index === 1) { if (item.isReblogged) { item.postActions.unboost(accountId, postId) } else { item.postActions.boost(accountId, postId) } + } else { + var shareUrl = item.shareStatusUrl() + if (shareUrl.length === 0) { + return + } + item._shareAction.resources = [{ + "data": shareUrl, + "linkTitle": item._shareLinkTitle, + "type": "text/x-url" + }] + item._shareAction.trigger() } } Rectangle { anchors.verticalCenter: parent.verticalCenter - x: horizontalActions.hoveredIndex === 1 ? parent.width / 2 : 0 - width: parent.width / 2 + x: (horizontalActions.hoveredIndex >= 0 ? horizontalActions.hoveredIndex : 0) * (parent.width / 3) + width: parent.width / 3 height: parent.height visible: horizontalActions.down && horizontalActions.hoveredIndex >= 0 color: Theme.rgba(Theme.highlightBackgroundColor, Theme.highlightBackgroundOpacity) @@ -393,7 +418,7 @@ SocialMediaFeedItem { anchors.fill: parent Label { - width: parent.width / 2 + width: parent.width / 3 height: parent.height horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter @@ -409,7 +434,7 @@ SocialMediaFeedItem { } Label { - width: parent.width / 2 + width: parent.width / 3 height: parent.height horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter @@ -423,6 +448,20 @@ SocialMediaFeedItem { ? Theme.secondaryHighlightColor : Theme.primaryColor)) : Theme.rgba(Theme.secondaryColor, 0.4) } + + Label { + width: parent.width / 3 + height: parent.height + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + font.pixelSize: Theme.fontSizeExtraLarge + text: "\u260D" + color: horizontalActions.actionEnabled + ? (((horizontalActions.down && horizontalActions.hoveredIndex === 2) + || (horizontalActions.highlighted && horizontalActions.hoveredIndex === 2)) + ? Theme.secondaryHighlightColor : Theme.primaryColor) + : Theme.rgba(Theme.secondaryColor, 0.4) + } } } } |
