Warning, /plasma-bigscreen/youtube-voice-application/ui/+android/SeekControl.qml is written in an unsupported language. File is not indexed.
0001 import QtMultimedia 5.12 0002 import QtQuick.Layouts 1.4 0003 import QtQuick 2.9 0004 import QtQuick.Controls 2.12 as Controls 0005 import org.kde.kirigami 2.10 as Kirigami 0006 import QtQuick.Templates 2.2 as Templates 0007 import QtGraphicalEffects 1.0 0008 0009 import Mycroft 1.0 as Mycroft 0010 0011 Item { 0012 id: seekControl 0013 property bool opened: false 0014 property int duration: 0 0015 property int playPosition: 0 0016 property int seekPosition: 0 0017 property bool enabled: true 0018 property bool seeking: false 0019 property var videoControl 0020 property string title 0021 0022 clip: true 0023 implicitWidth: parent.width 0024 implicitHeight: mainLayout.implicitHeight + Kirigami.Units.largeSpacing * 2 0025 opacity: opened 0026 0027 Behavior on opacity { 0028 OpacityAnimator { 0029 duration: Kirigami.Units.longDuration 0030 easing.type: Easing.InOutCubic 0031 } 0032 } 0033 0034 onOpenedChanged: { 0035 if (opened) { 0036 hideTimer.restart(); 0037 } 0038 } 0039 0040 onFocusChanged: { 0041 if(focus) { 0042 backButton.forceActiveFocus() 0043 } 0044 } 0045 0046 Timer { 0047 id: hideTimer 0048 interval: 5000 0049 onTriggered: { 0050 seekControl.opened = false; 0051 videoRoot.forceActiveFocus(); 0052 } 0053 } 0054 0055 Rectangle { 0056 width: parent.width 0057 height: parent.height 0058 color: Qt.rgba(Kirigami.Theme.backgroundColor.r, Kirigami.Theme.backgroundColor.g, Kirigami.Theme.backgroundColor.b, 0.6) 0059 //color: "white" 0060 y: opened ? 0 : parent.height 0061 0062 Behavior on y { 0063 YAnimator { 0064 duration: Kirigami.Units.longDuration 0065 easing.type: Easing.OutCubic 0066 } 0067 } 0068 0069 ColumnLayout { 0070 id: mainLayout 0071 0072 anchors { 0073 fill: parent 0074 margins: Kirigami.Units.largeSpacing 0075 } 0076 0077 RowLayout { 0078 id: mainLayout2 0079 Layout.fillHeight: true 0080 Controls.RoundButton { 0081 id: backButton 0082 height: Kirigami.Units.gridUnit * 2 0083 Layout.preferredWidth: parent.width > 600 ? Kirigami.Units.iconSizes.large : Kirigami.Units.iconSizes.medium 0084 Layout.preferredHeight: Layout.preferredWidth 0085 highlighted: focus ? 1 : 0 0086 icon.name: "go-previous-symbolic" 0087 z: 1000 0088 onClicked: { 0089 Mycroft.MycroftController.sendRequest("mycroft.gui.screen.close", {}); 0090 video.stop(); 0091 } 0092 KeyNavigation.up: video 0093 KeyNavigation.right: button 0094 Keys.onReturnPressed: { 0095 hideTimer.restart(); 0096 Mycroft.MycroftController.sendRequest("mycroft.gui.screen.close", {}); 0097 video.stop(); 0098 } 0099 onFocusChanged: { 0100 hideTimer.restart(); 0101 } 0102 } 0103 Controls.RoundButton { 0104 id: button 0105 Layout.preferredWidth: parent.width > 600 ? Kirigami.Units.iconSizes.large : Kirigami.Units.iconSizes.medium 0106 Layout.preferredHeight: Layout.preferredWidth 0107 highlighted: focus ? 1 : 0 0108 icon.name: videoControl.playbackState === MediaPlayer.PlayingState ? "media-playback-pause" : "media-playback-start" 0109 z: 1000 0110 onClicked: { 0111 video.playbackState === MediaPlayer.PlayingState ? video.pause() : video.play(); 0112 hideTimer.restart(); 0113 } 0114 KeyNavigation.up: video 0115 KeyNavigation.left: backButton 0116 KeyNavigation.right: slider 0117 Keys.onReturnPressed: { 0118 video.playbackState === MediaPlayer.PlayingState ? video.pause() : video.play(); 0119 hideTimer.restart(); 0120 } 0121 onFocusChanged: { 0122 hideTimer.restart(); 0123 } 0124 } 0125 0126 Templates.Slider { 0127 id: slider 0128 Layout.fillWidth: true 0129 Layout.alignment: Qt.AlignVCenter 0130 implicitHeight: Kirigami.Units.gridUnit 0131 value: seekControl.playPosition 0132 from: 0 0133 to: seekControl.duration 0134 z: 1000 0135 property bool navSliderItem 0136 property int minimumValue: 0 0137 property int maximumValue: 20 0138 onMoved: { 0139 seekControl.seekPosition = value; 0140 hideTimer.restart(); 0141 } 0142 0143 onNavSliderItemChanged: { 0144 if(slider.navSliderItem){ 0145 recthandler.color = "red" 0146 } else if (slider.focus) { 0147 recthandler.color = Kirigami.Theme.linkColor 0148 } 0149 } 0150 0151 onFocusChanged: { 0152 if(!slider.focus){ 0153 recthandler.color = Kirigami.Theme.textColor 0154 } else { 0155 recthandler.color = Kirigami.Theme.linkColor 0156 } 0157 } 0158 0159 handle: Rectangle { 0160 id: recthandler 0161 x: slider.position * (parent.width - width) 0162 implicitWidth: Kirigami.Units.gridUnit 0163 implicitHeight: implicitWidth 0164 radius: width 0165 color: Kirigami.Theme.textColor 0166 } 0167 background: Item { 0168 Rectangle { 0169 id: groove 0170 anchors { 0171 verticalCenter: parent.verticalCenter 0172 left: parent.left 0173 right: parent.right 0174 } 0175 radius: height 0176 height: Math.round(Kirigami.Units.gridUnit/3) 0177 color: Qt.rgba(Kirigami.Theme.textColor.r, Kirigami.Theme.textColor.g, Kirigami.Theme.textColor.b, 0.3) 0178 Rectangle { 0179 anchors { 0180 left: parent.left 0181 top: parent.top 0182 bottom: parent.bottom 0183 } 0184 radius: height 0185 color: Kirigami.Theme.highlightColor 0186 width: slider.position * (parent.width - slider.handle.width/2) + slider.handle.width/2 0187 } 0188 } 0189 0190 Controls.Label { 0191 anchors { 0192 left: parent.left 0193 top: groove.bottom 0194 topMargin: Kirigami.Units.smallSpacing 0195 } 0196 horizontalAlignment: Text.AlignLeft 0197 verticalAlignment: Text.AlignVCenter 0198 text: formatTime(playPosition) 0199 color: "white" 0200 } 0201 0202 Controls.Label { 0203 anchors { 0204 right: parent.right 0205 top: groove.bottom 0206 topMargin: Kirigami.Units.smallSpacing 0207 } 0208 horizontalAlignment: Text.AlignRight 0209 verticalAlignment: Text.AlignVCenter 0210 text: formatTime(duration) 0211 } 0212 } 0213 KeyNavigation.up: video 0214 KeyNavigation.left: button 0215 Keys.onReturnPressed: { 0216 hideTimer.restart(); 0217 if(!navSliderItem){ 0218 navSliderItem = true 0219 } else { 0220 navSliderItem = false 0221 } 0222 } 0223 0224 Keys.onLeftPressed: { 0225 console.log("leftPressedonSlider") 0226 hideTimer.restart(); 0227 if(navSliderItem) { 0228 video.seek(video.position - 5000) 0229 } else { 0230 button.forceActiveFocus() 0231 } 0232 } 0233 0234 Keys.onRightPressed: { 0235 hideTimer.restart(); 0236 if(navSliderItem) { 0237 video.seek(video.position + 5000) 0238 } 0239 } 0240 } 0241 0242 Controls.RoundButton { 0243 id: infoButton 0244 height: Kirigami.Units.gridUnit * 2 0245 Layout.preferredWidth: parent.width > 600 ? Kirigami.Units.iconSizes.large : Kirigami.Units.iconSizes.medium 0246 Layout.preferredHeight: Layout.preferredWidth 0247 highlighted: focus ? 1 : 0 0248 icon.name: "documentinfo" 0249 z: 1000 0250 onClicked: { 0251 videoInformationPop.open() 0252 hideTimer.restart(); 0253 } 0254 KeyNavigation.up: video 0255 KeyNavigation.left: slider 0256 Keys.onReturnPressed: { 0257 clicked() 0258 } 0259 onFocusChanged: { 0260 hideTimer.restart(); 0261 } 0262 } 0263 } 0264 } 0265 } 0266 0267 Controls.Popup { 0268 id: videoInformationPop 0269 width: parent.width - Kirigami.Units.gridUnit * 4 0270 height: width 0271 parent: root 0272 x: Math.round((parent.width - width) / 2) 0273 y: Math.round((parent.height - height) / 2) 0274 dim: true 0275 0276 background: Rectangle { 0277 color: Qt.rgba(0,0,0,0.8) 0278 } 0279 0280 contentItem: Item { 0281 ColumnLayout { 0282 id: informationColumn 0283 width: parent.width 0284 spacing: Kirigami.Units.largeSpacing 0285 0286 Controls.Label { 0287 id: vidTitle 0288 visible: true 0289 maximumLineCount: 2 0290 wrapMode: Text.Wrap 0291 Layout.maximumWidth: parent.width 0292 Layout.alignment: Qt.AlignTop | Qt.AlignLeft 0293 text: "Title: " + videoTitle 0294 z: 100 0295 } 0296 0297 Controls.Label { 0298 id: vidAuthor 0299 visible: true 0300 maximumLineCount: 2 0301 wrapMode: Text.Wrap 0302 Layout.maximumWidth: parent.width 0303 Layout.alignment: Qt.AlignTop | Qt.AlignLeft 0304 text: "Published By: " + videoAuthor 0305 z: 100 0306 } 0307 0308 Controls.Label { 0309 id: vidCount 0310 visible: true 0311 maximumLineCount: 2 0312 wrapMode: Text.Wrap 0313 Layout.maximumWidth: parent.width 0314 Layout.alignment: Qt.AlignTop | Qt.AlignLeft 0315 text: "Views: " + getViewCount(videoViewCount) 0316 z: 100 0317 } 0318 0319 Controls.Label { 0320 id: vidPublishDate 0321 visible: true 0322 maximumLineCount: 2 0323 wrapMode: Text.Wrap 0324 Layout.maximumWidth: parent.width 0325 Layout.alignment: Qt.AlignTop | Qt.AlignLeft 0326 text: setPublishedDate(videoPublishDate) 0327 z: 100 0328 } 0329 } 0330 0331 Controls.Button { 0332 id: closeInformationBarButton 0333 anchors.bottom: parent.bottom 0334 width: parent.width 0335 height: parent.height * 0.15 0336 text: "Close" 0337 icon.name: "dialog-close" 0338 onClicked: { 0339 videoInformationPop.close() 0340 } 0341 } 0342 } 0343 } 0344 0345 function formatTime(timeInMs) { 0346 if (!timeInMs || timeInMs <= 0) return "0:00" 0347 var seconds = timeInMs / 1000; 0348 var minutes = Math.floor(seconds / 60) 0349 seconds = Math.floor(seconds % 60) 0350 if (seconds < 10) seconds = "0" + seconds; 0351 return minutes + ":" + seconds 0352 } 0353 }