Warning, /utilities/notae/src/ui/TextEditor.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-FileCopyrightText: 2023 Felipe Kinoshita <kinofhek@gmail.com> 0002 // SPDX-License-Identifier: GPL-3.0-or-later 0003 0004 import QtQuick 2.15 0005 import QtQuick.Controls 2.15 as QQC2 0006 import QtQuick.Layouts 1.15 0007 0008 import org.kde.kirigami 2.20 as Kirigami 0009 0010 import org.kde.notae 1.0 0011 0012 QQC2.Page { 0013 id: control 0014 0015 focus: true 0016 0017 property alias text: body.text 0018 property alias body: body 0019 property alias document: document 0020 property alias scrollView: _scrollView 0021 0022 property alias canUndo: body.canUndo 0023 property alias canRedo: body.canRedo 0024 0025 DocumentHandler { 0026 id: document 0027 0028 document: body.textDocument 0029 cursorPosition: body.cursorPosition 0030 selectionStart: body.selectionStart 0031 selectionEnd: body.selectionEnd 0032 backgroundColor: control.Kirigami.Theme.backgroundColor 0033 0034 onSearchFound: { 0035 body.select(start, end) 0036 } 0037 0038 onFileUrlChanged: { 0039 root.title = fileName 0040 } 0041 } 0042 0043 contentItem: Item { 0044 clip: false 0045 0046 QQC2.ScrollView { 0047 id: _scrollView 0048 0049 anchors.fill: parent 0050 0051 clip: false 0052 0053 Flickable { 0054 id: _flickable 0055 0056 anchors.fill: parent 0057 0058 clip: false 0059 0060 boundsBehavior: Flickable.StopAtBounds 0061 boundsMovement: Flickable.StopAtBounds 0062 0063 QQC2.TextArea.flickable: QQC2.TextArea { 0064 id: body 0065 0066 text: document.text 0067 textFormat: TextEdit.PlainText 0068 0069 wrapMode: Text.Wrap 0070 0071 padding: Kirigami.Units.largeSpacing 0072 0073 background: Rectangle { 0074 Kirigami.Theme.colorSet: Kirigami.Theme.View 0075 Kirigami.Theme.inherit: false 0076 color: Kirigami.Theme.backgroundColor 0077 0078 Rectangle { 0079 Kirigami.Theme.colorSet: Kirigami.Theme.View 0080 Kirigami.Theme.inherit: false 0081 color: Qt.darker(Kirigami.Theme.backgroundColor, 1.03) 0082 0083 visible: control.focus 0084 width: body.width 0085 height: body.cursorRectangle.height 0086 y: body.cursorRectangle.y 0087 } 0088 } 0089 0090 Component.onCompleted: body.forceActiveFocus() 0091 } 0092 } 0093 } 0094 } 0095 }