diff --git a/src/main.qml b/src/main.qml index 38c058a..66e0d14 100644 --- a/src/main.qml +++ b/src/main.qml @@ -1,156 +1,239 @@ import QtQuick 2.9 import QtQuick.Controls 2.3 import org.kde.kirigami 2.7 as Kirigami import org.kde.mauikit 1.0 as Maui import org.kde.mauikit 1.1 as MauiLab import QtQuick.Layouts 1.3 import "widgets" import "views/notes" import "views/links" import "views/books" Maui.ApplicationWindow { id: root title: qsTr("Buho") Maui.App.handleAccounts: true Maui.App.description: qsTr("Buho allows you to take quick notes, collect links and organize notes as books.") Maui.App.iconName: "qrc:/buho.svg" // Maui.App.enableCSD: true readonly property var views : ({ notes: 0, links: 1, books: 2 }) + mainMenu: MenuItem + { + text: qsTr("Settings") + icon.name: "settings-configure" + onTriggered: _settingsDialog.open() + } + Maui.PieButton { id: addButton z: 999 anchors.right: parent.right anchors.bottom: parent.bottom anchors.margins: height height: Maui.Style.toolBarHeight icon.name: "list-add" icon.color: Kirigami.Theme.highlightedTextColor alignment: Qt.AlignLeft Action { icon.name: "view-pim-notes" onTriggered: newNote() } Action { icon.name: "view-pim-news" onTriggered: newLink() } Action { icon.name: "view-pim-journal" onTriggered: newBook() } } + MauiLab.SettingsDialog + { + id: _settingsDialog + MauiLab.SettingsSection + { + title: qsTr("Syncing") + description: qsTr("Configure the syncing options.") + + Switch + { + checkable: true + Kirigami.FormData.label: qsTr("Auto Fetch on Start Up") + Layout.fillWidth: true + } + } + + MauiLab.SettingsSection + { + title: qsTr("Notes") + description: qsTr("Configure the notes view behavior.") + + Switch + { + checkable: true + Kirigami.FormData.label: qsTr("Rich Text Formating") + Layout.fillWidth: true + } + } + + MauiLab.SettingsSection + { + title: qsTr("Links") + description: qsTr("Configure the app plugins and behavior.") + + Switch + { + checkable: true + Kirigami.FormData.label: qsTr("Cached") + Layout.fillWidth: true + } + } + + MauiLab.SettingsSection + { + title: qsTr("Books") + description: qsTr("Configure the app plugins and behavior.") + + Item + { + Kirigami.FormData.label: qsTr("Editor") + Kirigami.FormData.isSection: true + } + + Switch + { + checkable: true + Kirigami.FormData.label: qsTr("Show Line Numbers") + Layout.fillWidth: true + } + + Switch + { + checkable: true + Kirigami.FormData.label: qsTr("Support Syntax Highlighting") + Layout.fillWidth: true + } + + Switch + { + checkable: true + Kirigami.FormData.label: qsTr("Auto Save") + Layout.fillWidth: true + } + } + } + // /***** COMPONENTS *****/ NewNoteDialog { id: newNoteDialog onNoteSaved: notesView.list.insert(note) } NewNoteDialog { id: editNote onNoteSaved: notesView.list.update(note, notesView.currentIndex) } NewLinkDialog { id: newLinkDialog onLinkSaved: linksView.list.insert(link) } NewLinkDialog { id: editLinkDialog onLinkSaved: linksView.list.update(link, linksView.currentIndex) } NewBookDialog { id: newBookDialog onBookSaved: { if(title && title.length) booksView.list.insert({title: title, count: 0}) } } // /***** VIEWS *****/ MauiLab.AppViews { id: swipeView anchors.fill: parent NotesView { id: notesView onNoteClicked: setNote(note) MauiLab.AppView.iconName: "view-pim-notes" MauiLab.AppView.title: qsTr("Notes") } LinksView { MauiLab.AppView.iconName: "view-pim-news" MauiLab.AppView.title: qsTr("Links") id: linksView onLinkClicked: setLink(link) } BooksView { id: booksView MauiLab.AppView.iconName: "view-pim-journal" MauiLab.AppView.title: qsTr("Books") } } function newNote() { swipeView.currentIndex = views.notes newNoteDialog.open() } function newLink() { swipeView.currentIndex = views.links newLinkDialog.open() } function newBook() { swipeView.currentIndex = views.books newBookDialog.open() } function setNote(note) { notesView.currentNote = note editNote.fill(note) editNote.open() } function setLink(link) { linksView.currentLink = link editLinkDialog.fill(link) editLinkDialog.open() } } diff --git a/src/views/books/BooksView.qml b/src/views/books/BooksView.qml index ae46b11..d55dbec 100644 --- a/src/views/books/BooksView.qml +++ b/src/views/books/BooksView.qml @@ -1,152 +1,152 @@ import QtQuick 2.9 import "../../widgets" import QtQuick.Controls 2.3 import QtQuick.Layouts 1.3 import org.kde.mauikit 1.0 as Maui import org.kde.kirigami 2.7 as Kirigami import Books 1.0 StackView { id: control property alias list : _booksList property alias cardsView : cardsView property bool showDetails: false property var currentBook : ({}) StackView { id: _stackView anchors.fill: parent initialItem: _booksPage } Component { id: _bookletComponent BookletPage { onExit: _stackView.pop() } } Maui.BaseModel { id: _booksModel list: _booksList } Books { id: _booksList currentBook: cardsView.currentIndex } Maui.Page { id: _booksPage - padding: showDetails ? 0 : Maui.Style.space.big + padding: showDetails ? 0 : 0 title : cardsView.count + " books" // headBar.leftContent: [ // ToolButton // { // icon.name: showDetails ? "view-list-icons" : "view-list-details" // onClicked: // { // showDetails = !showDetails // } // } // ] headBar.visible: !_holder.visible headBar.rightContent: [ ToolButton { icon.name: "view-sort" } ] Maui.Holder { id: _holder visible: !cardsView.count emoji: "qrc:/view-books.svg" emojiSize: Maui.Style.iconSizes.huge title : qsTr("There are not Books!") body: qsTr("You can create new books and organize your notes") } Maui.GridView { id: cardsView visible: !_holder.visible anchors.fill: parent adaptContent: true itemSize: Maui.Style.iconSizes.huge + Maui.Style.space.big cellHeight: itemSize * 1.5 model: _booksModel delegate: Maui.ItemDelegate { id: _delegate width: cardsView.itemSize height: cardsView.cellHeight padding: Maui.Style.space.small background: Item {} isCurrentItem: GridView.isCurrentItem ToolTip.delay: 1000 ToolTip.timeout: 5000 ToolTip.visible: hovered ToolTip.text: model.url Maui.GridItemTemplate { isCurrentItem: _delegate.isCurrentItem hovered: _delegate.hovered anchors.fill: parent label1.text: model.title iconSizeHint: parent.height * 0.6 iconSource: "qrc:/booklet.svg" } Maui.Badge { anchors { left: parent.left top: parent.top margins: Maui.Style.space.small } Kirigami.Theme.backgroundColor: Kirigami.Theme.neutralTextColor Kirigami.Theme.textColor: Qt.darker(Kirigami.Theme.neutralTextColor, 2.4) text: model.count } Connections { target:_delegate onClicked: { console.log("BOOKLET CLICKED", index) cardsView.currentIndex = index control.currentBook = _booksList.get(index) _stackView.push(_bookletComponent) } } } } } } diff --git a/src/views/notes/NotesView.qml b/src/views/notes/NotesView.qml index 6464c66..d088e0d 100644 --- a/src/views/notes/NotesView.qml +++ b/src/views/notes/NotesView.qml @@ -1,355 +1,357 @@ import QtQuick 2.10 import QtQuick.Controls 2.10 import QtQuick.Layouts 1.3 import org.kde.mauikit 1.0 as Maui import org.kde.mauikit 1.1 as MauiLab import org.kde.kirigami 2.7 as Kirigami import Notes 1.0 import Qt.labs.platform 1.0 as Labs import "../../widgets" Maui.Page { property var currentNote : ({}) property alias cardsView : cardsView property alias model : notesModel property alias list : notesList property alias currentIndex : cardsView.currentIndex signal noteClicked(var note) flickable: cardsView padding: 0 headBar.visible: !cardsView.holder.visible headBar.leftContent: Maui.ToolActions { autoExclusive: true expanded: isWide currentIndex : cardsView.viewType === MauiLab.AltBrowser.ViewType.List ? 0 : 1 + display: ToolButton.TextBesideIcon + Action { text: qsTr("List") icon.name: "view-list-details" onTriggered: cardsView.viewType = MauiLab.AltBrowser.ViewType.List } Action { - text: qsTr("Grid") + text: qsTr("Cards") icon.name: "view-list-icons" onTriggered: cardsView.viewType= MauiLab.AltBrowser.ViewType.Grid } } headBar.middleContent: Maui.TextField { Layout.fillWidth: true placeholderText: qsTr("Search ") + notesList.count + " " + qsTr("notes") onAccepted: notesModel.filter = text onCleared: notesModel.filter = "" } headBar.rightContent: [ ToolButton { icon.name: "view-sort" onClicked: sortMenu.open(); Menu { id: sortMenu Labs.MenuItemGroup { id: orderGroup } Labs.MenuItemGroup { id: sortGroup } MenuItem { text: qsTr("Ascedent") checkable: true checked: notesList.order === Notes.ASC onTriggered: notesList.order = Notes.ASC } MenuItem { text: qsTr("Descendent") checkable: true checked: notesList.order === Notes.DESC onTriggered: notesList.order = Notes.DESC } MenuSeparator{} Labs.MenuItem { text: qsTr("Title") checkable: true checked: notesList.sortBy === Notes.TITLE onTriggered: notesList.sortBy = Notes.TITLE group: orderGroup } Labs.MenuItem { text: qsTr("Color") checkable: true checked: notesList.sortBy === Notes.COLOR onTriggered: notesList.sortBy = Notes.COLOR group: orderGroup } Labs.MenuItem { text: qsTr("Add date") checkable: true checked: notesList.sortBy === Notes.ADDDATE onTriggered: notesList.sortBy = Notes.ADDDATE group: orderGroup } Labs.MenuItem { text: qsTr("Updated") checkable: true checked: notesList.sortBy === Notes.Modified onTriggered: notesList.sortBy = Notes.Modified group: orderGroup } Labs.MenuItem { text: qsTr("Favorite") checkable: true checked: notesList.sortBy === Notes.FAVORITE onTriggered: notesList.sortBy = Notes.FAVORITE group: orderGroup } } }, ToolButton { id: favButton icon.name: "love" checkable: true icon.color: checked ? Kirigami.Theme.highlightColor : Kirigami.Theme.textColor } ] Notes { id: notesList } Maui.BaseModel { id: notesModel list: notesList recursiveFilteringEnabled: true sortCaseSensitivity: Qt.CaseInsensitive filterCaseSensitivity: Qt.CaseInsensitive } ColumnLayout { anchors.fill: parent spacing: 0 Rectangle { visible: favButton.checked Layout.alignment: Qt.AlignVCenter Layout.fillWidth: true height: cardsView.itemHeight color: Kirigami.Theme.backgroundColor Maui.Holder { id: holder visible: favedList.count == 0 emoji: "qrc:/edit-pin.svg" emojiSize: Maui.Style.iconSizes.big isMask: true title : qsTr("No favorites!") body: qsTr("No matched favorites notes. You can fav your notes to access them quickly") z: 999 } CardsList { id: favedList height: parent.height *0.9 width: parent.width * 0.9 anchors.centerIn: parent itemHeight: 150 itemWidth: itemHeight * 1.5 onItemClicked: noteClicked(cardsView.model.get(index)) } } CardsView { id: cardsView Layout.fillHeight: true Layout.fillWidth: true holder.visible: notesList.count < 1 holder.emoji: "qrc:/view-notes.svg" holder.emojiSize: Maui.Style.iconSizes.huge holder.title :qsTr("No notes!") holder.body: qsTr("Click here to create a new note") model: notesModel listDelegate: CardDelegate { anchors.horizontalCenter: parent.horizontalCenter width: parent.width - Maui.Style.space.big height: 150 onClicked: { currentIndex = index currentNote = notesList.get(index) noteClicked(currentNote) } onRightClicked: { currentIndex = index currentNote = notesList.get(index) _notesMenu.popup() } onPressAndHold: { currentIndex = index currentNote = notesList.get(index) _notesMenu.popup() } } gridDelegate: Item { id: delegate width: cardsView.gridView.cellWidth height: cardsView.gridView.cellHeight CardDelegate { anchors.fill: parent anchors.margins: Maui.Style.space.medium onClicked: { currentIndex = index currentNote = notesList.get(index) noteClicked(currentNote) } onRightClicked: { currentIndex = index currentNote = notesList.get(index) _notesMenu.popup() } onPressAndHold: { currentIndex = index currentNote = notesList.get(index) _notesMenu.popup() } } } Connections { target: cardsView.holder onActionTriggered: newNote() } Menu { id: _notesMenu width: colorBar.implicitWidth + Maui.Style.space.medium property bool isFav: currentNote.favorite == 1 MenuItem { icon.name: "love" text: qsTr(_notesMenu.isFav? "UnFav" : "Fav") onTriggered: { notesList.update(({"favorite": _notesMenu.isFav ? 0 : 1}), cardsView.currentIndex) _notesMenu.close() } } MenuItem { icon.name: "document-export" text: qsTr("Export") onTriggered: { _notesMenu.close() } } MenuItem { icon.name : "edit-copy" text: qsTr("Copy") onTriggered: { Maui.Handy.copyToClipboard({'text': currentNote.content}) _notesMenu.close() } } MenuSeparator { } MenuItem { icon.name: "edit-delete" text: qsTr("Remove") Kirigami.Theme.textColor: Kirigami.Theme.negativeTextColor onTriggered: { notesList.remove(cardsView.currentIndex) _notesMenu.close() } } MenuSeparator { } MenuItem { width: parent.width height: Maui.Style.rowHeight ColorsBar { id: colorBar anchors.centerIn: parent onColorPicked: { notesList.update(({"color": color}), cardsView.currentIndex) _notesMenu.close() } } } } } } }