main.qml 5.25 KB
Newer Older
Yuri Chornoivan's avatar
Yuri Chornoivan committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/*************************************************************************************
 *  Copyright (C) 2015 by Aleix Pol <aleixpol@kde.org>                               *
 *                                                                                   *
 *  This program is free software; you can redistribute it and/or                    *
 *  modify it under the terms of the GNU General Public License                      *
 *  as published by the Free Software Foundation; either version 2                   *
 *  of the License, or (at your option) any later version.                           *
 *                                                                                   *
 *  This program is distributed in the hope that it will be useful,                  *
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of                   *
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                    *
 *  GNU General Public License for more details.                                     *
 *                                                                                   *
 *  You should have received a copy of the GNU General Public License                *
 *  along with this program; if not, write to the Free Software                      *
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA   *
 *************************************************************************************/

19
20
import QtQuick 2.2
import QtQuick.Layouts 1.2
Carl Schwan's avatar
Carl Schwan committed
21
import org.kde.kirigami 2.14 as Kirigami
22
import org.kde.analitza 1.0
23
import org.kde.kalgebra.mobile 1.0
24

Aleix Pol Gonzalez's avatar
Aleix Pol Gonzalez committed
25
Kirigami.ApplicationWindow
26
27
{
    id: rootItem
28
29
    height: 800
    width: Kirigami.Units.gridUnit * 70
30
    visible: true
31

32
33
34
    readonly property int columnWidth: Kirigami.Units.gridUnit * 13
    wideScreen: width > columnWidth * 5

Carl Schwan's avatar
Carl Schwan committed
35
36
37
38
    Kirigami.PagePool {
        id: mainPagePool
    }

Aleix Pol Gonzalez's avatar
Aleix Pol Gonzalez committed
39
    globalDrawer: Kirigami.GlobalDrawer {
40
41
        id: drawer

42
43
        modal: !rootItem.wideScreen
        onModalChanged: drawerOpen = !modal
44
        handleVisible: modal
45
46
47
48
49
50
51
52
53
54
55
56
57
58
        width: contentItem ? columnWidth : 0

        header: Kirigami.AbstractApplicationHeader {
            topPadding: Kirigami.Units.smallSpacing
            bottomPadding: Kirigami.Units.largeSpacing
            leftPadding: Kirigami.Units.smallSpacing
            rightPadding: Kirigami.Units.smallSpacing
            implicitHeight: Kirigami.Units.gridUnit * 2
            Kirigami.Heading {
                level: 1
                text: i18n("KAlgebra")
                Layout.fillWidth: true
            }
        }
59

60
        drawerOpen: true
61

Carl Schwan's avatar
Carl Schwan committed
62
63
64
65
66
67
68
69
        actions: [
            Kirigami.PagePoolAction {
                icon.name: "utilities-terminal"
                text: i18n("Calculator")
                page: "qrc:/Console.qml"
                pagePool: mainPagePool
            },
            Kirigami.PagePoolAction {
70
                id: show2dPlotAction
Carl Schwan's avatar
Carl Schwan committed
71
72
73
74
75
76
                icon.name: "draw-bezier-curves"
                text: i18n("Graph 2D")
                page: "qrc:/Plot2D.qml"
                pagePool: mainPagePool
            },
            Kirigami.PagePoolAction {
77
                id: show3dPlotAction
Carl Schwan's avatar
Carl Schwan committed
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
                icon.name: "adjustrgb"
                text: i18n("Graph 3D")
                page: "qrc:/Plot3D.qml"
                pagePool: mainPagePool
            },
            Kirigami.PagePoolAction {
                icon.name: "kspread"
                text: i18n("Value Tables")
                page: "qrc:/Tables.qml"
                pagePool: mainPagePool
            },
            Kirigami.PagePoolAction {
                icon.name: "document-properties"
                text: i18n("Variables")
                page: "qrc:/VariablesView.qml"
                pagePool: mainPagePool
            },
            Kirigami.PagePoolAction {
                icon.name: "documentation"
                text: i18n("Dictionary")
                page: "qrc:/Dictionary.qml"
                pagePool: mainPagePool
            },
            Kirigami.PagePoolAction {
                icon.name: "help-about"
                text: i18n("About KAlgebra")
                page: "qrc:/About.qml"
                pagePool: mainPagePool
106
            }
Carl Schwan's avatar
Carl Schwan committed
107
        ]
108
    }
109

110
111
112
113
114
115
116
117
118
119
120
    readonly property Component customDrawer: Kirigami.OverlayDrawer {
        leftPadding: 0
        rightPadding: 0
        topPadding: 0
        bottomPadding: 0

        edge: Qt.application.layoutDirection == Qt.RightToLeft ? Qt.LeftEdge : Qt.RightEdge
        modal: !rootItem.wideScreen
        onModalChanged: drawerOpen = !modal
        drawerOpen: true
        onContentItemChanged: if (contentItem) {
121
            contentItem.visible = (mainPagePool.lastLoadedItem.drawerContent !== undefined);
122
        }
123
        width: mainPagePool.lastLoadedItem.drawerContent ? columnWidth : 0
124
125
126
127
128
129
130
131
132
133
134
135
136

        contentItem: mainPagePool.lastLoadedItem.drawerContent ?? null
        handleVisible: mainPagePool.lastLoadedItem.drawerContent !== undefined
    }

    readonly property Component normalDrawer: Kirigami.ContextDrawer {}

    Component.onCompleted: if (Kirigami.Settings.isMobile) {
        contextDrawer = normalDrawer.createObject(rootItem);
    } else {
        contextDrawer = customDrawer.createObject(rootItem);
    }

Carl Schwan's avatar
Carl Schwan committed
137
    pageStack.initialPage: mainPagePool.loadPage("qrc:/Console.qml")
138
}