Load fullscreenimage directly. Tweak reply UI.
This commit is contained in:
parent
ce688e9756
commit
ef469ee347
|
@ -2,7 +2,7 @@ import QtQuick 2.12
|
|||
import QtQuick.Controls 2.12
|
||||
|
||||
ApplicationWindow {
|
||||
property string eventId
|
||||
property string filename
|
||||
property url localPath
|
||||
|
||||
id: root
|
||||
|
@ -11,7 +11,7 @@ ApplicationWindow {
|
|||
visible: true
|
||||
visibility: Qt.WindowFullScreen
|
||||
|
||||
title: "Image View - " + eventId
|
||||
title: "Image View - " + filename
|
||||
|
||||
color: "#BB000000"
|
||||
|
||||
|
@ -26,8 +26,8 @@ ApplicationWindow {
|
|||
width: Math.min(sourceSize.width, root.width)
|
||||
height: Math.min(sourceSize.height, root.height)
|
||||
|
||||
fillMode: Image.PreserveAspectFit
|
||||
cache: false
|
||||
fillMode: Image.PreserveAspectFit
|
||||
|
||||
source: localPath
|
||||
}
|
||||
|
|
|
@ -174,7 +174,7 @@ ColumnLayout {
|
|||
folderDialog.chosen.connect(function(path) {
|
||||
if (!path) return
|
||||
|
||||
currentRoom.downloadFile(eventId, path + "/" + (content.filename || content.body))
|
||||
currentRoom.downloadFile(eventId, path + "/" + currentRoom.fileNameToDownload(eventId))
|
||||
})
|
||||
|
||||
folderDialog.open()
|
||||
|
@ -186,7 +186,7 @@ ColumnLayout {
|
|||
else
|
||||
{
|
||||
openOnFinished = true
|
||||
currentRoom.downloadFile(eventId, Platform.StandardPaths.writableLocation(Platform.StandardPaths.CacheLocation) + "/" + eventId.replace(":", "_").replace("/", "_").replace("+", "_") + (message || ".tmp"))
|
||||
currentRoom.downloadFile(eventId, Platform.StandardPaths.writableLocation(Platform.StandardPaths.CacheLocation) + "/" + eventId.replace(":", "_").replace("/", "_").replace("+", "_") + currentRoom.fileNameToDownload(eventId))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@ ColumnLayout {
|
|||
readonly property bool sentByMe: author === currentRoom.localUser
|
||||
|
||||
property bool openOnFinished: false
|
||||
property bool showOnFinished: false
|
||||
readonly property bool downloaded: progressInfo && progressInfo.completed
|
||||
|
||||
id: root
|
||||
|
@ -27,10 +26,6 @@ ColumnLayout {
|
|||
spacing: 0
|
||||
|
||||
onDownloadedChanged: {
|
||||
if (downloaded && showOnFinished) {
|
||||
showSavedFile()
|
||||
showOnFinished = false
|
||||
}
|
||||
if (downloaded && openOnFinished) {
|
||||
openSavedFile()
|
||||
openOnFinished = false
|
||||
|
@ -160,7 +155,7 @@ ColumnLayout {
|
|||
|
||||
id: messageMouseArea
|
||||
|
||||
onPrimaryClicked: downloadAndShow()
|
||||
onPrimaryClicked: fullScreenImage.createObject(parent, {"filename": eventId, "localPath": currentRoom.urlToDownload(eventId)}).show()
|
||||
|
||||
onSecondaryClicked: {
|
||||
var contextMenu = imageDelegateContextMenu.createObject(ApplicationWindow.overlay)
|
||||
|
@ -215,34 +210,19 @@ ColumnLayout {
|
|||
folderDialog.chosen.connect(function(path) {
|
||||
if (!path) return
|
||||
|
||||
currentRoom.downloadFile(eventId, path + "/" + (content.filename || content.body))
|
||||
currentRoom.downloadFile(eventId, path + "/" + currentRoom.fileNameToDownload(eventId))
|
||||
})
|
||||
|
||||
folderDialog.open()
|
||||
}
|
||||
|
||||
function downloadAndShow()
|
||||
{
|
||||
if (downloaded) showSavedFile()
|
||||
else
|
||||
{
|
||||
showOnFinished = true
|
||||
currentRoom.downloadFile(eventId, Platform.StandardPaths.writableLocation(Platform.StandardPaths.CacheLocation) + "/" + eventId.replace(":", "_").replace("/", "_").replace("+", "_") + (message || ".tmp"))
|
||||
}
|
||||
}
|
||||
|
||||
function showSavedFile()
|
||||
{
|
||||
fullScreenImage.createObject(parent, {"eventId": eventId, "localPath": progressInfo.localPath}).show()
|
||||
}
|
||||
|
||||
function downloadAndOpen()
|
||||
{
|
||||
if (downloaded) openSavedFile()
|
||||
else
|
||||
{
|
||||
openOnFinished = true
|
||||
currentRoom.downloadFile(eventId, Platform.StandardPaths.writableLocation(Platform.StandardPaths.CacheLocation) + "/" + eventId.replace(":", "_").replace("/", "_").replace("+", "_") + (message || ".tmp"))
|
||||
currentRoom.downloadFile(eventId, Platform.StandardPaths.writableLocation(Platform.StandardPaths.CacheLocation) + "/" + eventId.replace(":", "_").replace("/", "_").replace("+", "_") + currentRoom.fileNameToDownload(eventId))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -136,7 +136,7 @@ ColumnLayout {
|
|||
|
||||
visible: replyEventId || ""
|
||||
|
||||
padding: 8
|
||||
padding: 0
|
||||
|
||||
background: RippleEffect {
|
||||
anchors.fill: parent
|
||||
|
@ -148,38 +148,22 @@ ColumnLayout {
|
|||
spacing: 8
|
||||
|
||||
Avatar {
|
||||
Layout.preferredWidth: 36
|
||||
Layout.preferredHeight: 36
|
||||
Layout.preferredWidth: 28
|
||||
Layout.preferredHeight: 28
|
||||
Layout.alignment: Qt.AlignTop
|
||||
|
||||
source: replyAuthor ? replyAuthor.avatarMediaId : ""
|
||||
hint: replyAuthor ? replyAuthor.displayName : "H"
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
Label {
|
||||
Layout.fillWidth: true
|
||||
|
||||
spacing: 0
|
||||
color: "white"
|
||||
text: "<style>a{color: white;} .user-pill{}</style>" + (replyDisplay || "")
|
||||
|
||||
Label {
|
||||
Layout.fillWidth: true
|
||||
|
||||
color: "white"
|
||||
text: replyAuthor ? replyAuthor.displayName : ""
|
||||
|
||||
font.pixelSize: 13
|
||||
font.weight: Font.Medium
|
||||
}
|
||||
|
||||
Label {
|
||||
Layout.fillWidth: true
|
||||
|
||||
color: "white"
|
||||
text: "<style>a{color: white;} .user-pill{}</style>" + (replyDisplay || "")
|
||||
|
||||
wrapMode: Label.Wrap
|
||||
textFormat: Label.RichText
|
||||
}
|
||||
wrapMode: Label.Wrap
|
||||
textFormat: Label.RichText
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -213,7 +197,7 @@ ColumnLayout {
|
|||
onLinkActivated: {
|
||||
if (link.startsWith("https://matrix.to/")) {
|
||||
var result = link.replace(/\?.*/, "").match("https://matrix.to/#/(!.*:.*)/(\\$.*:.*)")
|
||||
if (result.length < 3) return
|
||||
if (!result || result.length < 3) return
|
||||
if (result[1] != currentRoom.id) return
|
||||
if (!result[2]) return
|
||||
goToEvent(result[2])
|
||||
|
|
|
@ -29,6 +29,14 @@ Dialog {
|
|||
|
||||
hint: user ? user.displayName : "No name"
|
||||
source: user ? user.avatarMediaId : null
|
||||
|
||||
RippleEffect {
|
||||
anchors.fill: parent
|
||||
|
||||
circular: true
|
||||
|
||||
onPrimaryClicked: fullScreenImage.createObject(parent, {"filename": user.diaplayName, "localPath": room.urlToMxcUrl(user.avatarUrl)}).show()
|
||||
}
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
|
@ -159,6 +167,12 @@ Dialog {
|
|||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: fullScreenImage
|
||||
|
||||
FullScreenImage {}
|
||||
}
|
||||
|
||||
onClosed: destroy()
|
||||
}
|
||||
|
||||
|
|
|
@ -282,7 +282,7 @@ Item {
|
|||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
|
||||
text: (lastEvent == "" ? topic : lastEvent).replace(/(\r\n\t|\n|\r\t)/gm,"")
|
||||
text: (lastEvent == "" ? topic : lastEvent).replace(/(\r\n\t|\n|\r\t)/gm," ")
|
||||
color: MPalette.lighter
|
||||
font.pixelSize: 13
|
||||
elide: Text.ElideRight
|
||||
|
|
|
@ -14,7 +14,7 @@ import Spectral 0.1
|
|||
import Spectral.Setting 0.1
|
||||
|
||||
ApplicationWindow {
|
||||
readonly property bool inPortrait: window.width < window.height
|
||||
readonly property bool inPortrait: window.width < 640
|
||||
|
||||
Material.theme: MPalette.theme
|
||||
Material.background: MPalette.background
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "csapi/typing.h"
|
||||
#include "events/accountdataevents.h"
|
||||
#include "events/typingevent.h"
|
||||
#include "jobs/downloadfilejob.h"
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QFileInfo>
|
||||
|
@ -233,3 +234,7 @@ QString SpectralRoom::postMarkdownText(const QString& markdown) {
|
|||
|
||||
return postHtmlText(markdown, result);
|
||||
}
|
||||
|
||||
QUrl SpectralRoom::urlToMxcUrl(QUrl mxcUrl) {
|
||||
return DownloadFileJob::makeRequestUrl(connection()->homeserver(), mxcUrl);
|
||||
}
|
||||
|
|
|
@ -84,6 +84,8 @@ class SpectralRoom : public Room {
|
|||
|
||||
Q_INVOKABLE QString postMarkdownText(const QString& markdown);
|
||||
|
||||
Q_INVOKABLE QUrl urlToMxcUrl(QUrl mxcUrl);
|
||||
|
||||
template <typename BaseEventT>
|
||||
QString eventToString(const BaseEventT& evt,
|
||||
Qt::TextFormat format = Qt::PlainText) {
|
||||
|
|
Loading…
Reference in New Issue