main.qml 6.08 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
    /***** PROPS *****/
camilo higuita's avatar
camilo higuita committed
18
    //    altToolBars: false
19

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

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

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

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

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

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

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

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

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

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

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

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

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

111
        Maui.PieButton
112
        {
113
            id: addButton
Camilo higuita's avatar
Camilo higuita committed
114
            anchors.fill : parent
115
            icon.name: "list-add"
116
            icon.color: Kirigami.Theme.highlightedTextColor
Camilo higuita's avatar
Camilo higuita committed
117
            barHeight: parent.height
118
            alignment: Qt.AlignLeft
119
            content: [
120
                ToolButton
121
                {
122
                    icon.name: "view-pim-notes"
123 124
                    onClicked: newNote()
                },
125
                ToolButton
126
                {
127
                    icon.name: "view-pim-news"
128 129
                    onClicked: newLink()
                },
130
                ToolButton
131
                {
132
                    icon.name: "view-pim-journal"
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
    //    /***** VIEWS *****/
172

Camilo Higuita's avatar
Camilo Higuita committed
173
    SwipeView
174
    {
175
        id: swipeView
176
        anchors.fill: parent
177
        currentIndex: currentView
Camilo Higuita's avatar
Camilo Higuita committed
178 179 180 181
        onCurrentIndexChanged:
        {
            currentView = currentIndex

182 183 184 185 186 187
//            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
188 189
        }

190
        interactive: isMobile
191

192 193 194
        NotesView
        {
            id: notesView
camilo higuita's avatar
camilo higuita committed
195
            onNoteClicked: setNote(note)
196
        }
camilo higuita's avatar
camilo higuita committed
197

198 199 200
        LinksView
        {
            id: linksView
201 202 203
            onLinkClicked: previewLink(link)
        }

204 205 206 207
        BooksView
        {
            id: booksView
        }
208 209
    }

210 211 212 213 214 215 216 217 218 219 220 221
    function newNote()
    {
        currentView = views.notes
        newNoteDialog.open()
    }

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

camilo higuita's avatar
camilo higuita committed
222 223
    function setNote(note)
    {
224
        var tags = notesView.list.getTags(notesView.currentIndex)
225
        note.tags = tags
camilo higuita's avatar
camilo higuita committed
226 227 228
        notesView.currentNote = note
        editNote.fill(note)
    }
229 230 231

    function previewLink(link)
    {
232
        var tags = linksView.list.getTags(linksView.currentIndex)
233
        link.tags = tags
Camilo Higuita's avatar
Camilo Higuita committed
234

235 236
        linksView.previewer.show(link)
    }
237
}