1
/* GCompris - BackgroundMusicList.qml
3
* Copyright (C) 2019 Aman Kumar Gupta <gupta2140@gmail.com>
6
* Aman Kumar Gupta <gupta2140@gmail.com> (Qt Quick)
8
* This program is free software; you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License as published by
10
* the Free Software Foundation; either version 3 of the License, or
11
* (at your option) any later version.
13
* This program is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU General Public License for more details.
18
* You should have received a copy of the GNU General Public License
19
* along with this program; if not, see <https://www.gnu.org/licenses/>.
23
import QtQuick.Controls 1.5
27
import "qrc:/gcompris/src/core/core.js" as Core
38
Keys.onEscapePressed: close()
42
property bool horizontalLayout: dialogBackground.width >= dialogBackground.height
43
property int margin30: Math.round(30 * ApplicationInfo.ratio)
47
Item { width: 10; height: 1 }
51
anchors.top: parent.top
52
Item { width: 1; height: 10 }
57
width: dialogBackground.width - 30
58
height: title.height * 1.2
64
text: qsTr("Background music")
65
width: dialogBackground.width - 30
66
horizontalAlignment: Text.AlignHCenter
67
verticalAlignment: Text.AlignVCenter
70
font.weight: Font.DemiBold
71
wrapMode: Text.WordWrap
78
width: dialogBackground.width - 30
79
height: dialogBackground.height - 100
87
anchors.margins: 10 * ApplicationInfo.ratio
88
contentHeight: musicGrid.height + musicInfo.height + margin30
89
flickableDirection: Flickable.VerticalFlick
95
spacing: 10 * ApplicationInfo.ratio
96
anchors.horizontalCenter: parent.horizontalCenter
99
model: dialogActivityConfig.configItem ? dialogActivityConfig.configItem.allBackgroundMusic : 0
102
width: (musicGrid.width - margin30) * 0.33
103
height: title.height * 2
106
text: modelData.slice(0, modelData.lastIndexOf('.'))
108
if(dialogActivityConfig.configItem.filteredBackgroundMusic.indexOf(modelData) == -1) {
109
// Keep the filtered playlist sorted w.r.t to their positions in "allBackgroundMusic" to maintain their playing order
110
var musicOriginalPosition = dialogActivityConfig.configItem.allBackgroundMusic.indexOf(modelData)
112
while(i < dialogActivityConfig.configItem.filteredBackgroundMusic.length) {
113
var filteredMusicName = dialogActivityConfig.configItem.filteredBackgroundMusic[i]
114
if(dialogActivityConfig.configItem.allBackgroundMusic.indexOf(filteredMusicName) > musicOriginalPosition)
118
dialogActivityConfig.configItem.filteredBackgroundMusic.splice(i, 0, modelData)
121
dialogActivityConfig.configItem.filteredBackgroundMusic.splice(dialogActivityConfig.configItem.filteredBackgroundMusic.indexOf(modelData), 1)
122
if(dialogActivityConfig.configItem.filteredBackgroundMusic == 0) {
123
dialogActivityConfig.configItem.filteredBackgroundMusic.push(modelData)
124
selectedIcon.visible = false
125
Core.showMessageDialog(dialogBackground,
126
qsTr("Disable the background music if you don't want to play them."),
134
selectedIcon.visible = !selectedIcon.visible
137
height: parent.height * 0.8
138
style: GCButtonStyle {
144
source: "qrc:/gcompris/src/core/resource/apply.svg"
145
sourceSize.width: height
146
sourceSize.height: height
148
height: parent.height / 4
149
anchors.bottom: parent.bottom
150
anchors.right: parent.right
152
visible: dialogActivityConfig.configItem.filteredBackgroundMusic ? dialogActivityConfig.configItem.filteredBackgroundMusic.indexOf(modelData) != -1 : false
161
spacing: 10 * ApplicationInfo.ratio
163
anchors.top: musicGrid.bottom
164
anchors.leftMargin: 20
167
//: Current background music playing
168
text: qsTr("Now Playing:")
169
width: dialogBackground.width - 30
170
horizontalAlignment: Text.AlignHCenter
173
wrapMode: Text.WordWrap
176
//: Title of the current background music playing
177
text: qsTr("Title: %1").arg(backgroundMusic.metaDataMusic[0])
178
width: dialogBackground.width - 30
179
horizontalAlignment: Text.AlignLeft
182
wrapMode: Text.WordWrap
185
//: Artist of the current background music playing
186
text: qsTr("Artist: %1").arg(backgroundMusic.metaDataMusic[1])
187
width: dialogBackground.width - 30
188
horizontalAlignment: Text.AlignLeft
191
wrapMode: Text.WordWrap
194
//: Year of the current background music playing
195
text: qsTr("Year: %1").arg(backgroundMusic.metaDataMusic[2])
196
width: dialogBackground.width - 30
197
horizontalAlignment: Text.AlignLeft
200
wrapMode: Text.WordWrap
203
//: Copyright of the current background music playing
204
text: qsTr("Copyright: %1").arg(backgroundMusic.metaDataMusic[3])
205
width: dialogBackground.width - 30
206
horizontalAlignment: Text.AlignLeft
209
wrapMode: Text.WordWrap
213
// The scroll buttons
215
anchors.right: parent.right
216
anchors.rightMargin: 5 * ApplicationInfo.ratio
217
anchors.bottom: flickableList.bottom
218
anchors.bottomMargin: 30 * ApplicationInfo.ratio
219
width: parent.width / 20
220
height: width * heightRatio
221
onUp: flickableList.flick(0, 1400)
222
onDown: flickableList.flick(0, -1400)
223
upVisible: (flickableList.visibleArea.yPosition <= 0) ? false : true
224
downVisible: ((flickableList.visibleArea.yPosition + flickableList.visibleArea.heightRatio) >= 1) ? false : true
227
Item { width: 1; height: 10 }