From 86f4f603a15f41003d929366d2c797886cfe7099 Mon Sep 17 00:00:00 2001 From: Chris Cochrun Date: Mon, 22 Jan 2024 13:21:50 -0600 Subject: [PATCH] fixing some things with NewVideo.qml First I've updated the styles to fit better. Then I've moved the timer into the NewVideo.qml item. This will help to make sure we know where that timer is coming from. --- src/qml/presenter/Library.qml | 11 +---------- src/qml/presenter/NewVideo.qml | 34 +++++++++++++++++++++++++--------- 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/src/qml/presenter/Library.qml b/src/qml/presenter/Library.qml index 642766e..cb8e2f6 100644 --- a/src/qml/presenter/Library.qml +++ b/src/qml/presenter/Library.qml @@ -1,4 +1,4 @@ -import QtQuick 2.13 +import QtQuick 2.15 import QtQuick.Controls 2.15 as Controls import QtQuick.Layouts 1.15 import Qt.labs.platform 1.1 as Labs @@ -82,15 +82,6 @@ Item { id: newVideo } - Timer { - id: videoDLTimer - interval: 3000 - running: !newVideo.sheetOpen - onTriggered: { - newVideo.clear(); - } - } - Presenter.LibraryItem { id: imageLibrary Layout.alignment: Qt.AlignTop diff --git a/src/qml/presenter/NewVideo.qml b/src/qml/presenter/NewVideo.qml index b334c5d..17bf96e 100644 --- a/src/qml/presenter/NewVideo.qml +++ b/src/qml/presenter/NewVideo.qml @@ -14,7 +14,7 @@ Kirigami.OverlaySheet { property bool ytdlLoaded: false header: Kirigami.Heading { - text: "Add a new video" + text: "Add a local video or download a new one" } ColumnLayout { @@ -25,31 +25,32 @@ Kirigami.OverlaySheet { anchors.fill: parent Controls.Label { id: videoInputLabel - text: "Enter a video" + text: "Video" } Controls.TextField { id: videoInput Layout.fillWidth: true hoverEnabled: true - placeholderText: "Enter a video url..." + placeholderText: "Download a video or enter one..." text: "" onEditingFinished: videoInput.text.startsWith("http") ? loadVideo() : showPassiveNotification("Coach called, this isn't it."); + background: Presenter.TextBackground {} } Controls.ToolButton { id: localButton - text: "Local Video" + text: videoInput.text.startsWith("http") ? "Download" : "Local Video" icon.name: "folder-videos-symbolic" hoverEnabled: true - onClicked: videoFileDialog.open() + onClicked: videoInput.text.startsWith("http") ? loadVideo() : videoFileDialog.open() } } } Item { id: centerItem - Layout.preferredHeight: Kirigami.Units.gridUnit * 30 + Layout.preferredHeight: ytdl.loaded ? Kirigami.Units.gridUnit * 20 : Kirigami.Units.gridUnit * 5 Layout.fillWidth: true Layout.alignment: Qt.AlignHCenter visible: true @@ -110,15 +111,19 @@ Kirigami.OverlaySheet { Controls.Label { id: videoTitle text: ytdl.title + wrapMode: Text.WordWrap + elide: Text.ElideRight } } Item { Layout.fillWidth: true Layout.preferredHeight: Kirigami.Units.gridUnit * 2 - Controls.Button { + Controls.ToolButton { anchors.right: parent.right text: "Ok" + icon.name: "check-filled" + hoverEnabled: true onClicked: { videoProxyModel.videoModel.newItem(ytdl.file); clear(); @@ -147,14 +152,25 @@ Kirigami.OverlaySheet { } + Timer { + id: videoDLTimer + interval: 3000 + running: !root.sheetOpen + onTriggered: { + clear(); + } + } + } function loadVideo() { - if (ytdl.getVideo(videoInput.text)) - loadingIndicator.visible = true; + ytdl.getVideo(videoInput.text) + /* if (ytdl.getVideo(videoInput.text)) */ + /* loadingIndicator.visible = true; */ } function clear() { + videoInput.text = ""; ytdl.title = ""; ytdl.thumbnail = ""; ytdl.loaded = false;