diff --git a/harbour-kvadraasolve.desktop b/harbour-kvadraasolve.desktop new file mode 100644 index 0000000..672dbae --- /dev/null +++ b/harbour-kvadraasolve.desktop @@ -0,0 +1,7 @@ +[Desktop Entry] +Type=Application +X-Nemo-Application-Type=silica-qt5 +Name=KvadraaSolve +Icon=harbour-kvadraasolve +Exec=harbour-kvadraasolve + diff --git a/harbour-kvadraasolve.png b/harbour-kvadraasolve.png new file mode 100644 index 0000000..e743717 Binary files /dev/null and b/harbour-kvadraasolve.png differ diff --git a/harbour-kvadraasolve.pro b/harbour-kvadraasolve.pro new file mode 100644 index 0000000..7de1d15 --- /dev/null +++ b/harbour-kvadraasolve.pro @@ -0,0 +1,23 @@ +# The name of your app. +# NOTICE: name defined in TARGET has a corresponding QML filename. +# If name defined in TARGET is changed, following needs to be +# done to match new name: +# - corresponding QML filename must be changed +# - desktop icon filename must be changed +# - desktop filename must be changed +# - icon definition filename in desktop file must be changed +TARGET = harbour-kvadraasolve + +CONFIG += sailfishapp + +SOURCES += src/harbour-kvadraasolve.cpp + +OTHER_FILES += qml/harbour-kvadraasolve.qml \ + qml/cover/CoverPage.qml \ + qml/pages/KvadraaSolve.qml \ + qml/pages/About.qml \ + qml/pages/Thanks.qml \ + rpm/harbour-kvadraasolve.spec \ + rpm/harbour-kvadraasolve.yaml \ + harbour-kvadraasolve.desktop + diff --git a/qml/harbour-kvadraasolve.qml b/qml/harbour-kvadraasolve.qml new file mode 100644 index 0000000..f4772e2 --- /dev/null +++ b/qml/harbour-kvadraasolve.qml @@ -0,0 +1,72 @@ +/* + Copyright (C) 2013 Jolla Ltd. + Contact: Thomas Perl + All rights reserved. + + You may use this file under the terms of BSD license as follows: + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Jolla Ltd nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR + ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +import QtQuick 2.0 +import Sailfish.Silica 1.0 +import "pages" + +ApplicationWindow +{ + id: appwin + //initialPage: KvadraaSolve {} + initialPage: kvadraaSolveComponent + cover: Qt.resolvedUrl("cover/CoverPage.qml") + + property KvadraaSolve _kvadraasolve + Component { + id: kvadraaSolveComponent + KvadraaSolve { + id: kvadraasolve + Component.onCompleted: appwin._kvadraasolve = kvadraasolve + } + } + + function getX1() { + if (_kvadraasolve._x1 === null) return "Type A, B, C first" + else + return _kvadraasolve._x1; + } + function getX2() { + + if (_kvadraasolve._x2 === null) return "Type A, B, C first" + else return _kvadraasolve._x2; + } + function getD() { + + if (_kvadraasolve._d === null) return "Type A, B, C first" + else return _kvadraasolve._d; + } + function getEqu() { + return _kvadraasolve._equation; + } + + +} + diff --git a/qml/pages/About.qml b/qml/pages/About.qml new file mode 100644 index 0000000..6df6f21 --- /dev/null +++ b/qml/pages/About.qml @@ -0,0 +1,71 @@ +/* + Copyright (C) 2013 Jolla Ltd. + Contact: Thomas Perl + All rights reserved. + + You may use this file under the terms of BSD license as follows: + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Jolla Ltd nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR + ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +import QtQuick 2.0 +import Sailfish.Silica 1.0 + + +Page { + id: page + Column { + anchors.fill: parent + anchors.margins: Theme.paddingLarge + + PageHeader { + title: "About Page" + } + + Label { + width: parent.width + horizontalAlignment: Text.AlignLeft + text: "Hello Sailors:)" + } + Label { + width: parent.width + horizontalAlignment: Text.AlignLeft + wrapMode: Text.WrapAtWordBoundaryOrAnywhere + textFormat: Text.RichText + //textFormat: Text.RichText + text: "\ +This is my first training application.
+ I'm still styding :)
+Source code is in my GitHub repo (van-ess0/KvadraaSolve).
+Contact me in Twitter @Van_ess0
+Thanks for using and best wishes!
" + onLinkActivated: { + Qt.openUrlExternally(link) + } + } + } +} diff --git a/qml/pages/KvadraaSolve.qml b/qml/pages/KvadraaSolve.qml new file mode 100644 index 0000000..62a1e44 --- /dev/null +++ b/qml/pages/KvadraaSolve.qml @@ -0,0 +1,214 @@ +/* + Copyright (C) 2013 Jolla Ltd. + Contact: Thomas Perl + All rights reserved. + + You may use this file under the terms of BSD license as follows: + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Jolla Ltd nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR + ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +import QtQuick 2.0 +import Sailfish.Silica 1.0 +import "../cover" + +Page { + id: page + + property alias _equation: equ.qua + property alias _x1: x1.text + property alias _x2: x2.text + property alias _d: d.text + + //Making string in the PullDownMenu and filling global variables + //for cover information + Item { + id: equ + property string ak: {if (a.text === '') 'A'; else a.text} + property string bk: {if (parseInt(b.text) < 0) b.text + 'X'; else if (b.text === '') '+BX'; else '+' + b.text + 'X' } + property string ck: {if (parseInt(c.text) < 0) c.text; else if (c.text === '') '+C'; else '+' + c.text} + property string qua: ak + 'X²' + bk + ck + '=0' + } + + + // To enable PullDownMenu, place our content in a SilicaFlickable + SilicaFlickable { + anchors.fill: parent + + // PullDownMenu and PushUpMenu must be declared in SilicaFlickable, SilicaListView or SilicaGridView + PullDownMenu { + MenuItem { + text: "Thanks" + onClicked: pageStack.push(Qt.resolvedUrl("Thanks.qml")) + } + MenuItem { + text: "About" + onClicked: pageStack.push(Qt.resolvedUrl("About.qml")) + } + Label { + width: parent.width + //height: (parent.height - head.height) / 10 + horizontalAlignment: Text.AlignHCenter + textFormat: Text.RichText + text: equ.qua + } + } + + + // Tell SilicaFlickable the height of its content. + contentHeight: column.height + + // Place our content in a Column. The PageHeader is always placed at the top + // of the page, followed by our content. + Column { + id: column + + width: page.width + height: page.height + anchors.margins: Theme.paddingLarge + spacing: Theme.paddingLarge + + + PageHeader { + id: head + title: "KvadraaSolve" + } + + //Getting A in Ax^2+Bx+C=0 + Item { + id:sqX + width: parent.width + height: (parent.height - head.height) / 5 + Label { + id: aLabel + width: parent.width / 10 + height: parent.height + textFormat: Text.RichText + font.bold: true + //anchors.leftMargin: Theme.paddingLarge + //anchors.rightMargin: Theme.paddingLarge + + //horizontalAlignment: Text.AlignLeft + text: "X²" + } + TextField { + id: a + width: parent.width - aLabel.width + height: parent.height + anchors.left: aLabel.right + horizontalAlignment: Text.AlignRight + //font.bold: true + placeholderText: "Enter A" + //text: "2" + validator: IntValidator{} + inputMethodHints: Qt.ImhDigitsOnly + //focus: true + } + } + Item { + id: x + width: parent.width + height: (parent.height - head.height) / 5 + Label { + id: bLabel + width: parent.width / 10 + height: parent.height + font.bold: true + //anchors.leftMargin: Theme.paddingLarge + //anchors.rightMargin: Theme.paddingLarge + + //horizontalAlignment: Text.AlignLeft + text: "X" + } + TextField { + id: b + width: parent.width - bLabel.width + height: parent.height + anchors.left: bLabel.right + horizontalAlignment: Text.AlignRight + //font.bold: true + placeholderText: "Enter B" + //text: "3" + validator: IntValidator{} + inputMethodHints: Qt.ImhDigitsOnly + } + } + + Item { + id:free + width: parent.width + height: (parent.height - head.height) / 5 + Label { + id: cLabel + width: parent.width / 10 + height: parent.height + font.bold: true + //anchors.leftMargin: Theme.paddingLarge + //anchors.rightMargin: Theme.paddingLarge + //horizontalAlignment: Text.AlignLeft + text: "Free" + } + TextField { + id: c + width: parent.width - cLabel.width + height: parent.height + anchors.left: cLabel.right + horizontalAlignment: Text.AlignRight + //font.bold: true + placeholderText: "Enter C" + //text: "-1" + validator: IntValidator{} + inputMethodHints: Qt.ImhDigitsOnly + } + } + + Label { + id: d + width: parent.width + font.weight: Font.Light + font.pointSize: 5 + //Text.fontSizeMode: 15 + property int discriminant: (parseInt(b.text) * parseInt(b.text) - 4 * parseInt(a.text) * parseInt(c.text)) + text: "D = " + discriminant + } + + Label { + id: x1 + width: parent.width + font.weight: Font.Light + //anchors.left: d.right + property real x1var: ((-parseInt(b.text) + Math.sqrt(d.discriminant)) / (2 * parseInt(a.text))) + text: 'X1 = ' + x1var + } + Label { + id: x2 + width: parent.width + font.weight: Font.Light + property real x2var: ((-parseInt(b.text) - Math.sqrt(d.discriminant)) / (2 * parseInt(a.text))) + text: 'X2 = ' + x2var + } + + } + } + +} diff --git a/qml/pages/Thanks.qml b/qml/pages/Thanks.qml new file mode 100644 index 0000000..03c9fab --- /dev/null +++ b/qml/pages/Thanks.qml @@ -0,0 +1,35 @@ +import QtQuick 2.0 +import Sailfish.Silica 1.0 + + +Page { + id: page + Column { + anchors.fill: parent + anchors.margins: Theme.paddingLarge + + PageHeader { + title: "Thanks Page" + } + Label { + width: parent.width + horizontalAlignment: Text.AlignLeft + wrapMode: Text.WrapAtWordBoundaryOrAnywhere + textFormat: Text.RichText + //textFormat: Text.RichText + text: "\ +Special thanks to:
+Amarchen for his HelloWorld-Pro which I used as example for a lot of things.
+Lanurmi for his SailFactor which I used as example for making cover useful
+Mariusmssj for his BMI-Calculator which I used as examlpe of small and useful application
+Ancelad for the nice icon." + onLinkActivated: { + Qt.openUrlExternally(link) + } + } + } +} diff --git a/rpm/harbour-kvadraasolve.spec b/rpm/harbour-kvadraasolve.spec new file mode 100644 index 0000000..b3b7777 --- /dev/null +++ b/rpm/harbour-kvadraasolve.spec @@ -0,0 +1,75 @@ +# +# Do NOT Edit the Auto-generated Part! +# Generated by: spectacle version 0.27 +# + +Name: harbour-kvadraasolve + +# >> macros +# << macros + +%{!?qtc_qmake:%define qtc_qmake %qmake} +%{!?qtc_qmake5:%define qtc_qmake5 %qmake5} +%{!?qtc_make:%define qtc_make make} +%{?qtc_builddir:%define _builddir %qtc_builddir} +Summary: Simple calc to solve quadratic equation. +Version: 1.1 +Release: 1 +Group: Qt/Qt +License: LICENSE +URL: http://example.org/ +Source0: %{name}-%{version}.tar.bz2 +Source100: harbour-kvadraasolve.yaml +Requires: sailfishsilica-qt5 >= 0.10.9 +BuildRequires: pkgconfig(sailfishapp) >= 0.0.10 +BuildRequires: pkgconfig(Qt5Core) +BuildRequires: pkgconfig(Qt5Qml) +BuildRequires: pkgconfig(Qt5Quick) +BuildRequires: desktop-file-utils + +%description +Short description of my SailfishOS Application + + +%prep +%setup -q -n %{name}-%{version} + +# >> setup +# << setup + +%build +# >> build pre +# << build pre + +%qtc_qmake5 + +%qtc_make %{?_smp_mflags} + +# >> build post +# << build post + +%install +rm -rf %{buildroot} +# >> install pre +# << install pre +%qmake5_install + +# >> install post +# << install post + +desktop-file-install --delete-original \ + --dir %{buildroot}%{_datadir}/applications \ + %{buildroot}%{_datadir}/applications/*.desktop + +%files +%defattr(-,root,root,-) +/usr/share/icons/hicolor/86x86/apps +/usr/share/applications +/usr/share/harbour-kvadraasolve +/usr/bin +%{_datadir}/icons/hicolor/86x86/apps/%{name}.png +%{_datadir}/applications/%{name}.desktop +%{_datadir}/%{name}/qml +%{_bindir} +# >> files +# << files diff --git a/rpm/harbour-kvadraasolve.yaml b/rpm/harbour-kvadraasolve.yaml new file mode 100644 index 0000000..dd939cd --- /dev/null +++ b/rpm/harbour-kvadraasolve.yaml @@ -0,0 +1,30 @@ +Name: harbour-kvadraasolve +Summary: Simple calc to solve quadratic equation. +Version: 1.1 +Release: 1 +Group: Qt/Qt +URL: http://example.org/ +License: +Sources: +- '%{name}-%{version}.tar.bz2' +Description: |- + This is my simple application to solve Quadratic equation. Requests about usability, functionality and others are welcome. +Configure: none +Builder: qtc5 +PkgConfigBR: +- Qt5Quick +- Qt5Qml +- Qt5Core +- sailfishapp >= 0.0.10 +Requires: +- sailfishsilica-qt5 >= 0.10.9 +Files: +- '%{_bindir}' +- '%{_datadir}/%{name}/qml' +- '%{_datadir}/applications/%{name}.desktop' +- '%{_datadir}/icons/hicolor/86x86/apps/%{name}.png' +- /usr/bin +- /usr/share/harbour-kvadraasolve +- /usr/share/applications +- /usr/share/icons/hicolor/86x86/apps +PkgBR: [] diff --git a/src/harbour-kvadraasolve.cpp b/src/harbour-kvadraasolve.cpp new file mode 100644 index 0000000..dfbb6d6 --- /dev/null +++ b/src/harbour-kvadraasolve.cpp @@ -0,0 +1,51 @@ +/* + Copyright (C) 2013 Jolla Ltd. + Contact: Thomas Perl + All rights reserved. + + You may use this file under the terms of BSD license as follows: + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Jolla Ltd nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR + ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifdef QT_QML_DEBUG +#include +#endif + +#include + + +int main(int argc, char *argv[]) +{ + // SailfishApp::main() will display "qml/template.qml", if you need more + // control over initialization, you can use: + // + // - SailfishApp::application(int, char *[]) to get the QGuiApplication * + // - SailfishApp::createView() to get a new QQuickView * instance + // - SailfishApp::pathTo(QString) to get a QUrl to a resource file + // + // To display the view, call "show()" (will show fullscreen on device). + + return SailfishApp::main(argc, argv); +} +