From 0fc887191dca356579d38347e660bb03abfbf7c4 Mon Sep 17 00:00:00 2001 From: Alexander Dydychkin Date: Tue, 26 Jul 2016 00:12:56 +0300 Subject: [PATCH] Added emojis in randomizer (need fix) --- .gitignore | 1 + harbour-chance.pro | 4 +- qml/emojis/{Emoji-01.png => emoji-0.png} | Bin qml/emojis/{Emoji-02.png => emoji-1.png} | Bin qml/emojis/{Emoji-03.png => emoji-2.png} | Bin qml/emojis/{Emoji-04.png => emoji-3.png} | Bin qml/emojis/{Emoji-05.png => emoji-4.png} | Bin qml/emojis/{Emoji-06.png => emoji-5.png} | Bin qml/emojis/{Emoji-07.png => emoji-6.png} | Bin qml/emojis/{Emoji-08.png => emoji-7.png} | Bin qml/pages/FirstPage.qml | 48 ++++++++++++++--------- rpm/harbour-chance.spec | 2 +- rpm/harbour-chance.yaml | 2 +- 13 files changed, 34 insertions(+), 23 deletions(-) create mode 100644 .gitignore rename qml/emojis/{Emoji-01.png => emoji-0.png} (100%) rename qml/emojis/{Emoji-02.png => emoji-1.png} (100%) rename qml/emojis/{Emoji-03.png => emoji-2.png} (100%) rename qml/emojis/{Emoji-04.png => emoji-3.png} (100%) rename qml/emojis/{Emoji-05.png => emoji-4.png} (100%) rename qml/emojis/{Emoji-06.png => emoji-5.png} (100%) rename qml/emojis/{Emoji-07.png => emoji-6.png} (100%) rename qml/emojis/{Emoji-08.png => emoji-7.png} (100%) diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8b95ceb --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.user \ No newline at end of file diff --git a/harbour-chance.pro b/harbour-chance.pro index d5b90dd..45c84fa 100755 --- a/harbour-chance.pro +++ b/harbour-chance.pro @@ -24,8 +24,8 @@ OTHER_FILES += qml/harbour-chance.qml \ rpm/harbour-chance.spec \ rpm/harbour-chance.yaml \ translations/*.ts \ - harbour-chance.desktop - #images/* \ + harbour-chance.desktop \ + emojis/* #qml/pages/magic-ball.png SAILFISHAPP_ICONS = 86x86 108x108 128x128 256x256 diff --git a/qml/emojis/Emoji-01.png b/qml/emojis/emoji-0.png similarity index 100% rename from qml/emojis/Emoji-01.png rename to qml/emojis/emoji-0.png diff --git a/qml/emojis/Emoji-02.png b/qml/emojis/emoji-1.png similarity index 100% rename from qml/emojis/Emoji-02.png rename to qml/emojis/emoji-1.png diff --git a/qml/emojis/Emoji-03.png b/qml/emojis/emoji-2.png similarity index 100% rename from qml/emojis/Emoji-03.png rename to qml/emojis/emoji-2.png diff --git a/qml/emojis/Emoji-04.png b/qml/emojis/emoji-3.png similarity index 100% rename from qml/emojis/Emoji-04.png rename to qml/emojis/emoji-3.png diff --git a/qml/emojis/Emoji-05.png b/qml/emojis/emoji-4.png similarity index 100% rename from qml/emojis/Emoji-05.png rename to qml/emojis/emoji-4.png diff --git a/qml/emojis/Emoji-06.png b/qml/emojis/emoji-5.png similarity index 100% rename from qml/emojis/Emoji-06.png rename to qml/emojis/emoji-5.png diff --git a/qml/emojis/Emoji-07.png b/qml/emojis/emoji-6.png similarity index 100% rename from qml/emojis/Emoji-07.png rename to qml/emojis/emoji-6.png diff --git a/qml/emojis/Emoji-08.png b/qml/emojis/emoji-7.png similarity index 100% rename from qml/emojis/Emoji-08.png rename to qml/emojis/emoji-7.png diff --git a/qml/pages/FirstPage.qml b/qml/pages/FirstPage.qml index ff19bed..8f7e9a6 100755 --- a/qml/pages/FirstPage.qml +++ b/qml/pages/FirstPage.qml @@ -7,16 +7,15 @@ Page { id: page allowedOrientations: Orientation.All - property real flag: 0 + property real number: 0 function answer() { var answers = ["It is certain.", "It is decidedly so.", "Without a doubt.", "Yes — definitely.", "You may rely on it.", "As I see it, yes.", "Most likely.", "Outlook good.", "Signs point to yes.", "Yes.", "Reply hazy, try again.", "Ask again later.", "Better not tell you now.", "Cannot predict now.", "Concentrate and ask again.", "Don’t count on it.", "My reply is no.", "My sources say no.", "Outlook not so good.", "Very doubtful."]; - //return Math.ceil(Math.random() *2); - //return Math.ceil(shakeSensor.random * 1000) % 2; - return answers [Math.ceil(shakeSensor.random * 1000) % 20]; + number = Math.ceil(shakeSensor.random * 1000) % 20; + return answers [number]; } function buttonAnswer() { @@ -25,7 +24,23 @@ Page { "Reply hazy, try again.", "Ask again later.", "Better not tell you now.", "Cannot predict now.", "Concentrate and ask again.", "Don’t count on it.", "My reply is no.", "My sources say no.", "Outlook not so good.", "Very doubtful."]; - return answers [Math.ceil(Math.random() * 20)]; + number = Math.ceil(Math.random() * 20); + return answers [number]; + } + + function getRandomInt(min, max) { + return Math.floor(Math.random() * (max - min + 1)) + min; + } + + function randEmoji(number) { + if (number >= 0 && number <= 9) + return getRandomInt(0, 2); + else + if (number >= 10 && number <= 14) + return getRandomInt(3, 5); + else + if (number >= 15 && number <= 19) + return getRandomInt(6, 7); } // To enable PullDownMenu, place our content in a SilicaFlickable @@ -54,7 +69,6 @@ Page { title: qsTr("Chance.") } - Text { id: output width: parent.width @@ -67,7 +81,6 @@ Page { //EnterKey.onClicked: buttonAnswer(); } - Button { id: convertButton text: qsTr("Go") @@ -82,7 +95,15 @@ Page { text: qsTr("Click or shake!") anchors.horizontalCenter: parent.horizontalCenter font.pixelSize: Theme.fontSizeExtraSmall - } + } + + Image { + id: emoji + source: "../emojis/emoji-" + randEmoji(number) + ".png" + anchors.horizontalCenter: parent.horizontalCenter + width: parent.width + height: sourceSize.height * width / sourceSize.width + } } } @@ -121,15 +142,4 @@ Page { } } - /* - IconButton { - id: magicBall - width: parent.width - icon.source: "./magic-ball.png" - //icon.source: "$PROJECT/icons/256x256/harbour-chance.png" - //icon.source: "../icons/256x256/harbour-chance.png" - //icon.source: "image://theme/icon-l-play" - onClicked: output.text = answer(); - } - */ } diff --git a/rpm/harbour-chance.spec b/rpm/harbour-chance.spec index 6f490f8..a37c95b 100755 --- a/rpm/harbour-chance.spec +++ b/rpm/harbour-chance.spec @@ -13,7 +13,7 @@ Name: harbour-chance %{!?qtc_make:%define qtc_make make} %{?qtc_builddir:%define _builddir %qtc_builddir} Summary: Chance evolved to magic ball! -Version: 1.2 +Version: 1.3 Release: 1 Group: Qt/Qt License: LICENSE diff --git a/rpm/harbour-chance.yaml b/rpm/harbour-chance.yaml index 610a79d..c65a044 100755 --- a/rpm/harbour-chance.yaml +++ b/rpm/harbour-chance.yaml @@ -1,6 +1,6 @@ Name: harbour-chance Summary: Chance evolved to magic ball! -Version: 1.2 +Version: 1.3 Release: 1 # The contents of the Group field should be one of the groups listed here: # http://gitorious.org/meego-developer-tools/spectacle/blobs/master/data/GROUPS