main.qml 6.45 KB
Newer Older
1
import QtQuick 2.9
camilo higuita's avatar
camilo higuita committed
2
import QtQuick.Controls 2.3
3
import org.kde.kirigami 2.7 as Kirigami
Camilo Higuita's avatar
Camilo Higuita committed
4
import org.kde.mauikit 1.0 as Maui
camilo higuita's avatar
camilo higuita committed
5
import QtQuick.Layouts 1.3
6

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

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

17

Camilo Higuita's avatar
Camilo Higuita committed
18
    /**** BRANDING COLORS ****/
camilo higuita's avatar
camilo higuita committed
19 20
    //    menuButton.colorScheme.highlightColor: accentColor
    //    searchButton.colorScheme.highlightColor: accentColor
21

camilo higuita's avatar
camilo higuita committed
22
    //    headBarBGColor: viewBackgroundColor
23 24
//    headBarFGColor: textColor
//    accentColor : "#ff9494"
25
    //    highlightColor: accentColor
26

27
//    altColorText : "white"/*Qt.darker(accentColor, 2.5)*/
camilo higuita's avatar
camilo higuita committed
28
    showAccounts: true
camilo higuita's avatar
camilo higuita committed
29 30
    Maui.App.description: qsTr("Buho allows you to take quick notes, collect links and take long notes organized by chapters.")
    Maui.App.iconName: "qrc:/buho.svg"
31

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

camilo higuita's avatar
camilo higuita committed
43
//    headBar.position: ToolBar.Footer
camilo higuita's avatar
camilo higuita committed
44 45
    headBar.middleContent: Kirigami.ActionToolBar
    {
camilo higuita's avatar
camilo higuita committed
46
        display: isWide ? ToolButton.TextBesideIcon : ToolButton.IconOnly
camilo higuita's avatar
camilo higuita committed
47
        position: ToolBar.Header
camilo higuita's avatar
camilo higuita committed
48 49
        Layout.fillWidth: true

camilo higuita's avatar
camilo higuita committed
50 51 52 53
        actions: [
            Kirigami.Action
            {
                onTriggered: currentView = views.notes
camilo higuita's avatar
camilo higuita committed
54
                //                icon.color: checked ? accentColor : textColor
55 56
//                Kirigami.Theme.highlightColor: accentColor
//                Kirigami.Theme.textColor: accentColor
57
                icon.name: "view-pim-notes"
camilo higuita's avatar
camilo higuita committed
58 59 60
                text: qsTr("Notes")
                checked: currentView === views.notes
            },
Camilo Higuita's avatar
Camilo Higuita committed
61

camilo higuita's avatar
camilo higuita committed
62 63 64
            Kirigami.Action
            {
                onTriggered: currentView = views.links
65 66
//                icon.color: checked ? accentColor : textColor
//                Kirigami.Theme.highlightColor: accentColor
67
                icon.name: "view-pim-news"
camilo higuita's avatar
camilo higuita committed
68 69 70
                text: qsTr("Links")
                checked: currentView === views.links
            },
Camilo Higuita's avatar
Camilo Higuita committed
71

camilo higuita's avatar
camilo higuita committed
72 73 74
            Kirigami.Action
            {
                onTriggered: currentView = views.books
75 76
//                icon.color: checked?  accentColor : textColor
//                Kirigami.Theme.highlightColor: accentColor
77
                icon.name: "view-pim-journal"
camilo higuita's avatar
camilo higuita committed
78 79 80
                text: qsTr("Books")
                checked: currentView === views.books
            },
81

camilo higuita's avatar
camilo higuita committed
82 83
            Kirigami.Action
            {
84 85
//                icon.color: checked ? accentColor : textColor
//                Kirigami.Theme.highlightColor: accentColor
camilo higuita's avatar
camilo higuita committed
86 87 88 89 90 91
                icon.name: "tag"
                text: qsTr("Tags")
                checked: currentView === views.tags
            }
        ]
    }
92

93
    //    headBar.colorScheme.borderColor: Qt.darker(accentColor, 1.4)
