Rewrite FileDialog in C++ && add setting to force async load timelime.
Also fixes repeat section label and empty space when message is redacted. Fixes #27
This commit is contained in:
@@ -8,6 +8,8 @@ import "form"
|
||||
|
||||
Page {
|
||||
property alias lazyLoad: generalForm.lazyLoad
|
||||
property alias asyncMessageDelegate: generalForm.asyncMessageDelegate
|
||||
|
||||
property alias darkTheme: appearanceForm.darkTheme
|
||||
property alias miniMode: appearanceForm.miniMode
|
||||
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
import QtQuick 2.9
|
||||
import QtQuick.Controls 2.2
|
||||
import QtQuick.Dialogs 1.2
|
||||
|
||||
FileDialog {
|
||||
id: locationDialog
|
||||
title: "Please choose a location"
|
||||
folder: shortcuts.home
|
||||
selectFolder: true
|
||||
|
||||
onAccepted: currentRoom.downloadFile(eventId, folder + "/" + currentRoom.fileNameToDownload(eventId))
|
||||
onVisibleChanged: visible ? {} : locationDialog.destroy()
|
||||
}
|
||||
@@ -17,7 +17,7 @@ Item {
|
||||
onDownloadedChanged: downloaded && openOnFinished ? openSavedFile() : {}
|
||||
|
||||
function saveFileAs() {
|
||||
Qt.createComponent("DownloadDialog.qml").createObject(this).open()
|
||||
matriqueController.saveFileAs(currentRoom, eventId)
|
||||
}
|
||||
|
||||
function downloadAndOpen()
|
||||
|
||||
@@ -4,7 +4,7 @@ import QtQuick.Controls.Material 2.2
|
||||
import Matrique 0.1
|
||||
|
||||
Item {
|
||||
id: messageDelegate
|
||||
readonly property bool hidden: marks === EventStatus.Redacted || marks === EventStatus.Hidden
|
||||
|
||||
readonly property bool darkTheme: Material.theme == Material.Dark
|
||||
readonly property color background: darkTheme ? "#242424" : "lightgrey"
|
||||
@@ -12,7 +12,7 @@ Item {
|
||||
readonly property bool sentByMe: author === currentRoom.localUser
|
||||
readonly property bool isState: eventType === "state" || eventType === "emote"
|
||||
|
||||
visible: marks !== EventStatus.Hidden
|
||||
id: messageDelegate
|
||||
|
||||
z: -5
|
||||
width: delegateLoader.width
|
||||
@@ -29,8 +29,10 @@ Item {
|
||||
Loader {
|
||||
id: delegateLoader
|
||||
|
||||
asynchronous: setting.asyncMessageDelegate
|
||||
|
||||
source: {
|
||||
if (eventType == "redaction") return ""
|
||||
if (eventType == "redaction" || hidden) return ""
|
||||
switch (eventType) {
|
||||
case "state":
|
||||
case "emote":
|
||||
|
||||
@@ -191,12 +191,15 @@ Item {
|
||||
}
|
||||
|
||||
delegate: Column {
|
||||
readonly property bool hidden: marks === EventStatus.Redacted || marks === EventStatus.Hidden
|
||||
|
||||
width: parent.width
|
||||
height: hidden ? -8 : undefined
|
||||
spacing: 8
|
||||
|
||||
RowLayout {
|
||||
width: parent.width * 0.8
|
||||
visible: section !== aboveSection
|
||||
visible: section !== aboveSection && !hidden
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
spacing: 8
|
||||
|
||||
@@ -300,30 +303,19 @@ Item {
|
||||
|
||||
contentItem: MaterialIcon { icon: "\ue226" }
|
||||
|
||||
onClicked: fileDialog.visible = true
|
||||
|
||||
FileDialog {
|
||||
id: fileDialog
|
||||
title: "Please choose a file"
|
||||
folder: shortcuts.home
|
||||
selectMultiple: false
|
||||
onAccepted: {
|
||||
currentRoom.uploadFile(fileUrl, fileUrl, matriqueController.getMIME(fileUrl))
|
||||
var fileTransferProgressCallback = function(id, sent, total) {
|
||||
if (id == fileUrl) { inputField.progress = sent / total }
|
||||
}
|
||||
var completedCallback = function(id, localFile, mxcUrl) {
|
||||
if (id == fileUrl) {
|
||||
matriqueController.postFile(currentRoom, localFile, mxcUrl)
|
||||
inputField.progress = 0
|
||||
currentRoom.fileTransferCompleted.disconnect(fileTransferProgressCallback)
|
||||
currentRoom.fileTransferCompleted.disconnect(completedCallback)
|
||||
}
|
||||
}
|
||||
|
||||
currentRoom.fileTransferProgress.connect(fileTransferProgressCallback)
|
||||
currentRoom.fileTransferCompleted.connect(completedCallback)
|
||||
onClicked: {
|
||||
var fileTransferProgressCallback = function(id, sent, total) {
|
||||
inputField.progress = sent / total
|
||||
}
|
||||
var completedCallback = function(id, localFile, mxcUrl) {
|
||||
inputField.progress = 0
|
||||
currentRoom.fileTransferCompleted.disconnect(fileTransferProgressCallback)
|
||||
currentRoom.fileTransferCompleted.disconnect(completedCallback)
|
||||
}
|
||||
|
||||
currentRoom.fileTransferProgress.connect(fileTransferProgressCallback)
|
||||
currentRoom.fileTransferCompleted.connect(completedCallback)
|
||||
matriqueController.uploadFile(currentRoom)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
import QtQuick 2.9
|
||||
|
||||
Item {
|
||||
|
||||
}
|
||||
@@ -3,12 +3,18 @@ import QtQuick.Controls 2.2
|
||||
|
||||
Page {
|
||||
property alias lazyLoad: lazyLoadSwitch.checked
|
||||
property alias asyncMessageDelegate: asyncMessageDelegateSwitch.checked
|
||||
|
||||
Column {
|
||||
Switch {
|
||||
id: lazyLoadSwitch
|
||||
text: "Lazy Load at Initial Sync"
|
||||
text: "Lazy load at initial sync"
|
||||
}
|
||||
Switch {
|
||||
id: asyncMessageDelegateSwitch
|
||||
text: "Force loading message delegates asynchronously"
|
||||
}
|
||||
|
||||
Button {
|
||||
text: "Invoke GC"
|
||||
highlighted: true
|
||||
|
||||
@@ -33,6 +33,7 @@ ApplicationWindow {
|
||||
property alias token: matriqueController.token
|
||||
|
||||
property alias lazyLoad: settingPage.lazyLoad
|
||||
property alias asyncMessageDelegate: settingPage.asyncMessageDelegate
|
||||
|
||||
property alias darkTheme: settingPage.darkTheme
|
||||
property alias miniMode: settingPage.miniMode
|
||||
|
||||
Reference in New Issue
Block a user