Warning, /education/gcompris/src/activities/menu/BackgroundMusicList.qml is written in an unsupported language. File is not indexed.
0001 /* GCompris - BackgroundMusicList.qml 0002 * 0003 * SPDX-FileCopyrightText: 2019 Aman Kumar Gupta <gupta2140@gmail.com> 0004 * 0005 * Authors: 0006 * Aman Kumar Gupta <gupta2140@gmail.com> (Qt Quick) 0007 * 0008 * SPDX-License-Identifier: GPL-3.0-or-later 0009 */ 0010 0011 import QtQuick 2.12 0012 import QtMultimedia 5.12 0013 import GCompris 1.0 0014 0015 import "../../core" 0016 import "qrc:/gcompris/src/core/core.js" as Core 0017 0018 Rectangle { 0019 id: dialogBackground 0020 color: "#696da3" 0021 border.color: "black" 0022 border.width: 1 0023 z: 10000 0024 anchors.fill: parent 0025 visible: false 0026 focus: visible 0027 0028 Keys.onPressed: { 0029 if(event.key === Qt.Key_Down) { 0030 scrollMusicList.down(); 0031 } else if(event.key === Qt.Key_Up) { 0032 scrollMusicList.up(); 0033 } 0034 } 0035 0036 Keys.onEscapePressed: close() 0037 0038 signal close 0039 0040 onClose: parent.forceActiveFocus(); 0041 0042 property bool horizontalLayout: dialogBackground.width >= dialogBackground.height 0043 property int margin30: Math.round(30 * ApplicationInfo.ratio) 0044 0045 Row { 0046 spacing: 2 0047 Item { width: 10; height: 1 } 0048 0049 Column { 0050 spacing: 10 0051 anchors.top: parent.top 0052 Item { width: 1; height: 10 } 0053 Rectangle { 0054 id: titleRectangle 0055 color: "#e6e6e6" 0056 radius: 6.0 0057 width: dialogBackground.width - 30 0058 height: title.height * 1.2 0059 border.color: "black" 0060 border.width: 2 0061 0062 GCText { 0063 id: title 0064 text: qsTr("Background music") 0065 width: dialogBackground.width - 30 0066 horizontalAlignment: Text.AlignHCenter 0067 verticalAlignment: Text.AlignVCenter 0068 color: "black" 0069 fontSize: 20 0070 font.weight: Font.DemiBold 0071 wrapMode: Text.WordWrap 0072 } 0073 } 0074 0075 Rectangle { 0076 color: "#e6e6e6" 0077 radius: 6.0 0078 width: dialogBackground.width - 30 0079 height: dialogBackground.height - 100 0080 border.color: "black" 0081 border.width: 2 0082 anchors.margins: 100 0083 0084 Flickable { 0085 id: flickableList 0086 anchors.fill: parent 0087 anchors.margins: 10 * ApplicationInfo.ratio 0088 contentHeight: musicGrid.height + musicInfo.height + margin30 0089 flickableDirection: Flickable.VerticalFlick 0090 clip: true 0091 0092 Flow { 0093 id: musicGrid 0094 width: parent.width 0095 spacing: 10 * ApplicationInfo.ratio 0096 anchors.horizontalCenter: parent.horizontalCenter 0097 0098 Repeater { 0099 model: dialogActivityConfig.configItem ? dialogActivityConfig.configItem.allBackgroundMusic : 0 0100 0101 Item { 0102 width: (musicGrid.width - margin30) * 0.33 0103 height: title.height * 2 0104 0105 GCButton { 0106 text: modelData.slice(0, modelData.lastIndexOf('.')) 0107 0108 onClicked: { 0109 if(dialogActivityConfig.configItem.filteredBackgroundMusic.indexOf(modelData) == -1) { 0110 // Keep the filtered playlist sorted w.r.t to their positions in "allBackgroundMusic" to maintain their playing order 0111 var musicOriginalPosition = dialogActivityConfig.configItem.allBackgroundMusic.indexOf(modelData) 0112 var i = 0 0113 while(i < dialogActivityConfig.configItem.filteredBackgroundMusic.length) { 0114 var filteredMusicName = dialogActivityConfig.configItem.filteredBackgroundMusic[i] 0115 if(dialogActivityConfig.configItem.allBackgroundMusic.indexOf(filteredMusicName) > musicOriginalPosition) 0116 break 0117 i++ 0118 } 0119 dialogActivityConfig.configItem.filteredBackgroundMusic.splice(i, 0, modelData) 0120 } 0121 else { 0122 dialogActivityConfig.configItem.filteredBackgroundMusic.splice(dialogActivityConfig.configItem.filteredBackgroundMusic.indexOf(modelData), 1) 0123 if(dialogActivityConfig.configItem.filteredBackgroundMusic == 0) { 0124 dialogActivityConfig.configItem.filteredBackgroundMusic.push(modelData) 0125 selectedIcon.visible = false 0126 Core.showMessageDialog(dialogBackground, 0127 qsTr("Disable the background music if you don't want to play them."), 0128 "", null, 0129 "", null, 0130 null 0131 ); 0132 } 0133 } 0134 0135 selectedIcon.visible = !selectedIcon.visible 0136 } 0137 width: parent.width 0138 height: parent.height * 0.8 0139 theme: "dark" 0140 0141 Image { 0142 id: selectedIcon 0143 source: "qrc:/gcompris/src/core/resource/apply.svg" 0144 sourceSize.width: height 0145 sourceSize.height: height 0146 width: height 0147 height: parent.height / 4 0148 anchors.bottom: parent.bottom 0149 anchors.right: parent.right 0150 anchors.margins: 2 0151 visible: dialogActivityConfig.configItem.filteredBackgroundMusic ? dialogActivityConfig.configItem.filteredBackgroundMusic.indexOf(modelData) != -1 : false 0152 } 0153 } 0154 } 0155 } 0156 } 0157 0158 Column { 0159 id: musicInfo 0160 spacing: 10 * ApplicationInfo.ratio 0161 width: parent.width 0162 anchors.top: musicGrid.bottom 0163 anchors.leftMargin: 20 0164 visible: backgroundMusic.playbackState === Audio.PlayingState && !backgroundMusic.muted 0165 GCText { 0166 //: Current background music playing 0167 text: qsTr("Now Playing:") 0168 width: dialogBackground.width - 30 0169 horizontalAlignment: Text.AlignHCenter 0170 color: "black" 0171 fontSize: mediumSize 0172 wrapMode: Text.WordWrap 0173 } 0174 GCText { 0175 //: Title of the current background music playing 0176 text: qsTr("Title: %1").arg(backgroundMusic.metaDataMusic[0]) 0177 width: dialogBackground.width - 30 0178 horizontalAlignment: Text.AlignLeft 0179 color: "black" 0180 fontSize: smallSize 0181 wrapMode: Text.WordWrap 0182 } 0183 GCText { 0184 //: Artist of the current background music playing 0185 text: qsTr("Artist: %1").arg(backgroundMusic.metaDataMusic[1]) 0186 width: dialogBackground.width - 30 0187 horizontalAlignment: Text.AlignLeft 0188 color: "black" 0189 fontSize: smallSize 0190 wrapMode: Text.WordWrap 0191 } 0192 GCText { 0193 //: Year of the current background music playing 0194 text: qsTr("Year: %1").arg(backgroundMusic.metaDataMusic[2]) 0195 width: dialogBackground.width - 30 0196 horizontalAlignment: Text.AlignLeft 0197 color: "black" 0198 fontSize: smallSize 0199 wrapMode: Text.WordWrap 0200 } 0201 GCText { 0202 //: Copyright of the current background music playing 0203 text: qsTr("Copyright: %1").arg(backgroundMusic.metaDataMusic[3]) 0204 width: dialogBackground.width - 30 0205 horizontalAlignment: Text.AlignLeft 0206 color: "black" 0207 fontSize: smallSize 0208 wrapMode: Text.WordWrap 0209 } 0210 } 0211 } 0212 // The scroll buttons 0213 GCButtonScroll { 0214 id: scrollMusicList 0215 anchors.right: parent.right 0216 anchors.rightMargin: 5 * ApplicationInfo.ratio 0217 anchors.bottom: flickableList.bottom 0218 anchors.bottomMargin: 30 * ApplicationInfo.ratio 0219 width: parent.width / 20 0220 height: width * heightRatio 0221 onUp: flickableList.flick(0, 1400) 0222 onDown: flickableList.flick(0, -1400) 0223 upVisible: flickableList.atYBeginning ? false : true 0224 downVisible: flickableList.atYEnd ? false : true 0225 } 0226 } 0227 Item { width: 1; height: 10 } 0228 } 0229 } 0230 0231 GCButtonCancel { 0232 onClose: { 0233 parent.close() 0234 } 0235 } 0236 }