camilo higuita's avatar
camilo higuita committed
94
//    headBar.implicitHeight: Maui.Style.toolBarHeight * 1.5
Camilo higuita's avatar
Camilo higuita committed
95 96 97 98 99 100

    Rectangle
    {
        z: 999
        anchors.right: parent.right
        anchors.bottom: parent.bottom
camilo higuita's avatar
camilo higuita committed
101 102 103
        anchors.margins: Maui.Style.toolBarHeight
        anchors.bottomMargin: Maui.Style.toolBarHeight
        height: Maui.Style.toolBarHeight
Camilo higuita's avatar
Camilo higuita committed
104 105
        width: height

106
        color: Kirigami.Theme.highlightColor
camilo higuita's avatar
camilo higuita committed
107
        radius: Maui.Style.radiusV
Camilo higuita's avatar
Camilo higuita committed
108

109
        Maui.PieButton
110
        {
111
            id: addButton
Camilo higuita's avatar
Camilo higuita committed
112
            anchors.fill : parent
113
            icon.name: "list-add"
114
            icon.color: Kirigami.Theme.highlightedTextColor
Camilo higuita's avatar
Camilo higuita committed
115
            barHeight: parent.height
116
            alignment: Qt.AlignLeft
117
            content: [
118
                ToolButton
119
                {
120
                    icon.name: "view-pim-notes"
121 122
                    onClicked: newNote()
                },
123
                ToolButton
124
                {
125
                    icon.name: "view-pim-news"
126 127
                    onClicked: newLink()
                },
128
                ToolButton
129
                {
130
                    icon.name: "view-pim-journal"
131
                    onClicked: newBook()
132 133
                }
            ]
134
        }
Camilo higuita's avatar
Camilo higuita committed
135
    }
136

137
    Maui.SyncDialog
Camilo Higuita's avatar
Camilo Higuita committed
138
    {
139
        id: syncDialog
Camilo Higuita's avatar
Camilo Higuita committed
140 141
    }

142
    mainMenu: [
143
        MenuItem
144 145 146 147 148 149 150 151
        {
            text: qsTr("Syncing")
            onTriggered: syncDialog.open()
        }
    ]

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

152 153 154
    NewNoteDialog
    {
        id: newNoteDialog
155
        onNoteSaved: notesView.list.insert(note)
156 157 158 159 160
    }

    NewNoteDialog
    {
        id: editNote
161
        onNoteSaved: notesView.list.update(note, notesView.currentIndex)
162 163
    }

Camilo Higuita's avatar
Camilo Higuita committed
164 165 166
    NewLinkDialog
    {
        id: newLinkDialog
167
        onLinkSaved: linksView.list.insert(link)
Camilo Higuita's avatar
Camilo Higuita committed
168 169
    }

170 171 172
    NewBookDialog
    {
        id: newBookDialog
173 174 175
        onBookSaved:
        {
            if(title && title.length)
camilo higuita's avatar
camilo higuita committed
176
                booksView.list.insert({title: title, count: 0})
177
        }
178 179
    }

180
    //    /***** VIEWS *****/
181

Camilo Higuita's avatar
Camilo Higuita committed
182
    SwipeView
183
    {
184
        id: swipeView
185
        anchors.fill: parent
186
        currentIndex: currentView
Camilo Higuita's avatar
Camilo Higuita committed
187 188 189 190
        onCurrentIndexChanged:
        {
            currentView = currentIndex

191 192 193 194 195 196
//            if(currentView === views.notes)
//                accentColor = "#ff9494"
//            else if(currentView === views.links)
//                accentColor = "#25affb"
//            else if(currentView === views.books)
//                accentColor = "#6bc5a5"
Camilo Higuita's avatar
Camilo Higuita committed
197 198
        }

199
        interactive: isMobile
200

201 202 203
        NotesView
        {
            id: notesView
camilo higuita's avatar
camilo higuita committed
204
            onNoteClicked: setNote(note)
Camilo Higuita's avatar
Camilo Higuita committed
205
        }
camilo higuita's avatar
camilo higuita committed
206

Camilo Higuita's avatar
Camilo Higuita committed
207 208 209
        LinksView
        {
            id: linksView
210 211 212
            onLinkClicked: previewLink(link)
        }

213 214 215 216
        BooksView
        {
            id: booksView
        }
217 218
    }

219 220 221 222 223 224 225 226 227 228 229 230
    function newNote()
    {
        currentView = views.notes
        newNoteDialog.open()
    }

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

231 232 233 234 235 236
    function newBook()
    {
        currentView = views.books
        newBookDialog.open()
    }

camilo higuita's avatar
camilo higuita committed
237 238
    function setNote(note)
    {
239
        var tags = notesView.list.getTags(notesView.currentIndex)
240
        note.tags = tags
camilo higuita's avatar
camilo higuita committed
241 242 243
        notesView.currentNote = note
        editNote.fill(note)
    }
244 245 246

    function previewLink(link)
    {
247
        var tags = linksView.list.getTags(linksView.currentIndex)
248
        link.tags = tags
Camilo Higuita's avatar
Camilo Higuita committed
249

250 251
        linksView.previewer.show(link)
    }
252
}