Warning, /office/klevernotes/src/contents/ui/pages/MainPage.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 import QtQuick.Controls 2.15 as QQC2 0007 0008 import org.kde.kirigami 2.19 as Kirigami 0009 0010 import "qrc:/contents/ui/textEditor" 0011 import "qrc:/contents/ui/todoEditor" 0012 0013 import org.kde.Klever 1.0 0014 0015 Kirigami.Page { 0016 id: root 0017 0018 readonly property bool hasNote: currentlySelected && currentlySelected.useCase === "Note" 0019 0020 property QtObject currentlySelected 0021 property QtObject editorView: editorLoader.item 0022 property QtObject todoView: todoLoader.item 0023 0024 title: hasNote ? currentlySelected.text : i18nc("@title:page", "Welcome") 0025 0026 actions: { 0027 if (hasNote) { 0028 // At first both Loaders item are "null" 0029 if (editorLoader.item && editorLoader.item.visible) { 0030 return editorLoader.item.actions 0031 } 0032 return todoLoader.item ? todoLoader.item.actions : [] 0033 } 0034 return [] 0035 } 0036 0037 onCurrentlySelectedChanged: if (root.hasNote) { 0038 const editor = editorView.editor 0039 const oldPath = editorView.path 0040 const text = editor.text 0041 editor.saveNote(text, oldPath) 0042 } 0043 0044 Loader { 0045 id: editorLoader 0046 0047 sourceComponent: EditorView { 0048 path: currentlySelected.path + "/note.md" 0049 visible: bottomToolBar.showNoteEditor 0050 } 0051 active: root.hasNote 0052 anchors.fill: parent 0053 } 0054 0055 Loader { 0056 id: todoLoader 0057 0058 sourceComponent: ToDoView { 0059 path: currentlySelected.path + "/todo.json" 0060 visible: !bottomToolBar.showNoteEditor 0061 } 0062 active: root.hasNote 0063 anchors.fill: parent 0064 } 0065 0066 0067 Kirigami.Card { 0068 id: placeHolder 0069 0070 anchors.fill: parent 0071 0072 visible: !root.hasNote 0073 0074 ColumnLayout { 0075 anchors.fill: parent 0076 0077 Kirigami.Theme.colorSet: Kirigami.Theme.View 0078 Kirigami.Theme.inherit: false 0079 0080 QQC2.Label { 0081 text: i18n("Welcome to KleverNotes!") 0082 wrapMode: Text.WordWrap 0083 horizontalAlignment: Text.AlignHCenter 0084 font.pointSize: 24 0085 0086 Layout.margins: Kirigami.Units.largeSpacing * 2 0087 Layout.fillWidth: true 0088 } 0089 0090 QQC2.Label { 0091 text: i18n("Create or select a note to start working !") 0092 wrapMode: Text.WordWrap 0093 horizontalAlignment: Text.AlignHCenter 0094 font.pointSize: 12 0095 0096 Layout.margins: Kirigami.Units.largeSpacing * 2 0097 Layout.fillWidth: true 0098 } 0099 } 0100 } 0101 0102 footer: BottomToolBar{ 0103 id: bottomToolBar 0104 0105 visible: root.hasNote 0106 } 0107 }