initial bits to make a ytdl addition

This commit is contained in:
Chris Cochrun 2023-04-21 13:42:18 -05:00
parent 405a310e02
commit 666c22ae66
12 changed files with 353 additions and 1 deletions

View file

@ -68,6 +68,7 @@ Item {
count: innerModel.count()
newItemFunction: (function() {
videoProxyModel.setFilterRegularExpression("");
newVideo.open();
})
deleteItemFunction: (function(rows) {
videoProxyModel.deleteVideos(rows)
@ -75,6 +76,19 @@ Item {
}
Presenter.NewVideo {
id: newVideo
}
Timer {
id: videoDLTimer
interval: 3000
running: !newVideo.sheetOpen
onTriggered: {
newVideo.clear();
}
}
Presenter.LibraryItem {
id: imageLibrary
Layout.alignment: Qt.AlignTop

View file

@ -0,0 +1,133 @@
import QtQuick 2.15
import QtQuick.Controls 2.15 as Controls
import QtQuick.Dialogs 1.3
import QtQuick.Layouts 1.15
import QtGraphicalEffects 1.15
import org.kde.kirigami 2.13 as Kirigami
import "./" as Presenter
import org.presenter 1.0
import Qt.labs.settings 1.0
Kirigami.OverlaySheet {
id: root
property bool ytdlLoaded: false
header: Kirigami.Heading {
text: "Add a new video"
}
ColumnLayout {
Controls.ToolBar {
id: toolbar
Layout.fillWidth: true
RowLayout {
anchors.fill: parent
Controls.Label {
id: videoInputLabel
text: "Enter a video"
}
Controls.TextField {
id: videoInput
Layout.fillWidth: true
hoverEnabled: true
placeholderText: "Enter a video url..."
text: ""
onEditingFinished: videoInput.text.startsWith("http") ? loadVideo() : showPassiveNotification("Coach called, this isn't it.");
}
}
}
Item {
id: centerItem
Layout.preferredHeight: Kirigami.Units.gridUnit * 25
Layout.fillWidth: true
Layout.alignment: Qt.AlignHCenter
visible: true
Controls.BusyIndicator {
id: loadingIndicator
anchors.centerIn: parent
running: ytdl.loading
}
Ytdl {
id: ytdl
loaded: false
loading: false
}
/* Rectangle { */
/* color: "blue" */
/* anchors.fill: parent */
/* } */
ColumnLayout {
id: loadedItem
anchors.fill: parent
visible: ytdl.loaded
Image {
id: thumbnailImage
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
Layout.fillWidth: true
Layout.preferredHeight: width * 9 / 16
source: ytdl.thumbnail
fillMode: Image.PreserveAspectFit
clip: true
Item {
id: mask
anchors.fill: thumbnailImage
visible: false
Rectangle {
color: "white"
radius: 20
anchors.centerIn: parent
width: thumbnailImage.paintedWidth
height: thumbnailImage.paintedHeight
}
}
OpacityMask {
anchors.fill: thumbnailImage
source: thumbnailImage
maskSource: mask
}
}
Item {
Layout.alignment: Qt.AlignTop | Qt.AlignLeft
Layout.fillWidth: true
Layout.fillHeight: true
Controls.Label {
id: videoTitle
text: ytdl.title
}
}
Item {
Layout.fillWidth: true
Layout.preferredHeight: Kirigami.Units.gridUnit * 2
Controls.Button {
anchors.right: parent.right
text: "Ok"
onClicked: { clear(); root.close();}
}
}
}
}
}
function loadVideo() {
if (ytdl.getVideo(videoInput.text))
loadingIndicator.visible = true;
}
function clear() {
ytdl.title = "";
ytdl.thumbnail = "";
ytdl.loaded = false;
ytdl.loading = false;
}
}

View file

@ -5,6 +5,7 @@ import QtQuick.Layouts 1.15
import org.kde.kirigami 2.13 as Kirigami
import "./" as Presenter
import mpv 1.0
import org.presenter 1.0
Item {
id: root