Add drag and drop support.
This commit is contained in:
parent
75c5c71855
commit
b4281896ba
|
@ -23,6 +23,18 @@ Item {
|
|||
room: currentRoom
|
||||
}
|
||||
|
||||
DropArea {
|
||||
anchors.fill: parent
|
||||
|
||||
enabled: currentRoom
|
||||
|
||||
onDropped: {
|
||||
if (!drop.hasUrls) return
|
||||
|
||||
currentRoom.uploadFile(drop.urls[0])
|
||||
}
|
||||
}
|
||||
|
||||
Column {
|
||||
anchors.centerIn: parent
|
||||
|
||||
|
|
|
@ -47,7 +47,15 @@ inline QSize getImageSize(const QUrl& imageUrl) {
|
|||
void SpectralRoom::chooseAndUploadFile() {
|
||||
auto localFile = QFileDialog::getOpenFileUrl(Q_NULLPTR, tr("Save File as"));
|
||||
if (!localFile.isEmpty()) {
|
||||
QString txnID = postFile(localFile.fileName(), localFile, false);
|
||||
uploadFile(localFile);
|
||||
}
|
||||
}
|
||||
|
||||
void SpectralRoom::uploadFile(const QUrl& url) {
|
||||
if (url.isEmpty())
|
||||
return;
|
||||
|
||||
QString txnID = postFile(url.fileName(), url, false);
|
||||
setHasFileUploading(true);
|
||||
connect(this, &Room::fileTransferCompleted,
|
||||
[=](QString id, QUrl localFile, QUrl mxcUrl) {
|
||||
|
@ -71,7 +79,6 @@ void SpectralRoom::chooseAndUploadFile() {
|
|||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void SpectralRoom::acceptInvitation() {
|
||||
connection()->joinRoom(id());
|
||||
|
|
|
@ -255,6 +255,7 @@ class SpectralRoom : public Room {
|
|||
|
||||
public slots:
|
||||
void chooseAndUploadFile();
|
||||
void uploadFile(const QUrl& url);
|
||||
void acceptInvitation();
|
||||
void forget();
|
||||
void sendTypingNotification(bool isTyping);
|
||||
|
|
Loading…
Reference in New Issue