Now about page is good. Fixed BUG with play of bells

This commit is contained in:
Claudio Maradonna 2017-08-23 12:02:27 +02:00
parent 01d5dd2f9c
commit 08cca3e186
9 changed files with 186 additions and 55 deletions

View File

@ -37,7 +37,8 @@ DISTFILES += \
qml/pages/PresetList.qml \
qml/pages/AboutPage.qml \
COPYING \
rpm/harbour-boxing-timer.changes
rpm/harbour-boxing-timer.changes \
qml/pages/js/helpers.js
HEADERS += \
src/boxingtimer.h \

View File

@ -30,7 +30,6 @@
import QtQuick 2.0
import Sailfish.Silica 1.0
import QtMultimedia 5.0
import Pw.Unitoo.Backend 1.0
import "pages"
@ -42,10 +41,7 @@ ApplicationWindow {
BoxingSettings {
id: settings
onPresetChanged: {
boxingTimer.loadPreset(preset)
boxingTimer.status = BoxingTimer.Stop
}
onPresetChanged: boxingTimer.loadPreset(preset)
}
initialPage: firstPage

View File

@ -2,5 +2,126 @@ import QtQuick 2.2
import Sailfish.Silica 1.0
Page {
id: aboutPage
SilicaFlickable {
anchors.fill: parent
contentHeight: column.height
Column {
id: column
width: aboutPage.width
spacing: Theme.paddingLarge
PageHeader { title: qsTr("About") }
Label {
anchors {
left: parent.left
right: parent.right
leftMargin: Theme.paddingLarge
rightMargin: Theme.paddingLarge
}
wrapMode: Text.Wrap
font.pixelSize: Theme.fontSizeSmall
text: qsTr("
\"Boxing Timer\" is a customizable timer for fighting sports like boxe.
You can set duration, rest and number of rounds. If you set 0 rounds, timer loops and count number of rounds.
You can save, load and delete your settings giving a name to them.
")
}
SectionHeader { text: qsTr("Developers") }
Label {
anchors {
left: parent.left
right: parent.right
leftMargin: Theme.paddingLarge
rightMargin: Theme.paddingLarge
}
wrapMode: Text.Wrap
font.pixelSize: Theme.fontSizeSmall
text: qsTr("
Copyright (C) 2017 Claudio Maradonna
Unitoo Team, Italy
")
}
Repeater {
model: ListModel {
ListElement { label: "Email" ; value: "claudio@unitoo.pw" }
ListElement { label: "Diaspora" ; value: "claudiounitoo@framasphere.org" }
ListElement { label: "Mastodon" ; value: "@unitoo" }
ListElement { label: "XMPP" ; value: "unitoo@fysh.in" }
}
delegate: Row {
width: aboutPage.width
spacing: Theme.paddingLarge
Label {
width: parent.width * 0.2; height: 25
font.pixelSize: Theme.fontSizeTiny
text: label
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
color: Theme.secondaryColor
}
Label {
height: 30
font.pixelSize: Theme.fontSizeSmall
text: value
verticalAlignment: Text.AlignVCenter
}
}
}
SectionHeader { text: qsTr("License") }
Label {
anchors {
left: parent.left
right: parent.right
leftMargin: Theme.paddingLarge
rightMargin: Theme.paddingLarge
}
wrapMode: Text.Wrap
font.pixelSize: Theme.fontSizeSmall
text: qsTr("
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
")
}
}
}
}

View File

@ -1,6 +1,8 @@
import QtQuick 2.2
import Sailfish.Silica 1.0
import "js/helpers.js" as Helper
Page {
onStatusChanged: {
if (status === PageStatus.Activating) {
@ -14,40 +16,54 @@ Page {
Column {
PageHeader { title: qsTr("Saved presets") }
width: parent.width
width: parent.width; height: parent.height
spacing: Theme.paddingLarge
SilicaListView {
id: presetsList
width: parent.width; height: 800
width: parent.width; height: parent.height
model: listModel
delegate: BackgroundItem {
width: parent.width
height: Theme.itemSizeSmall
delegate: ListItem {
width: parent.width
onClicked: {
settings.preset = presetsList.model.get(index).name
onClicked: {
settings.preset = presetsList.model.get(index).name
pageStack.pop(firstPage)
}
pageStack.pop(firstPage)
}
Label {
text: name
menu: ContextMenu {
MenuItem {
text: qsTr("Delete")
color: highlighted ? Theme.highlightColor : Theme.primaryColor
onClicked: {
settings.deletePreset(presetsList.model.get(index).name)
anchors {
left: parent.left
right: parent.right
if (settings.presetsList().length < 1) {
pageStack.popAttached()
}
}
}
}
verticalCenter: parent.verticalCenter
Label {
text: name
margins: Theme.paddingLarge
}
}
color: highlighted ? Theme.highlightColor : Theme.primaryColor
anchors {
left: parent.left
right: parent.right
verticalCenter: parent.verticalCenter
margins: Theme.paddingLarge
}
}
}
ListModel {

View File

@ -33,6 +33,7 @@ import Sailfish.Silica 1.0
import Pw.Unitoo.Backend 1.0
import "js/converter.js" as Converter
import "js/helpers.js" as Helper
Page {
id: settingsPage
@ -46,17 +47,9 @@ Page {
property int mRoundMs: settings.roundsMs
property int mRestMs: settings.restMs
function pushPopPresetListPage() {
if (settings.presetsList().length > 0) {
pageStack.pushAttached(Qt.resolvedUrl("PresetList.qml"))
} else {
pageStack.popAttached()
}
}
onStatusChanged: {
if (status === PageStatus.Active) {
pushPopPresetListPage();
Helper.pushPresetListPage();
}
}
@ -73,20 +66,11 @@ Page {
roundsSlider.value,
roundsTimeSlider.value,
Converter.sToMs(restSlider.value)
)
)
pushPopPresetListPage();
}
}
}
boxingTimer.loadPreset(presetName.text)
PushUpMenu {
MenuItem {
text: qsTr("Delete")
onClicked: {
settings.deletePreset(presetName.text)
pushPopPresetListPage();
Helper.pushPresetListPage();
}
}
}

View File

@ -40,7 +40,6 @@ Page {
SilicaFlickable {
anchors.fill: parent
// PullDownMenu and PushUpMenu must be declared in SilicaFlickable, SilicaListView or SilicaGridView
PullDownMenu {
MenuItem {
text: qsTr("About")
@ -80,12 +79,10 @@ Page {
SectionHeader { text: boxingTimer.preset }
Label {
id: labelTimer
width: parent.width
horizontalAlignment: Text.AlignHCenter
font.pixelSize: 244
font.pixelSize: Theme.fontSizeHuge * 3.3
text: boxingTimer.remainingTimeToString
color: boxingTimer.status == BoxingTimer.Rest ? Theme.secondaryColor : Theme.primaryColor
}
@ -115,7 +112,7 @@ Page {
width: parent.width
horizontalAlignment: Text.AlignHCenter
font.pixelSize: 196
font.pixelSize: Theme.fontSizeHuge * 2.6
text: boxingTimer.roundsToString
}
}

5
qml/pages/js/helpers.js Normal file
View File

@ -0,0 +1,5 @@
function pushPresetListPage() {
if (settings.presetsList().length > 0) {
pageStack.pushAttached(Qt.resolvedUrl("../PresetList.qml"))
}
}

View File

@ -15,6 +15,10 @@ BoxingTimer::BoxingTimer() :
this->settings = new BoxingSettings();
this->mRemainingMilliseconds = settings->getRoundMilliseconds();
this->playBell = new QSound(":/audio/resources/play.wav");
this->restBell = new QSound(":/audio/resources/rest.wav");
this->stopBell = new QSound(":/audio/resources/stop.wav");
QObject::connect(this, SIGNAL(statusChanged()), this, SLOT(applyStatus()));
QObject::connect(this, SIGNAL(timeout()), this, SLOT(updateRemainingMilliseconds()));
}
@ -149,6 +153,8 @@ const QString BoxingTimer::roundsToString() {
void BoxingTimer::loadPreset(const QString &preset) {
this->settings->setPreset(preset);
this->mRemainingMilliseconds = settings->getRoundMilliseconds();
this->mStatus = Status::Stop;
emit presetChanged();
emit roundsToStringChanged();
@ -157,10 +163,10 @@ void BoxingTimer::loadPreset(const QString &preset) {
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");
this->playBell->play();
} else if (this->mStatus == Status::Rest) {
this->restBell->play();
} else if (this->mStatus == Status::Stop) {
QSound::play(":/audio/resources/stop.wav");
this->stopBell->play();
}
}

View File

@ -13,6 +13,7 @@
* @defgroup QML What interacts with view
*/
class QSound;
class BoxingSettings;
/**
@ -157,6 +158,10 @@ class BoxingTimer : public QTimer {
void setRemainingMilliseconds(const int &milliseconds);
void setRound(const int &round);
QSound *playBell;
QSound *restBell;
QSound *stopBell;
void songsBell();
Status mStatus;