Real "copy URL" & "copy path" context menu entries
Replace the poorly implemented 2-in-1 "copy address" media event menu option with: - Copy <mediaType> address: visible for non-encrypted media, always copies the http URL - Copy local path: always visible for already downloaded media, even if they were downloaded before mirage was started
This commit is contained in:
@@ -13,6 +13,6 @@ AudioPlayer {
|
||||
HoverHandler {
|
||||
onHoveredChanged:
|
||||
eventDelegate.hoveredMediaTypeUrl =
|
||||
hovered ? [Utils.Media.Audio, audio.source] : []
|
||||
hovered ? [Utils.Media.Audio, audio.source, loader.title] : []
|
||||
}
|
||||
}
|
||||
|
@@ -5,11 +5,12 @@ import QtQuick.Layouts 1.12
|
||||
import Clipboard 0.1
|
||||
import "../../.."
|
||||
import "../../../Base"
|
||||
import "../../../PythonBridge"
|
||||
|
||||
HColumnLayout {
|
||||
id: eventDelegate
|
||||
|
||||
property var hoveredMediaTypeUrl: []
|
||||
property var hoveredMediaTypeUrl: [] // [] or [mediaType, url, title]
|
||||
|
||||
property var fetchProfilesFuture: null
|
||||
|
||||
@@ -41,7 +42,7 @@ HColumnLayout {
|
||||
combine
|
||||
|
||||
readonly property int cursorShape:
|
||||
eventContent.hoveredLink || hoveredMediaTypeUrl.length > 0 ?
|
||||
eventContent.hoveredLink || hoveredMediaTypeUrl.length === 3 ?
|
||||
Qt.PointingHandCursor :
|
||||
|
||||
eventContent.hoveredSelectable ? Qt.IBeamCursor :
|
||||
@@ -140,8 +141,25 @@ HColumnLayout {
|
||||
|
||||
property var media: []
|
||||
property string link: ""
|
||||
property var localPath: null
|
||||
property Future getLocalFuture: null
|
||||
|
||||
onClosed: { media = []; link = "" }
|
||||
readonly property bool isEncryptedMedia:
|
||||
Object.keys(JSON.parse(model.media_crypt_dict)).length > 0
|
||||
|
||||
onClosed: {
|
||||
if (getLocalFuture) getLocalFuture.cancel()
|
||||
media = []
|
||||
link = ""
|
||||
}
|
||||
|
||||
onOpened: if (media.length === 3 && media[1].startsWith("mxc://")) {
|
||||
getLocalFuture = py.callCoro(
|
||||
"media_cache.get_local_media",
|
||||
[media[1], media[2]],
|
||||
path => { localPath = path; getLocalFuture = null },
|
||||
)
|
||||
}
|
||||
|
||||
HMenuItem {
|
||||
icon.name: "toggle-select-message"
|
||||
@@ -163,14 +181,21 @@ HColumnLayout {
|
||||
onTriggered: eventList.checkFromLastToHere(model.index)
|
||||
}
|
||||
|
||||
HMenuItem {
|
||||
icon.name: "copy-local-path"
|
||||
text: qsTr("Copy local path")
|
||||
visible: Boolean(contextMenu.localPath)
|
||||
onTriggered:
|
||||
Clipboard.text =
|
||||
contextMenu.localPath.replace(/^file:\/\//, "")
|
||||
}
|
||||
|
||||
HMenuItem {
|
||||
id: copyMedia
|
||||
icon.name: "copy-link"
|
||||
text:
|
||||
contextMenu.media.length < 1 ? "" :
|
||||
|
||||
contextMenu.media[0] === Utils.Media.Page ?
|
||||
qsTr("Copy page address") :
|
||||
contextMenu.media.length === 0 || isEncryptedMedia ?
|
||||
"" :
|
||||
|
||||
contextMenu.media[0] === Utils.Media.File ?
|
||||
qsTr("Copy file address") :
|
||||
@@ -181,17 +206,13 @@ HColumnLayout {
|
||||
contextMenu.media[0] === Utils.Media.Video ?
|
||||
qsTr("Copy video address") :
|
||||
|
||||
contextMenu.media[0] === Utils.Media.Audio ?
|
||||
qsTr("Copy audio address") :
|
||||
|
||||
qsTr("Copy media address")
|
||||
qsTr("Copy audio address")
|
||||
|
||||
visible: Boolean(text)
|
||||
onTriggered: Clipboard.text = contextMenu.media[1]
|
||||
}
|
||||
|
||||
HMenuItem {
|
||||
id: copyLink
|
||||
icon.name: "copy-link"
|
||||
text: qsTr("Copy link address")
|
||||
visible: Boolean(contextMenu.link)
|
||||
@@ -201,12 +222,8 @@ HColumnLayout {
|
||||
HMenuItem {
|
||||
icon.name: "copy-text"
|
||||
text:
|
||||
eventList.selectedCount ?
|
||||
qsTr("Copy selection") :
|
||||
|
||||
copyMedia.visible ?
|
||||
qsTr("Copy filename") :
|
||||
|
||||
eventList.selectedCount ? qsTr("Copy selection") :
|
||||
contextMenu.media.length > 0 ? qsTr("Copy filename") :
|
||||
qsTr("Copy text")
|
||||
|
||||
onTriggered: {
|
||||
|
@@ -60,12 +60,8 @@ HTile {
|
||||
return
|
||||
}
|
||||
|
||||
eventDelegate.hoveredMediaTypeUrl = [
|
||||
Utils.Media.File,
|
||||
// XXX
|
||||
// loader.downloadedPath.replace(/^file:\/\//, "") ||
|
||||
loader.mediaUrl
|
||||
]
|
||||
eventDelegate.hoveredMediaTypeUrl =
|
||||
[Utils.Media.File, loader.mediaUrl, loader.title]
|
||||
}
|
||||
|
||||
Binding on backgroundColor {
|
||||
|
@@ -99,12 +99,8 @@ HMxcImage {
|
||||
return
|
||||
}
|
||||
|
||||
eventDelegate.hoveredMediaTypeUrl = [
|
||||
Utils.Media.Image,
|
||||
// XXX
|
||||
// loader.downloadedPath.replace(/^file:\/\//, "") ||
|
||||
loader.mediaUrl
|
||||
]
|
||||
eventDelegate.hoveredMediaTypeUrl =
|
||||
[Utils.Media.Image, loader.mediaUrl, loader.title]
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -27,6 +27,8 @@ HLoader {
|
||||
eventList.getMediaType(singleMediaInfo) :
|
||||
utils.getLinkType(mediaUrl)
|
||||
|
||||
readonly property string cachedLocalPath: ""
|
||||
|
||||
readonly property string thumbnailMxc: singleMediaInfo.thumbnail_url
|
||||
|
||||
|
||||
|
@@ -12,5 +12,5 @@ VideoPlayer {
|
||||
|
||||
onHoveredChanged:
|
||||
eventDelegate.hoveredMediaTypeUrl =
|
||||
hovered ? [Utils.Media.Video, video.source] : []
|
||||
hovered ? [Utils.Media.Video, video.source, loader.title] : []
|
||||
}
|
||||
|
Reference in New Issue
Block a user