From 7290b39664f87dd8a3bf81589749f65694ea61f8 Mon Sep 17 00:00:00 2001 From: Jooncheol Park Date: Wed, 15 Apr 2015 19:42:24 +0900 Subject: Initial commit for AM Monitor --- Button.qml | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 Button.qml (limited to 'Button.qml') diff --git a/Button.qml b/Button.qml new file mode 100644 index 0000000..2607ccb --- /dev/null +++ b/Button.qml @@ -0,0 +1,96 @@ +import QtQuick 2.0 +import com.windriver.ammonitor 1.0 + +Item { + id :button + anchors.horizontalCenter: parent.horizontalCenter + width: 100 + height: 100 + property bool pressed: hitbox.pressed && hitbox.containsMouse + + property var amCommandIF + property string amSource + property string amSink + property string mediaRole + property string audioFilePath + property int connectionID : 0 + property string iconName + property string title : "no title" + + Rectangle { + anchors.fill: parent + anchors.margins: 4 + color: paplayer.playing?"darkGray":"lightGray" + radius: 10 + border.width: 1 + border.color: "gray" + + Image { + id: icon + height: (pressed||paplayer.playing)?(parent.height/3):(parent.height/2) + fillMode: Image.PreserveAspectFit + anchors.horizontalCenter: parent.horizontalCenter + y: (parent.height - (height + titleText.height)) / 2 + source: "images/icon_"+iconName+".png" + } + Image { + height: parent.height / 5 + fillMode: Image.PreserveAspectFit + x: parent.width - width - (width/2) + y: (height/2) + source: "images/volume-up.png" + visible: paplayer.playing + } + Text { + id: titleText + anchors.top: icon.bottom + anchors.horizontalCenter: parent.horizontalCenter + text: title + font.pixelSize: parent.height / 6 + } + Text { + id: descText + visible: pressed||paplayer.playing + anchors.top: titleText.bottom + anchors.horizontalCenter: parent.horizontalCenter + //text: "Connecting '"+amSource+"' to '"+amSink+"'" + text: amSource+" => "+amSink + font.pixelSize: parent.height / 10 + } + PAPlayer { + id: paplayer + role: mediaRole + file: audioFilePath + source: amSource + sink: amSink + onPlayStateChanged: { + if(!playing && button.connectionID != 0) { + console.log('11 trying to disconnect AM connection: '+button.connectionID) + amCommandIF.disconnect(button.connectionID); + button.connectionID = 0 + } + } + } + + MouseArea { + id: hitbox + anchors.fill: parent + onClicked : { + if(paplayer.isPlaying()) { + console.log('trying to disconnect AM connection: '+button.connectionID) + if(button.connectionID != 0) { + if(amCommandIF.disconnect(button.connectionID)) + paplayer.stop() + button.connectionID = 0 + } + } else { + button.connectionID = amCommandIF.connect(amSource, amSink); + console.log('AM Connected: '+button.connectionID) + if(button.connectionID > 0) + paplayer.play() + } + } + } + } +} + -- cgit v1.2.1