New attachment mechanism. Also add image from clipboard.
This commit is contained in:
@@ -11,3 +11,4 @@ FontFamilyDialog 2.0 FontFamilyDialog.qml
|
||||
AccountDetailDialog 2.0 AccountDetailDialog.qml
|
||||
OpenFileDialog 2.0 OpenFileDialog.qml
|
||||
OpenFolderDialog 2.0 OpenFolderDialog.qml
|
||||
ImageClipboardDialog 2.0 ImageClipboardDialog.qml
|
||||
|
||||
@@ -31,7 +31,7 @@ Item {
|
||||
|
||||
connection: root.connection
|
||||
|
||||
onNewMessage: if (!window.active && MSettings.showNotification) spectralController.postNotification(roomId, eventId, roomName, senderName, text, icon)
|
||||
onNewMessage: if (!window.active && MSettings.showNotification) notificationsManager.postNotification(roomId, eventId, roomName, senderName, text, icon)
|
||||
}
|
||||
|
||||
SortFilterProxyModel {
|
||||
|
||||
@@ -3,10 +3,12 @@ import QtQuick.Controls 2.12
|
||||
import QtQuick.Layouts 1.12
|
||||
import QtQuick.Controls.Material 2.12
|
||||
import Qt.labs.qmlmodels 1.0
|
||||
import Qt.labs.platform 1.0
|
||||
|
||||
import Spectral.Component 2.0
|
||||
import Spectral.Component.Emoji 2.0
|
||||
import Spectral.Component.Timeline 2.0
|
||||
import Spectral.Dialog 2.0
|
||||
import Spectral.Effect 2.0
|
||||
|
||||
import Spectral 0.1
|
||||
@@ -31,10 +33,113 @@ Item {
|
||||
onDropped: {
|
||||
if (!drop.hasUrls) return
|
||||
|
||||
currentRoom.uploadFile(drop.urls[0])
|
||||
roomPanelInput.attach(drop.urls[0])
|
||||
}
|
||||
}
|
||||
|
||||
ImageClipboard {
|
||||
id: imageClipboard
|
||||
}
|
||||
|
||||
Popup {
|
||||
anchors.centerIn: parent
|
||||
|
||||
id: attachDialog
|
||||
|
||||
padding: 16
|
||||
|
||||
contentItem: RowLayout {
|
||||
Control {
|
||||
Layout.preferredWidth: 160
|
||||
Layout.fillHeight: true
|
||||
|
||||
padding: 16
|
||||
|
||||
contentItem: ColumnLayout {
|
||||
spacing: 16
|
||||
|
||||
MaterialIcon {
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
|
||||
icon: "\ue2c8"
|
||||
font.pixelSize: 64
|
||||
color: MPalette.lighter
|
||||
}
|
||||
|
||||
Label {
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
|
||||
text: "Choose local file"
|
||||
}
|
||||
}
|
||||
|
||||
background: RippleEffect {
|
||||
onClicked: {
|
||||
attachDialog.close()
|
||||
|
||||
var fileDialog = openFileDialog.createObject(ApplicationWindow.overlay)
|
||||
|
||||
fileDialog.chosen.connect(function(path) {
|
||||
if (!path) return
|
||||
|
||||
roomPanelInput.attach(path)
|
||||
})
|
||||
|
||||
fileDialog.open()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
Layout.preferredWidth: 1
|
||||
Layout.fillHeight: true
|
||||
|
||||
color: MPalette.banner
|
||||
}
|
||||
|
||||
Control {
|
||||
Layout.preferredWidth: 160
|
||||
Layout.fillHeight: true
|
||||
|
||||
padding: 16
|
||||
|
||||
contentItem: ColumnLayout {
|
||||
spacing: 16
|
||||
|
||||
MaterialIcon {
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
|
||||
icon: "\ue410"
|
||||
font.pixelSize: 64
|
||||
color: MPalette.lighter
|
||||
}
|
||||
|
||||
Label {
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
|
||||
text: "Clipboard image"
|
||||
color: MPalette.foreground
|
||||
}
|
||||
}
|
||||
|
||||
background: RippleEffect {
|
||||
onClicked: {
|
||||
var localPath = StandardPaths.writableLocation(StandardPaths.CacheLocation) + "/screenshots/" + (new Date()).getTime() + ".png"
|
||||
imageClipboard.saveImage(localPath)
|
||||
roomPanelInput.attach(localPath)
|
||||
attachDialog.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: openFileDialog
|
||||
|
||||
OpenFileDialog {}
|
||||
}
|
||||
|
||||
Column {
|
||||
anchors.centerIn: parent
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import QtQuick.Controls.Material 2.12
|
||||
|
||||
import Spectral.Component 2.0
|
||||
import Spectral.Component.Emoji 2.0
|
||||
import Spectral.Dialog 2.0
|
||||
import Spectral.Effect 2.0
|
||||
import Spectral.Setting 0.1
|
||||
|
||||
@@ -21,6 +22,9 @@ Control {
|
||||
property int autoCompleteBeginPosition
|
||||
property int autoCompleteEndPosition
|
||||
|
||||
property bool hasAttachment: false
|
||||
property url attachmentPath
|
||||
|
||||
id: root
|
||||
|
||||
padding: 0
|
||||
@@ -171,13 +175,13 @@ Control {
|
||||
Layout.alignment: Qt.AlignBottom
|
||||
|
||||
id: uploadButton
|
||||
visible: !isReply
|
||||
visible: !isReply && !hasAttachment
|
||||
|
||||
contentItem: MaterialIcon {
|
||||
icon: "\ue226"
|
||||
}
|
||||
|
||||
onClicked: currentRoom.chooseAndUploadFile()
|
||||
onClicked: attachDialog.open()
|
||||
|
||||
BusyIndicator {
|
||||
anchors.fill: parent
|
||||
@@ -202,6 +206,51 @@ Control {
|
||||
onClicked: clearReply()
|
||||
}
|
||||
|
||||
Control {
|
||||
Layout.margins: 6
|
||||
Layout.preferredHeight: 36
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
|
||||
visible: hasAttachment
|
||||
|
||||
rightPadding: 8
|
||||
|
||||
background: Rectangle {
|
||||
color: MPalette.accent
|
||||
radius: height / 2
|
||||
antialiasing: true
|
||||
}
|
||||
|
||||
contentItem: RowLayout {
|
||||
spacing: 0
|
||||
|
||||
ToolButton {
|
||||
Layout.preferredWidth: height
|
||||
Layout.fillHeight: true
|
||||
|
||||
id: cancelAttachmentButton
|
||||
|
||||
contentItem: MaterialIcon {
|
||||
icon: "\ue5cd"
|
||||
color: "white"
|
||||
font.pixelSize: 18
|
||||
}
|
||||
|
||||
onClicked: {
|
||||
hasAttachment = false
|
||||
attachmentPath = ""
|
||||
}
|
||||
}
|
||||
|
||||
Label {
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
|
||||
text: attachmentPath != "" ? attachmentPath.toString().substring(attachmentPath.toString().lastIndexOf('/') + 1, attachmentPath.length) : ""
|
||||
color: "white"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TextArea {
|
||||
property real progress: 0
|
||||
|
||||
@@ -307,6 +356,12 @@ Control {
|
||||
if (text.trim().length === 0) { return }
|
||||
if(!currentRoom) { return }
|
||||
|
||||
if (hasAttachment) {
|
||||
currentRoom.uploadFile(attachmentPath, text)
|
||||
clearAttachment()
|
||||
return
|
||||
}
|
||||
|
||||
var PREFIX_ME = '/me '
|
||||
var PREFIX_NOTICE = '/notice '
|
||||
var PREFIX_RAINBOW = '/rainbow '
|
||||
@@ -372,6 +427,10 @@ Control {
|
||||
}
|
||||
}
|
||||
|
||||
ImageClipboard {
|
||||
id: imageClipboard
|
||||
}
|
||||
|
||||
function insert(str) {
|
||||
inputField.insert(inputField.cursorPosition, str)
|
||||
}
|
||||
@@ -396,4 +455,14 @@ Control {
|
||||
autoCompleteListView.visible = false
|
||||
emojiPicker.visible = false
|
||||
}
|
||||
|
||||
function attach(localPath) {
|
||||
hasAttachment = true
|
||||
attachmentPath = localPath
|
||||
}
|
||||
|
||||
function clearAttachment() {
|
||||
hasAttachment = false
|
||||
attachmentPath = ""
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user