Skip to content

Commit

Permalink
Added emojis in randomizer (need fix)
Browse files Browse the repository at this point in the history
  • Loading branch information
GoAlexander committed Jul 25, 2016
1 parent f25860b commit 0fc8871
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 23 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.user
4 changes: 2 additions & 2 deletions harbour-chance.pro
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
48 changes: 29 additions & 19 deletions qml/pages/FirstPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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
Expand Down Expand Up @@ -54,7 +69,6 @@ Page {
title: qsTr("Chance.")
}


Text {
id: output
width: parent.width
Expand All @@ -67,7 +81,6 @@ Page {
//EnterKey.onClicked: buttonAnswer();
}


Button {
id: convertButton
text: qsTr("Go")
Expand All @@ -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
}
}
}

Expand Down Expand Up @@ -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();
}
*/
}
2 changes: 1 addition & 1 deletion rpm/harbour-chance.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion rpm/harbour-chance.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 0fc8871

Please sign in to comment.