Commit 2fd38088 authored by Timothée Giet's avatar Timothée Giet Committed by Johnny Jazeix
Browse files

menu, core, finish backgroundMusic integration

add music title and artist display in the menu config page
add full metadata display in the BackgroundMusicList page
fix layout of menu config page
move intro music to backgroundMusic player for better consistency,
and at the same time fix random problems with music order
parent 7283f176
......@@ -40,6 +40,7 @@ Rectangle {
signal close
property bool horizontalLayout: dialogBackground.width >= dialogBackground.height
property int margin30: Math.round(30 * ApplicationInfo.ratio)
Row {
spacing: 2
......@@ -60,7 +61,7 @@ Rectangle {
GCText {
id: title
text: qsTr("Pieces of background music")
text: qsTr("Background music")
width: dialogBackground.width - 30
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
......@@ -83,25 +84,23 @@ Rectangle {
Flickable {
id: flickableList
anchors.fill: parent
anchors.topMargin: 10
anchors.leftMargin: 20
contentWidth: parent.width
contentHeight: musicGrid.height
anchors.margins: 10 * ApplicationInfo.ratio
contentHeight: musicGrid.height + musicInfo.height + margin30
flickableDirection: Flickable.VerticalFlick
clip: true
Flow {
id: musicGrid
width: parent.width
spacing: 40
spacing: 10 * ApplicationInfo.ratio
anchors.horizontalCenter: parent.horizontalCenter
Repeater {
model: dialogActivityConfig.configItem ? dialogActivityConfig.configItem.allBackgroundMusic : 0
Item {
width: dialogBackground.horizontalLayout ? dialogBackground.width / 5 : dialogBackground.width / 4
height: dialogBackground.height / 5
width: (musicGrid.width - margin30) * 0.33
height: title.height * 2
Button {
text: modelData.slice(0, modelData.lastIndexOf('.'))
......@@ -156,6 +155,60 @@ Rectangle {
}
}
}
Column {
id: musicInfo
spacing: 10 * ApplicationInfo.ratio
width: parent.width
anchors.top: musicGrid.bottom
anchors.leftMargin: 20
GCText {
//: Current background music playing
text: qsTr("Now Playing:")
width: dialogBackground.width - 30
horizontalAlignment: Text.AlignHCenter
color: "black"
fontSize: mediumSize
wrapMode: Text.WordWrap
}
GCText {
//: Title of the current background music playing
text: qsTr("Title: %1").arg(backgroundMusic.metaDataMusic[0])
width: dialogBackground.width - 30
horizontalAlignment: Text.AlignLeft
color: "black"
fontSize: smallSize
wrapMode: Text.WordWrap
}
GCText {
//: Artist of the current background music playing
text: qsTr("Artist: %1").arg(backgroundMusic.metaDataMusic[1])
width: dialogBackground.width - 30
horizontalAlignment: Text.AlignLeft
color: "black"
fontSize: smallSize
wrapMode: Text.WordWrap
}
GCText {
//: Date of the current background music playing
text: qsTr("Date: %1").arg(backgroundMusic.metaDataMusic[2])
width: dialogBackground.width - 30
horizontalAlignment: Text.AlignLeft
color: "black"
fontSize: smallSize
wrapMode: Text.WordWrap
}
GCText {
//: Copyright of the current background music playing
text: qsTr("Copyright: %1").arg(backgroundMusic.metaDataMusic[3])
width: dialogBackground.width - 30
horizontalAlignment: Text.AlignLeft
color: "black"
fontSize: smallSize
wrapMode: Text.WordWrap
}
}
}
// The scroll buttons
GCButtonScroll {
......
......@@ -40,7 +40,7 @@ Item {
Column {
id: column
spacing: 10
spacing: 10 * ApplicationInfo.ratio
width: parent.width
move: Transition {
......@@ -51,7 +51,7 @@ Item {
Row {
id: demoModeBox
width: parent.width
spacing: 10
spacing: 10 * ApplicationInfo.ratio
property bool checked: !ApplicationSettings.isDemoMode
......@@ -214,7 +214,18 @@ Item {
}
Flow {
spacing: 5
spacing: 5 * ApplicationInfo.ratio
width: parent.width
GCText {
id: audioEffectsVolumeText
text: qsTr("Audio effects volume")
fontSize: mediumSize
wrapMode: Text.WordWrap
}
}
Flow {
spacing: 5 * ApplicationInfo.ratio
width: parent.width
GCSlider {
id: audioEffectsVolumeSlider
......@@ -225,12 +236,6 @@ Item {
onValueChanged: ApplicationSettings.audioEffectsVolume = value / 10;
scrollEnabled: false
}
GCText {
id: audioEffectsVolumeText
text: qsTr("Audio effects volume")
fontSize: mediumSize
wrapMode: Text.WordWrap
}
}
GCDialogCheckBox {
......@@ -241,30 +246,44 @@ Item {
isBackgroundMusicEnabled = checked;
}
}
Flow {
width: parent.width
spacing: 5 * ApplicationInfo.ratio
width: parent.width
GCText {
text: qsTr("Background Music")
fontSize: mediumSize
height: 50 * ApplicationInfo.ratio
}
Image {
source: "qrc:/gcompris/src/core/resource/bar_next.svg"
height: Math.min(50 * ApplicationInfo.ratio, parent.width / 8)
sourceSize.width: height
// Padding
Item {
height: 1
width: 10 * ApplicationInfo.ratio
MouseArea {
anchors.fill: parent
enabled: (backgroundMusic.playbackState == Audio.PlayingState && !backgroundMusic.muted)
onClicked: backgroundMusic.nextAudio()
}
}
}
Flow {
width: parent.width
spacing: 5 * ApplicationInfo.ratio
Button {
id: backgroundMusicName
height: 30 * ApplicationInfo.ratio
width: background.width * 0.8
text: {
if(backgroundMusic.playbackState != Audio.PlayingState)
return qsTr("Not playing")
return configItem.extractMusicNameFromPath(backgroundMusic.source)
else if (backgroundMusic.metaDataMusic[0] != undefined)
return (qsTr("Title: %1 Artist: %2").arg(backgroundMusic.metaDataMusic[0]).arg(backgroundMusic.metaDataMusic[1]))
else if (String(backgroundMusic.source).slice(0, 37) === "qrc:/gcompris/src/core/resource/intro")
return qsTr("Introduction music")
return ""
}
style: GCButtonStyle {}
onClicked: {
......@@ -272,37 +291,11 @@ Item {
backgroundMusicList.visible = true
}
}
// Padding
Item {
height: 1
width: 10 * ApplicationInfo.ratio
}
Image {
source: "qrc:/gcompris/src/core/resource/bar_next.svg"
sourceSize.height: Math.min(50 * ApplicationInfo.ratio, parent.width / 8)
MouseArea {
anchors.fill: parent
enabled: (backgroundMusic.playbackState == Audio.PlayingState && !backgroundMusic.muted)
onClicked: backgroundMusic.nextAudio()
}
}
}
Flow {
spacing: 5
width: parent.width
GCSlider {
id: backgroundMusicVolumeSlider
width: 250 * ApplicationInfo.ratio
maximumValue: 10
minimumValue: 0
value: backgroundMusicVolume * 10
onValueChanged: ApplicationSettings.backgroundMusicVolume = value / 10;
scrollEnabled: false
}
GCText {
id: backgroundMusicVolumeText
text: qsTr("Background music volume")
......@@ -311,6 +304,16 @@ Item {
}
}
GCSlider {
id: backgroundMusicVolumeSlider
width: 250 * ApplicationInfo.ratio
maximumValue: 10
minimumValue: 0
value: backgroundMusicVolume * 10
onValueChanged: ApplicationSettings.backgroundMusicVolume = value / 10;
scrollEnabled: false
}
GCDialogCheckBox {
id: enableFullscreenBox
text: qsTr("Fullscreen")
......@@ -374,6 +377,12 @@ Item {
label: qsTr("Font selector")
}
}
GCText {
id: baseFontSizeText
text: qsTr("Font size")
fontSize: mediumSize
wrapMode: Text.WordWrap
}
Flow {
spacing: 5
width: parent.width
......@@ -386,12 +395,6 @@ Item {
onValueChanged: ApplicationSettings.baseFontSize = value;
scrollEnabled: false
}
GCText {
id: baseFontSizeText
text: qsTr("Font size")
fontSize: mediumSize
wrapMode: Text.WordWrap
}
Button {
height: 30 * ApplicationInfo.ratio
text: qsTr("Default");
......@@ -409,6 +412,12 @@ Item {
label: qsTr("Font Capitalization")
}
}
GCText {
id: fontLetterSpacingText
text: qsTr("Font letter spacing")
fontSize: mediumSize
wrapMode: Text.WordWrap
}
Flow {
spacing: 5
width: parent.width
......@@ -421,12 +430,6 @@ Item {
onValueChanged: ApplicationSettings.fontLetterSpacing = value;
scrollEnabled: false
}
GCText {
id: fontLetterSpacingText
text: qsTr("Font letter spacing")
fontSize: mediumSize
wrapMode: Text.WordWrap
}
Button {
height: 30 * ApplicationInfo.ratio
text: qsTr("Default");
......@@ -508,12 +511,11 @@ Item {
fontSize: mediumSize
height: 50 * ApplicationInfo.ratio
}
}
// Padding
Item {
height: 1
width: 10 * ApplicationInfo.ratio
}
Flow {
width: parent.width
spacing: 5 * ApplicationInfo.ratio
Image {
source: "qrc:/gcompris/src/core/resource/bar_next.svg"
......@@ -527,12 +529,6 @@ Item {
}
}
// Padding
Item {
height: 1
width: 5 * ApplicationInfo.ratio
}
// Level filtering
Repeater {
id: filterRepeater
......@@ -596,12 +592,6 @@ Item {
}
}
// Padding
Item {
height: 1
width: 5 * ApplicationInfo.ratio
}
Image {
source: "qrc:/gcompris/src/core/resource/bar_previous.svg"
sourceSize.height: Math.min(50 * ApplicationInfo.ratio, parent.width / 8)
......
......@@ -118,8 +118,8 @@ ApplicationSettings::ApplicationSettings(const QString &configPath, QObject *par
m_fontLetterSpacing = m_config.value(FONT_LETTER_SPACING, GC_DEFAULT_FONT_LETTER_SPACING).toReal();
m_isEmbeddedFont = m_config.value(IS_CURRENT_FONT_EMBEDDED, true).toBool();
m_filteredBackgroundMusic = m_config.value(FILTERED_BACKGROUND_MUSIC_KEY, ApplicationInfo::getInstance()->getBackgroundMusicFromRcc()).toStringList();
m_backgroundMusicVolume = m_config.value(BACKGROUND_MUSIC_VOLUME_KEY, 1).toReal();
m_audioEffectsVolume = m_config.value(AUDIO_EFFECTS_VOLUME_KEY, 1).toReal();
m_backgroundMusicVolume = m_config.value(BACKGROUND_MUSIC_VOLUME_KEY, 0.4).toReal();
m_audioEffectsVolume = m_config.value(AUDIO_EFFECTS_VOLUME_KEY, 0.7).toReal();
// Init the activation mode
if(QLatin1String(ACTIVATION_MODE) == "no")
......
......@@ -75,6 +75,18 @@ Item {
*/
property alias errorString: audio.errorString
/**
* type:bool
* check if the player is for background music
*/
property bool isBackgroundMusic: false
/**
* type:array
* background music metadata
*/
property var metaDataMusic: ["", "", "", ""]
/**
* Trigger this signal externally to play the next audio in the "files". This, in turn, stops the currently playing audio and check the necessary
* conditions (see onStopped signal in "audio" element) and decides what needs to be done for the next audio.
......@@ -172,7 +184,7 @@ Item {
source = ""
source = file
files.push(file)
_playNextFile()
silenceTimer.start()
} else {
files.push(file)
}
......@@ -203,13 +215,14 @@ Item {
function _playNextFile() {
if(files.length == 0)
return
var nextFile = files.shift()
if(nextFile === '') {
audio.source = ""
source = ""
gcaudio.done()
} else {
audio.source = ""
audio.source = nextFile
source = ""
source = nextFile
if(!muted)
audio.play()
}
......@@ -232,6 +245,11 @@ Item {
else
gcaudio.done()
}
metaData.onMetaDataChanged: {
if(isBackgroundMusic) {
metaDataMusic = [metaData.title, metaData.contributingArtist, metaData.year, metaData.copyright]
}
}
}
Timer {
......
......@@ -109,9 +109,6 @@ Window {
}
Component.onCompleted: {
if(ApplicationSettings.isAudioEffectsEnabled)
append(ApplicationInfo.getAudioFilePath("qrc:/gcompris/src/core/resource/intro.$CA"))
if (DownloadManager.areVoicesRegistered())
delayedWelcomeTimer.playWelcome();
else {
......@@ -130,50 +127,42 @@ Window {
GCAudio {
id: backgroundMusic
isBackgroundMusic: true
muted: !ApplicationSettings.isBackgroundMusicEnabled
volume: ApplicationSettings.backgroundMusicVolume
onMutedChanged: {
if(!hasAudio && !delayedbackgroundMusic.running && !files.length) {
delayedbackgroundMusic.playBackgroundMusic()
if(!hasAudio && !files.length) {
backgroundMusic.playBackgroundMusic()
}
}
onDone: delayedbackgroundMusic.playBackgroundMusic()
Timer {
id: delayedbackgroundMusic
interval: (ApplicationSettings.isAudioVoicesEnabled && !ApplicationSettings.isAudioEffectsEnabled) ? 2000 : 20000
repeat: false
onTriggered: {
delayedbackgroundMusic.playBackgroundMusic();
}
onDone: backgroundMusic.playBackgroundMusic()
function playBackgroundMusic() {
rccBackgroundMusic = ApplicationInfo.getBackgroundMusicFromRcc()
for(var i = 0; i < filteredBackgroundMusic.length; i++) {
backgroundMusic.append(ApplicationInfo.getAudioFilePath("backgroundMusic/" + filteredBackgroundMusic[i]))
}
if(main.isMusicalActivityRunning)
backgroundMusic.pause()
function playBackgroundMusic() {
rccBackgroundMusic = ApplicationInfo.getBackgroundMusicFromRcc()
for(var i = 0; i < filteredBackgroundMusic.length; i++) {
backgroundMusic.append(ApplicationInfo.getAudioFilePath("backgroundMusic/" + filteredBackgroundMusic[i]))
}
if(main.isMusicalActivityRunning)
backgroundMusic.pause()
}
Component.onCompleted: {
if(ApplicationSettings.isBackgroundMusicEnabled)
backgroundMusic.append(ApplicationInfo.getAudioFilePath("qrc:/gcompris/src/core/resource/intro.$CA"))
if(ApplicationSettings.isBackgroundMusicEnabled
&& DownloadManager.haveLocalResource(DownloadManager.getBackgroundMusicResources())) {
if(!ApplicationSettings.isAudioEffectsEnabled && !ApplicationSettings.isAudioVoicesEnabled) {
delayedbackgroundMusic.playBackgroundMusic()
}
else {
delayedbackgroundMusic.start()
}
backgroundMusic.playBackgroundMusic()
}
else {
DownloadManager.backgroundMusicRegistered.connect(delayedbackgroundMusic.playBackgroundMusic)
DownloadManager.backgroundMusicRegistered.connect(backgroundMusic.playBackgroundMusic)
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment