main.qml 4.27 KB
Newer Older
1 2 3 4 5
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

6
import "src/widgets"
7
import "src/views/notes"
Camilo Higuita's avatar
Camilo Higuita committed
8
import "src/views/links"
9
import "src/views/books"
10

11 12
Maui.ApplicationWindow
{
13
    id: root
14 15
    title: qsTr("Buho")

16
    /***** PROPS *****/
Camilo Higuita's avatar
Camilo Higuita committed
17
    altToolBars: true
18
    floatingBar: true
Camilo Higuita's avatar
Camilo Higuita committed
19
    footBarOverlap: true
20
    allowRiseContent: false
21

Camilo Higuita's avatar
Camilo Higuita committed
22 23
    accentColor : "#8981d8"
    menuDrawer.bannerImageSource: "qrc:/Faq.png"
24
    property int currentView : views.notes
25 26 27
    property var views : ({
                              notes: 0,
                              links: 1,
28 29 30
                              books: 2,
                              tags: 3,
                              search: 4
31 32
                          })

33
    headBar.middleContent: [
34

35 36
        Maui.ToolButton
        {
37
            display: root.isWide ? ToolButton.TextBesideIcon : ToolButton.IconOnly
38
            onClicked: currentView = views.notes
39
            iconColor: currentView === views.notes? highlightColor : textColor
40 41
            iconName: "draw-text"
            text: qsTr("Notes")
42
        },
Camilo Higuita's avatar
Camilo Higuita committed
43

44 45
        Maui.ToolButton
        {
46
            display: root.isWide ? ToolButton.TextBesideIcon : ToolButton.IconOnly
47
            onClicked: currentView = views.links
48
            iconColor: currentView === views.links? highlightColor : textColor
49 50
            iconName: "link"
            text: qsTr("Links")
51
        },
Camilo Higuita's avatar
Camilo Higuita committed
52

53 54
        Maui.ToolButton
        {
55
            display: root.isWide ? ToolButton.TextBesideIcon : ToolButton.IconOnly
56
            iconColor: currentView === views.books? highlightColor : textColor
57 58
            iconName: "document-new"
            text: qsTr("Books")
59 60 61 62 63
        },

        Maui.ToolButton
        {
            display: root.isWide ? ToolButton.TextBesideIcon : ToolButton.IconOnly
64
            iconColor: currentView === views.tags? highlightColor : textColor
65 66
            iconName: "tag"
            text: qsTr("Tags")
67
        }
68
    ]
69

Camilo Higuita's avatar
Camilo Higuita committed
70
    footBarMargins: space.huge
71
    footBarAligment: Qt.AlignRight
72
    footBar.middleContent: [
73

74
        Maui.PieButton
75
        {
76 77
            id: addButton
            iconName: "list-add"
78
            iconColor: "white"
79 80

            model: ListModel
81
            {
82 83 84
                ListElement {iconName: "document-new"; mid: "page"}
                ListElement {iconName: "link"; mid: "link"}
                ListElement {iconName: "draw-text"; mid: "note"}
85 86
            }

87 88 89
            onItemClicked:
            {
                if(item.mid === "note")
90
                newNote()
91
                else if(item.mid === "link")
92
                newLink()
93
            }
94
        }
95
    ]
96

97 98
    /***** COMPONENTS *****/

Camilo Higuita's avatar
Camilo Higuita committed
99 100 101 102
    Connections
    {
        target: owl
        onNoteInserted: notesView.append(note)
103
        onLinkInserted: linksView.append(link)
Camilo Higuita's avatar
Camilo Higuita committed
104 105
    }

106 107 108
    NewNoteDialog
    {
        id: newNoteDialog
109
        onNoteSaved: owl.insertNote(note)
110 111 112 113 114 115 116
    }

    NewNoteDialog
    {
        id: editNote
        onNoteSaved:
        {
117
            if(owl.updateNote(note))
Camilo Higuita's avatar
Camilo Higuita committed
118
                notesView.cardsView.currentItem.update(note)
119
        }
120 121
    }

Camilo Higuita's avatar
Camilo Higuita committed
122 123 124
    NewLinkDialog
    {
        id: newLinkDialog
Camilo Higuita's avatar
Camilo Higuita committed
125
        onLinkSaved: owl.insertLink(link)
Camilo Higuita's avatar
Camilo Higuita committed
126 127
    }

128 129
    /***** VIEWS *****/

Camilo Higuita's avatar
Camilo Higuita committed
130
  SwipeView
131
    {
132
        id: swipeView
133
        anchors.fill: parent
134 135
        currentIndex: currentView
        onCurrentIndexChanged: currentView = currentIndex
136
        interactive: isMobile
137

Camilo Higuita's avatar
Camilo Higuita committed
138

139 140 141
        NotesView
        {
            id: notesView
camilo higuita's avatar
camilo higuita committed
142
            onNoteClicked: setNote(note)
Camilo Higuita's avatar
Camilo Higuita committed
143
        }
camilo higuita's avatar
camilo higuita committed
144

Camilo Higuita's avatar
Camilo Higuita committed
145 146 147
        LinksView
        {
            id: linksView
148 149 150 151 152 153
            onLinkClicked: previewLink(link)
        }

        BooksView
        {
            id: booksView
154
        }
155

156 157
    }

158 159 160
    Component.onCompleted:
    {
        notesView.populate()
161
        linksView.populate()
162
    }
camilo higuita's avatar
camilo higuita committed
163

164 165 166 167 168 169 170 171 172 173 174 175 176

    function newNote()
    {
        currentView = views.notes
        newNoteDialog.open()
    }

    function newLink()
    {
        currentView = views.links
        newLinkDialog.open()
    }

camilo higuita's avatar
camilo higuita committed
177 178
    function setNote(note)
    {
179 180
        var tags = owl.getNoteTags(note.id)
        note.tags = tags
camilo higuita's avatar
camilo higuita committed
181 182 183
        notesView.currentNote = note
        editNote.fill(note)
    }
184 185 186 187 188

    function previewLink(link)
    {
        var tags = owl.getLinkTags(link.link)
        link.tags = tags
Camilo Higuita's avatar
Camilo Higuita committed
189

190 191
        linksView.previewer.show(link)
    }
192
}