Fix file dialog and media drawer opening

The 'mediaDrawer' did not open before.
The file dialog had an invalid name filter before which resulted in only showing directories.

The 'fileChooser' opens with a correct name filter and uses Enums for all available name filters now.
An unused argument of 'openFileDialog()' is removed.
parent a19767de
Pipeline #42915 passed with stage
in 2 minutes and 32 seconds
...@@ -48,9 +48,9 @@ ChatPageBase { ...@@ -48,9 +48,9 @@ ChatPageBase {
return chatDisplayName ? chatDisplayName : currentChatJid return chatDisplayName ? chatDisplayName : currentChatJid
} }
property alias mediaDrawer: mediaDrawer
property bool isWritingSpoiler property bool isWritingSpoiler
property string messageToCorrect property string messageToCorrect
readonly property bool cameraAvailable: Multimedia.QtMultimedia.availableCameras.length > 0 readonly property bool cameraAvailable: Multimedia.QtMultimedia.availableCameras.length > 0
title: chatName title: chatName
...@@ -322,9 +322,9 @@ ChatPageBase { ...@@ -322,9 +322,9 @@ ChatPageBase {
id: fileChooserLoader id: fileChooserLoader
} }
function openFileDialog(filterName, filter, title) { function openFileDialog(nameFilter, title) {
fileChooserLoader.source = "qrc:/qml/elements/FileChooser.qml" fileChooserLoader.source = "qrc:/qml/elements/FileChooser.qml"
fileChooserLoader.item.selectedNameFilter = filterName fileChooserLoader.item.selectedNameFilter = nameFilter
fileChooserLoader.item.accepted.connect(function() { sendMediaSheet.sendFile(Kaidan.messageModel.currentChatJid, fileChooserLoader.item.fileUrl) }) fileChooserLoader.item.accepted.connect(function() { sendMediaSheet.sendFile(Kaidan.messageModel.currentChatJid, fileChooserLoader.item.fileUrl) })
if (title !== undefined) if (title !== undefined)
fileChooserLoader.item.title = title fileChooserLoader.item.title = title
...@@ -372,8 +372,7 @@ ChatPageBase { ...@@ -372,8 +372,7 @@ ChatPageBase {
case Enums.MessageType.MessageAudio: case Enums.MessageType.MessageAudio:
case Enums.MessageType.MessageVideo: case Enums.MessageType.MessageVideo:
case Enums.MessageType.MessageDocument: case Enums.MessageType.MessageDocument:
openFileDialog(MediaUtilsInstance.filterName(model.modelData), openFileDialog(MediaUtilsInstance.namedFilter(model.modelData),
MediaUtilsInstance.filter(model.modelData),
MediaUtilsInstance.label(model.modelData)) MediaUtilsInstance.label(model.modelData))
break break
case Enums.MessageType.MessageText: case Enums.MessageType.MessageText:
......
...@@ -166,7 +166,7 @@ Controls.Pane { ...@@ -166,7 +166,7 @@ Controls.Pane {
if (Kirigami.Settings.isMobile) if (Kirigami.Settings.isMobile)
chatPage.mediaDrawer.open() chatPage.mediaDrawer.open()
else else
chatPage.openFileDialog(qsTr("All files"), "*", MediaUtilsInstance.label(Enums.MessageType.MessageFile)) chatPage.openFileDialog(MediaUtilsInstance.namedFilter(Enums.MessageType.MessageFile), MediaUtilsInstance.label(Enums.MessageType.MessageFile))
} }
} }
......
...@@ -30,16 +30,18 @@ ...@@ -30,16 +30,18 @@
import QtQuick.Dialogs 1.3 import QtQuick.Dialogs 1.3
import im.kaidan.kaidan 1.0
import MediaUtils 0.1
FileDialog { FileDialog {
id: fileDialog id: fileDialog
folder: shortcuts.home folder: shortcuts.home
nameFilters: [ nameFilters: [
"Images (*.jpg *.jpeg *.png *.gif)", MediaUtilsInstance.namedFilter(Enums.MessageType.MessageImage),
"Videos (*.mp4 *.mkv *.avi *.webm)", MediaUtilsInstance.namedFilter(Enums.MessageType.MessageVideo),
"Audio files (*.mp3 *.wav *.flac *.ogg *.m4a *.mka)", MediaUtilsInstance.namedFilter(Enums.MessageType.MessageAudio),
"Documents (*.doc *.docx *.odt)", MediaUtilsInstance.namedFilter(Enums.MessageType.MessageDocument),
"All files (*)", MediaUtilsInstance.namedFilter(Enums.MessageType.MessageFile)
selectedNameFilter
] ]
// TODO: support multiple files // TODO: support multiple files
// Currently the problem is that the fileUrls list isn't cleared // Currently the problem is that the fileUrls list isn't cleared
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment