Remove attach dialog
This was used when you pressed the "Attach file/image" button but had an image copied to your clipboard - allowing you to select from either source. This is a weird thing to ask, the button should always prompt you with a file dialog. It's still possible to paste an image from your clipboard with CTRL+V, but there isn't a way to do it via right-click yet. Fixes #712
This commit is contained in:
@@ -1,64 +0,0 @@
|
||||
// SPDX-FileCopyrightText: 2020 Carl Schwan <carl@carlschwan.de>
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
import QtCore
|
||||
import QtQuick
|
||||
import QtQuick.Controls as QQC2
|
||||
import QtQuick.Layouts
|
||||
|
||||
import org.kde.kirigami as Kirigami
|
||||
|
||||
import org.kde.neochat
|
||||
|
||||
QQC2.Popup {
|
||||
id: root
|
||||
|
||||
padding: Kirigami.Units.largeSpacing
|
||||
|
||||
signal chosen(string path)
|
||||
|
||||
contentItem: RowLayout {
|
||||
|
||||
spacing: Kirigami.Units.smallSpacing
|
||||
|
||||
QQC2.ToolButton {
|
||||
Layout.fillHeight: true
|
||||
|
||||
icon.name: 'mail-attachment'
|
||||
|
||||
text: i18nc("@action:button", "Choose local file")
|
||||
|
||||
onClicked: {
|
||||
root.close();
|
||||
var fileDialog = openFileDialog.createObject(QQC2.Overlay.overlay) as OpenFileDialog;
|
||||
fileDialog.chosen.connect(path => root.chosen(path));
|
||||
fileDialog.open();
|
||||
}
|
||||
}
|
||||
|
||||
Kirigami.Separator {}
|
||||
|
||||
QQC2.ToolButton {
|
||||
Layout.fillHeight: true
|
||||
|
||||
icon.name: 'insert-image'
|
||||
text: i18nc("@action:button", "Clipboard image")
|
||||
onClicked: {
|
||||
const path = StandardPaths.standardLocations(StandardPaths.CacheLocation)[0] + "/screenshots/" + (new Date()).getTime() + ".png";
|
||||
if (!Clipboard.saveImage(path)) {
|
||||
return;
|
||||
}
|
||||
root.chosen(path);
|
||||
root.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
Component {
|
||||
id: openFileDialog
|
||||
|
||||
OpenFileDialog {
|
||||
parentWindow: Window.window
|
||||
currentFolder: StandardPaths.standardLocations(StandardPaths.HomeLocation)[0]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,6 @@ ecm_add_qml_module(Chatbar GENERATE_PLUGIN_SOURCE
|
||||
URI org.kde.neochat.chatbar
|
||||
OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/src/org/kde/neochat/chatbar
|
||||
QML_FILES
|
||||
AttachDialog.qml
|
||||
ChatBar.qml
|
||||
ChatBarCore.qml
|
||||
RichEditBar.qml
|
||||
|
||||
@@ -43,11 +43,7 @@ RowLayout {
|
||||
|
||||
function addAttachment(): void {
|
||||
if (!root.contentModel.hasRichFormatting) {
|
||||
if (LibNeoChat.Clipboard.hasImage) {
|
||||
attachDialog();
|
||||
} else {
|
||||
fileDialog();
|
||||
}
|
||||
fileDialog();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -58,22 +54,11 @@ RowLayout {
|
||||
standardButtons: Kirigami.Dialog.Ok | Kirigami.Dialog.Cancel
|
||||
});
|
||||
warningDialog.onAccepted.connect(() => {
|
||||
if (LibNeoChat.Clipboard.hasImage) {
|
||||
attachmentButton.attachDialog();
|
||||
} else {
|
||||
attachmentButton.fileDialog();
|
||||
}
|
||||
attachmentButton.fileDialog();
|
||||
});
|
||||
warningDialog.open();
|
||||
}
|
||||
|
||||
function attachDialog(): void {
|
||||
let dialog = Qt.createComponent('org.kde.neochat.chatbar', 'AttachDialog').createObject(QQC2.Overlay.overlay) as AttachDialog;
|
||||
dialog.anchors.centerIn = QQC2.Overlay.overlay;
|
||||
dialog.chosen.connect(path => root.contentModel.addAttachment(path));
|
||||
dialog.open();
|
||||
}
|
||||
|
||||
function fileDialog(): void {
|
||||
let dialog = Qt.createComponent('org.kde.neochat.libneochat', 'OpenFileDialog').createObject(QQC2.Overlay.overlay, {
|
||||
parentWindow: Window.window,
|
||||
|
||||
Reference in New Issue
Block a user