<commit_before>/*
 * Copyright 2011 Intel Corporation.
 *
 * This program is licensed under the terms and conditions of the
 * Apache License, version 2.0.  The full text of the Apache License is at 	
 * http://www.apache.org/licenses/LICENSE-2.0
 */

import Qt 4.7
import MeeGo.Labs.Components 0.1
import MeeGo.Panels 0.1
import MeeGo.Sharing 0.1
import MeeGo.Media 0.1

FlipPanel {
    id: container

    Translator {
        catalog: "meego-ux-panels-music"
    }

    //Because we do not have a universal launcher
    //Need to modify model that this app is launched
    function notifyModel()
    {
        appsModel.favorites.append("/usr/share/meego-ux-appgrid/applications/meego-app-music.desktop")
    }


    ListModel{
        id: backSettingsModel

        ListElement {
            //i18n OK, as it gets properly set in the Component.onCompleted - long drama why this is necessary - limitation in QML translation capabilities
            settingsTitle: "Recently played"
            custPropName: "RecentlyPlayed"
            isVisible: true
        }
        ListElement {
            //i18n OK, as it gets properly set in the Component.onCompleted - long drama why this is necessary - limitation in QML translation capabilities
            settingsTitle: "Playlists"
            custPropName: "Playlists"
            isVisible: true
        }

        //Get around i18n issues w/ the qsTr of the strings being in a different file
        Component.onCompleted: {
            backSettingsModel.setProperty(0, "settingsTitle", qsTr("Recently played"));
            backSettingsModel.setProperty(1, "settingsTitle", qsTr("Playlists"));
        }
    }



    MusicListModel {
        id: musicRecentsModel
        type:MusicListModel.ListofRecentlyPlayed
        limit: 2
        sort: MusicListModel.SortByDefault
    }

    onPanelObjChanged: {
        playlistsModel.hideItemsByURN(panelObj.HiddenItems);
        musicRecentsModel.hideItemsByURN(panelObj.HiddenItems);
    }



    MusicListModel {
        id: playlistsModel
        type:MusicListModel.ListofPlaylists
        limit: 0
        sort: MusicListModel.SortByDefault
    }



    front: Panel {
        panelTitle: qsTr("Music")
        panelContent: {
            var count = 0;
            if (musicIntf.state == "playing" || musicIntf.state == "paused")
                count = count+1;
            if (backSettingsModel.get(0).isVisible)
                count = count + musicRecentsModel.count;
            if (backSettingsModel.get(1).isVisible)
                count = count + playlistsModel.count;
            if (count)
                return itemModelOne;
            else
                return itemModelOOBE;
//            (((playlistsModel.count + musicRecentsModel.count == 0) && (musicIntf.state != "playing" && musicIntf.state != "paused")) ? itemModelOOBE : itemModelOne)
        }
        leftIconSource: "image://theme/panels/pnl_icn_music"
    }

    back: BackPanelStandard {
        panelTitle: qsTr("Music settings")
        //panelContent: itemModelSizes
        settingsListModel: backSettingsModel
        isBackPanel: true
        leftIconSource: "image://theme/panels/pnl_icn_music"

        onClearHistClicked:{
            musicRecentsModel.clear()
        }

    }

    MusicInterface {
        id: musicIntf
        property bool ready: false;
        //Work around some weird delays in the dbus propogation of the currently playing/next tracks
        //Actually, I think the issue is in the MusicListModel - my theory
        //is that, if tracker hasn't populated the URNs we're requesting into the MusicDatabase yet,
        //then we won't get anything from the model...
        //So, we're really just giving tracker time to populate the DB on startup...
        Component.onCompleted: {
            if (state == "playing" || state == "paused") {
                refreshTimer.start();
            } else {
                ready = true;
            }
        }
    }

    Timer {
        id: refreshTimer
        interval: 3000
        onTriggered: {
            console.log("Refreshing music!");
            musicIntf.refresh()
            musicIntf.ready = true;
        }
    }

    resources: [
        VisualItemModel {
            id: itemModelOOBE
            Item {
                height: container.height
                width: container.width
                //anchors.left:  container.left
                //anchors.left: parent.left


                Text {
                    id: textOOBE
                    anchors.left: parent.left
                    anchors.right:  parent.right
                    anchors.top: parent.top
                    anchors.topMargin: panelSize.contentTopMargin
                    anchors.leftMargin: panelSize.contentSideMargin
                    anchors.rightMargin: panelSize.contentSideMargin
                    width: parent.width
                    text: qsTr("Enjoy your music.")
                    wrapMode: Text.WrapAtWordBoundaryOrAnywhere
                    color: panelColors.textColor
                }

                Button {
                    id: btnOOBE
                    anchors.top:  textOOBE.bottom
                    anchors.topMargin: panelSize.contentTopMargin
                    title: qsTr("Open Music!")
                    anchors.horizontalCenter: parent.horizontalCenter
                    onClicked: {
                        spinnerContainer.startSpinner();<commit_msg>Actually finish fixing music panel side of BMC#15306 - Music & Web panels are flickable even when OOBE content is shown<commit_after>/*
 * Copyright 2011 Intel Corporation.
 *
 * This program is licensed under the terms and conditions of the
 * Apache License, version 2.0.  The full text of the Apache License is at 	
 * http://www.apache.org/licenses/LICENSE-2.0
 */

import Qt 4.7
import MeeGo.Labs.Components 0.1
import MeeGo.Panels 0.1
import MeeGo.Sharing 0.1
import MeeGo.Media 0.1

FlipPanel {
    id: container

    Translator {
        catalog: "meego-ux-panels-music"
    }

    //Because we do not have a universal launcher
    //Need to modify model that this app is launched
    function notifyModel()
    {
        appsModel.favorites.append("/usr/share/meego-ux-appgrid/applications/meego-app-music.desktop")
    }


    ListModel{
        id: backSettingsModel

        ListElement {
            //i18n OK, as it gets properly set in the Component.onCompleted - long drama why this is necessary - limitation in QML translation capabilities
            settingsTitle: "Recently played"
            custPropName: "RecentlyPlayed"
            isVisible: true
        }
        ListElement {
            //i18n OK, as it gets properly set in the Component.onCompleted - long drama why this is necessary - limitation in QML translation capabilities
            settingsTitle: "Playlists"
            custPropName: "Playlists"
            isVisible: true
        }

        //Get around i18n issues w/ the qsTr of the strings being in a different file
        Component.onCompleted: {
            backSettingsModel.setProperty(0, "settingsTitle", qsTr("Recently played"));
            backSettingsModel.setProperty(1, "settingsTitle", qsTr("Playlists"));
        }
    }



    MusicListModel {
        id: musicRecentsModel
        type:MusicListModel.ListofRecentlyPlayed
        limit: 2
        sort: MusicListModel.SortByDefault
    }

    onPanelObjChanged: {
        playlistsModel.hideItemsByURN(panelObj.HiddenItems);
        musicRecentsModel.hideItemsByURN(panelObj.HiddenItems);
    }



    MusicListModel {
        id: playlistsModel
        type:MusicListModel.ListofPlaylists
        limit: 0
        sort: MusicListModel.SortByDefault
    }



    front: Panel {
        panelTitle: qsTr("Music")
        panelContent: {
            var count = 0;
            if (musicIntf.state == "playing" || musicIntf.state == "paused")
                count = count+1;
            if (backSettingsModel.get(0).isVisible)
                count = count + musicRecentsModel.count;
            if (backSettingsModel.get(1).isVisible)
                count = count + playlistsModel.count;
            if (count)
                return itemModelOne;
            else
                return itemModelOOBE;
//            (((playlistsModel.count + musicRecentsModel.count == 0) && (musicIntf.state != "playing" && musicIntf.state != "paused")) ? itemModelOOBE : itemModelOne)
        }
        leftIconSource: "image://theme/panels/pnl_icn_music"
    }

    back: BackPanelStandard {
        panelTitle: qsTr("Music settings")
        //panelContent: itemModelSizes
        settingsListModel: backSettingsModel
        isBackPanel: true
        leftIconSource: "image://theme/panels/pnl_icn_music"

        onClearHistClicked:{
            musicRecentsModel.clear()
        }

    }

    MusicInterface {
        id: musicIntf
        property bool ready: false;
        //Work around some weird delays in the dbus propogation of the currently playing/next tracks
        //Actually, I think the issue is in the MusicListModel - my theory
        //is that, if tracker hasn't populated the URNs we're requesting into the MusicDatabase yet,
        //then we won't get anything from the model...
        //So, we're really just giving tracker time to populate the DB on startup...
        Component.onCompleted: {
            if (state == "playing" || state == "paused") {
                refreshTimer.start();
            } else {
                ready = true;
            }
        }
    }

    Timer {
        id: refreshTimer
        interval: 3000
        onTriggered: {
            console.log("Refreshing music!");
            musicIntf.refresh()
            musicIntf.ready = true;
        }
    }

    resources: [
        VisualItemModel {
            id: itemModelOOBE
            Item {
                height: childrenRect.height
                width: container.width
                //anchors.left:  container.left
                //anchors.left: parent.left


                Text {
                    id: textOOBE
                    anchors.left: parent.left
                    anchors.right:  parent.right
                    anchors.top: parent.top
                    anchors.topMargin: panelSize.contentTopMargin
                    anchors.leftMargin: panelSize.contentSideMargin
                    anchors.rightMargin: panelSize.contentSideMargin
                    width: parent.width
                    text: qsTr("Enjoy your music.")
                    wrapMode: Text.WrapAtWordBoundaryOrAnywhere
                    color: panelColors.textColor
                }

                Button {
                    id: btnOOBE
                    anchors.top:  textOOBE.bottom
                    anchors.topMargin: panelSize.contentTopMargin
                    title: qsTr("Open Music!")
                    anchors.horizontalCenter: parent.horizontalCenter
                    onClicked: {
                        spinnerContainer.startSpinner();
{'fraction_non_alphanumeric': 0.0787593814992314, 'fraction_numerical': 0.00714350302920698, 'mean_word_length': 1.7594810379241517, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1051764', 'n_tokens_mistral': 3039, 'n_tokens_neox': 2842, 'n_words': 759}