main.qml 5.34 KB
Newer Older
1 2
import QtQuick 2.9
import QtQuick.Controls 2.2
3
import org.kde.kirigami 2.4 as Kirigami
Camilo Higuita's avatar
Camilo Higuita committed
4
import org.kde.mauikit 1.0 as Maui
5

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 *****/
17
    floatingBar: true
Camilo Higuita's avatar
Camilo Higuita committed
18
    footBarOverlap: true
19
    allowRiseContent: false
20
//    altToolBars: false
21

Camilo Higuita's avatar
Camilo Higuita committed
22
    /**** BRANDING COLORS ****/
23 24 25 26
    menuButton.colorScheme.highlightColor: accentColor
    searchButton.colorScheme.highlightColor: accentColor
    headBarBGColor: viewBackgroundColor
    headBarFGColor: textColor
Camilo higuita's avatar
Camilo higuita committed
27
    accentColor : "#ff9494"
28
    //    highlightColor: accentColor
29

Camilo higuita's avatar
Camilo higuita committed
30
    altColorText : "white"/*Qt.darker(accentColor, 2.5)*/
Camilo Higuita's avatar
Camilo Higuita committed
31

32 33
    about.appDescription: qsTr("Buho allows you to take quick notes, collect links and take long notes organized by chapters.")
    about.appIcon: "qrc:/buho.svg"
34

35
    property int currentView : views.notes
36 37 38 39 40 41 42
    readonly property var views : ({
                                       notes: 0,
                                       links: 1,
                                       books: 2,
                                       tags: 3,
                                       search: 4
                                   })
43
    property color headBarTint : Qt.lighter(headBarBGColor, 1.25)
44

45
    headBar.middleContent: [
46 47
        Maui.ToolButton
        {
48
            onClicked: currentView = views.notes
49 50
            iconColor: currentView === views.notes? accentColor : textColor
            colorScheme.highlightColor: accentColor
Camilo higuita's avatar
Camilo higuita committed
51
            iconName: "view-notes"
52
            text: qsTr("Notes")
53
        },
Camilo Higuita's avatar
Camilo Higuita committed
54

55 56
        Maui.ToolButton
        {
57
            onClicked: currentView = views.links
58 59
            iconColor: currentView === views.links? accentColor : textColor
            colorScheme.highlightColor: accentColor
Camilo higuita's avatar
Camilo higuita committed
60
            iconName: "view-links"
61
            text: qsTr("Links")
62
        },
Camilo Higuita's avatar
Camilo Higuita committed
63

64 65
        Maui.ToolButton
        {
Camilo higuita's avatar
Camilo higuita committed
66
            onClicked: currentView = views.books
67 68
            iconColor: currentView === views.books?  accentColor : textColor
            colorScheme.highlightColor: accentColor
Camilo higuita's avatar
Camilo higuita committed
69
            iconName: "view-books"
70
            text: qsTr("Books")
71 72 73 74
        },

        Maui.ToolButton
        {
75 76
            iconColor: currentView === views.tags? accentColor : textColor
            colorScheme.highlightColor: accentColor
77 78
            iconName: "tag"
            text: qsTr("Tags")
79
        }
80
    ]
81

82 83 84
    //    headBar.colorScheme.borderColor: Qt.darker(accentColor, 1.4)
    headBar.drawBorder: false
    headBar.implicitHeight: toolBarHeight * 1.5
85 86
    footBar.colorScheme.backgroundColor: accentColor
    footBar.colorScheme.borderColor: Qt.darker(accentColor, 1.4)
Camilo Higuita's avatar
Camilo Higuita committed
87
    footBarMargins: space.huge
88
    footBarAligment: Qt.AlignRight
89
    footBar.middleContent: [
90

91
        Maui.PieButton
92
        {
93 94
            id: addButton
            iconName: "list-add"
Camilo higuita's avatar
Camilo higuita committed
95
            iconColor: altColorText
96
            barHeight: footBar.height
97
            alignment: Qt.AlignLeft
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
            content: [
                Maui.ToolButton
                {
                    iconName: "view-notes"
                    onClicked: newNote()
                },
                Maui.ToolButton
                {
                    iconName: "view-links"
                    onClicked: newLink()
                },
                Maui.ToolButton
                {
                    iconName: "view-books"
                }
            ]
114
        }
115
    ]
116

117

118
    Maui.SyncDialog
Camilo Higuita's avatar
Camilo Higuita committed
119
    {
120 121
        id: syncDialog

Camilo Higuita's avatar
Camilo Higuita committed
122 123
    }

124 125 126 127 128 129 130 131 132 133
    mainMenu: [
        Maui.MenuItem
        {
            text: qsTr("Syncing")
            onTriggered: syncDialog.open()
        }
    ]

    //    /***** COMPONENTS *****/

134 135 136
    NewNoteDialog
    {
        id: newNoteDialog
137
        onNoteSaved: notesView.list.insert(note)
138 139 140 141 142
    }

    NewNoteDialog
    {
        id: editNote
143
        onNoteSaved: notesView.list.update(note, notesView.currentIndex)
144 145
    }

Camilo Higuita's avatar
Camilo Higuita committed
146 147 148
    NewLinkDialog
    {
        id: newLinkDialog
149
        onLinkSaved: linksView.list.insert(link)
Camilo Higuita's avatar
Camilo Higuita committed
150 151
    }

152
    //    /***** VIEWS *****/
153

Camilo Higuita's avatar
Camilo Higuita committed
154
    SwipeView
155
    {
156
        id: swipeView
157
        anchors.fill: parent
158
        currentIndex: currentView
Camilo Higuita's avatar
Camilo Higuita committed
159 160 161 162 163
        onCurrentIndexChanged:
        {
            currentView = currentIndex

            if(currentView === views.notes)
Camilo higuita's avatar
Camilo higuita committed
164
                accentColor = "#ff9494"
Camilo Higuita's avatar
Camilo Higuita committed
165
            else if(currentView === views.links)
Camilo higuita's avatar
Camilo higuita committed
166 167 168
                accentColor = "#25affb"
            else if(currentView === views.books)
                accentColor = "#6bc5a5"
Camilo Higuita's avatar
Camilo Higuita committed
169 170
        }

171
        interactive: isMobile
172

173 174 175
        NotesView
        {
            id: notesView
camilo higuita's avatar
camilo higuita committed
176
            onNoteClicked: setNote(note)
Camilo Higuita's avatar
Camilo Higuita committed
177
        }
camilo higuita's avatar
camilo higuita committed
178

Camilo Higuita's avatar
Camilo Higuita committed
179 180 181
        LinksView
        {
            id: linksView
182 183 184
            onLinkClicked: previewLink(link)
        }

Camilo higuita's avatar
Camilo higuita committed
185 186 187 188
        BooksView
        {
            id: booksView
        }
189

190 191
    }

192

193 194 195 196 197 198 199 200 201 202 203 204
    function newNote()
    {
        currentView = views.notes
        newNoteDialog.open()
    }

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

camilo higuita's avatar
camilo higuita committed
205 206
    function setNote(note)
    {
207
        var tags = notesView.list.getTags(notesView.currentIndex)
208
        note.tags = tags
camilo higuita's avatar
camilo higuita committed
209 210 211
        notesView.currentNote = note
        editNote.fill(note)
    }
212 213 214

    function previewLink(link)
    {
215
        var tags = linksView.list.getTags(linksView.currentIndex)
216
        link.tags = tags
Camilo Higuita's avatar
Camilo Higuita committed
217

218 219
        linksView.previewer.show(link)
    }
220
}