File messages (qml)
This commit is contained in:
parent
ea12c9f9bc
commit
a8166462ad
@ -111,6 +111,7 @@ Rectangle {
|
|||||||
case MtxEvent.NoticeMessage: return "delegates/NoticeMessage.qml"
|
case MtxEvent.NoticeMessage: return "delegates/NoticeMessage.qml"
|
||||||
case MtxEvent.TextMessage: return "delegates/TextMessage.qml"
|
case MtxEvent.TextMessage: return "delegates/TextMessage.qml"
|
||||||
case MtxEvent.ImageMessage: return "delegates/ImageMessage.qml"
|
case MtxEvent.ImageMessage: return "delegates/ImageMessage.qml"
|
||||||
|
case MtxEvent.FileMessage: return "delegates/FileMessage.qml"
|
||||||
//case MtxEvent.VideoMessage: return "delegates/VideoMessage.qml"
|
//case MtxEvent.VideoMessage: return "delegates/VideoMessage.qml"
|
||||||
case MtxEvent.Redacted: return "delegates/Redacted.qml"
|
case MtxEvent.Redacted: return "delegates/Redacted.qml"
|
||||||
default: return "delegates/placeholder.qml"
|
default: return "delegates/placeholder.qml"
|
||||||
|
57
resources/qml/delegates/FileMessage.qml
Normal file
57
resources/qml/delegates/FileMessage.qml
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
import QtQuick 2.6
|
||||||
|
|
||||||
|
Row {
|
||||||
|
Rectangle {
|
||||||
|
radius: 10
|
||||||
|
color: colors.dark
|
||||||
|
height: row.height
|
||||||
|
width: row.width
|
||||||
|
|
||||||
|
Row {
|
||||||
|
id: row
|
||||||
|
|
||||||
|
spacing: 15
|
||||||
|
padding: 12
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
color: colors.light
|
||||||
|
radius: 22
|
||||||
|
height: 44
|
||||||
|
width: 44
|
||||||
|
Image {
|
||||||
|
id: img
|
||||||
|
anchors.centerIn: parent
|
||||||
|
|
||||||
|
source: "qrc:/icons/icons/ui/arrow-pointing-down.png"
|
||||||
|
fillMode: Image.Pad
|
||||||
|
|
||||||
|
}
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
onClicked: timelineManager.saveMedia(eventData.url, eventData.filename, eventData.mimetype, eventData.type)
|
||||||
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Column {
|
||||||
|
TextEdit {
|
||||||
|
text: eventData.body
|
||||||
|
textFormat: TextEdit.PlainText
|
||||||
|
readOnly: true
|
||||||
|
wrapMode: Text.Wrap
|
||||||
|
selectByMouse: true
|
||||||
|
color: colors.text
|
||||||
|
}
|
||||||
|
TextEdit {
|
||||||
|
text: eventData.filesize
|
||||||
|
textFormat: TextEdit.PlainText
|
||||||
|
readOnly: true
|
||||||
|
wrapMode: Text.Wrap
|
||||||
|
selectByMouse: true
|
||||||
|
color: colors.text
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Rectangle {
|
||||||
|
}
|
||||||
|
}
|
@ -122,6 +122,7 @@
|
|||||||
<file>qml/delegates/TextMessage.qml</file>
|
<file>qml/delegates/TextMessage.qml</file>
|
||||||
<file>qml/delegates/NoticeMessage.qml</file>
|
<file>qml/delegates/NoticeMessage.qml</file>
|
||||||
<file>qml/delegates/ImageMessage.qml</file>
|
<file>qml/delegates/ImageMessage.qml</file>
|
||||||
|
<file>qml/delegates/FileMessage.qml</file>
|
||||||
<file>qml/delegates/Redacted.qml</file>
|
<file>qml/delegates/Redacted.qml</file>
|
||||||
<file>qml/delegates/placeholder.qml</file>
|
<file>qml/delegates/placeholder.qml</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
|
@ -87,8 +87,9 @@ eventFormattedBody(const mtx::events::RoomEvent<T> &e)
|
|||||||
if (pos != std::string::npos)
|
if (pos != std::string::npos)
|
||||||
temp.erase(pos, std::string("</mx-reply>").size());
|
temp.erase(pos, std::string("</mx-reply>").size());
|
||||||
return QString::fromStdString(temp);
|
return QString::fromStdString(temp);
|
||||||
} else
|
} else {
|
||||||
return QString::fromStdString(e.content.body);
|
return QString::fromStdString(e.content.body).toHtmlEscaped().replace("\n", "<br>");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
@ -138,6 +139,20 @@ eventFilename(const mtx::events::RoomEvent<mtx::events::msg::File> &e)
|
|||||||
return QString::fromStdString(e.content.body);
|
return QString::fromStdString(e.content.body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
auto
|
||||||
|
eventFilesize(const mtx::events::RoomEvent<T> &e) -> decltype(e.content.info.size)
|
||||||
|
{
|
||||||
|
return e.content.info.size;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
int64_t
|
||||||
|
eventFilesize(const T &)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
QString
|
QString
|
||||||
eventMimeType(const T &)
|
eventMimeType(const T &)
|
||||||
@ -341,6 +356,7 @@ TimelineModel::roleNames() const
|
|||||||
{Timestamp, "timestamp"},
|
{Timestamp, "timestamp"},
|
||||||
{Url, "url"},
|
{Url, "url"},
|
||||||
{Filename, "filename"},
|
{Filename, "filename"},
|
||||||
|
{Filesize, "filesize"},
|
||||||
{MimeType, "mimetype"},
|
{MimeType, "mimetype"},
|
||||||
{Height, "height"},
|
{Height, "height"},
|
||||||
{Width, "width"},
|
{Width, "width"},
|
||||||
@ -423,6 +439,12 @@ TimelineModel::data(const QModelIndex &index, int role) const
|
|||||||
case Filename:
|
case Filename:
|
||||||
return QVariant(boost::apply_visitor(
|
return QVariant(boost::apply_visitor(
|
||||||
[](const auto &e) -> QString { return eventFilename(e); }, event));
|
[](const auto &e) -> QString { return eventFilename(e); }, event));
|
||||||
|
case Filesize:
|
||||||
|
return QVariant(boost::apply_visitor(
|
||||||
|
[](const auto &e) -> QString {
|
||||||
|
return utils::humanReadableFileSize(eventFilesize(e));
|
||||||
|
},
|
||||||
|
event));
|
||||||
case MimeType:
|
case MimeType:
|
||||||
return QVariant(boost::apply_visitor(
|
return QVariant(boost::apply_visitor(
|
||||||
[](const auto &e) -> QString { return eventMimeType(e); }, event));
|
[](const auto &e) -> QString { return eventMimeType(e); }, event));
|
||||||
|
@ -130,6 +130,7 @@ public:
|
|||||||
Timestamp,
|
Timestamp,
|
||||||
Url,
|
Url,
|
||||||
Filename,
|
Filename,
|
||||||
|
Filesize,
|
||||||
MimeType,
|
MimeType,
|
||||||
Height,
|
Height,
|
||||||
Width,
|
Width,
|
||||||
|
Loading…
Reference in New Issue
Block a user