fix(URLUnfurling): Updated image context menu
Also moved copyToClipboard function in Utils and updated Chat section to use it from there Closes #11941
This commit is contained in:
parent
61b217c5eb
commit
ed065a94f9
|
@ -231,11 +231,6 @@ QtObject {
|
||||||
stickersModuleInst.send(channelId, hash, replyTo, pack, url)
|
stickersModuleInst.send(channelId, hash, replyTo, pack, url)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: This seems to be better in Utils.qml
|
|
||||||
function copyToClipboard(text) {
|
|
||||||
globalUtilsInst.copyToClipboard(text)
|
|
||||||
}
|
|
||||||
|
|
||||||
function isCurrentUser(pubkey) {
|
function isCurrentUser(pubkey) {
|
||||||
return userProfileInst.pubKey === pubkey
|
return userProfileInst.pubKey === pubkey
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,7 +90,7 @@ ColumnLayout {
|
||||||
asset.name: "copy"
|
asset.name: "copy"
|
||||||
iconButton.onClicked: {
|
iconButton.onClicked: {
|
||||||
let link = Utils.getCommunityShareLink(root.community.id)
|
let link = Utils.getCommunityShareLink(root.community.id)
|
||||||
root.rootStore.copyToClipboard(link)
|
Utils.copyToClipboard(link)
|
||||||
tooltip.visible = !tooltip.visible
|
tooltip.visible = !tooltip.visible
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,7 @@ StatusModal {
|
||||||
: Global.leaveCommunityRequested(root.community.name, root.community.id, root.community.outroMessage)
|
: Global.leaveCommunityRequested(root.community.name, root.community.id, root.community.outroMessage)
|
||||||
}
|
}
|
||||||
onCopyToClipboard: {
|
onCopyToClipboard: {
|
||||||
root.store.copyToClipboard(link);
|
Utils.copyToClipboard(link);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,7 @@ StatusDialog {
|
||||||
objectName: "copyCommunityPrivateKeyButton"
|
objectName: "copyCommunityPrivateKeyButton"
|
||||||
onClicked: {
|
onClicked: {
|
||||||
text = qsTr("Copied")
|
text = qsTr("Copied")
|
||||||
root.store.copyToClipboard(root.privateKey)
|
Utils.copyToClipboard(root.privateKey)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,9 +106,8 @@ QtObject {
|
||||||
openPopup(downloadPageComponent, popupProperties)
|
openPopup(downloadPageComponent, popupProperties)
|
||||||
}
|
}
|
||||||
|
|
||||||
function openImagePopup(image) {
|
function openImagePopup(image, url) {
|
||||||
var popup = imagePopupComponent.createObject(popupParent)
|
openPopup(imagePopupComponent, {image: image, url: url})
|
||||||
popup.openPopup(image)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function openProfilePopup(publicKey: string, parentPopup, cb) {
|
function openProfilePopup(publicKey: string, parentPopup, cb) {
|
||||||
|
|
|
@ -12,6 +12,8 @@ Popup {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
property var store
|
property var store
|
||||||
|
property var image
|
||||||
|
property string url: ""
|
||||||
|
|
||||||
modal: true
|
modal: true
|
||||||
Overlay.modal: Rectangle {
|
Overlay.modal: Rectangle {
|
||||||
|
@ -26,12 +28,12 @@ Popup {
|
||||||
}
|
}
|
||||||
padding: 0
|
padding: 0
|
||||||
|
|
||||||
function setPopupData(image) {
|
onOpened: {
|
||||||
messageImage.source = image.source;
|
messageImage.source = root.image.source;
|
||||||
const maxHeight = Global.applicationWindow.height - 80
|
const maxHeight = Global.applicationWindow.height - 80
|
||||||
const maxWidth = Global.applicationWindow.width - 80
|
const maxWidth = Global.applicationWindow.width - 80
|
||||||
|
|
||||||
if (image.sourceSize.width >= maxWidth || image.sourceSize.height >= maxHeight) {
|
if (root.image.sourceSize.width >= maxWidth || root.image.sourceSize.height >= maxHeight) {
|
||||||
this.width = maxWidth
|
this.width = maxWidth
|
||||||
this.height = maxHeight
|
this.height = maxHeight
|
||||||
} else {
|
} else {
|
||||||
|
@ -40,11 +42,6 @@ Popup {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function openPopup(image) {
|
|
||||||
setPopupData(image);
|
|
||||||
open()
|
|
||||||
}
|
|
||||||
|
|
||||||
contentItem: AnimatedImage {
|
contentItem: AnimatedImage {
|
||||||
id: messageImage
|
id: messageImage
|
||||||
asynchronous: true
|
asynchronous: true
|
||||||
|
@ -64,7 +61,7 @@ Popup {
|
||||||
if (mouse.button === Qt.RightButton)
|
if (mouse.button === Qt.RightButton)
|
||||||
Global.openMenu(imageContextMenu,
|
Global.openMenu(imageContextMenu,
|
||||||
messageImage,
|
messageImage,
|
||||||
{ imageSource: messageImage.source })
|
{ imageSource: messageImage.source, url: root.url})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,21 @@
|
||||||
|
import QtQuick 2.15
|
||||||
import StatusQ.Popups 0.1
|
import StatusQ.Popups 0.1
|
||||||
|
|
||||||
import utils 1.0
|
import utils 1.0
|
||||||
|
|
||||||
StatusMenu {
|
StatusMenu {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
|
property string url
|
||||||
property string imageSource
|
property string imageSource
|
||||||
|
|
||||||
|
QtObject {
|
||||||
|
id: d
|
||||||
|
readonly property bool isUnfurled: (!!url&&url!=="")
|
||||||
readonly property bool isGif: root.imageSource.toLowerCase().endsWith(".gif")
|
readonly property bool isGif: root.imageSource.toLowerCase().endsWith(".gif")
|
||||||
|
}
|
||||||
|
|
||||||
StatusAction {
|
StatusAction {
|
||||||
text: root.isGif ? qsTr("Copy GIF") : qsTr("Copy image")
|
text: d.isGif ? qsTr("Copy GIF") : qsTr("Copy image")
|
||||||
icon.name: "copy"
|
icon.name: "copy"
|
||||||
enabled: !!root.imageSource
|
enabled: !!root.imageSource
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
|
@ -19,11 +24,29 @@ StatusMenu {
|
||||||
}
|
}
|
||||||
|
|
||||||
StatusAction {
|
StatusAction {
|
||||||
text: root.isGif ? qsTr("Download GIF") : qsTr("Download image")
|
text: d.isGif ? qsTr("Download GIF") : qsTr("Download image")
|
||||||
icon.name: "download"
|
icon.name: "download"
|
||||||
enabled: !!root.imageSource
|
enabled: !!root.imageSource
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
Global.openDownloadImageDialog(root.imageSource)
|
Global.openDownloadImageDialog(root.imageSource);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
StatusAction {
|
||||||
|
text: qsTr("Copy link")
|
||||||
|
icon.name: "copy"
|
||||||
|
enabled: d.isUnfurled
|
||||||
|
onTriggered: {
|
||||||
|
Utils.copyToClipboard(url);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
StatusAction {
|
||||||
|
text: qsTr("Open link")
|
||||||
|
icon.name: "browser"
|
||||||
|
enabled: d.isUnfurled
|
||||||
|
onTriggered: {
|
||||||
|
Qt.openUrlExternally(url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ ColumnLayout {
|
||||||
|
|
||||||
property bool isCurrentUser: false
|
property bool isCurrentUser: false
|
||||||
|
|
||||||
signal imageClicked(var image, var mouse, var imageSource)
|
signal imageClicked(var image, var mouse, var imageSource, string url)
|
||||||
|
|
||||||
Repeater {
|
Repeater {
|
||||||
id: linksRepeater
|
id: linksRepeater
|
||||||
|
@ -86,8 +86,8 @@ ColumnLayout {
|
||||||
id: linkImage
|
id: linkImage
|
||||||
|
|
||||||
readonly property bool globalAnimationEnabled: root.messageStore.playAnimation
|
readonly property bool globalAnimationEnabled: root.messageStore.playAnimation
|
||||||
|
readonly property string urlLink: url
|
||||||
property bool localAnimationEnabled: true
|
property bool localAnimationEnabled: true
|
||||||
|
|
||||||
objectName: "LinksMessageView_unfurledImageComponent_linkImage"
|
objectName: "LinksMessageView_unfurledImageComponent_linkImage"
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
source: thumbnailUrl
|
source: thumbnailUrl
|
||||||
|
@ -101,7 +101,7 @@ ColumnLayout {
|
||||||
if (isAnimated && !playing)
|
if (isAnimated && !playing)
|
||||||
localAnimationEnabled = true
|
localAnimationEnabled = true
|
||||||
else
|
else
|
||||||
root.imageClicked(linkImage.imageAlias, mouse, source)
|
root.imageClicked(linkImage.imageAlias, mouse, source, urlLink)
|
||||||
}
|
}
|
||||||
imageAlias.cache: localAnimationEnabled // GIFs can only loop/play properly with cache enabled
|
imageAlias.cache: localAnimationEnabled // GIFs can only loop/play properly with cache enabled
|
||||||
Loader {
|
Loader {
|
||||||
|
|
|
@ -312,13 +312,13 @@ Loader {
|
||||||
Global.openMenu(addReactionContextMenu, root, {}, point)
|
Global.openMenu(addReactionContextMenu, root, {}, point)
|
||||||
}
|
}
|
||||||
|
|
||||||
function onImageClicked(image, mouse, imageSource) {
|
function onImageClicked(image, mouse, imageSource, url = "") {
|
||||||
switch (mouse.button) {
|
switch (mouse.button) {
|
||||||
case Qt.LeftButton:
|
case Qt.LeftButton:
|
||||||
Global.openImagePopup(image)
|
Global.openImagePopup(image, url)
|
||||||
break;
|
break;
|
||||||
case Qt.RightButton:
|
case Qt.RightButton:
|
||||||
Global.openMenu(imageContextMenuComponent, image, { imageSource })
|
Global.openMenu(imageContextMenuComponent, image, { imageSource, url })
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -762,8 +762,8 @@ Loader {
|
||||||
messageStore: root.messageStore
|
messageStore: root.messageStore
|
||||||
store: root.rootStore
|
store: root.rootStore
|
||||||
isCurrentUser: root.amISender
|
isCurrentUser: root.amISender
|
||||||
onImageClicked: (image, mouse, imageSource) => {
|
onImageClicked: (image, mouse, imageSource, url) => {
|
||||||
d.onImageClicked(image, mouse, imageSource)
|
d.onImageClicked(image, mouse, imageSource, url)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ QtObject {
|
||||||
signal openDownloadModalRequested(bool available, string version, string url)
|
signal openDownloadModalRequested(bool available, string version, string url)
|
||||||
signal openChangeProfilePicPopup(var cb)
|
signal openChangeProfilePicPopup(var cb)
|
||||||
signal openBackUpSeedPopup()
|
signal openBackUpSeedPopup()
|
||||||
signal openImagePopup(var image)
|
signal openImagePopup(var image, string url)
|
||||||
signal openProfilePopupRequested(string publicKey, var parentPopup, var cb)
|
signal openProfilePopupRequested(string publicKey, var parentPopup, var cb)
|
||||||
signal openEditDisplayNamePopup()
|
signal openEditDisplayNamePopup()
|
||||||
signal openActivityCenterPopupRequested()
|
signal openActivityCenterPopupRequested()
|
||||||
|
|
|
@ -704,6 +704,10 @@ QtObject {
|
||||||
return text
|
return text
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function copyToClipboard(text) {
|
||||||
|
globalUtilsInst.copyToClipboard(text)
|
||||||
|
}
|
||||||
|
|
||||||
function copyImageToClipboardByUrl(content) {
|
function copyImageToClipboardByUrl(content) {
|
||||||
globalUtilsInst.copyImageToClipboardByUrl(content)
|
globalUtilsInst.copyImageToClipboardByUrl(content)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue