From df09d1b2ef0e506951d475d862f15c6925db0abe Mon Sep 17 00:00:00 2001 From: Black Hat Date: Sun, 23 Jun 2019 15:11:22 +0800 Subject: [PATCH] Only show option to upload image from clipboard when there is image in clipboard. --- imports/Spectral/Panel/RoomPanelInput.qml | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/imports/Spectral/Panel/RoomPanelInput.qml b/imports/Spectral/Panel/RoomPanelInput.qml index 693029030..cae34ff9e 100644 --- a/imports/Spectral/Panel/RoomPanelInput.qml +++ b/imports/Spectral/Panel/RoomPanelInput.qml @@ -181,7 +181,21 @@ Control { icon: "\ue226" } - onClicked: attachDialog.open() + onClicked: { + if (imageClipboard.hasImage) { + attachDialog.open() + } else { + var fileDialog = openFileDialog.createObject(ApplicationWindow.overlay) + + fileDialog.chosen.connect(function(path) { + if (!path) return + + roomPanelInput.attach(path) + }) + + fileDialog.open() + } + } BusyIndicator { anchors.fill: parent @@ -428,10 +442,6 @@ Control { } } - ImageClipboard { - id: imageClipboard - } - function insert(str) { inputField.insert(inputField.cursorPosition, str) }