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 {
return chatDisplayName ? chatDisplayName : currentChatJid
}
property alias mediaDrawer: mediaDrawer
property bool isWritingSpoiler
property string messageToCorrect
readonly property bool cameraAvailable: Multimedia.QtMultimedia.availableCameras.length > 0
title: chatName
......@@ -322,9 +322,9 @@ ChatPageBase {
id: fileChooserLoader
}
function openFileDialog(filterName, filter, title) {
function openFileDialog(nameFilter, title) {
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) })
if (title !== undefined)
fileChooserLoader.item.title = title
......@@ -372,8 +372,7 @@ ChatPageBase {
case Enums.MessageType.MessageAudio:
case Enums.MessageType.MessageVideo:
case Enums.MessageType.MessageDocument:
openFileDialog(MediaUtilsInstance.filterName(model.modelData),
MediaUtilsInstance.filter(model.modelData),
openFileDialog(MediaUtilsInstance.namedFilter(model.modelData),
MediaUtilsInstance.label(model.modelData))
break
case Enums.MessageType.MessageText:
......
......@@ -166,7 +166,7 @@ Controls.Pane {
if (Kirigami.Settings.isMobile)
chatPage.mediaDrawer.open()
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 @@
import QtQuick.Dialogs 1.3
import im.kaidan.kaidan 1.0
import MediaUtils 0.1
FileDialog {
id: fileDialog
folder: shortcuts.home
nameFilters: [
"Images (*.jpg *.jpeg *.png *.gif)",
"Videos (*.mp4 *.mkv *.avi *.webm)",
"Audio files (*.mp3 *.wav *.flac *.ogg *.m4a *.mka)",
"Documents (*.doc *.docx *.odt)",
"All files (*)",
selectedNameFilter
MediaUtilsInstance.namedFilter(Enums.MessageType.MessageImage),
MediaUtilsInstance.namedFilter(Enums.MessageType.MessageVideo),
MediaUtilsInstance.namedFilter(Enums.MessageType.MessageAudio),
MediaUtilsInstance.namedFilter(Enums.MessageType.MessageDocument),
MediaUtilsInstance.namedFilter(Enums.MessageType.MessageFile)
]
// TODO: support multiple files
// 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