Warning, /network/neochat/src/qml/AttachDialog.qml is written in an unsupported language. File is not indexed.

0001 // SPDX-FileCopyrightText: 2020 Carl Schwan <carl@carlschwan.de>
0002 // SPDX-License-Identifier: GPL-2.0-or-later
0003 
0004 import QtCore
0005 import QtQuick
0006 import QtQuick.Controls as QQC2
0007 import QtQuick.Layouts
0008 
0009 import org.kde.kirigami as Kirigami
0010 
0011 import org.kde.neochat
0012 
0013 QQC2.Popup {
0014     id: root
0015 
0016     padding: 16
0017 
0018     signal chosen(string path)
0019 
0020     contentItem: RowLayout {
0021         QQC2.ToolButton {
0022             Layout.preferredWidth: 160
0023             Layout.fillHeight: true
0024 
0025             icon.name: 'mail-attachment'
0026 
0027             text: i18n("Choose local file")
0028 
0029             onClicked: {
0030                 root.close();
0031                 var fileDialog = openFileDialog.createObject(QQC2.ApplicationWindow.overlay);
0032                 fileDialog.chosen.connect(path => root.chosen(path));
0033                 fileDialog.open();
0034             }
0035         }
0036 
0037         Kirigami.Separator {}
0038 
0039         QQC2.ToolButton {
0040             Layout.preferredWidth: 160
0041             Layout.fillHeight: true
0042 
0043             padding: 16
0044 
0045             icon.name: 'insert-image'
0046             text: i18n("Clipboard image")
0047             onClicked: {
0048                 const path = StandardPaths.standardLocations(StandardPaths.CacheLocation)[0] + "/screenshots/" + (new Date()).getTime() + ".png";
0049                 if (!Clipboard.saveImage(path)) {
0050                     return;
0051                 }
0052                 root.chosen(path);
0053                 root.close();
0054             }
0055         }
0056     }
0057     Component {
0058         id: openFileDialog
0059 
0060         OpenFileDialog {
0061             parentWindow: Window.window
0062             currentFolder: StandardPaths.standardLocations(StandardPaths.HomeLocation)[0]
0063         }
0064     }
0065 }