Compare commits

..

1 Commits

Author SHA1 Message Date
Fushan Wen
a61976ae91 Allow to drag image from image delegate 2023-07-22 23:54:11 +08:00
4 changed files with 31 additions and 10 deletions

View File

@@ -4,12 +4,10 @@
#include <QObject>
#include <QTest>
#include "neochatuser.h"
#include "texthandler.h"
#include <Quotient/quotient_common.h>
#include <Quotient/syncdata.h>
#include <Quotient/user.h>
#include <qnamespace.h>
using namespace Quotient;
@@ -557,9 +555,9 @@ void TextHandlerTest::receiveRichPlainUrl()
void TextHandlerTest::receiveRichEmote()
{
auto event = room->messageEvents().at(1).get();
auto author = new NeoChatUser(event->senderId(), connection);
auto author = static_cast<NeoChatUser *>(room->user(event->senderId()));
const QString testInputString = QStringLiteral("This is an emote.");
const QString testOutputString = QStringLiteral("* <a href=\"https://matrix.to/#/@example:example.org\" style=\"color:#000000")
const QString testOutputString = QStringLiteral("* <a href=\"https://matrix.to/#/@example:example.org\" style=\"color:") + author->color().name()
+ QStringLiteral("\">@example:example.org</a> This is an emote.");
TextHandler testTextHandler;
@@ -646,5 +644,5 @@ void TextHandlerTest::linkPreviewsReject()
QCOMPARE(testTextHandler.getLinkPreviews(), testOutputLinks);
}
QTEST_MAIN(TextHandlerTest)
QTEST_GUILESS_MAIN(TextHandlerTest)
#include "texthandlertest.moc"

View File

@@ -1941,7 +1941,7 @@ QByteArray NeoChatRoom::roomAcountDataJson(const QString &eventType)
QUrl NeoChatRoom::avatarForMember(NeoChatUser *user) const
{
const auto &url = memberAvatarUrl(user->id());
if (url.isEmpty() || url.scheme() != "mxc"_ls) {
if (url.isEmpty()) {
return {};
}
auto avatar = connection()->makeMediaUrl(url);

View File

@@ -105,6 +105,10 @@ TimelineContainer {
Layout.preferredHeight: imageHeight
source: root.mediaInfo.source
Drag.active: dragHandler.active
Drag.dragType: Drag.Automatic
Drag.supportedActions: Qt.CopyAction
Image {
anchors.fill: parent
source: root.mediaInfo.tempInfo.source
@@ -141,6 +145,28 @@ TimelineContainer {
}
}
Item {
anchors.fill: parent
DragHandler {
id: dragHandler
enabled: img.status === Image.Ready
onActiveChanged: {
if (active) {
img.grabToImage((result) => {
img.Drag.mimeData = {
"image/png": result.image,
};
img.Drag.active = dragHandler.active;
});
} else {
img.Drag.active = false;
}
}
}
}
TapHandler {
acceptedButtons: Qt.LeftButton
onTapped: {

View File

@@ -74,7 +74,7 @@ Kirigami.OverlayDrawer {
active: roomDrawer.drawerOpen
sourceComponent: ColumnLayout {
readonly property string userSearchText: userListView.headerItem ? userListView.headerItem.userListSearchField.text : ''
readonly property string userSearchText: userListView.headerItem.userListSearchField.text
property alias highlightedUser: userListView.currentIndex
spacing: 0
@@ -129,9 +129,6 @@ Kirigami.OverlayDrawer {
Layout.fillWidth: true
Layout.topMargin: Kirigami.Units.smallSpacing
sourceComponent: room.isDirectChat() ? directChatDrawerHeader : groupChatDrawerHeader
onItemChanged: if (item) {
userListView.positionViewAtBeginning();
}
}
Kirigami.ListSectionHeader {