Warning, /plasma-bigscreen/youtube-voice-application/ui/SeekControl.qml is written in an unsupported language. File is not indexed.
0001 import QtMultimedia 5.13 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 0087 Image { 0088 anchors.centerIn: parent 0089 width: parent.width * 0.50 0090 height: width 0091 source: "images/back.png" 0092 } 0093 0094 z: 1000 0095 onClicked: { 0096 Mycroft.MycroftController.sendRequest("mycroft.gui.screen.close", {}); 0097 video.stop(); 0098 } 0099 KeyNavigation.up: video 0100 KeyNavigation.right: button 0101 Keys.onReturnPressed: { 0102 hideTimer.restart(); 0103 Mycroft.MycroftController.sendRequest("mycroft.gui.screen.close", {}); 0104 video.stop(); 0105 } 0106 onFocusChanged: { 0107 hideTimer.restart(); 0108 } 0109 } 0110 Controls.RoundButton { 0111 id: button 0112 Layout.preferredWidth: parent.width > 600 ? Kirigami.Units.iconSizes.large : Kirigami.Units.iconSizes.medium 0113 Layout.preferredHeight: Layout.preferredWidth 0114 highlighted: focus ? 1 : 0 0115 0116 Image { 0117 anchors.centerIn: parent 0118 width: parent.width * 0.50 0119 height: width 0120 source: videoControl.playbackState === MediaPlayer.PlayingState ? Qt.resolvedUrl("images/simple-pause.svg") : Qt.resolvedUrl("images/simple-play.svg") 0121 } 0122 0123 z: 1000 0124 onClicked: { 0125 video.playbackState === MediaPlayer.PlayingState ? video.pause() : video.play(); 0126 hideTimer.restart(); 0127 } 0128 KeyNavigation.up: video 0129 KeyNavigation.left: backButton 0130 KeyNavigation.right: slider 0131 Keys.onReturnPressed: { 0132 video.playbackState === MediaPlayer.PlayingState ? video.pause() : video.play(); 0133 hideTimer.restart(); 0134 } 0135 onFocusChanged: { 0136 hideTimer.restart(); 0137 } 0138 } 0139 0140 Templates.Slider { 0141 id: slider 0142 Layout.fillWidth: true 0143 Layout.alignment: Qt.AlignVCenter 0144 implicitHeight: Kirigami.Units.gridUnit 0145 value: seekControl.playPosition 0146 from: 0 0147 to: seekControl.duration 0148 z: 1000 0149 property bool navSliderItem 0150 property int minimumValue: 0 0151 property int maximumValue: 20 0152 onMoved: { 0153 seekControl.seekPosition = value; 0154 hideTimer.restart(); 0155 } 0156 0157 onNavSliderItemChanged: { 0158 if(slider.navSliderItem){ 0159 recthandler.color = "red" 0160 } else if (slider.focus) { 0161 recthandler.color = Kirigami.Theme.linkColor 0162 } 0163 } 0164 0165 onFocusChanged: { 0166 if(!slider.focus){ 0167 recthandler.color = Kirigami.Theme.textColor 0168 } else { 0169 recthandler.color = Kirigami.Theme.linkColor 0170 } 0171 } 0172 0173 handle: Rectangle { 0174 id: recthandler 0175 x: slider.position * (parent.width - width) 0176 implicitWidth: Kirigami.Units.gridUnit 0177 implicitHeight: implicitWidth 0178 radius: width 0179 color: Kirigami.Theme.textColor 0180 } 0181 background: Item { 0182 Rectangle { 0183 id: groove 0184 anchors { 0185 verticalCenter: parent.verticalCenter 0186 left: parent.left 0187 right: parent.right 0188 } 0189 radius: height 0190 height: Math.round(Kirigami.Units.gridUnit/3) 0191 color: Qt.rgba(Kirigami.Theme.textColor.r, Kirigami.Theme.textColor.g, Kirigami.Theme.textColor.b, 0.3) 0192 Rectangle { 0193 anchors { 0194 left: parent.left 0195 top: parent.top 0196 bottom: parent.bottom 0197 } 0198 radius: height 0199 color: Kirigami.Theme.highlightColor 0200 width: slider.position * (parent.width - slider.handle.width/2) + slider.handle.width/2 0201 } 0202 } 0203 0204 Controls.Label { 0205 anchors { 0206 left: parent.left 0207 top: groove.bottom 0208 topMargin: Kirigami.Units.smallSpacing 0209 } 0210 horizontalAlignment: Text.AlignLeft 0211 verticalAlignment: Text.AlignVCenter 0212 text: formatTime(playPosition) 0213 color: "white" 0214 } 0215 0216 Controls.Label { 0217 anchors { 0218 right: parent.right 0219 top: groove.bottom 0220 topMargin: Kirigami.Units.smallSpacing 0221 } 0222 horizontalAlignment: Text.AlignRight 0223 verticalAlignment: Text.AlignVCenter 0224 text: formatTime(duration) 0225 } 0226 } 0227 KeyNavigation.up: video 0228 KeyNavigation.left: button 0229 Keys.onReturnPressed: { 0230 hideTimer.restart(); 0231 if(!navSliderItem){ 0232 navSliderItem = true 0233 } else { 0234 navSliderItem = false 0235 } 0236 } 0237 0238 Keys.onLeftPressed: { 0239 console.log("leftPressedonSlider") 0240 hideTimer.restart(); 0241 if(navSliderItem) { 0242 video.seek(video.position - 5000) 0243 } else { 0244 button.forceActiveFocus() 0245 } 0246 } 0247 0248 Keys.onRightPressed: { 0249 hideTimer.restart(); 0250 if(navSliderItem) { 0251 video.seek(video.position + 5000) 0252 } 0253 } 0254 } 0255 0256 Controls.RoundButton { 0257 id: infoButton 0258 height: Kirigami.Units.gridUnit * 2 0259 Layout.preferredWidth: parent.width > 600 ? Kirigami.Units.iconSizes.large : Kirigami.Units.iconSizes.medium 0260 Layout.preferredHeight: Layout.preferredWidth 0261 highlighted: focus ? 1 : 0 0262 z: 1000 0263 0264 Image { 0265 anchors.centerIn: parent 0266 width: parent.width * 0.50 0267 height: width 0268 source: "images/information.png" 0269 } 0270 0271 onClicked: { 0272 videoInformationPop.open() 0273 hideTimer.restart(); 0274 } 0275 KeyNavigation.up: video 0276 KeyNavigation.left: slider 0277 Keys.onReturnPressed: { 0278 clicked() 0279 } 0280 onFocusChanged: { 0281 hideTimer.restart(); 0282 } 0283 } 0284 } 0285 } 0286 } 0287 0288 Controls.Popup { 0289 id: videoInformationPop 0290 width: parent.width - Kirigami.Units.gridUnit * 4 0291 height: width 0292 parent: root 0293 x: Math.round((parent.width - width) / 2) 0294 y: Math.round((parent.height - height) / 2) 0295 dim: true 0296 0297 background: Rectangle { 0298 color: Qt.rgba(0,0,0,0.8) 0299 } 0300 0301 contentItem: Item { 0302 ColumnLayout { 0303 id: informationColumn 0304 width: parent.width 0305 spacing: Kirigami.Units.largeSpacing 0306 0307 Controls.Label { 0308 id: vidTitle 0309 visible: true 0310 maximumLineCount: 2 0311 wrapMode: Text.Wrap 0312 Layout.maximumWidth: parent.width 0313 Layout.alignment: Qt.AlignTop | Qt.AlignLeft 0314 text: "Title: " + videoTitle 0315 z: 100 0316 } 0317 0318 Controls.Label { 0319 id: vidAuthor 0320 visible: true 0321 maximumLineCount: 2 0322 wrapMode: Text.Wrap 0323 Layout.maximumWidth: parent.width 0324 Layout.alignment: Qt.AlignTop | Qt.AlignLeft 0325 text: "Published By: " + videoAuthor 0326 z: 100 0327 } 0328 0329 Controls.Label { 0330 id: vidCount 0331 visible: true 0332 maximumLineCount: 2 0333 wrapMode: Text.Wrap 0334 Layout.maximumWidth: parent.width 0335 Layout.alignment: Qt.AlignTop | Qt.AlignLeft 0336 text: "Views: " + getViewCount(videoViewCount) 0337 z: 100 0338 } 0339 0340 Controls.Label { 0341 id: vidPublishDate 0342 visible: true 0343 maximumLineCount: 2 0344 wrapMode: Text.Wrap 0345 Layout.maximumWidth: parent.width 0346 Layout.alignment: Qt.AlignTop | Qt.AlignLeft 0347 text: setPublishedDate(videoPublishDate) 0348 z: 100 0349 } 0350 } 0351 0352 Controls.Button { 0353 id: closeInformationBarButton 0354 anchors.bottom: parent.bottom 0355 width: parent.width 0356 height: parent.height * 0.15 0357 text: "Close" 0358 icon.name: "dialog-close" 0359 onClicked: { 0360 videoInformationPop.close() 0361 } 0362 } 0363 } 0364 } 0365 0366 function formatTime(timeInMs) { 0367 if (!timeInMs || timeInMs <= 0) return "0:00" 0368 var seconds = timeInMs / 1000; 0369 var minutes = Math.floor(seconds / 60) 0370 seconds = Math.floor(seconds % 60) 0371 if (seconds < 10) seconds = "0" + seconds; 0372 return minutes + ":" + seconds 0373 } 0374 }