@@ -6,6 +6,7 @@
|
|||||||
import QtQuick 2.12
|
import QtQuick 2.12
|
||||||
import QtQuick.Controls 2.12
|
import QtQuick.Controls 2.12
|
||||||
import QtQuick.Layouts 1.12
|
import QtQuick.Layouts 1.12
|
||||||
|
import Qt.labs.platform 1.0 as Platform
|
||||||
import org.kde.kirigami 2.13 as Kirigami
|
import org.kde.kirigami 2.13 as Kirigami
|
||||||
|
|
||||||
import NeoChat.Component 1.0
|
import NeoChat.Component 1.0
|
||||||
@@ -39,6 +40,17 @@ ToolBar {
|
|||||||
}
|
}
|
||||||
Kirigami.Theme.colorSet: Kirigami.Theme.View
|
Kirigami.Theme.colorSet: Kirigami.Theme.View
|
||||||
|
|
||||||
|
Action {
|
||||||
|
id: pasteAction
|
||||||
|
shortcut: StandardKey.Paste
|
||||||
|
onTriggered: {
|
||||||
|
if (Clipboard.hasImage) {
|
||||||
|
root.pasteImage();
|
||||||
|
}
|
||||||
|
activeFocusItem.paste();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
contentItem: ColumnLayout {
|
contentItem: ColumnLayout {
|
||||||
id: layout
|
id: layout
|
||||||
spacing: 0
|
spacing: 0
|
||||||
@@ -303,10 +315,13 @@ ToolBar {
|
|||||||
Keys.onEscapePressed: closeAll()
|
Keys.onEscapePressed: closeAll()
|
||||||
|
|
||||||
Keys.onPressed: {
|
Keys.onPressed: {
|
||||||
|
console.log(Qt.Key_Paste, event.key);
|
||||||
if (event.key === Qt.Key_PageDown) {
|
if (event.key === Qt.Key_PageDown) {
|
||||||
switchRoomDown();
|
switchRoomDown();
|
||||||
} else if (event.key === Qt.Key_PageUp) {
|
} else if (event.key === Qt.Key_PageUp) {
|
||||||
switchRoomUp();
|
switchRoomUp();
|
||||||
|
} else if (event.key === Qt.Key_V && event.modifiers & Qt.ControlModifier) {
|
||||||
|
root.pasteImage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -407,6 +422,11 @@ ToolBar {
|
|||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (Clipboard.hasImage) {
|
if (Clipboard.hasImage) {
|
||||||
|
documentHandler.paste()
|
||||||
|
const localPath = Platform.StandardPaths.writableLocation(Platform.StandardPaths.CacheLocation) + "/screenshots/" + (new Date()).getTime() + ".png"
|
||||||
|
if (!Clipboard.saveImage(localPath)) return
|
||||||
|
chatTextInput.attach(localPath)
|
||||||
|
attachDialog.close()
|
||||||
attachDialog.open()
|
attachDialog.open()
|
||||||
} else {
|
} else {
|
||||||
var fileDialog = openFileDialog.createObject(ApplicationWindow.overlay)
|
var fileDialog = openFileDialog.createObject(ApplicationWindow.overlay)
|
||||||
@@ -497,4 +517,12 @@ ToolBar {
|
|||||||
hasAttachment = false
|
hasAttachment = false
|
||||||
attachmentPath = ""
|
attachmentPath = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function pasteImage() {
|
||||||
|
var localPath = Platform.StandardPaths.writableLocation(Platform.StandardPaths.CacheLocation) + "/screenshots/" + (new Date()).getTime() + ".png";
|
||||||
|
if (!Clipboard.saveImage(localPath)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
root.attach(localPath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user