import QtQuick 2.0

Item {
    id:root
    Loader{
        id:loader
        anchors.fill: parent
    }

    function show(text){

        if(loader.sourceComponent  === null){
            loader.sourceComponent  = component
        }
        loader.item.text = text
        //loader.item.bg.color="black"
        console.log(text)
    }

    function show2(text){

        if(loader.sourceComponent  === null){
            loader.sourceComponent  = component
        }
        loader.item.text = text
        //loader.item.bg.color="red"
        console.log(text)
    }

    function exit(){
        loader.sourceComponent = undefined
    }


    Component{
        id:component
        Item {
            id:item
            property alias text:fgtext.text


            Rectangle{
                id:bg
                anchors.fill: parent
                color: "black"
                opacity: 0.5
                radius: 4
                MouseArea{
                    anchors.fill: parent
                    drag.target:item
                    drag.axis:Drag.XAndYAxis
                }
            }

            Item {
                id:fg
                z:bg.z+1
                anchors.fill: parent
                Text {
                    id: fgtext
                    anchors.centerIn: parent
                    color: "white"
                    font.bold: true
                    font.pixelSize: 15
                }
                Image {
                    anchors.right: parent.right
                    anchors.top: parent.top
                    source: "qrc:/img/close.png"
                    MouseArea{
                        anchors.fill: parent
                        onClicked:{
                            root.exit()
                        }
                    }
                }

            }
        }
    }

}
