Warning, /plasma/plasma-workspace/applets/clipboard/contents/ui/EditPage.qml is written in an unsupported language. File is not indexed.
0001 /*
0002 SPDX-FileCopyrightText: 2021 Bharadwaj Raju <bharadwaj.raju777@protonmail.com>
0003
0004 SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006
0007 import QtQuick 2.15
0008 import QtQuick.Controls 2.15 as QQC2 // For StackView
0009 import QtQuick.Layouts 1.1
0010 import org.kde.plasma.components 3.0 as PlasmaComponents3
0011 import org.kde.kirigami 2.20 as Kirigami
0012 import org.kde.kquickcontrolsaddons 2.0
0013
0014 ColumnLayout {
0015 spacing: 0
0016 property alias text: textArea.text
0017 property string uuid
0018
0019 property var header: Item {}
0020
0021 Keys.onPressed: event => {
0022 if (event.key === Qt.Key_Escape) {
0023 stack.pop()
0024 event.accepted = true;
0025 }
0026 }
0027
0028 function saveAndExit() {
0029 clipboardSource.edit(uuid, text);
0030 stack.pop();
0031 done();
0032 }
0033
0034 function done() {
0035 // The modified item will be pushed to the top, and we would like to highlight the real first item
0036 Qt.callLater(() => {stack.initialItem.view.currentIndex = 0;});
0037 }
0038
0039 QQC2.StackView.onStatusChanged: {
0040 if (QQC2.StackView.status === QQC2.StackView.Active) {
0041 textArea.forceActiveFocus(Qt.ActiveWindowFocusReason);
0042 textArea.cursorPosition = textArea.text.length;
0043 main.editing = true;
0044 } else {
0045 main.editing = false;
0046 }
0047 }
0048
0049 Shortcut {
0050 sequence: StandardKey.Save
0051 onActivated: saveAndExit()
0052 }
0053
0054 PlasmaComponents3.ScrollView {
0055 Layout.fillWidth: true
0056 Layout.fillHeight: true
0057 Layout.leftMargin: Kirigami.Units.smallSpacing * 2
0058 Layout.rightMargin: PlasmaComponents3.ScrollBar.vertical.visible ? 0 : Kirigami.Units.smallSpacing * 2
0059 Layout.topMargin: Kirigami.Units.smallSpacing * 2
0060
0061 PlasmaComponents3.TextArea {
0062 id: textArea
0063 wrapMode: TextEdit.Wrap
0064 textFormat: TextEdit.PlainText
0065
0066 KeyNavigation.up: dialogItem.KeyNavigation.up
0067 Keys.onPressed: event => {
0068 if ((event.key === Qt.Key_Return || event.key === Qt.Key_Enter) && !(event.modifiers & Qt.ShiftModifier)) {
0069 saveAndExit();
0070 event.accepted = true;
0071 } else {
0072 event.accepted = false;
0073 }
0074 }
0075 }
0076 }
0077
0078 RowLayout {
0079 Layout.alignment: Qt.AlignRight
0080 Layout.margins: Kirigami.Units.smallSpacing * 2
0081 PlasmaComponents3.Button {
0082 text: i18nc("@action:button", "Save")
0083 icon.name: "document-save"
0084 KeyNavigation.up: textArea
0085 KeyNavigation.right: cancelButton
0086 onClicked: saveAndExit()
0087 }
0088 PlasmaComponents3.Button {
0089 id: cancelButton
0090 text: i18nc("@action:button", "Cancel")
0091 icon.name: "dialog-cancel"
0092 KeyNavigation.up: textArea
0093 onClicked: stack.pop()
0094 }
0095 }
0096 }