main.qml 6.42 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"
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 94
    //    headBar.colorScheme.borderColor: Qt.darker(accentColor, 1.4)
    headBar.drawBorder: false
camilo higuita's avatar
camilo higuita committed
95
//    headBar.implicitHeight: toolBarHeight * 1.5
Camilo higuita's avatar
Camilo higuita committed
96 97 98 99 100 101

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

107
        color: Kirigami.Theme.highlightColor
Camilo higuita's avatar
Camilo higuita committed
108 109
        radius: radiusV

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

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

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

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

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

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

165 166 167
    NewLinkDialog
    {
        id: newLinkDialog
168
        onLinkSaved: linksView.list.insert(link)
169 170
    }

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

181
    //    /***** VIEWS *****/
182

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

192 193 194 195 196 197
//            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
198 199
        }

200
        interactive: isMobile
201

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

208 209 210
        LinksView
        {
            id: linksView
211 212 213
            onLinkClicked: previewLink(link)
        }

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

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

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

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

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

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

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