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.
This commit is contained in:
Chris Cochrun 2024-01-22 13:21:50 -06:00
parent 1e5cb67f13
commit 86f4f603a1
2 changed files with 26 additions and 19 deletions

View file

@ -1,4 +1,4 @@
import QtQuick 2.13 import QtQuick 2.15
import QtQuick.Controls 2.15 as Controls import QtQuick.Controls 2.15 as Controls
import QtQuick.Layouts 1.15 import QtQuick.Layouts 1.15
import Qt.labs.platform 1.1 as Labs import Qt.labs.platform 1.1 as Labs
@ -82,15 +82,6 @@ Item {
id: newVideo id: newVideo
} }
Timer {
id: videoDLTimer
interval: 3000
running: !newVideo.sheetOpen
onTriggered: {
newVideo.clear();
}
}
Presenter.LibraryItem { Presenter.LibraryItem {
id: imageLibrary id: imageLibrary
Layout.alignment: Qt.AlignTop Layout.alignment: Qt.AlignTop

View file

@ -14,7 +14,7 @@ Kirigami.OverlaySheet {
property bool ytdlLoaded: false property bool ytdlLoaded: false
header: Kirigami.Heading { header: Kirigami.Heading {
text: "Add a new video" text: "Add a local video or download a new one"
} }
ColumnLayout { ColumnLayout {
@ -25,31 +25,32 @@ Kirigami.OverlaySheet {
anchors.fill: parent anchors.fill: parent
Controls.Label { Controls.Label {
id: videoInputLabel id: videoInputLabel
text: "Enter a video" text: "Video"
} }
Controls.TextField { Controls.TextField {
id: videoInput id: videoInput
Layout.fillWidth: true Layout.fillWidth: true
hoverEnabled: true hoverEnabled: true
placeholderText: "Enter a video url..." placeholderText: "Download a video or enter one..."
text: "" text: ""
onEditingFinished: videoInput.text.startsWith("http") ? loadVideo() : showPassiveNotification("Coach called, this isn't it."); onEditingFinished: videoInput.text.startsWith("http") ? loadVideo() : showPassiveNotification("Coach called, this isn't it.");
background: Presenter.TextBackground {}
} }
Controls.ToolButton { Controls.ToolButton {
id: localButton id: localButton
text: "Local Video" text: videoInput.text.startsWith("http") ? "Download" : "Local Video"
icon.name: "folder-videos-symbolic" icon.name: "folder-videos-symbolic"
hoverEnabled: true hoverEnabled: true
onClicked: videoFileDialog.open() onClicked: videoInput.text.startsWith("http") ? loadVideo() : videoFileDialog.open()
} }
} }
} }
Item { Item {
id: centerItem id: centerItem
Layout.preferredHeight: Kirigami.Units.gridUnit * 30 Layout.preferredHeight: ytdl.loaded ? Kirigami.Units.gridUnit * 20 : Kirigami.Units.gridUnit * 5
Layout.fillWidth: true Layout.fillWidth: true
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
visible: true visible: true
@ -110,15 +111,19 @@ Kirigami.OverlaySheet {
Controls.Label { Controls.Label {
id: videoTitle id: videoTitle
text: ytdl.title text: ytdl.title
wrapMode: Text.WordWrap
elide: Text.ElideRight
} }
} }
Item { Item {
Layout.fillWidth: true Layout.fillWidth: true
Layout.preferredHeight: Kirigami.Units.gridUnit * 2 Layout.preferredHeight: Kirigami.Units.gridUnit * 2
Controls.Button { Controls.ToolButton {
anchors.right: parent.right anchors.right: parent.right
text: "Ok" text: "Ok"
icon.name: "check-filled"
hoverEnabled: true
onClicked: { onClicked: {
videoProxyModel.videoModel.newItem(ytdl.file); videoProxyModel.videoModel.newItem(ytdl.file);
clear(); clear();
@ -147,14 +152,25 @@ Kirigami.OverlaySheet {
} }
Timer {
id: videoDLTimer
interval: 3000
running: !root.sheetOpen
onTriggered: {
clear();
}
}
} }
function loadVideo() { function loadVideo() {
if (ytdl.getVideo(videoInput.text)) ytdl.getVideo(videoInput.text)
loadingIndicator.visible = true; /* if (ytdl.getVideo(videoInput.text)) */
/* loadingIndicator.visible = true; */
} }
function clear() { function clear() {
videoInput.text = "";
ytdl.title = ""; ytdl.title = "";
ytdl.thumbnail = ""; ytdl.thumbnail = "";
ytdl.loaded = false; ytdl.loaded = false;