Confirm uploading from path in clipboard

This commit is contained in:
miruka 2020-07-15 20:22:29 -04:00
parent 2d623118b5
commit 60832b2fcd
5 changed files with 79 additions and 3 deletions

View File

@ -1,5 +1,6 @@
# TODO
- power control focus
- idlemanager: what if setPresence call fails due to network?
- block power level change when offline
- fix power level control button layout when apply button is loading
@ -158,7 +159,6 @@
- Add upload keybindings (close failed upload, pause, resume)
- Handle errors when setting an avatar
- Show confirmation box when picking file to upload or uploading from clipboard
- Show proper progress ring for mxc thumbnails loading
- Sentinel function to report local file paths for already downloaded media,

View File

@ -21,8 +21,14 @@ HButton {
HShortcut {
sequences: window.settings.keys.sendFileFromPathInClipboard
onActivated: utils.sendFile(
chat.userId, chat.roomId, Clipboard.text.trim(),
onActivated: utils.makePopup(
"Popups/ConfirmUploadPopup.qml",
{
userId: chat.userId,
roomId: chat.roomId,
roomName: chat.roomInfo.display_name,
filePath: Clipboard.text.trim(),
},
)
}

View File

@ -0,0 +1,62 @@
// 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"
HColumnPopup {
id: popup
property string userId
property string roomId
property string roomName
property string filePath
readonly property string fileName: filePath.split("/").slice(-1)[0]
page.footer: AutoDirectionLayout {
ApplyButton {
id: uploadButton
text: qsTr("Send")
icon.name: "confirm-uploading-file"
onClicked: {
utils.sendFile(popup.userId, popup.roomId, filePath)
popup.close()
}
}
CancelButton {
id: cancelButton
onClicked: popup.close()
}
}
onOpened: uploadButton.forceActiveFocus()
SummaryLabel {
text:
qsTr("Send %1 to %2?")
.arg(utils.htmlColorize(fileName, theme.colors.accentText))
.arg(utils.htmlColorize(roomName, theme.colors.accentText))
textFormat: Text.StyledText
}
HImage {
source: popup.filePath
fillMode: Image.PreserveAspectFit
visible: status !== Image.Error
Layout.fillWidth: true
Layout.fillHeight: true
Layout.preferredHeight:
status === Image.Ready ?
width / (implicitWidth / implicitHeight) :
0
Behavior on Layout.preferredHeight { HNumberAnimation {} }
}
}

View File

@ -191,6 +191,11 @@ QtObject {
}
function htmlColorize(text, color) {
return `<font color="${color}">${text}</font>`
}
function processedEventText(ev) {
const type = ev.event_type
const unknownMsg = type === "RoomMessageUnknown"

View File

@ -0,0 +1,3 @@
<svg height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg">
<path d="m24 0-6 22-8.129-7.239 7.802-8.234-10.458 7.227-7.215-1.754zm-15 16.668v7.332l3.258-4.431z"/>
</svg>

After

Width:  |  Height:  |  Size: 198 B