Warning, /office/klevernotes/src/contents/ui/textEditor/EditorView.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 // SPDX-FileCopyrightText: 2022 Louis Schul <schul9louis@gmail.com>
0003
0004 import QtQuick 2.15
0005 import QtQuick.Layouts 1.15
0006
0007 import org.kde.kirigami 2.19 as Kirigami
0008
0009 import org.kde.Klever 1.0
0010
0011 import "qrc:/contents/ui/dialogs"
0012
0013 GridLayout {
0014 id: root
0015
0016 required property string path
0017 readonly property TextEditor editor: editor
0018 readonly property TextDisplay display: display
0019 readonly property QtObject imagePickerDialog: toolbar.imagePickerDialog
0020 readonly property QtObject cheatSheet: cheatSheet
0021
0022 property list<Kirigami.Action> actions: [
0023 Kirigami.Action {
0024 id: linkedNotesAction
0025
0026 enabled: Config.noteMapEnabled
0027 visible: enabled
0028 shortcut: "Ctrl+M"
0029 tooltip: i18nc("@tooltip, will be followed by the shortcut", "Linked notes") + " (" + shortcut + ")"
0030 icon.name: "gnumeric-link-internal"
0031
0032 onTriggered: {
0033 noteMapLoader.item.open()
0034 }
0035 },
0036 Kirigami.Action {
0037 id: pdfPrinter
0038
0039 shortcut: "Ctrl+P"
0040 tooltip: i18nc("@tooltip, Print action, will be followed by the shortcut", "Print") + " (" + shortcut + ")"
0041 icon.name: "viewpdf"
0042
0043 onTriggered: {
0044 applicationWindow().switchToPage('Printing')
0045 }
0046 },
0047 Kirigami.Action {
0048 id: editorToggler
0049
0050 shortcut: "Ctrl+Shift+8"
0051 tooltip: i18nc("@tooltip, will be followed by the shortcut", "View/Hide editor") + " (" + shortcut + ")"
0052 checked: true
0053 checkable: true
0054 icon.name: editorToggler.checked ? "text-flow-into-frame" : "text-unflow"
0055
0056 onTriggered: if (!editorToggler.checked && !viewToggler.checked) {
0057 editorToggler.checked = true
0058 }
0059 },
0060 Kirigami.Action {
0061 id: viewToggler
0062
0063 shortcut: "Ctrl+Shift+9"
0064 tooltip: i18nc("@tooltip, display as in 'the note preview', will be followed by the shortcut", "View/Hide preview") + " (" + shortcut + ")"
0065 checked: applicationWindow().wideScreen
0066 checkable: true
0067 icon.name: viewToggler.checked ? "quickview" : "view-hidden"
0068
0069 onTriggered: if (!viewToggler.checked && !editorToggler.checked) {
0070 viewToggler.checked = true
0071 }
0072 }
0073 ]
0074
0075 rows: 4
0076 columns: 2
0077
0078 FileSaverDialog {
0079 id: pdfSaver
0080
0081 caller: pdfPrinter
0082 noteName: root.noteName ? root.noteName : ""
0083 }
0084
0085 TextToolBar {
0086 id: toolbar
0087
0088 notePath: root.path
0089 editorTextArea: root.editor.textArea
0090
0091 Layout.row: 0
0092 }
0093
0094 // This item can be seen as useless but it prevent a weird bug with the height not being adjusted
0095 Item {
0096 Layout.row: 1
0097 Layout.fillHeight: true
0098 Layout.fillWidth: true
0099
0100 GridLayout {
0101 rows: columns > 1 ? 1 : 2
0102 columns: parent.width > Kirigami.Units.gridUnit * 30 ? 2 : 1
0103 anchors.fill:parent
0104
0105 TextEditor{
0106 id: editor
0107
0108 visible: editorToggler.checked
0109 path: root.path
0110
0111 Layout.fillWidth:true
0112 Layout.fillHeight:true
0113 Layout.preferredHeight: parent.columns === 2 ? parent.height : parent.height/2
0114 Layout.preferredWidth: parent.columns === 2 ? parent.width/2 : parent.width
0115
0116 onTextChanged: {
0117 display.text = text //Workaround
0118 }
0119 }
0120
0121 TextDisplay{
0122 id: display
0123
0124 visible: viewToggler.checked
0125
0126 text: editor.text //Doesn't update ?!
0127 path: root.path.replace("note.md", "")
0128
0129 Layout.fillWidth:true
0130 Layout.fillHeight:true
0131 Layout.preferredHeight: parent.columns === 2 ? parent.height : parent.height/2
0132 Layout.preferredWidth: parent.columns === 2 ? parent.width/2 : parent.width
0133 }
0134 }
0135 }
0136
0137 CheatSheet {
0138 id: cheatSheet
0139 }
0140
0141 Loader {
0142 id: noteMapLoader
0143
0144 sourceComponent: NotesMap {
0145 id: linkedNotesMap
0146
0147 parser: display.parser
0148 }
0149 active: Config.noteMapEnabled
0150 }
0151 }