Implement drag&drop support for flatpaks

BUG: 495552
This commit is contained in:
Tobias Fella
2025-11-10 17:52:15 +01:00
committed by Tobias Fella
parent 65c6f4c1d3
commit 38523c97c5
4 changed files with 20 additions and 8 deletions

View File

@@ -253,7 +253,6 @@ Kirigami.Page {
id: timelineView
messageFilterModel: root.messageFilterModel
compactLayout: NeoChatConfig.compactLayout
fileDropEnabled: !Controller.isFlatpak
markReadCondition: NeoChatConfig.markReadCondition
}
}

View File

@@ -3,6 +3,10 @@
#include "chatbarcache.h"
#include <QMimeData>
#include <KUrlMimeData>
#include <Quotient/roommember.h>
#include "eventhandler.h"
@@ -295,4 +299,17 @@ void ChatBarCache::clearCache()
clearRelations();
}
void ChatBarCache::drop(QList<QUrl> 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"

View File

@@ -198,6 +198,8 @@ public:
*/
Q_INVOKABLE void postMessage();
Q_INVOKABLE void drop(QList<QUrl> urls, const QString &transferPortal);
Q_SIGNALS:
void textChanged();
void relationIdChanged(const QString &oldEventId, const QString &newEventId);

View File

@@ -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 {