From kde-commits Sun Dec 08 16:46:39 2013 From: Mathias Kraus Date: Sun, 08 Dec 2013 16:46:39 +0000 To: kde-commits Subject: [abakus] src/mobile/sailfish: use the harmattan qml files for sailfish Message-Id: X-MARC-Message: https://marc.info/?l=kde-commits&m=138652121429018 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: UNKN= OWN] * A +175 -0 src/mobile/sailfish/qml/KeyPadLogic.qml [License: UNKNOW= N] * A +118 -0 src/mobile/sailfish/qml/MainPage.qml [License: UNKNOWN] = * A +85 -0 src/mobile/sailfish/qml/ResultViewItem.qml [License: UNK= NOWN] * 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 whic= h are listed at that page. http://commits.kde.org/abakus/ebc5f53537671207b464c9c8e87ba6c2bbb04a10 diff --git a/src/mobile/sailfish/abakus-sailfishos.pro b/src/mobile/sailfis= h/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 +=3D \ ../../common/functionmodel.h \ ../../common/function.h = -OTHER_FILES +=3D 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 +=3D 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 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/B= utton.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 !=3D 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/E= ditor.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 =3D text} + + function addText(text) { + var selectionStart =3D editor.selectionStart + var selectionEnd =3D editor.selectionEnd + var editorTextLength =3D editor.text.length + var finalCursorPosition =3D selectionStart + text.length + editor.text =3D editor.text.substring(0, selectionStart) + text + = editor.text.substring(selectionEnd, editorTextLength) + //this is needed, because a text change can trigger the setEditorT= ext signal from mainWindow, which replace the text + if(selectionStart + text.length + editorTextLength - selectionEnd = =3D=3D=3D editor.text.length) + { + editor.cursorPosition =3D finalCursorPosition + } + } + + function removeText() { + var selectionStart =3D editor.selectionStart + var selectionEnd =3D editor.selectionEnd + var editorTextLength =3D editor.text.length + var finalCursorPosition =3D selectionStart =3D=3D selectionEnd ? s= electionStart - 1 : selectionStart + editor.text =3D editor.text.substring(0, finalCursorPosition) + ed= itor.text.substring(selectionEnd, editorTextLength) + editor.cursorPosition =3D 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 =3D=3D 0 + text: "Enter expression" + } + } + + Text { + id: clearButtonText + visible: false + font.pointSize: root.fontPointSize + text: " internal.keyPadSwipeTreshold) + { + internal.selectedKeyPad =3D 2 + contentX =3D root.width + contentHeight =3D genericPad.height + container.height =3D genericPad.height + } + else + { + internal.selectedKeyPad =3D 1 + contentX =3D 0 + } + break + case 2: + if(contentX < root.width - internal.keyPadSwipeTreshol= d) + { + internal.selectedKeyPad =3D 1 + contentX =3D 0 + contentHeight =3D logicPad.height + container.height =3D logicPad.height + } + else if(contentX > root.width + 50) + { + internal.selectedKeyPad =3D 3 + contentX =3D 2 * root.width + contentHeight =3D trigPad.height + container.height =3D trigPad.height + } + else + { + internal.selectedKeyPad =3D 2 + contentX =3D root.width + } + break + case 3: + if(contentX < 2 * root.width - internal.keyPadSwipeTre= shold) + { + internal.selectedKeyPad =3D 2 + contentX =3D root.width + contentHeight =3D genericPad.height + container.height =3D genericPad.height + } + else + { + internal.selectedKeyPad =3D 3 + contentX =3D 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 =3D=3D=3D 1 ? "orang= e" : "black" + } + Rectangle { + width: 16 + height: width + radius: width / 2 + antialiasing: true + color: "orange" + border.width: 3 + border.color: internal.selectedKeyPad =3D=3D=3D 2 ? "orang= e" : "black" + } + Rectangle { + width: 16 + height: width + radius: width / 2 + antialiasing: true + color: "orange" + border.width: 3 + border.color: internal.selectedKeyPad =3D=3D=3D 3 ? "orang= e" : "black" + } + } + } +} diff --git a/src/mobile/sailfish/qml/KeyPadFunctionsAndNumerals.qml b/src/m= obile/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=CB=A3" + 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/sailfis= h/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: "=CF=80" + 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=C2=B2" + onPressed: root.pressed("^2") + } + Button { + width: root.buttonWidth + height: root.buttonHeight + text: "=E2=88=9A" + 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: "=C3=97" + onPressed: root.pressed("*") + } + Button { + width: root.buttonWidth + height: root.buttonHeight + text: "=C3=B7" + 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=CB=A3" + 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: "=3D" + 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: "=3D" + 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 =3D 0 + var itemIndexNext =3D mainWindow.getVisibleHistoryItemIndex(i) + var minTagSize =3D 0 + + while(itemIndexNext > -1) + { + tagItemDummy.text =3D mainWindow.getTag(itemIndexNext) + if(minTagSize < tagItemDummy.width) + { + minTagSize =3D tagItemDummy.width + } + ++i + itemIndexNext =3D mainWindow.getVisibleHistoryItemIndex(i) + } + + tagItemDummy.text =3D "" + history.minTagSize =3D 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/sailfi= sh/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 =3D=3D=3D currentHistoryIndex ? internal.highlightC= olor : 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 =3D=3D=3D "" ? 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/sailf= ish/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/mai= n.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: "=CF=80" - 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=C2=B2" - onClicked: root.pressed("^2") - } - Button { - width: root.width / 5 - height: root.buttonHeight - text: "=E2=88=9A" - 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: "=C3=97" - onClicked: root.pressed("*") - } - Button { - width: root.width / 5 - height: root.buttonHeight - text: "=C3=B7" - 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: "=3D" - onClicked: root.evaluate() - } - } -} diff --git a/src/mobile/sailfish/qml/pages/MainPage.qml b/src/mobile/sailfi= sh/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 =3D expression - onResultSelected: editor.text +=3D result - onTagSelected: editor.text +=3D tag - - Component.onCompleted: { - mainWindow.addVisibleHistoryItemIndex(model.index) - history.updateTagWidth() - } - - Component.onDestruction: { - mainWindow.removeVisibleHistoryItemIndex(model.ind= ex) - history.updateTagWidth() - } - } - - Label { - id: tagItemDummy - font.italic: true - visible: false - } - - function updateTagWidth() { - var i =3D 0 - var itemIndexNext =3D mainWindow.getVisibleHistoryItem= Index(i) - var minTagSize =3D 0 - - while(itemIndexNext > -1) - { - tagItemDummy.text =3D mainWindow.getTag(itemIndexN= ext) - if(minTagSize < tagItemDummy.width) - { - minTagSize =3D tagItemDummy.width - } - ++i - itemIndexNext =3D mainWindow.getVisibleHistoryItem= Index(i) - } - - tagItemDummy.text =3D "" - history.minTagSize =3D 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 =3D=3D Qt.Key_Return || event.key =3D= =3D 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 =3D editorText - } - } - - IconButton{ - id: clearButton - icon.source: "image://theme/icon-l-backspace" - onClicked: editor.text =3D "" - onPressAndHold: editor.text =3D "" - } - } - - KeyPad { - id: keypad - width: parent.width - - onPressed: editor.text =3D 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 =3D=3D 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 =3D=3D currentHistoryIndex ? highlightColor : r= owBackground - = - 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 =3D=3D currentHistoryIndex ? highlightColor : r= owBackground - = - 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 =3D=3D "" ? 0 : currentMinTagSize - height: parent.height - color: model.index =3D=3D currentHistoryIndex ? highlightColor : r= owBackground - = - 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/sa= ilfish/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 - } - } - } -} - - - - -