2020-07-17 05:59:54 +10:00
|
|
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
|
|
|
|
|
|
|
import QtQuick 2.12
|
|
|
|
import QtQuick.Controls 2.12
|
|
|
|
import QtQuick.Layouts 1.12
|
|
|
|
import "../Base"
|
|
|
|
import "../Base/Buttons"
|
2020-07-18 00:30:06 +10:00
|
|
|
//
|
|
|
|
// Make sure to initialize the image provider by
|
|
|
|
// importing this first:
|
|
|
|
import Clipboard 0.1
|
2020-07-17 05:59:54 +10:00
|
|
|
|
|
|
|
HColumnPopup {
|
|
|
|
id: popup
|
|
|
|
|
|
|
|
property string userId
|
|
|
|
property string roomId
|
|
|
|
property string roomName
|
|
|
|
|
|
|
|
|
2020-07-17 07:41:02 +10:00
|
|
|
contentWidthLimit: theme.controls.popup.defaultWidth * 1.25
|
|
|
|
|
2020-07-17 05:59:54 +10:00
|
|
|
page.footer: AutoDirectionLayout {
|
|
|
|
ApplyButton {
|
|
|
|
id: uploadButton
|
|
|
|
text: qsTr("Send")
|
|
|
|
icon.name: "confirm-uploading-file"
|
|
|
|
onClicked: {
|
|
|
|
py.callClientCoro(
|
|
|
|
popup.userId,
|
|
|
|
"send_clipboard_image",
|
|
|
|
[popup.roomId, Clipboard.image],
|
|
|
|
)
|
|
|
|
popup.close()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CancelButton {
|
|
|
|
id: cancelButton
|
|
|
|
onClicked: popup.close()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
onOpened: uploadButton.forceActiveFocus()
|
|
|
|
|
|
|
|
SummaryLabel {
|
|
|
|
text:
|
|
|
|
qsTr("Send copied image to %1?")
|
|
|
|
.arg(utils.htmlColorize(roomName, theme.colors.accentText))
|
|
|
|
|
|
|
|
textFormat: Text.StyledText
|
|
|
|
}
|
|
|
|
|
|
|
|
HImage {
|
|
|
|
id: image
|
|
|
|
|
|
|
|
property int updateCounter: 0
|
|
|
|
|
|
|
|
source: "image://clipboard/" + updateCounter
|
2020-07-17 07:29:49 +10:00
|
|
|
sourceSize.width: popup.contentWidthLimit
|
2020-07-17 05:59:54 +10:00
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
2020-07-17 07:17:58 +10:00
|
|
|
Layout.preferredHeight:
|
2020-07-17 05:59:54 +10:00
|
|
|
status === Image.Ready ?
|
|
|
|
width / (implicitWidth / implicitHeight) :
|
2020-07-17 07:17:58 +10:00
|
|
|
96 * theme.uiScale // for spinner
|
2020-07-17 05:59:54 +10:00
|
|
|
|
|
|
|
Behavior on Layout.preferredHeight { HNumberAnimation {} }
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: Clipboard
|
|
|
|
|
|
|
|
function onContentChanged() {
|
|
|
|
Clipboard.hasImage ? image.updateCounter += 1 : popup.close()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|