import Quickshell
import Quickshell.Io
import QtQuick
import QtQuick.Layouts
import Quickshell.Widgets
import QtQuick.Effects
// import playbutton.svg

Item {
    id: root
    Layout.fillHeight: true
    implicitWidth: hi.width
    property PlayerControllerV2 player: PlayerControllerV2;

    MouseArea {
        anchors.fill: parent
        hoverEnabled: true
        onEntered: event => {
            audioPopup.visible = true;
        }
        onExited: event => {
            audioPopup.visible = false;
        }
    }
    Image {
        source: player.activePlayer.trackArtUrl;
        anchors.fill: parent
        fillMode: Image.PreserveAspectCrop

        layer.enabled: true
        layer.effect: MultiEffect {
            blur: 0.3
            blurEnabled: true
        }
    }
    // parent.aaaaa: false
    RowLayout {
        id: hi
        Item {
            implicitHeight: 30;
            implicitWidth: 30;
            IconImage {
                implicitSize: 30;
                source: "root:assets/media_player/skip_next.svg";
                scale: -1
            }
            MouseArea {
                anchors.fill: parent
                onPressed: event => {
                    player.activePlayer.previous();
                }
            }
        }
        Item {
            implicitHeight: 30;
            implicitWidth: 30;
            IconImage {
                implicitSize: 30;
                source: !player.activePlayer.isPlaying ? "root:/assets/media_player/playbutton.svg" : "root:/assets/media_player/pausebutton.svg";
            }
            MouseArea {
                anchors.fill: parent
                hoverEnabled: false
                onPressed: event => {
                    player.activePlayer.togglePlaying();
                }
            }
        }

        Item {
            implicitHeight: 30;
            implicitWidth: 30;
            IconImage {
                implicitSize: 30;
                source: "root:assets/media_player/skip_next.svg";
            }
            MouseArea {
                anchors.fill: parent
                onPressed: event => {
                    player.activePlayer.next();
                }
            }
        }
    }
    PlayerPopup {
        id: audioPopup
    }
}
