diff --git a/src/qml/presenter/NewVideo.qml b/src/qml/presenter/NewVideo.qml index 4190b2f..b334c5d 100644 --- a/src/qml/presenter/NewVideo.qml +++ b/src/qml/presenter/NewVideo.qml @@ -49,7 +49,7 @@ Kirigami.OverlaySheet { Item { id: centerItem - Layout.preferredHeight: Kirigami.Units.gridUnit * 25 + Layout.preferredHeight: Kirigami.Units.gridUnit * 30 Layout.fillWidth: true Layout.alignment: Qt.AlignHCenter visible: true @@ -119,7 +119,11 @@ Kirigami.OverlaySheet { Controls.Button { anchors.right: parent.right text: "Ok" - onClicked: { clear(); root.close();} + onClicked: { + videoProxyModel.videoModel.newItem(ytdl.file); + clear(); + root.close(); + } } } } diff --git a/src/rust/ytdl.rs b/src/rust/ytdl.rs index a9f85d0..13c4784 100644 --- a/src/rust/ytdl.rs +++ b/src/rust/ytdl.rs @@ -22,6 +22,8 @@ mod ytdl { loaded: bool, #[qproperty] loading: bool, + #[qproperty] + file: QUrl, } impl qobject::Ytdl { @@ -54,13 +56,22 @@ mod ytdl { let output = ytdl.into_single_video().unwrap(); println!("{:?}", output.title); println!("{:?}", output.thumbnail); + println!("{:?}", output.url); let title = QString::from(&output.title); - let thumbnail = QUrl::from(&output.thumbnail.unwrap()); + let thumbnail = QUrl::from(&output.thumbnail.unwrap_or_default()); + let mut file = String::from(output_dirs); + file.push_str("/"); + file.push_str(&output.title); + file.push_str("."); + file.push_str(&output.ext.unwrap_or_default()); + println!("{:?}", file); + thread.queue(move |mut qobject_ytdl| { qobject_ytdl.as_mut().set_loaded(true); qobject_ytdl.as_mut().set_loading(false); qobject_ytdl.as_mut().set_title(title); qobject_ytdl.as_mut().set_thumbnail(thumbnail); + qobject_ytdl.as_mut().set_file(QUrl::from(&file)); }) }); true