Warning, /network/kdeconnect-kde/smsapp/qml/AttachmentViewer.qml is written in an unsupported language. File is not indexed.
0001 /** 0002 * SPDX-FileCopyrightText: 2020 Aniket Kumar <anikketkumar786@gmail.com> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 */ 0006 0007 import QtQuick 0008 import QtQuick.Layouts 0009 import QtQuick.Controls 0010 import org.kde.kirigami as Kirigami 0011 import QtMultimedia 0012 0013 Kirigami.Page { 0014 id: root 0015 property string filePath 0016 property string mimeType 0017 0018 actions: [ 0019 Kirigami.Action { 0020 text: i18nd("kdeconnect-sms", "Open with default") 0021 icon.name: "window-new" 0022 onTriggered: { 0023 Qt.openUrlExternally(filePath); 0024 } 0025 } 0026 ] 0027 0028 contentItem: Rectangle { 0029 anchors.fill: parent 0030 0031 Rectangle { 0032 id: imageViewer 0033 visible: mimeType.match("image") 0034 anchors.horizontalCenter: parent.horizontalCenter 0035 width: image.width 0036 height: parent.height - y 0037 y: root.implicitHeaderHeight 0038 color: parent.color 0039 0040 Image { 0041 id: image 0042 source: parent.visible ? filePath : "" 0043 anchors.horizontalCenter: parent.horizontalCenter 0044 anchors.verticalCenter: parent.verticalCenter 0045 width: sourceSize.width 0046 height: parent.height 0047 fillMode: Image.PreserveAspectFit 0048 } 0049 } 0050 0051 MediaPlayer { 0052 id: mediaPlayer 0053 source: filePath 0054 0055 onPositionChanged: { 0056 if (mediaPlayer.position > 1000 && mediaPlayer.duration - mediaPlayer.position < 1000) { 0057 playAndPauseButton.icon.name = "media-playback-start" 0058 mediaPlayer.pause() 0059 mediaPlayer.seek(0) 0060 } 0061 } 0062 } 0063 0064 Item { 0065 width: parent.width 0066 height: parent.height - mediaControls.height 0067 anchors.topMargin: root.implicitHeaderHeight 0068 0069 MediaPlayer { 0070 source: mediaPlayer 0071 videoOutput: VideoOutput { 0072 anchors.fill: parent 0073 fillMode: VideoOutput.PreserveAspectFit 0074 0075 // By default QML's videoOutput element rotates the vdeeo files by 90 degrees in clockwise direction 0076 orientation: -90 0077 } 0078 } 0079 } 0080 0081 Rectangle { 0082 id: mediaControls 0083 visible: mimeType.match("video") 0084 width: parent.width 0085 height: 50 0086 anchors.horizontalCenter: parent.horizontalCenter 0087 anchors.bottom: parent.bottom 0088 color: Kirigami.Theme.backgroundColor 0089 0090 Rectangle { 0091 anchors.top: parent.top 0092 width: parent.width 0093 height: 1 0094 color: "lightGray" 0095 } 0096 0097 ColumnLayout { 0098 anchors.horizontalCenter: parent.horizontalCenter 0099 width: parent.width 0100 0101 Rectangle { 0102 id: progressBar 0103 Layout.fillWidth: parent 0104 Layout.leftMargin: Kirigami.Units.largeSpacing 0105 Layout.rightMargin: Kirigami.Units.largeSpacing 0106 Layout.topMargin: Kirigami.Units.smallSpacing 0107 radius: 5 0108 height: 5 0109 0110 color: "gray" 0111 0112 Rectangle { 0113 anchors.left: parent.left 0114 anchors.top: parent.top 0115 anchors.bottom: parent.bottom 0116 radius: 5 0117 0118 width: mediaPlayer.duration > 0 ? parent.width*mediaPlayer.position/mediaPlayer.duration : 0 0119 0120 color: { 0121 Kirigami.Theme.colorSet = Kirigami.Theme.View 0122 var accentColor = Kirigami.Theme.highlightColor 0123 return Qt.tint(Kirigami.Theme.backgroundColor, Qt.rgba(accentColor.r, accentColor.g, accentColor.b, 1)) 0124 } 0125 } 0126 0127 MouseArea { 0128 anchors.fill: parent 0129 0130 onClicked: { 0131 if (mediaPlayer.seekable) { 0132 mediaPlayer.seek(mediaPlayer.duration * mouse.x/width); 0133 } 0134 } 0135 } 0136 } 0137 0138 RowLayout { 0139 Layout.alignment: Qt.AlignHCenter 0140 spacing: Kirigami.Units.largeSpacing 0141 0142 Button { 0143 id: backwardButton 0144 icon.name: "media-seek-backward" 0145 0146 onClicked: { 0147 if (mediaPlayer.seekable) { 0148 mediaPlayer.seek(mediaPlayer.position - 2000) 0149 } 0150 } 0151 } 0152 0153 Button { 0154 id: playAndPauseButton 0155 icon.name: "media-playback-pause" 0156 0157 onClicked: { 0158 if (icon.name == "media-playback-start") { 0159 mediaPlayer.play() 0160 icon.name = "media-playback-pause" 0161 } else { 0162 mediaPlayer.pause() 0163 icon.name = "media-playback-start" 0164 } 0165 } 0166 } 0167 0168 Button { 0169 id: forwardButton 0170 icon.name: "media-seek-forward" 0171 0172 onClicked: { 0173 if (mediaPlayer.seekable) { 0174 mediaPlayer.seek(mediaPlayer.position + 2000) 0175 } 0176 } 0177 } 0178 } 0179 } 0180 } 0181 } 0182 0183 Component.onCompleted: { 0184 mediaPlayer.play() 0185 } 0186 }