diff --git a/src/app/qml/RoomPage.qml b/src/app/qml/RoomPage.qml index 2f585ee44..d879d63e1 100644 --- a/src/app/qml/RoomPage.qml +++ b/src/app/qml/RoomPage.qml @@ -253,7 +253,6 @@ Kirigami.Page { id: timelineView messageFilterModel: root.messageFilterModel compactLayout: NeoChatConfig.compactLayout - fileDropEnabled: !Controller.isFlatpak markReadCondition: NeoChatConfig.markReadCondition } } diff --git a/src/libneochat/chatbarcache.cpp b/src/libneochat/chatbarcache.cpp index 002ea3b24..35bd9c86a 100644 --- a/src/libneochat/chatbarcache.cpp +++ b/src/libneochat/chatbarcache.cpp @@ -3,6 +3,10 @@ #include "chatbarcache.h" +#include + +#include + #include #include "eventhandler.h" @@ -295,4 +299,17 @@ void ChatBarCache::clearCache() clearRelations(); } +void ChatBarCache::drop(QList u, const QString &transferPortal) +{ + QMimeData mimeData; + mimeData.setUrls(u); + if (!transferPortal.isEmpty()) { + mimeData.setData(u"application/vnd.portal.filetransfer"_s, transferPortal.toLatin1()); + } + auto urls = KUrlMimeData::urlsFromMimeData(&mimeData); + if (urls.size() > 0) { + setAttachmentPath(urls[0].toString()); + } +} + #include "moc_chatbarcache.cpp" diff --git a/src/libneochat/chatbarcache.h b/src/libneochat/chatbarcache.h index 2d19811a6..ada09c4e2 100644 --- a/src/libneochat/chatbarcache.h +++ b/src/libneochat/chatbarcache.h @@ -198,6 +198,8 @@ public: */ Q_INVOKABLE void postMessage(); + Q_INVOKABLE void drop(QList urls, const QString &transferPortal); + Q_SIGNALS: void textChanged(); void relationIdChanged(const QString &oldEventId, const QString &newEventId); diff --git a/src/timeline/TimelineView.qml b/src/timeline/TimelineView.qml index 591aef1c9..f331713f4 100644 --- a/src/timeline/TimelineView.qml +++ b/src/timeline/TimelineView.qml @@ -31,11 +31,6 @@ QQC2.ScrollView { */ required property bool compactLayout - /** - * @brief Whether the compact message layout is to be used. - */ - property bool fileDropEnabled: true - /** * @brief The TimelineMarkReadCondition to use for when messages should be marked as read automatically. */ @@ -268,8 +263,7 @@ QQC2.ScrollView { DropArea { id: dropAreaFile anchors.fill: parent - onDropped: drop => { _private.room.mainCache.attachmentPath = drop.urls[0] } - enabled: root.fileDropEnabled + onDropped: drop => _private.room.mainCache.drop(drop.urls, drop.getDataAsString("application/vnd.portal.filetransfer")) } QQC2.Pane {