diff --git a/main.qml b/main.qml index 446ec45..86b97d6 100644 --- a/main.qml +++ b/main.qml @@ -1,118 +1,126 @@ import QtQuick 2.9 import QtQuick.Controls 2.2 import org.kde.kirigami 2.0 as Kirigami import org.kde.maui 1.0 as Maui import "src/widgets" import "src/views/notes" Maui.ApplicationWindow { id: root title: qsTr("Buho") /***** PROPS *****/ property var views : ({ notes: 0, links: 1, books: 2 }) headBar.middleContent: Row { spacing: space.medium Maui.ToolButton { display: root.isWide ? ToolButton.TextBesideIcon : ToolButton.IconOnly iconName: "draw-text" text: qsTr("Notes") } Maui.ToolButton { display: root.isWide ? ToolButton.TextBesideIcon : ToolButton.IconOnly iconName: "link" text: qsTr("Links") } Maui.ToolButton { display: root.isWide ? ToolButton.TextBesideIcon : ToolButton.IconOnly iconName: "document-new" text: qsTr("Books") } } footBar.middleContent: Maui.PieButton { id: addButton iconName: "list-add" model: ListModel { ListElement {iconName: "document-new"; mid: "page"} ListElement {iconName: "link"; mid: "link"} ListElement {iconName: "draw-text"; mid: "note"} } onItemClicked: { if(item.mid === "note") newNoteDialog.open() } } footBar.leftContent: Maui.ToolButton { iconName: "document-share" } footBar.rightContent: Maui.ToolButton { iconName: "archive-remove" } /***** COMPONENTS *****/ NewNoteDialog { id: newNoteDialog onNoteSaved: { if(owl.insertNote(note.title, note.body, note.color, note.tags)) notesView.append(note) } } NewNoteDialog { id: editNote onNoteSaved: { + console.log("BAHABHABH", notesView.currentNote.id) owl.updateNote(notesView.currentNote.id, note.title, note.body, note.color, note.tags) } } /***** VIEWS *****/ SwipeView { anchors.fill: parent currentIndex: views.notes NotesView { id: notesView - onNoteClicked: editNote.fill(note) + onNoteClicked: setNote(note) + } } Component.onCompleted: { notesView.populate() } + + function setNote(note) + { + notesView.currentNote = note + editNote.fill(note) + } } diff --git a/src/widgets/NewNoteDialog.qml b/src/widgets/NewNoteDialog.qml index a2063ff..7634e06 100644 --- a/src/widgets/NewNoteDialog.qml +++ b/src/widgets/NewNoteDialog.qml @@ -1,238 +1,237 @@ import QtQuick 2.9 import QtQuick.Controls 2.2 import QtQuick.Layouts 1.0 import org.kde.maui 1.0 as Maui Popup { parent: ApplicationWindow.overlay height: parent.height * (isMobile ? 0.8 : 0.7) width: parent.width * (isMobile ? 0.9 : 0.7) property string selectedColor : "#ffffe6" signal noteSaved(var note) x: (parent.width / 2) - (width / 2) y: (parent.height /2 ) - (height / 2) padding: 1 Rectangle { id: bg color: selectedColor z: -1 anchors.fill: parent } ColumnLayout { anchors.fill: parent Maui.ToolBar { Layout.fillWidth: true leftContent: [ Maui.ToolButton { iconName: "format-text-bold" }, Maui.ToolButton { iconName: "format-text-italic-symbolic" }, Maui.ToolButton { iconName: "format-text-underline-symbolic" }, Maui.ToolButton { iconName: "format-text-uppercase" } ] rightContent: Row { spacing: space.medium Rectangle { color:"#ffded4" anchors.verticalCenter: parent.verticalCenter height: iconSizes.medium width: height radius: Math.max(height, width) border.color: borderColor MouseArea { anchors.fill: parent onClicked: selectedColor = parent.color } } Rectangle { color:"#d3ffda" anchors.verticalCenter: parent.verticalCenter height: iconSizes.medium width: height radius: Math.max(height, width) border.color: borderColor MouseArea { anchors.fill: parent onClicked: selectedColor = parent.color } } Rectangle { color:"#caf3ff" anchors.verticalCenter: parent.verticalCenter height: iconSizes.medium width: height radius: Math.max(height, width) border.color: borderColor MouseArea { anchors.fill: parent onClicked: selectedColor = parent.color } } Rectangle { color:"#ccc1ff" anchors.verticalCenter: parent.verticalCenter height: iconSizes.medium width: height radius: Math.max(height, width) border.color: borderColor MouseArea { anchors.fill: parent onClicked: selectedColor = parent.color } } Rectangle { color:"#ffcdf4" anchors.verticalCenter: parent.verticalCenter height: iconSizes.medium width: height radius: Math.max(height, width) border.color: borderColor MouseArea { anchors.fill: parent onClicked: selectedColor = parent.color } } Maui.ToolButton { iconName: "overflow-menu" } } } TextField { id: title Layout.fillWidth: true Layout.margins: space.medium height: 24 placeholderText: qsTr("Title") font.weight: Font.Bold font.bold: true background: Rectangle { color: "transparent" } } ScrollView { Layout.fillHeight: true Layout.fillWidth: true Layout.margins: space.medium TextArea { id: body placeholderText: qsTr("Body") background: Rectangle { color: "transparent" } } } Row { Layout.fillWidth: true width: parent.width Layout.margins: space.medium Layout.alignment: Qt.AlignRight spacing: space.medium Button { id: save text: qsTr("Save") onClicked: { close() - clearNote() noteSaved({ - title: title.text, body: body.text, color: selectedColor, tags: "" }) + clearNote() + } } Button { id: discard text: qsTr("Discard") onClicked: { - clearNote() close() clearNote() } } } } function clearNote() { title.clear() body.clear() } function fill(note) { title.text = note.title body.text = note.body open() } }