Debian Codegraph @

app/ui/BottomEdgePage.qml

raw
1 /*
2 * Copyright (C) 2019 UBports
3 *
4 * This file is part of Lomiri Calculator App
5 *
6 * Lomiri Calculator App is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 3 as
8 * published by the Free Software Foundation.
9 *
10 * Lomiri Calculator App is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 import QtQuick 2.4
19 import Lomiri.Components 1.3
20 import QtQuick.Controls.Suru 2.2
21
22 Page {
23 width: bottomEdge.width
24 height: bottomEdge.height
25
26 property int pressedKey: -1
27 property string pressedKeyText: ""
28
29 header: PageHeader {
30 visible: false
31 }
32
33 Rectangle {
34 anchors.fill: parent
35 color: Suru.backgroundColor
36 }
37
38 CalcKeyboard {
39 id: calcKeyboard
40
41 anchors.fill: parent
42
43 KeyboardPage {
44 buttonRatio: 0.6
45 buttonMaxHeight: scrollableView.height / 10.0
46
47 // TODO determin if this is the best user experience
48 onClicked: bottomEdge.collapse()
49
50 keyboardModel: new Array(
51 { text: "xⁿ", name: "power", pushText: "^", kbdKeys: [Qt.Key_AsciiCircum, 16781906] }, //Number needed to make key work with the German keyboard layout as that character is normally typed by pressing the circumflex key twice but that does not work here
52 { text: "x²", name: "square", pushText: "^2", kbdKeys: [Qt.Key_twosuperior] },
53 { text: "x³", name: "cube", pushText: "^3", kbdKeys: [Qt.Key_threesuperior] },
54 // TRANSLATORS Natural logarithm symbol (logarithm to the base e)
55 { text: i18n.tr("log"), name: "logarithm", pushText: "log(", kbdKeys: [Qt.Key_L] },
56 { text: "ℯ", name: "eNumber", pushText: "E", kbdKeys: [Qt.Key_E] },
57 { text: "π", name: "piNumber", pushText: "pi", kbdKeys: [Qt.Key_P] },
58 // TRANSLATORS Modulo operation: Finds the remainder after division of one number by another
59 { text: i18n.tr("mod"), name: "modulo", pushText: "%", kbdKeys: [Qt.Key_Percent] },
60 { text: "!", name: "factorialNumber", kbdKeys: [Qt.Key_Exclam] },
61 { text: "ℯⁿ", name: "exp", pushText: "E^" },
62 { text: "1/x", name: "multiplicativeInverse", pushText: "^-1" },
63 { text: "1/x²", name: "multiplicativeInverse2", pushText: "^-2" },
64 { text: "1/x³", name: "multiplicativeInverse3", pushText: "^-3" },
65 { text: "i", name: "i", pushText: "i", kbdKeys: [Qt.Key_I] },
66 { text: "sin", name: "sinus", pushText: "sin(", kbdKeys: [Qt.Key_S] },
67 { text: "cos", name: "cos", pushText: "cos(", kbdKeys: [Qt.Key_C] },
68 { text: "tan", name: "tangens", pushText: "tan(", kbdKeys: [Qt.Key_T] },
69 { text: "|x|", name: "abs", pushText: "abs(", kbdKeys: [Qt.Key_A, Qt.Key_Bar] },
70 { text: "sin⁻¹", name: "arcsinus", pushText: "asin(" },
71 { text: "cos⁻¹", name: "arccos", pushText: "acos(" },
72 { text: "tan⁻¹", name: "arctangens", pushText: "atan(" }
73 )
74 }
75 }
76
77 Icon {
78 id: close
79 width: units.gu(3)
80 height: units.gu(1.5)
81 anchors {
82 top: parent.top
83 topMargin: units.gu(0.5)
84 horizontalCenter: parent.horizontalCenter
85 }
86
87 name: "toolkit_bottom-edge-hint"
88 rotation: 180
89
90 MouseArea {
91 anchors.fill: parent
92 height: units.gu(1)
93
94 onClicked: bottomEdge.collapse()
95 }
96 }
97
98 SwipeArea {
99 anchors.fill: parent
100 direction: SwipeArea.Downwards
101
102 onDraggingChanged: {
103 if (!dragging) {
104 bottomEdge.collapse()
105 }
106 }
107 }
108 }