Fix picking same file twice not working

This commit is contained in:
miruka 2019-11-06 08:55:47 -04:00
parent 487446046f
commit de41e859be
7 changed files with 23 additions and 10 deletions

View File

@ -130,7 +130,7 @@ class Upload(ModelItem):
def __lt__(self, other: "Upload") -> bool:
# TODO
# Sort from newest upload to oldest.
return self.start_date > other.start_date

View File

@ -27,6 +27,11 @@ HSplitView {
UploadsBar {
Layout.fillWidth: true
Layout.minimumHeight: implicitHeight
Layout.preferredHeight: implicitHeight * uploadsCount
Layout.maximumHeight: chatSplitView.height / 6
Behavior on Layout.preferredHeight { HNumberAnimation {} }
}
InviteBanner {

View File

@ -215,8 +215,7 @@ Rectangle {
HFileDialogOpener {
dialog.title: qsTr("Select files to upload")
onFileChanged: {
if (! file) return
onFilePicked: {
let path = Qt.resolvedUrl(file).replace(/^file:/, "")
let args = [chatPage.roomId, path]
py.callClientCoro(chatPage.userId, "send_file", args)

View File

@ -9,21 +9,22 @@ Rectangle {
implicitHeight: firstDelegate ? firstDelegate.height : 0
color: theme.chat.typingMembers.background
opacity: implicitHeight ? 1 : 0
clip: true
property int delegateHeight: 0
property int maxShownDelegates: 1
readonly property var firstDelegate:
uploadsList.contentItem.visibleChildren[0]
readonly property alias uploadsCount: uploadsList.count
Behavior on implicitHeight { HNumberAnimation {} }
HListView {
id: uploadsList
enableFlicking: false
width: parent.width
anchors.fill: parent
model: HListModel {
keyField: "uuid"
@ -33,7 +34,6 @@ Rectangle {
delegate: HColumnLayout {
id: delegate
width: uploadsList.width
Component.onCompleted: Utils.debug(delegate)
HRowLayout {
HLabel {

View File

@ -6,7 +6,7 @@ HFileDialogOpener {
fill: false
dialog.title: qsTr("Save decryption keys file as...")
dialog.fileMode: FileDialog.SaveFile
onFileChanged: {
onFilePicked: {
exportPasswordPopup.file = file
exportPasswordPopup.open()
}

View File

@ -5,6 +5,10 @@ Item {
id: opener
anchors.fill: fill ? parent : undefined
signal filePicked()
property bool fill: true
property alias dialog: fileDialog
@ -17,6 +21,7 @@ Item {
enum FileType { All, Images }
property int fileType: HFileDialogOpener.FileType.All
TapHandler { enabled: fill; onTapped: fileDialog.open() }
FileDialog {
@ -56,7 +61,11 @@ Item {
opener.selectedFile = Qt.binding(() => Qt.resolvedUrl(currentFile))
opener.file = Qt.binding(() => Qt.resolvedUrl(file))
}
onAccepted: { opener.selectedFile = currentFile, opener.file = file }
onAccepted: {
opener.selectedFile = currentFile
opener.file = file
opener.filePicked(file)
}
onRejected: { selectedFile = ""; file = ""}
}
}

View File

@ -5,7 +5,7 @@ import "../Popups"
HFileDialogOpener {
fill: false
dialog.title: qsTr("Select a decryption keys file to import")
onFileChanged: {
onFilePicked: {
importPasswordPopup.file = file
importPasswordPopup.open()
}