[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [abakus] src/mobile/sailfish: use the harmattan qml files for sailfish
From: Mathias Kraus <k.hias () gmx ! de>
Date: 2013-12-08 16:46:39
Message-ID: E1VphV9-0007Zf-4w () scm ! kde ! org
[Download RAW message or body]
Git commit ebc5f53537671207b464c9c8e87ba6c2bbb04a10 by Mathias Kraus.
Committed on 08/12/2013 at 16:35.
Pushed by mkraus into branch 'master'.
use the harmattan qml files for sailfish
M +1 -6 src/mobile/sailfish/abakus-sailfishos.pro
M +1 -0 src/mobile/sailfish/main.cpp
A +61 -0 src/mobile/sailfish/qml/Button.qml [License: UNKNOWN] *
A +118 -0 src/mobile/sailfish/qml/Editor.qml [License: UNKNOWN] *
A +194 -0 src/mobile/sailfish/qml/KeyPad.qml [License: UNKNOWN] *
A +175 -0 src/mobile/sailfish/qml/KeyPadFunctionsAndNumerals.qml [License: \
UNKNOWN] * A +175 -0 src/mobile/sailfish/qml/KeyPadGeneric.qml [License: \
UNKNOWN] * A +175 -0 src/mobile/sailfish/qml/KeyPadLogic.qml [License: \
UNKNOWN] * A +118 -0 src/mobile/sailfish/qml/MainPage.qml [License: \
UNKNOWN] * A +85 -0 src/mobile/sailfish/qml/ResultViewItem.qml [License: \
UNKNOWN] * D +0 -15 src/mobile/sailfish/qml/cover/CoverPage.qml
M +9 -4 src/mobile/sailfish/qml/main.qml
D +0 -177 src/mobile/sailfish/qml/pages/KeyPad.qml
D +0 -143 src/mobile/sailfish/qml/pages/MainPage.qml
D +0 -84 src/mobile/sailfish/qml/pages/ResultViewItem.qml
D +0 -29 src/mobile/sailfish/qml/pages/SettingsPage.qml
The files marked with a * at the end have a non valid license. Please read: \
http://techbase.kde.org/Policies/Licensing_Policy and use the headers which are \
listed at that page.
http://commits.kde.org/abakus/ebc5f53537671207b464c9c8e87ba6c2bbb04a10
diff --git a/src/mobile/sailfish/abakus-sailfishos.pro \
b/src/mobile/sailfish/abakus-sailfishos.pro index 11d799f..9feace6 100644
--- a/src/mobile/sailfish/abakus-sailfishos.pro
+++ b/src/mobile/sailfish/abakus-sailfishos.pro
@@ -50,12 +50,7 @@ HEADERS += \
../../common/functionmodel.h \
../../common/function.h
-OTHER_FILES += qml/abakus.qml \
- qml/cover/CoverPage.qml \
- qml/pages/MainPage.qml \
- qml/pages/KeyPad.qml \
- qml/pages/ResultViewItem.qml \
- qml/pages/SettingsPage.qml \
+OTHER_FILES += qml/* \
rpm/abakus.spec \
rpm/abakus.yaml \
abakus.desktop
diff --git a/src/mobile/sailfish/main.cpp b/src/mobile/sailfish/main.cpp
index d1b1b7f..2fc9017 100644
--- a/src/mobile/sailfish/main.cpp
+++ b/src/mobile/sailfish/main.cpp
@@ -38,6 +38,7 @@ int main(int argc, char **argv)
QScopedPointer<QQuickView> view(SailfishApp::createView());
mainObject->setView(view.data());
+ view->setResizeMode(QQuickView::SizeRootObjectToView);
view->setSource(SailfishApp::pathTo("qml/main.qml"));
view->show();
diff --git a/src/mobile/sailfish/qml/Button.qml b/src/mobile/sailfish/qml/Button.qml
new file mode 100644
index 0000000..ea7257a
--- /dev/null
+++ b/src/mobile/sailfish/qml/Button.qml
@@ -0,0 +1,61 @@
+import QtQuick 2.0
+
+Rectangle {
+ id: root
+ color: mouseArea.pressed ? buttonColorHighlight : buttonColor
+ radius: height / 4
+ enabled: text.length != 0
+
+ property alias text: label.text
+
+ property int fontPointSize: 24
+ property string buttonColor: "black"
+ property string buttonColorHighlight: "orange"
+ property string textColor: "white"
+ property string textColorHighlight: "black"
+
+ signal pressed()
+ signal pressAndHold()
+
+ Text {
+ id: label
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.verticalCenter: parent.verticalCenter
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ color: mouseArea.pressed ? root.textColorHighlight : root.textColor
+ font.bold: true
+ font.pixelSize: root.height / 1.8
+ }
+
+ Rectangle {
+ visible: mouseArea.pressed
+ width: label.width * 2 + 20
+ height: label.height * 2 + 20
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.bottom: parent.top
+ anchors.bottomMargin: 15
+ radius: parent.radius
+ color: parent.color
+ border.color: buttonColor
+ border.width: 2
+
+ Text {
+ anchors.fill: parent
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ color: label.color
+ font.bold: label.font.bold
+ font.pixelSize: label.font.pixelSize * 2
+ text: label.text
+ }
+ }
+
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+
+ onClicked: root.pressed()
+ onPressAndHold: root.pressAndHold()
+ }
+}
diff --git a/src/mobile/sailfish/qml/Editor.qml b/src/mobile/sailfish/qml/Editor.qml
new file mode 100644
index 0000000..a2ff6ff
--- /dev/null
+++ b/src/mobile/sailfish/qml/Editor.qml
@@ -0,0 +1,118 @@
+import QtQuick 2.0
+
+Rectangle {
+ id: root
+ color: "black"
+ border.color: "dimgray"
+ border.width: 2
+ height: editorHeight.height + 16
+
+ property int fontPointSize: 24
+ property string fontColorEditor: "orange"
+ property string fontColorEditorSelection: "black"
+ property string colorEditorSelection: "orange"
+
+ signal textChanged(string text)
+ signal historyPrevious()
+ signal historyNext()
+
+ function selectAll() {editor.selectAll()}
+
+ function text() {return editor.text}
+
+ function setText(text) {editor.text = text}
+
+ function addText(text) {
+ var selectionStart = editor.selectionStart
+ var selectionEnd = editor.selectionEnd
+ var editorTextLength = editor.text.length
+ var finalCursorPosition = selectionStart + text.length
+ editor.text = editor.text.substring(0, selectionStart) + text + \
editor.text.substring(selectionEnd, editorTextLength) + //this is needed, \
because a text change can trigger the setEditorText signal from mainWindow, which \
replace the text + if(selectionStart + text.length + editorTextLength - \
selectionEnd === editor.text.length) + {
+ editor.cursorPosition = finalCursorPosition
+ }
+ }
+
+ function removeText() {
+ var selectionStart = editor.selectionStart
+ var selectionEnd = editor.selectionEnd
+ var editorTextLength = editor.text.length
+ var finalCursorPosition = selectionStart == selectionEnd ? selectionStart - \
1 : selectionStart + editor.text = editor.text.substring(0, \
finalCursorPosition) + editor.text.substring(selectionEnd, editorTextLength) + \
editor.cursorPosition = finalCursorPosition + }
+
+ Rectangle {
+ width: parent.width
+ height: parent.height
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.top: parent.top
+ anchors.topMargin: -parent.border.width/2
+ color: parent.color
+ }
+
+ //this is needed, because in the current SDK, the edior resizes a few pixels, \
when entering a text + TextInput {
+ id: editorHeight
+ font.pointSize: root.fontPointSize
+ text: "42"
+ }
+
+ TextInput {
+ id: editor
+ anchors.left: parent.left
+ anchors.leftMargin: 10
+ anchors.right: clearButton.left
+ anchors.rightMargin: 10
+ anchors.verticalCenter: parent.verticalCenter
+ focus: true
+ activeFocusOnPress: false
+ selectByMouse: true
+ clip:false
+ font.pointSize: root.fontPointSize
+ color: root.fontColorEditor
+ selectedTextColor: fontColorEditorSelection
+ selectionColor: colorEditorSelection
+
+ onTextChanged: root.textChanged(text)
+
+ Keys.onUpPressed: root.historyPrevious()
+ Keys.onDownPressed: root.historyNext()
+
+ Text {
+ id: placeholderText
+ anchors.fill: parent
+ font.pointSize: root.fontPointSize
+ color: "dimgray"
+ visible: editor.text.length == 0
+ text: "Enter expression"
+ }
+ }
+
+ Text {
+ id: clearButtonText
+ visible: false
+ font.pointSize: root.fontPointSize
+ text: "<X"//"⌫"
+ }
+
+ Button {
+ id: clearButton
+ width: clearButtonText.width
+ height: clearButtonText.height
+ anchors.right: parent.right
+ anchors.rightMargin: 20
+ anchors.verticalCenter: parent.verticalCenter
+ textColor: "dimgray"
+ textColorHighlight: "white"
+ buttonColorHighlight: buttonColor
+ fontPointSize: root.fontPointSize
+ text: clearButtonText.text//"⌫"
+ visible: editor.text.length != 0
+
+ onPressed: removeText()
+ onPressAndHold: editor.text = ""
+ }
+}
diff --git a/src/mobile/sailfish/qml/KeyPad.qml b/src/mobile/sailfish/qml/KeyPad.qml
new file mode 100644
index 0000000..5f46b4f
--- /dev/null
+++ b/src/mobile/sailfish/qml/KeyPad.qml
@@ -0,0 +1,194 @@
+import QtQuick 2.0
+
+Rectangle {
+ id: root
+ height: flickable.height + 20
+ color: "black"
+
+ signal pressed(string value)
+ signal evaluate()
+
+ Component.onCompleted: {
+ genericPad.pressed.connect(pressed)
+ genericPad.evaluate.connect(evaluate)
+ logicPad.pressed.connect(pressed)
+ logicPad.evaluate.connect(evaluate)
+ trigPad.pressed.connect(pressed)
+ trigPad.evaluate.connect(evaluate)
+
+ delayedLoadingTimer.running = true
+ }
+
+ Timer {
+ id: delayedLoadingTimer
+ interval: 200
+ running: false
+ repeat: false
+ onTriggered: {
+ flickable.contentX = root.width
+ internal.animationDuration = 250
+ }
+ }
+
+ QtObject {
+ id: internal
+
+ property int spacing: 0
+ property int buttonWidth: width / 5 - spacing
+ property int buttonHeight: width / 8
+
+ property int selectedKeyPad: 2
+ property int keyPadSwipeTreshold: width / 4
+ property int animationDuration: 0
+ }
+
+ Flickable {
+ id: flickable
+ anchors.top: parent.top
+ anchors.horizontalCenter: parent.horizontalCenter
+ width: parent.width
+ height: container.height
+ contentWidth: container.width
+ contentHeight: container.height
+ flickableDirection: Flickable.HorizontalFlick
+ pressDelay: 50
+
+ Behavior on contentX { NumberAnimation { duration: \
internal.animationDuration; easing.type: Easing.OutQuad } } + Behavior on \
height { NumberAnimation { duration: internal.animationDuration; easing.type: \
Easing.OutQuad } } +
+ onFlickStarted: {
+ // this will stop flicking and an onMovementEnded event will be \
generated + contentX = contentX
+ }
+
+ onMovementEnded: {
+ switch(internal.selectedKeyPad) {
+ case 1:
+ if(contentX > internal.keyPadSwipeTreshold)
+ {
+ internal.selectedKeyPad = 2
+ contentX = root.width
+ contentHeight = genericPad.height
+ container.height = genericPad.height
+ }
+ else
+ {
+ internal.selectedKeyPad = 1
+ contentX = 0
+ }
+ break
+ case 2:
+ if(contentX < root.width - internal.keyPadSwipeTreshold)
+ {
+ internal.selectedKeyPad = 1
+ contentX = 0
+ contentHeight = logicPad.height
+ container.height = logicPad.height
+ }
+ else if(contentX > root.width + 50)
+ {
+ internal.selectedKeyPad = 3
+ contentX = 2 * root.width
+ contentHeight = trigPad.height
+ container.height = trigPad.height
+ }
+ else
+ {
+ internal.selectedKeyPad = 2
+ contentX = root.width
+ }
+ break
+ case 3:
+ if(contentX < 2 * root.width - internal.keyPadSwipeTreshold)
+ {
+ internal.selectedKeyPad = 2
+ contentX = root.width
+ contentHeight = genericPad.height
+ container.height = genericPad.height
+ }
+ else
+ {
+ internal.selectedKeyPad = 3
+ contentX = 2 * root.width
+ }
+ break
+ }
+ }
+
+ Item {
+ id: container
+ width: logicPad.width + genericPad.width +trigPad.width
+ height: genericPad.height
+ anchors.top: parent.top
+ anchors.horizontalCenter: parent.horizontalCenter
+
+ KeyPadLogic {
+ id: logicPad
+ anchors.top: parent.top
+ anchors.right: genericPad.left
+
+ spacing: internal.spacing
+ buttonWidth: internal.buttonWidth
+ buttonHeight: internal.buttonHeight
+ }
+ KeyPadGeneric {
+ id: genericPad
+ anchors.top: parent.top
+ anchors.horizontalCenter: parent.horizontalCenter
+
+ spacing: internal.spacing
+ buttonWidth: internal.buttonWidth
+ buttonHeight: internal.buttonHeight
+ }
+ KeyPadFunctionsAndNumerals {
+ id: trigPad
+ anchors.top: parent.top
+ anchors.left: genericPad.right
+
+ spacing: internal.spacing
+ buttonWidth: internal.buttonWidth
+ buttonHeight: internal.buttonHeight
+ }
+ }
+ }
+
+ Item {
+ id: activePadIndicator
+ height: 20
+ anchors.bottom: parent.bottom
+ anchors.horizontalCenter: parent.horizontalCenter
+
+ Row {
+ anchors.centerIn: parent
+ spacing: 10
+
+ Rectangle {
+ width: 16
+ height: width
+ radius: width / 2
+ antialiasing: true
+ color: "orange"
+ border.width: 3
+ border.color: internal.selectedKeyPad === 1 ? "orange" : "black"
+ }
+ Rectangle {
+ width: 16
+ height: width
+ radius: width / 2
+ antialiasing: true
+ color: "orange"
+ border.width: 3
+ border.color: internal.selectedKeyPad === 2 ? "orange" : "black"
+ }
+ Rectangle {
+ width: 16
+ height: width
+ radius: width / 2
+ antialiasing: true
+ color: "orange"
+ border.width: 3
+ border.color: internal.selectedKeyPad === 3 ? "orange" : "black"
+ }
+ }
+ }
+}
diff --git a/src/mobile/sailfish/qml/KeyPadFunctionsAndNumerals.qml \
b/src/mobile/sailfish/qml/KeyPadFunctionsAndNumerals.qml new file mode 100644
index 0000000..cdae53e
--- /dev/null
+++ b/src/mobile/sailfish/qml/KeyPadFunctionsAndNumerals.qml
@@ -0,0 +1,175 @@
+import QtQuick 2.0
+
+Grid {
+ id: root
+
+ property int buttonWidth: 40
+ property int buttonHeight: 20
+
+ signal pressed(string value)
+ signal evaluate()
+
+ columns: 5
+ spacing: 0
+
+ // first row
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: "ans"
+ onPressed: root.pressed(text)
+ }
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: "e"
+ onPressed: root.pressed(text)
+ }
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: ""
+ onPressed: root.pressed(text)
+ }
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: ""
+ onPressed: root.pressed(text)
+ }
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: ""
+ onPressed: root.pressed(text)
+ }
+
+ // second row
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: "sin"
+ onPressed: root.pressed("sin(")
+ }
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: "cos"
+ onPressed: root.pressed("cos(")
+ }
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: "tan"
+ onPressed: root.pressed("tan(")
+ }
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: ""
+ onPressed: root.pressed(text)
+ }
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: ""
+ onPressed: root.pressed(text)
+ }
+
+ // third row
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: "abs"
+ onPressed: root.pressed("abs(")
+ }
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: ""
+ onPressed: root.pressed(text)
+ }
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: "ln"
+ onPressed: root.pressed("ln(")
+ }
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: "log"
+ onPressed: root.pressed("log(")
+ }
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: "eˣ"
+ onPressed: root.pressed("exp(")
+ }
+
+ // fourth row
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: "round"
+ onPressed: root.pressed("round(")
+ }
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: "ceil"
+ onPressed: root.pressed("ceil(")
+ }
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: "floor"
+ onPressed: root.pressed("floor(")
+ }
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: "int"
+ onPressed: root.pressed("int(")
+ }
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: "frac"
+ onPressed: root.pressed("frac(")
+ }
+
+ // fifth row
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: "hex"
+ onPressed: root.pressed("hex(")
+ }
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: "bin"
+ onPressed: root.pressed("bin(")
+ }
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: "dec"
+ onPressed: root.pressed("dec(")
+ }
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: "oct"
+ onPressed: root.pressed("oct(")
+ }
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: ""
+ textColor: "orange"
+ onPressed: root.evaluate()
+ }
+}
diff --git a/src/mobile/sailfish/qml/KeyPadGeneric.qml \
b/src/mobile/sailfish/qml/KeyPadGeneric.qml new file mode 100644
index 0000000..7df34d1
--- /dev/null
+++ b/src/mobile/sailfish/qml/KeyPadGeneric.qml
@@ -0,0 +1,175 @@
+import QtQuick 2.0
+
+Grid {
+ id: root
+
+ property int buttonWidth: 40
+ property int buttonHeight: 20
+
+ signal pressed(string value)
+ signal evaluate()
+
+ columns: 5
+ spacing: 0
+
+ // first row
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: "sin"
+ onPressed: root.pressed("sin(")
+ }
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: "cos"
+ onPressed: root.pressed("cos(")
+ }
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: "Ï€"
+ onPressed: root.pressed("pi")
+ }
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: "("
+ onPressed: root.pressed(text)
+ }
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: ")"
+ onPressed: root.pressed(text)
+ }
+
+ // second row
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: "7"
+ onPressed: root.pressed(text)
+ }
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: "8"
+ onPressed: root.pressed(text)
+ }
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: "9"
+ onPressed: root.pressed(text)
+ }
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: "x ²"
+ onPressed: root.pressed("^2")
+ }
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: "√"
+ onPressed: root.pressed("sqrt(")
+ }
+
+ // third row
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: "4"
+ onPressed: root.pressed(text)
+ }
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: "5"
+ onPressed: root.pressed(text)
+ }
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: "6"
+ onPressed: root.pressed(text)
+ }
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: "×"
+ onPressed: root.pressed("*")
+ }
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: "÷"
+ onPressed: root.pressed("/")
+ }
+
+ // fourth row
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: "1"
+ onPressed: root.pressed(text)
+ }
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: "2"
+ onPressed: root.pressed(text)
+ }
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: "3"
+ onPressed: root.pressed(text)
+ }
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: "+"
+ onPressed: root.pressed(text)
+ }
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: "-"
+ onPressed: root.pressed(text)
+ }
+
+ // fifth row
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: "0"
+ onPressed: root.pressed(text)
+ }
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: "."
+ onPressed: root.pressed(text)
+ }
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: "10Ë£"
+ onPressed: root.pressed("*10^")
+ }
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: "ans"
+ onPressed: root.pressed(text)
+ }
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: "="
+ textColor: "orange"
+ onPressed: root.evaluate()
+ }
+}
diff --git a/src/mobile/sailfish/qml/KeyPadLogic.qml \
b/src/mobile/sailfish/qml/KeyPadLogic.qml new file mode 100644
index 0000000..851b38f
--- /dev/null
+++ b/src/mobile/sailfish/qml/KeyPadLogic.qml
@@ -0,0 +1,175 @@
+import QtQuick 2.0
+
+Grid {
+ id: root
+
+ property int buttonWidth: 40
+ property int buttonHeight: 20
+
+ signal pressed(string value)
+ signal evaluate()
+
+ columns: 5
+ spacing: 0
+
+ // first row
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: "<<"
+ onPressed: root.pressed(text)
+ }
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: ">>"
+ onPressed: root.pressed(text)
+ }
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: "hex"
+ onPressed: root.pressed("hex(")
+ }
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: "bin"
+ onPressed: root.pressed("bin(")
+ }
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: "oct"
+ onPressed: root.pressed("oct(")
+ }
+
+ // second row
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: "7"
+ onPressed: root.pressed(text)
+ }
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: "8"
+ onPressed: root.pressed(text)
+ }
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: "9"
+ onPressed: root.pressed(text)
+ }
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: "E"
+ onPressed: root.pressed(text)
+ }
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: "F"
+ onPressed: root.pressed(text)
+ }
+
+ // third row
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: "4"
+ onPressed: root.pressed(text)
+ }
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: "5"
+ onPressed: root.pressed(text)
+ }
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: "6"
+ onPressed: root.pressed(text)
+ }
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: "C"
+ onPressed: root.pressed(text)
+ }
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: "D"
+ onPressed: root.pressed(text)
+ }
+
+ // fourth row
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: "1"
+ onPressed: root.pressed(text)
+ }
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: "2"
+ onPressed: root.pressed(text)
+ }
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: "3"
+ onPressed: root.pressed(text)
+ }
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: "A"
+ onPressed: root.pressed(text)
+ }
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: "B"
+ onPressed: root.pressed(text)
+ }
+
+ // fifth row
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: "0"
+ onPressed: root.pressed(text)
+ }
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: "0x"
+ onPressed: root.pressed(text)
+ }
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: "0b"
+ onPressed: root.pressed(text)
+ }
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: "0o"
+ onPressed: root.pressed(text)
+ }
+ Button {
+ width: root.buttonWidth
+ height: root.buttonHeight
+ text: "="
+ textColor: "orange"
+ onPressed: root.evaluate()
+ }
+}
diff --git a/src/mobile/sailfish/qml/MainPage.qml \
b/src/mobile/sailfish/qml/MainPage.qml new file mode 100644
index 0000000..e733b42
--- /dev/null
+++ b/src/mobile/sailfish/qml/MainPage.qml
@@ -0,0 +1,118 @@
+import QtQuick 2.0
+//import abakus 1.0 as Abakus
+
+Rectangle {
+ id: root
+ color: "black"
+
+ QtObject {
+ id: internal
+
+ property int fontPointSize: 24
+ property string fontColorEditor: "orange"
+ property string fontColorExpression: "gray"
+ property string fontColorResult: "dodgerblue"
+ property string fontColorTag: "gray"
+ }
+
+ ListView {
+ id: history
+ anchors.left: parent.left
+ anchors.leftMargin: 10
+ anchors.right: parent.right
+ anchors.top: parent.top
+ anchors.bottom: editor.top
+
+ currentIndex: count -1
+ clip: true
+
+ property int minTagSize: 0
+
+ model: resultModel
+ delegate: ResultViewItem {
+ currentHistoryIndex: history.currentIndex
+ currentMinTagSize: history.minTagSize + 10
+
+ fontPointSize: internal.fontPointSize
+ fontColorExpression: internal.fontColorExpression
+ fontColorResult: internal.fontColorResult
+ fontColorTag: internal.fontColorTag
+
+ onExpressionSelected: editor.addText(expression)
+ onResultSelected: editor.addText(result)
+ onTagSelected: editor.addText(tag)
+
+ Component.onCompleted: {
+ mainWindow.addVisibleHistoryItemIndex(model.index)
+ history.updateTagWidth()
+ }
+
+ Component.onDestruction: {
+ mainWindow.removeVisibleHistoryItemIndex(model.index)
+ history.updateTagWidth()
+ }
+ }
+
+ Text {
+ id: tagItemDummy
+ font.italic: true
+ visible: false
+ font.pointSize: internal.fontPointSize
+ }
+
+ function updateTagWidth() {
+ var i = 0
+ var itemIndexNext = mainWindow.getVisibleHistoryItemIndex(i)
+ var minTagSize = 0
+
+ while(itemIndexNext > -1)
+ {
+ tagItemDummy.text = mainWindow.getTag(itemIndexNext)
+ if(minTagSize < tagItemDummy.width)
+ {
+ minTagSize = tagItemDummy.width
+ }
+ ++i
+ itemIndexNext = mainWindow.getVisibleHistoryItemIndex(i)
+ }
+
+ tagItemDummy.text = ""
+ history.minTagSize = minTagSize
+ }
+
+ Component.onCompleted: history.positionViewAtEnd()
+ }
+
+ Editor {
+ id: editor
+ width: parent.width
+ anchors.bottom: keypad.top
+ anchors.bottomMargin: border.width
+ fontPointSize: internal.fontPointSize
+ fontColorEditor: internal.fontColorEditor
+
+ onTextChanged: mainWindow.slotTextChanged(text)
+
+ onHistoryPrevious: mainWindow.historyPrevious()
+ onHistoryNext: mainWindow.historyNext()
+
+ Connections {
+ target: mainWindow
+
+ onSetEditorText: editor.setText(editorText)
+ }
+ }
+
+ KeyPad {
+ id: keypad
+ width: parent.width
+ anchors.bottom: parent.bottom
+
+ onPressed: editor.addText(value)
+
+ onEvaluate: {
+ mainWindow.slotEvaluate(editor.text())
+ editor.selectAll()
+ }
+ }
+}
diff --git a/src/mobile/sailfish/qml/ResultViewItem.qml \
b/src/mobile/sailfish/qml/ResultViewItem.qml new file mode 100644
index 0000000..cfeaea6
--- /dev/null
+++ b/src/mobile/sailfish/qml/ResultViewItem.qml
@@ -0,0 +1,85 @@
+import QtQuick 2.0
+
+Rectangle {
+ id: root
+ width: parent.width
+ height: expression.width + result.width + tag.width > parent.width ? 2 * \
rowHeight : rowHeight + color: model.index === currentHistoryIndex ? \
internal.highlightColor : internal.rowBackground +
+ property int currentHistoryIndex: 0
+ property int currentMinTagSize: 0
+
+ property int rowHeight: 40
+
+ property int fontPointSize: 24
+ property string fontColorExpression: "lightgray"
+ property string fontColorResult: "dodgerblue"
+ property string fontColorTag: "lightgray"
+
+ signal expressionSelected(string expression)
+ signal resultSelected(string result)
+ signal tagSelected(string tag)
+
+ QtObject {
+ id: internal
+
+ property string rowBackground: "transparent"
+ property string highlightColor: "transparent"
+ }
+
+ Text {
+ id: expression
+ height: root.rowHeight
+ anchors.left: parent.left
+ anchors.top: parent.top
+ horizontalAlignment: Text.AlignLeft
+ verticalAlignment: Text.AlignVCenter
+ color: fontColorExpression
+ text: model.expression
+ font.pointSize: root.fontPointSize
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: root.expressionSelected(model.expression)
+ onDoubleClicked: console.log("TODO")
+ }
+ }
+
+ Text {
+ id: result
+ height: root.rowHeight
+ anchors.right: tag.left
+ anchors.bottom: parent.bottom
+ horizontalAlignment: Text.AlignRight
+ verticalAlignment: Text.AlignVCenter
+ color: fontColorResult
+ text: model.result
+ font.pointSize: root.fontPointSize
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: root.resultSelected(model.result)
+ onDoubleClicked: console.log("TODO")
+ }
+ }
+
+ Text {
+ id: tag
+ width: model.tag === "" ? 0 : currentMinTagSize
+ height: root.rowHeight
+ anchors.right: parent.right
+ anchors.bottom: parent.bottom
+ horizontalAlignment: Text.AlignLeft
+ verticalAlignment: Text.AlignVCenter
+ font.italic: true
+ color: fontColorTag
+ text: model.tag
+ font.pointSize: root.fontPointSize
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: root.tagSelected(model.tag)
+ onDoubleClicked: {}//do nothing
+ }
+ }
+}
diff --git a/src/mobile/sailfish/qml/cover/CoverPage.qml \
b/src/mobile/sailfish/qml/cover/CoverPage.qml deleted file mode 100644
index 2a54cb9..0000000
--- a/src/mobile/sailfish/qml/cover/CoverPage.qml
+++ /dev/null
@@ -1,15 +0,0 @@
-import QtQuick 2.0
-import Sailfish.Silica 1.0
-
-Rectangle {
- anchors.fill: parent
- color: "black"
-
- Label {
- id: label
- anchors.centerIn: parent
- text: "My Cover"
- }
-}
-
-
diff --git a/src/mobile/sailfish/qml/main.qml b/src/mobile/sailfish/qml/main.qml
index 6492b2c..af70a9c 100644
--- a/src/mobile/sailfish/qml/main.qml
+++ b/src/mobile/sailfish/qml/main.qml
@@ -1,8 +1,13 @@
import QtQuick 2.0
-import Sailfish.Silica 1.0
-import "pages"
-ApplicationWindow
+Item
{
- initialPage: MainPage { }
+ id: appWindow
+
+ MainPage {
+ id: mainPage
+ width: parent.width
+ height: parent.height
+ anchors.centerIn: parent
+ }
}
diff --git a/src/mobile/sailfish/qml/pages/KeyPad.qml \
b/src/mobile/sailfish/qml/pages/KeyPad.qml deleted file mode 100644
index cc4f207..0000000
--- a/src/mobile/sailfish/qml/pages/KeyPad.qml
+++ /dev/null
@@ -1,177 +0,0 @@
-import QtQuick 2.0
-import Sailfish.Silica 1.0
-
-Column {
- id: root
- spacing: 4
-
- property int buttonHeight: width / 8
-
- signal pressed(string value)
- signal evaluate()
-
- Row {
- Button {
- width: root.width / 5
- height: root.buttonHeight
- text: "sin"
- onClicked: root.pressed("sin(")
- }
- Button {
- width: root.width / 5
- height: root.buttonHeight
- text: "cos"
- onClicked: root.pressed("cos(")
- }
- Button {
- width: root.width / 5
- height: root.buttonHeight
- text: "Ï€"
- onClicked: root.pressed("pi")
- }
- Button {
- width: root.width / 5
- height: root.buttonHeight
- text: "("
- onClicked: root.pressed(text)
- }
- Button {
- width: root.width / 5
- height: root.buttonHeight
- text: ")"
- onClicked: root.pressed(text)
- }
- }
-
- Row {
- Button {
- width: root.width / 5
- height: root.buttonHeight
- text: "7"
- onClicked: root.pressed(text)
- }
- Button {
- width: root.width / 5
- height: root.buttonHeight
- text: "8"
- onClicked: root.pressed(text)
- }
- Button {
- width: root.width / 5
- height: root.buttonHeight
- text: "9"
- onClicked: root.pressed(text)
- }
- Button {
- width: root.width / 5
- height: root.buttonHeight
- text: "x ²"
- onClicked: root.pressed("^2")
- }
- Button {
- width: root.width / 5
- height: root.buttonHeight
- text: "√"
- onClicked: root.pressed("sqrt(")
- }
- }
-
- Row {
- Button {
- width: root.width / 5
- height: root.buttonHeight
- text: "4"
- onClicked: root.pressed(text)
- }
- Button {
- width: root.width / 5
- height: root.buttonHeight
- text: "5"
- onClicked: root.pressed(text)
- }
- Button {
- width: root.width / 5
- height: root.buttonHeight
- text: "6"
- onClicked: root.pressed(text)
- }
- Button {
- width: root.width / 5
- height: root.buttonHeight
- text: "×"
- onClicked: root.pressed("*")
- }
- Button {
- width: root.width / 5
- height: root.buttonHeight
- text: "÷"
- onClicked: root.pressed("/")
- }
- }
-
- Row {
- Button {
- width: root.width / 5
- height: root.buttonHeight
- text: "1"
- onClicked: root.pressed(text)
- }
- Button {
- width: root.width / 5
- height: root.buttonHeight
- text: "2"
- onClicked: root.pressed(text)
- }
- Button {
- width: root.width / 5
- height: root.buttonHeight
- text: "3"
- onClicked: root.pressed(text)
- }
- Button {
- width: root.width / 5
- height: root.buttonHeight
- text: "+"
- onClicked: root.pressed(text)
- }
- Button {
- width: root.width / 5
- height: root.buttonHeight
- text: "-"
- onClicked: root.pressed(text)
- }
- }
-
- Row {
- Button {
- width: root.width / 5
- height: root.buttonHeight
- text: "0"
- onClicked: root.pressed(text)
- }
- Button {
- width: root.width / 5
- height: root.buttonHeight
- text: "."
- onClicked: root.pressed(text)
- }
- Button {
- width: root.width / 5
- height: root.buttonHeight
- text: "10^x"
- onClicked: root.pressed("*10^")
- }
- Button {
- width: root.width / 5
- height: root.buttonHeight
- text: "ans"
- onClicked: root.pressed(text)
- }
- Button {
- width: root.width / 5
- height: root.buttonHeight
- text: "="
- onClicked: root.evaluate()
- }
- }
-}
diff --git a/src/mobile/sailfish/qml/pages/MainPage.qml \
b/src/mobile/sailfish/qml/pages/MainPage.qml deleted file mode 100644
index afa0a1c..0000000
--- a/src/mobile/sailfish/qml/pages/MainPage.qml
+++ /dev/null
@@ -1,143 +0,0 @@
-import QtQuick 2.0
-import Sailfish.Silica 1.0
-import abakus 1.0 as Abakus
-
-Page {
- id: page
-
- SilicaFlickable {
- anchors.fill: parent
-
- // PullDownMenu and PushUpMenu must be declared in SilicaFlickable, \
SilicaListView or SilicaGridView
- PushUpMenu {
- MenuItem {
- text: "Settings"
- onClicked: pageStack.push(Qt.resolvedUrl("SettingsPage.qml"))
- }
- }
-
- // Tell SilicaFlickable the height of its content.
- contentHeight: childrenRect.height
-
- Column {
- width: parent.width
- anchors.top: parent.top
-
- SilicaListView {
- id: history
- width: parent.width
- height: page.height - (editorRow.height + keypad.height + 10)
-
- VerticalScrollDecorator { flickable: history }
-
- currentIndex: count -1
- clip: true
-
- property int minTagSize: 0
-
- model: resultModel
- delegate: ResultViewItem {
- currentHistoryIndex: history.currentIndex
- currentMinTagSize: history.minTagSize
-
- onExpressionSelected: editor.text = expression
- onResultSelected: editor.text += result
- onTagSelected: editor.text += tag
-
- Component.onCompleted: {
- mainWindow.addVisibleHistoryItemIndex(model.index)
- history.updateTagWidth()
- }
-
- Component.onDestruction: {
- mainWindow.removeVisibleHistoryItemIndex(model.index)
- history.updateTagWidth()
- }
- }
-
- Label {
- id: tagItemDummy
- font.italic: true
- visible: false
- }
-
- function updateTagWidth() {
- var i = 0
- var itemIndexNext = mainWindow.getVisibleHistoryItemIndex(i)
- var minTagSize = 0
-
- while(itemIndexNext > -1)
- {
- tagItemDummy.text = mainWindow.getTag(itemIndexNext)
- if(minTagSize < tagItemDummy.width)
- {
- minTagSize = tagItemDummy.width
- }
- ++i
- itemIndexNext = mainWindow.getVisibleHistoryItemIndex(i)
- }
-
- tagItemDummy.text = ""
- history.minTagSize = minTagSize
- }
-
- Component.onCompleted: history.positionViewAtEnd()
- }
-
- Row {
- id: editorRow
- width: page.width
-
- TextField {
- id: editor
- width: page.width - clearButton.width
- focus: true
- placeholderText: "Enter expression"
- enableSoftwareInputPanel: false
- textMargin: 5
- clip:false
- z: 0
-
- Keys.onPressed: {
- if(event.key == Qt.Key_Return || event.key == Qt.Key_Enter) \
{
- mainWindow.slotEvaluate(editor.text)
- editor.selectAll()
- }
- }
-
- onTextChanged: mainWindow.slotTextChanged(text)
-
- Keys.onUpPressed: mainWindow.historyPrevious()
- Keys.onDownPressed: mainWindow.historyNext()
-
- Connections {
- target: mainWindow
-
- onSetEditorText: editor.text = editorText
- }
- }
-
- IconButton{
- id: clearButton
- icon.source: "image://theme/icon-l-backspace"
- onClicked: editor.text = ""
- onPressAndHold: editor.text = ""
- }
- }
-
- KeyPad {
- id: keypad
- width: parent.width
-
- onPressed: editor.text = editor.text + value
-
- onEvaluate: {
- mainWindow.slotEvaluate(editor.text)
- editor.selectAll()
- }
- }
- }
- }
-}
-
-
diff --git a/src/mobile/sailfish/qml/pages/ResultViewItem.qml \
b/src/mobile/sailfish/qml/pages/ResultViewItem.qml deleted file mode 100644
index bf89fd3..0000000
--- a/src/mobile/sailfish/qml/pages/ResultViewItem.qml
+++ /dev/null
@@ -1,84 +0,0 @@
-import QtQuick 2.0
-import Sailfish.Silica 1.0
-
-Row {
- id: root
- width: parent.width
- height: 40//theme.standardItemHeight
-
- property string rowBackground: "transparent"//model.index % 2 == 0 ? "white" : \
"whitesmoke"
- property string highlightColor: "lightblue"
-
- property int currentHistoryIndex: 0
- property int currentMinTagSize: 0
-
- signal expressionSelected(string expression)
- signal resultSelected(string result)
- signal tagSelected(string tag)
-
- Rectangle {
- id: expressionItem
- width: parent.width - resultItem.width - tagItem.width
- height: parent.height
- color: model.index == currentHistoryIndex ? highlightColor : rowBackground
-
- Label {
- height: parent.height
- horizontalAlignment: Text.AlignLeft
- verticalAlignment: Text.AlignVCenter
- color: "darkgrey"
- clip: true
- text: model.expression
-
- MouseArea {
- anchors.fill: parent
- onClicked: root.expressionSelected(model.expression)
- onDoubleClicked: console.log("TODO")
- }
- }
- }
-
- Rectangle {
- id: resultItem
- width: resultItemText.width
- height: parent.height
- color: model.index == currentHistoryIndex ? highlightColor : rowBackground
-
- Label {
- id: resultItemText
- height: parent.height
- horizontalAlignment: Text.AlignRight
- verticalAlignment: Text.AlignVCenter
- clip: true
- text: model.result
-
- MouseArea {
- anchors.fill: parent
- onClicked: root.resultSelected(model.result)
- onDoubleClicked: console.log("TODO")
- }
- }
- }
-
- Rectangle {
- id: tagItem
- width: model.tag == "" ? 0 : currentMinTagSize
- height: parent.height
- color: model.index == currentHistoryIndex ? highlightColor : rowBackground
-
- Label {
- height: parent.height
- horizontalAlignment: Text.AlignLeft
- verticalAlignment: Text.AlignVCenter
- font.italic: true
- color: "darkgrey"
- text: model.tag
-
- MouseArea {
- anchors.fill: parent
- onClicked: root.tagSelected(model.tag)
- onDoubleClicked: {}//do nothing
- }
- }
- }
-}
diff --git a/src/mobile/sailfish/qml/pages/SettingsPage.qml \
b/src/mobile/sailfish/qml/pages/SettingsPage.qml deleted file mode 100644
index 210014a..0000000
--- a/src/mobile/sailfish/qml/pages/SettingsPage.qml
+++ /dev/null
@@ -1,29 +0,0 @@
-import QtQuick 2.0
-import Sailfish.Silica 1.0
-
-Page {
- id: page
- SilicaFlickable {
- id: listView
- anchors.fill: parent
-
- Column {
- width: page.width
- spacing: theme.paddingLarge
- PageHeader {
- title: "Settings"
- }
- Label {
- x: theme.paddingLarge
- text: "TODO"
- color: theme.secondaryHighlightColor
- font.pixelSize: theme.fontSizeLarge
- }
- }
- }
-}
-
-
-
-
-
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic