main.qml 6.32 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

Camilo higuita's avatar
Camilo higuita committed
93 94 95 96 97
    Rectangle
    {
        z: 999
        anchors.right: parent.right
        anchors.bottom: parent.bottom
camilo higuita's avatar
camilo higuita committed
98 99 100
        anchors.margins: Maui.Style.toolBarHeight
        anchors.bottomMargin: Maui.Style.toolBarHeight
        height: Maui.Style.toolBarHeight
Camilo higuita's avatar
Camilo higuita committed
101 102
        width: height

103
        color: Kirigami.Theme.highlightColor
camilo higuita's avatar
camilo higuita committed
104
        radius: Maui.Style.radiusV
Camilo higuita's avatar
Camilo higuita committed
105

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

134
    Maui.SyncDialog
Camilo Higuita's avatar
Camilo Higuita committed
135
    {
136
        id: syncDialog
Camilo Higuita's avatar
Camilo Higuita committed
137 138
    }

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

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

149 150 151
    NewNoteDialog
    {
        id: newNoteDialog
152
        onNoteSaved: notesView.list.insert(note)
153 154 155 156 157
    }

    NewNoteDialog
    {
        id: editNote
158
        onNoteSaved: notesView.list.update(note, notesView.currentIndex)
159 160
    }

161 162 163
    NewLinkDialog
    {
        id: newLinkDialog
164
        onLinkSaved: linksView.list.insert(link)
165 166
    }

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

177
    //    /***** VIEWS *****/
178

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

188 189 190 191 192 193
//            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
194 195
        }

196
        interactive: isMobile
197

198 199 200
        NotesView
        {
            id: notesView
camilo higuita's avatar
camilo higuita committed
201
            onNoteClicked: setNote(note)
202
        }
camilo higuita's avatar
camilo higuita committed
203

204 205 206
        LinksView
        {
            id: linksView
207 208 209
            onLinkClicked: previewLink(link)
        }

210 211 212 213
        BooksView
        {
            id: booksView
        }
214 215
    }

216 217 218 219 220 221 222 223 224 225 226 227
    function newNote()
    {
        currentView = views.notes
        newNoteDialog.open()
    }

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

228 229 230 231 232 233
    function newBook()
    {
        currentView = views.books
        newBookDialog.open()
    }

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

    function previewLink(link)
    {
244
        var tags = linksView.list.getTags(linksView.currentIndex)
245
        link.tags = tags
Camilo Higuita's avatar
Camilo Higuita committed
246

247 248
        linksView.previewer.show(link)
    }
249
}