Added audio resources like ring bells

This commit is contained in:
Claudio Maradonna 2017-08-22 23:07:50 +02:00
parent 882ed92bc7
commit 01d5dd2f9c
8 changed files with 24 additions and 16 deletions

View File

@ -5,6 +5,8 @@ DEFINES += APP_RELEASE=\\\"$$RELEASE\\\"
CONFIG += sailfishapp CONFIG += sailfishapp
QT += multimedia
SOURCES += src/harbour-boxing-timer.cpp \ SOURCES += src/harbour-boxing-timer.cpp \
src/boxingtimer.cpp \ src/boxingtimer.cpp \
src/boxingsettings.cpp src/boxingsettings.cpp

View File

@ -1,5 +1,7 @@
<RCC> <RCC>
<qresource prefix="/audio"> <qresource prefix="/audio">
<file>resources/bell.wav</file> <file>resources/play.wav</file>
<file>resources/rest.wav</file>
<file>resources/stop.wav</file>
</qresource> </qresource>
</RCC> </RCC>

View File

@ -37,12 +37,6 @@ import "pages"
ApplicationWindow { ApplicationWindow {
BoxingTimer { BoxingTimer {
id: boxingTimer id: boxingTimer
onStatusChanged: {
if (status === BoxingTimer.Start) {
bell.play()
}
}
} }
BoxingSettings { BoxingSettings {
@ -54,12 +48,6 @@ ApplicationWindow {
} }
} }
SoundEffect {
id: bell
source: "qrc:/audio/resources/bell.wav"
}
initialPage: firstPage initialPage: firstPage
cover: Qt.resolvedUrl("cover/CoverPage.qml") cover: Qt.resolvedUrl("cover/CoverPage.qml")
allowedOrientations: Orientation.Portrait allowedOrientations: Orientation.Portrait

BIN
resources/play.wav Normal file

Binary file not shown.

BIN
resources/rest.wav Normal file

Binary file not shown.

BIN
resources/stop.wav Normal file

Binary file not shown.

View File

@ -1,6 +1,7 @@
#include <QObject> #include <QObject>
#include <QTime> #include <QTime>
#include <QSettings> #include <QSettings>
#include <QSound>
#include "boxingtimer.h" #include "boxingtimer.h"
#include "boxingsettings.h" #include "boxingsettings.h"
@ -11,9 +12,8 @@ BoxingTimer::BoxingTimer() :
mOldStatus(Status::Default) { mOldStatus(Status::Default) {
this->setTimerType(Qt::VeryCoarseTimer); this->setTimerType(Qt::VeryCoarseTimer);
settings = new BoxingSettings(); this->settings = new BoxingSettings();
this->mRemainingMilliseconds = settings->getRoundMilliseconds();
mRemainingMilliseconds = settings->getRoundMilliseconds();
QObject::connect(this, SIGNAL(statusChanged()), this, SLOT(applyStatus())); QObject::connect(this, SIGNAL(statusChanged()), this, SLOT(applyStatus()));
QObject::connect(this, SIGNAL(timeout()), this, SLOT(updateRemainingMilliseconds())); QObject::connect(this, SIGNAL(timeout()), this, SLOT(updateRemainingMilliseconds()));
@ -58,6 +58,8 @@ void BoxingTimer::start(const int &milliseconds) {
} }
void BoxingTimer::applyStatus() { void BoxingTimer::applyStatus() {
this->songsBell();
switch (this->mStatus) { switch (this->mStatus) {
case Status::Reset: case Status::Reset:
if (this->mOldStatus == Status::Start) { if (this->mOldStatus == Status::Start) {
@ -105,6 +107,8 @@ void BoxingTimer::updateRemainingMilliseconds() {
this->nextRound(); this->nextRound();
} }
this->songsBell();
} }
} }
@ -150,3 +154,13 @@ void BoxingTimer::loadPreset(const QString &preset) {
emit roundsToStringChanged(); emit roundsToStringChanged();
emit remainingTimeToStringChanged(); emit remainingTimeToStringChanged();
} }
void BoxingTimer::songsBell() {
if (this->mStatus == Status::Start) {
QSound::play(":/audio/resources/play.wav");
} else if (this->mStatus == Status::Rest || this->mStatus == Status::Pause) {
QSound::play(":/audio/resources/rest.wav");
} else if (this->mStatus == Status::Stop) {
QSound::play(":/audio/resources/stop.wav");
}
}

View File

@ -157,6 +157,8 @@ class BoxingTimer : public QTimer {
void setRemainingMilliseconds(const int &milliseconds); void setRemainingMilliseconds(const int &milliseconds);
void setRound(const int &round); void setRound(const int &round);
void songsBell();
Status mStatus; Status mStatus;
Status mOldStatus; Status mOldStatus;