harbour-tooter/qml/pages/components/MyMedia.qml

152 lines
4.3 KiB
QML
Raw Normal View History

2017-06-16 17:45:04 +03:00
import QtQuick 2.0
import Sailfish.Silica 1.0
import QtMultimedia 5.0
2017-06-16 17:45:04 +03:00
Item {
2020-06-29 11:48:06 +03:00
id: myMedia
2017-06-16 17:45:04 +03:00
property string type : ""
property string previewURL: ""
property string mediaURL: ""
property string url: ""
2017-07-20 13:14:16 +03:00
Rectangle {
2020-06-22 21:13:05 +03:00
opacity: 0.4
2017-07-20 13:14:16 +03:00
color: Theme.highlightDimmerColor
anchors.fill: parent
2017-07-20 13:14:16 +03:00
}
2017-07-20 13:14:16 +03:00
Image {
2020-06-29 11:48:06 +03:00
visible: type == 'image'
opacity: img.status === Image.Ready ? 0.0 : 1.0
2020-06-22 21:13:05 +03:00
Behavior on opacity { FadeAnimator {} }
2020-06-29 11:48:06 +03:00
source: "image://theme/icon-m-image?"
anchors.centerIn: parent
}
Image {
visible: type == 'video' || type == "gifv"
opacity: img.status === Image.Ready ? 0.0 : 1.0
Behavior on opacity { FadeAnimator {} }
source: "image://theme/icon-m-file-video?"
anchors.centerIn: parent
}
Text {
anchors{
topMargin: 10
}
id: audioUrl
visible: type == 'audio'
text: "<a href='" + url + "'>" + 'Audio file' + '</a>'
font.pixelSize: Theme.fontSizeLarge
}
2020-06-29 11:48:06 +03:00
//Image {
MediaItem {
id: audioContent
2020-06-29 11:48:06 +03:00
visible: type == 'audio'
opacity: img.status === Image.Ready ? 0.0 : 1.0
2020-06-29 11:48:06 +03:00
Behavior on opacity { FadeAnimator {} }
mimeType: 'audio/mp3'
url: url
//source: "image://theme/icon-m-file-audio?"
anchors.centerIn: parent
/*MouseArea {
anchors.fill: parent
onClicked: {
pageStack.push(Qt.resolvedUrl("./MediaFullScreen.qml"), {
"url": url,
"type": type
})
}
}*/
2017-07-20 13:14:16 +03:00
}
2017-07-20 16:26:20 +03:00
Rectangle {
id: progressRec
width: 0
height: Theme.paddingSmall
color: Theme.highlightBackgroundColor
anchors.bottom: parent.bottom
2017-07-20 16:26:20 +03:00
}
2017-06-16 17:45:04 +03:00
Image {
id: img
2020-06-29 11:48:06 +03:00
visible: type != 'audio'
2017-06-16 17:45:04 +03:00
asynchronous: true
opacity: status === Image.Ready ? 1.0 : 0.0
Behavior on opacity { FadeAnimator {} }
source: previewURL
fillMode: Image.PreserveAspectCrop
anchors.fill: parent
2017-07-20 16:26:20 +03:00
onProgressChanged: {
if (progress != 1)
progressRec.width = parent.width * progress
else {
progressRec.width = 0;
}
}
2017-06-16 17:45:04 +03:00
MouseArea {
anchors.fill: parent
onClicked: {
pageStack.push(Qt.resolvedUrl("./MediaFullScreen.qml"), {
"previewURL": previewURL,
"mediaURL": mediaURL,
"type": type
})
2017-06-16 17:45:04 +03:00
}
}
Image {
id: videoIcon
visible: type === "video" || type === "gifv"
2020-06-29 11:48:06 +03:00
source: "image://theme/icon-l-play?"
anchors.centerIn: parent
}
BusyIndicator {
id: mediaLoader
2020-07-03 11:45:30 +03:00
visible: type != 'audio'
size: BusyIndicatorSize.Large
running: img.status !== Image.Ready
opacity: img.status === Image.Ready ? 0.0 : 1.0
2020-07-03 11:45:30 +03:00
anchors {
verticalCenter: parent.verticalCenter
horizontalCenter: parent.horizontalCenter
}
}
Rectangle {
id: mediaWarning
color: Theme.highlightDimmerColor
2020-06-22 21:13:05 +03:00
visible: typeof status_sensitive != "undefined" && status_sensitive ? true : false
Image {
source: "image://theme/icon-l-attention?"+Theme.highlightColor
anchors.centerIn: parent
}
2020-07-03 11:45:30 +03:00
anchors.fill: parent
MouseArea {
anchors.fill: parent
onClicked: parent.visible = false
}
}
IconButton {
id: mediaDlBtn
icon.source: "image://theme/icon-m-cloud-download"
anchors {
right: parent.right
rightMargin: Theme.horizontalPageMargin
bottom: parent.bottom
bottomMargin: Theme.horizontalPageMargin
}
onClicked: {
var filename = url.split("/")
FileDownloader.downloadFile(url, filename[filename.length-1])
}
}
2017-06-16 17:45:04 +03:00
}
}