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
QT += multimedia
SOURCES += src/harbour-boxing-timer.cpp \
src/boxingtimer.cpp \
src/boxingsettings.cpp

View File

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

View File

@ -37,12 +37,6 @@ import "pages"
ApplicationWindow {
BoxingTimer {
id: boxingTimer
onStatusChanged: {
if (status === BoxingTimer.Start) {
bell.play()
}
}
}
BoxingSettings {
@ -54,12 +48,6 @@ ApplicationWindow {
}
}
SoundEffect {
id: bell
source: "qrc:/audio/resources/bell.wav"
}
initialPage: firstPage
cover: Qt.resolvedUrl("cover/CoverPage.qml")
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 <QTime>
#include <QSettings>
#include <QSound>
#include "boxingtimer.h"
#include "boxingsettings.h"
@ -11,9 +12,8 @@ BoxingTimer::BoxingTimer() :
mOldStatus(Status::Default) {
this->setTimerType(Qt::VeryCoarseTimer);
settings = new BoxingSettings();
mRemainingMilliseconds = settings->getRoundMilliseconds();
this->settings = new BoxingSettings();
this->mRemainingMilliseconds = settings->getRoundMilliseconds();
QObject::connect(this, SIGNAL(statusChanged()), this, SLOT(applyStatus()));
QObject::connect(this, SIGNAL(timeout()), this, SLOT(updateRemainingMilliseconds()));
@ -58,6 +58,8 @@ void BoxingTimer::start(const int &milliseconds) {
}
void BoxingTimer::applyStatus() {
this->songsBell();
switch (this->mStatus) {
case Status::Reset:
if (this->mOldStatus == Status::Start) {
@ -105,6 +107,8 @@ void BoxingTimer::updateRemainingMilliseconds() {
this->nextRound();
}
this->songsBell();
}
}
@ -150,3 +154,13 @@ void BoxingTimer::loadPreset(const QString &preset) {
emit roundsToStringChanged();
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 setRound(const int &round);
void songsBell();
Status mStatus;
Status mOldStatus;