1/*
2    SPDX-FileCopyrightText: 2018 Andreas Cord-Landwehr <cordlandwehr@kde.org>
3
4    SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
5*/
6
7import QtQuick 2.5
8import QtQuick.Layouts 1.3
9import QtQuick.Controls 2.0 as QQC2
10import org.kde.kirigami 2.7 as Kirigami
11import artikulate 1.0
12
13Kirigami.GlobalDrawer {
14    id: root
15
16    title: "Artikulate"
17    titleIcon: "artikulate"
18    resetMenuOnTriggered: false
19    bottomPadding: 0
20    property QtObject pageStack
21
22    // enforce drawer always to be open
23    modal: false
24    handleVisible: false
25
26    topContent: [
27        ColumnLayout {
28            spacing: 0
29            Layout.fillWidth: true
30            Layout.leftMargin: -root.leftPadding
31            Layout.rightMargin: -root.rightPadding
32            ActionListItem {
33                action: Kirigami.Action {
34                    text: i18n("Training")
35                    iconName: "artikulate"
36                    onTriggered: {
37                        root.pageStack.clear();
38                        root.pageStack.push(welcomePageComponent);
39                    }
40                }
41            }
42            Kirigami.Separator {
43                Layout.fillWidth: true
44            }
45        }
46    ]
47
48    // ordinary Kirigami actions are filled from training units/phrases
49    actions: sessionActions.actions
50    DrawerTrainingActions {
51        id: sessionActions
52        session: g_trainingSession
53        onTriggerPhraseView: {
54            root.pageStack.clear();
55            root.pageStack.push(trainingPageComponent);
56        }
57    }
58    Connections {
59        target: g_trainingSession
60        onCloseUnit: {
61            root.resetMenu()
62        }
63    }
64
65//TODO integrate again
66//     [
67//         Kirigami.Action {
68//             text: i18n("Help")
69//             iconName: "help-about"
70//             Kirigami.Action {
71//                 text: i18n("Artikulate Handbook")
72//                 iconName: "help-contents"
73//                 onTriggered: {
74//                     triggerAction("help_contents");
75//                     globalDrawer.resetMenu();
76//                 }
77//             }
78//             Kirigami.Action {
79//                 text: i18n("Report Bug")
80//                 iconName: "tools-report-bug"
81//                 onTriggered: {
82//                     triggerAction("help_report_bug");
83//                     globalDrawer.resetMenu();
84//                 }
85//             }
86//             Kirigami.Action {
87//                 text: i18n("About KDE")
88//                 iconName: "help-about"
89//                 onTriggered: {
90//                     triggerAction("help_about_kde")
91//                     globalDrawer.resetMenu();
92//                 }
93//             }
94//         }
95//     ]
96
97    ColumnLayout {
98        spacing: 0
99        Layout.fillWidth: true
100        Layout.leftMargin: -root.leftPadding
101        Layout.rightMargin: -root.rightPadding
102
103        Kirigami.Separator {
104            Layout.fillWidth: true
105        }
106
107//TODO currently disabled while contents have to be ported
108//        ActionListItem {
109//            action: Kirigami.Action {
110//                text: i18n("Statistics")
111//                iconName: "user-properties"
112//                onTriggered: {
113//                    root.pageStack.pop();
114//                    root.pageStack.push(profileSettingsPageComponent);
115//                }
116//            }
117//        }
118//        ActionListItem {
119//            action: Kirigami.Action {
120//                text: i18n("Settings")
121//                iconName: "settings-configure"
122//                onTriggered: triggerSettingsDialog()
123//            }
124//        }
125        ActionListItem {
126            action: Kirigami.Action {
127                text: i18n("Download Training")
128                iconName: "get-hot-new-stuff"
129                onTriggered: {
130                    root.pageStack.pop();
131                    root.pageStack.push(downloadPageComponent);
132                }
133            }
134        }
135        ActionListItem {
136            action: Kirigami.Action {
137                text: i18n("About Artikulate")
138                iconName: "help-about"
139                onTriggered: {
140                    if (root.pageStack.layers.depth < 2) {
141                        root.pageStack.layers.push(aboutPageComponent)
142                    }
143                }
144            }
145        }
146    }
147}
148