Skip to content
main.qml 4.5 KiB
Newer Older
Kevin Whitaker's avatar
Kevin Whitaker committed
/***************************************************************************
 *   Copyright (C) 2019 by Kevin Whiaker <eyecreate@eyecreate.org>                            *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA .        *
 ***************************************************************************/

import QtQuick 2.1
import QtQuick.Layouts 1.1
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.plasmoid 2.0
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.plasma.extras 2.0 as PlasmaExtras

Item {
    Plasmoid.fullRepresentation: ColumnLayout {
        Layout.minimumWidth: units.gridUnit * 20
        Layout.minimumHeight: units.gridUnit * 10
       
        PlasmaExtras.ScrollArea {
            id:scrollingList
            Layout.fillHeight: true
            Layout.fillWidth: true
            ListView {
                id:trackList
                delegate:PlasmaComponents.ListItem {
                    checked: index==0?true:false
                    content: Text{
                        text:modelData
                    }
                }
            }
        }
        PlasmaCore.DataSource {
            id:castSource
            engine: "simplecast"
            connectedSources: ["Playlist","CurrentState"]
            interval: 500
            onNewData: {
                if(sourceName == "Playlist")
                {
                    trackList.model = data.trackNames;
                }
            }
        }
        PlasmaComponents.ProgressBar {
            id:trackProgress
            Layout.fillWidth: true
            maximumValue: castSource.data.CurrentState.trackDuration
            value: castSource.data.CurrentState.trackPosition
        }
Kevin Whitaker's avatar
Kevin Whitaker committed
        RowLayout {
            PlasmaComponents.Button {
                Layout.minimumWidth: units.gridUnit * 2
                Layout.minimumHeight: units.gridUnit * 2
Kevin Whitaker's avatar
Kevin Whitaker committed
                iconSource: castSource.data.CurrentState.playingState?"media-playback-pause":"media-playback-start"
                onClicked: {
                    var service = castSource.serviceForSource("CurrentState");
                    var playPause = service.operationDescription("changePlayState");
                    playPause.playing = !castSource.data.CurrentState.playingState;
                    service.startOperationCall(playPause);
                }
            }
            PlasmaComponents.Button {
                Layout.minimumWidth: units.gridUnit * 2
                Layout.minimumHeight: units.gridUnit * 2
Kevin Whitaker's avatar
Kevin Whitaker committed
                iconSource: "media-skip-forward"
                onClicked: {
                    var service = castSource.serviceForSource("CurrentState");
                    var nextTrack = service.operationDescription("skipToNextTrack");
                    service.startOperationCall(nextTrack);
                }
            }
            PlasmaComponents.TextField {
                Layout.fillWidth: true
                Layout.minimumWidth: units.gridWidth * 10
                id:url
            }
            PlasmaComponents.Button {
                text:"Add URL"
                onClicked: {
                    var service = castSource.serviceForSource("CurrentState");
                    var loadTrack = service.operationDescription("addURLToPlaylist");
                    loadTrack.URL = url.text;
                    service.startOperationCall(loadTrack);
                }
            }
        }
    }
    //TODO: Plasmoid.compactRepresentation?
}