Warning, /office/marknote/src/contents/ui/EditPage.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-FileCopyrightText: 2023 Mathis BrĂ¼chert <mbb@kaidan.im> 0002 // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0003 0004 import QtQuick 2.15 0005 import org.kde.kirigami 2.19 as Kirigami 0006 import QtQuick.Controls 2.0 0007 import QtQuick.Layouts 1.12 0008 0009 import org.kde.marknote 1.0 0010 0011 Kirigami.ScrollablePage { 0012 id: root 0013 property string path 0014 property string name 0015 property bool saved : true 0016 Kirigami.Theme.colorSet: Kirigami.Theme.View 0017 titleDelegate: RowLayout { 0018 visible: name 0019 Layout.fillWidth: true 0020 Item { Layout.fillWidth: true } 0021 Rectangle { 0022 height:5 0023 width: 5 0024 radius: 2.5 0025 color: Kirigami.Theme.textColor 0026 visible: !saved 0027 } 0028 Kirigami.Heading { 0029 text: name 0030 type: saved? Kirigami.Heading.Type.Normal:Kirigami.Heading.Type.Primary 0031 0032 } 0033 Item { Layout.fillWidth: true } 0034 } 0035 0036 MouseArea{ 0037 anchors.fill: parent 0038 cursorShape: Qt.IBeamCursor 0039 onClicked: { 0040 textArea.cursorPosition = textArea.length 0041 textArea.forceActiveFocus() 0042 } 0043 } 0044 0045 RowLayout { 0046 visible: name 0047 z: 600000 0048 y: root.height - 100 0049 width: root.width 0050 parent: root.overlay 0051 ToolBar { 0052 id: toolbar 0053 0054 Layout.margins: 10 0055 Layout.alignment:Qt.AlignHCenter 0056 background: Kirigami.ShadowedRectangle { 0057 Kirigami.Theme.inherit: false 0058 Kirigami.Theme.colorSet: Kirigami.Theme.Window 0059 shadow.size: 15 0060 shadow.yOffset: 3 0061 shadow.color: Qt.rgba(0, 0, 0, 0.2) 0062 color: Kirigami.Theme.backgroundColor 0063 border.color: Kirigami.ColorUtils.tintWithAlpha(Kirigami.Theme.backgroundColor, Kirigami.Theme.textColor, 0.2) 0064 border.width: 1 0065 radius: 5 0066 } 0067 RowLayout { 0068 ToolButton { 0069 id: boldButton 0070 Shortcut { 0071 sequence: "Ctrl+B" 0072 onActivated: boldButton.clicked() 0073 } 0074 icon.name: "format-text-bold" 0075 text: i18nc("@action:button", "Bold") 0076 display: AbstractButton.IconOnly 0077 checkable: true 0078 checked: document.bold 0079 onClicked: { 0080 document.bold = !document.bold 0081 } 0082 } 0083 ToolButton { 0084 id: italicButton 0085 Shortcut { 0086 sequence: "Ctrl+I" 0087 onActivated: italicButton.clicked() 0088 } 0089 icon.name: "format-text-italic" 0090 text: i18nc("@action:button", "Italic") 0091 display: AbstractButton.IconOnly 0092 checkable: true 0093 checked: document.italic 0094 onClicked: { 0095 document.italic = !document.italic 0096 } 0097 } 0098 ToolButton { 0099 id: underlineButton 0100 Shortcut { 0101 sequence: "Ctrl+U" 0102 onActivated: underlineButton.clicked() 0103 } 0104 icon.name: "format-text-underline" 0105 text: i18nc("@action:button", "Underline") 0106 display: AbstractButton.IconOnly 0107 checkable: true 0108 checked: document.underline 0109 onClicked: { 0110 document.underline = !document.underline 0111 } 0112 } 0113 ToolButton { 0114 enabled: false 0115 icon.name: "format-text-strikethrough" 0116 text: i18nc("@action:button", "Strikethrough") 0117 display: AbstractButton.IconOnly 0118 checkable: true 0119 } 0120 ToolButton { 0121 enabled: false 0122 icon.name: "draw-highlight" 0123 text: i18nc("@action:button", "highlight") 0124 display: AbstractButton.IconOnly 0125 checkable: true 0126 } 0127 Kirigami.Separator { 0128 Layout.fillHeight: true 0129 Layout.margins: 0 0130 } 0131 ToolButton { 0132 enabled: false 0133 icon.name: "format-list-unordered" 0134 text: i18n("Add list") 0135 display: AbstractButton.IconOnly 0136 checkable: true 0137 0138 } 0139 ToolButton { 0140 enabled: false 0141 icon.name: "format-list-ordered" 0142 text: i18n("Add numbered list") 0143 display: AbstractButton.IconOnly 0144 checkable: true 0145 } 0146 Kirigami.Separator { 0147 Layout.fillHeight: true 0148 Layout.margins: 0 0149 } 0150 ComboBox { 0151 enabled: false 0152 displayText: i18n("Heading %1", parseInt(currentText) + 1) 0153 model: 6 0154 } 0155 } 0156 } 0157 } 0158 RowLayout{ 0159 visible: name 0160 width: root.width 0161 height: flickable.contentHeight 0162 Flickable { 0163 0164 id: flickable 0165 Layout.alignment: Qt.AlignHCenter 0166 Layout.maximumWidth: Kirigami.Units.gridUnit * 40 0167 Layout.margins: 0 0168 Layout.fillHeight: true 0169 Layout.fillWidth: true 0170 contentWidth: width 0171 TextArea.flickable: TextArea { 0172 id: textArea 0173 background: Item { 0174 0175 } 0176 onTextChanged: { 0177 saved = false 0178 saveTimer.restart() 0179 } 0180 persistentSelection: true 0181 textMargin: Kirigami.Units.gridUnit 0182 height: parent.height 0183 textFormat: TextEdit.MarkdownText 0184 wrapMode: TextEdit.Wrap 0185 0186 DocumentHandler { 0187 id: document 0188 document: textArea.textDocument 0189 cursorPosition: textArea.cursorPosition 0190 selectionStart: textArea.selectionStart 0191 selectionEnd: textArea.selectionEnd 0192 // textColor: TODO 0193 Component.onCompleted: document.load(path) 0194 Component.onDestruction: document.saveAs(path) 0195 onLoaded: { 0196 textArea.text = text 0197 } 0198 onError: (message) => { 0199 print(message) 0200 } 0201 } 0202 } 0203 0204 Timer{ 0205 id: saveTimer 0206 repeat: false 0207 interval: 1000 0208 onTriggered: { 0209 if (root.name) { 0210 document.saveAs(path) 0211 console.log("timer ") 0212 saved = true 0213 } 0214 } 0215 } 0216 } 0217 } 0218 }