Collapsible left panel + progress bar
This commit is contained in:
+6
-1
@@ -1,5 +1,5 @@
|
||||
use crate::args::ArgsConfig;
|
||||
use crate::types::{Playlist, Video, VideoDownloadQuality};
|
||||
use crate::types::{Playlist, Queues, Video, VideoDownloadQuality};
|
||||
use eframe::egui::{Context, Ui};
|
||||
use eframe::{CreationContext, Frame, Storage};
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -10,6 +10,8 @@ pub(crate) struct Application {
|
||||
layers: Vec<Box<dyn crate::layer::Layer>>,
|
||||
pub(crate) data: Data,
|
||||
pub(crate) data_dir: String,
|
||||
pub(crate) progress_percent: f32,
|
||||
pub(crate) progress_info: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Default)]
|
||||
@@ -23,6 +25,7 @@ pub struct AppSettings {
|
||||
|
||||
#[derive(Serialize, Deserialize, Default)]
|
||||
pub(crate) struct Data {
|
||||
pub(crate) queues: Queues,
|
||||
pub(crate) playlists: Vec<Playlist>,
|
||||
pub(crate) videos: Vec<Video>,
|
||||
pub(crate) root_path: String,
|
||||
@@ -61,6 +64,8 @@ impl Application {
|
||||
layers,
|
||||
data,
|
||||
data_dir: args_config.data_dir.clone(),
|
||||
progress_percent: 0.0,
|
||||
progress_info: "".to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,16 +13,10 @@ use tracing::warn;
|
||||
use yt_dlp::client::LibraryInstaller;
|
||||
|
||||
pub(crate) struct Downloader {
|
||||
video_queue: Vec<Video>,
|
||||
playlists_queue: Vec<Playlist>,
|
||||
added_queue: Vec<String>,
|
||||
yt_downloader: Option<yt_dlp::Downloader>,
|
||||
|
||||
tokio_handle: Handle,
|
||||
|
||||
yt_dlp_installed: bool,
|
||||
rejected_yt_dlp_install: bool,
|
||||
|
||||
ffmpeg_installed: bool,
|
||||
rejected_ffmpeg_install: bool,
|
||||
}
|
||||
@@ -37,9 +31,6 @@ impl Downloader {
|
||||
pub fn new() -> Self {
|
||||
let yt_downloader = None;
|
||||
Self {
|
||||
video_queue: Vec::new(),
|
||||
playlists_queue: Vec::new(),
|
||||
added_queue: Vec::new(),
|
||||
yt_downloader,
|
||||
tokio_handle: Handle::current(),
|
||||
yt_dlp_installed: false,
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
use crate::app::Application;
|
||||
use crate::layer::Layer;
|
||||
use eframe::egui::Ui;
|
||||
use eframe::emath::{Pos2, Rect};
|
||||
use eframe::{Frame, egui};
|
||||
use tracing::warn;
|
||||
|
||||
#[derive(Default)]
|
||||
pub(crate) struct LeftPanel {
|
||||
show_panel: bool,
|
||||
url_bar: String,
|
||||
}
|
||||
|
||||
impl Layer for LeftPanel {
|
||||
fn ui(&mut self, application: &mut Application, ui: &mut Ui, _frame: &mut Frame) {
|
||||
let window_size = ui.input(|i| i.viewport().outer_rect).unwrap_or_else(|| {
|
||||
warn!("Failed to get window size");
|
||||
Rect {
|
||||
min: Pos2 { x: 0., y: 0. },
|
||||
max: Pos2 { x: 1., y: 1. },
|
||||
}
|
||||
});
|
||||
egui::panel::Panel::left("left_panel")
|
||||
.min_size(window_size.width() / 5.)
|
||||
.max_size((window_size.width() / 5.) + 2.)
|
||||
.show_collapsible(ui, &mut self.show_panel, |ui| {
|
||||
// TODO: Display a list of videos and playlists
|
||||
|
||||
// Progress bar and status info
|
||||
egui::Panel::bottom("bottom_panel").show(ui, |ui| {
|
||||
ui.vertical_centered(|ui| {
|
||||
ui.horizontal(|ui| {
|
||||
ui.text_edit_singleline(&mut self.url_bar);
|
||||
if ui.button("Download").clicked() {
|
||||
// TODO: Add check for if link is valid
|
||||
application
|
||||
.data
|
||||
.queues
|
||||
.added_queue
|
||||
.push(self.url_bar.clone());
|
||||
}
|
||||
});
|
||||
ui.separator();
|
||||
ui.label(format!("{}", application.progress_info));
|
||||
ui.horizontal(|ui| {
|
||||
ui.label(format!("{:.1}%", application.progress_percent * 100.));
|
||||
ui.add(egui::ProgressBar::new(application.progress_percent));
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
use crate::left_panel::LeftPanel;
|
||||
use crate::top_bar_layer::TopBarLayer;
|
||||
use std::fs;
|
||||
use std::path::PathBuf;
|
||||
@@ -11,6 +12,7 @@ mod layer;
|
||||
mod logging;
|
||||
mod top_bar_layer;
|
||||
mod types;
|
||||
mod left_panel;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
@@ -34,6 +36,7 @@ async fn main() {
|
||||
|
||||
let mut layers: Vec<Box<dyn layer::Layer>> = Vec::new();
|
||||
layers.push(Box::new(TopBarLayer::default()));
|
||||
layers.push(Box::new(LeftPanel::default()));
|
||||
layers.push(Box::new(downloader::Downloader::new()));
|
||||
|
||||
let mut options = eframe::NativeOptions::default();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::app::Application;
|
||||
use crate::layer::Layer;
|
||||
use crate::types::VideoDownloadQuality;
|
||||
use eframe::egui::Ui;
|
||||
use eframe::egui::{Ui, Widget};
|
||||
use eframe::{Frame, egui};
|
||||
use tracing::warn;
|
||||
|
||||
|
||||
@@ -30,6 +30,12 @@ pub(crate) struct Playlist {
|
||||
pub(crate) num_videos: usize,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Default)]
|
||||
pub(crate) struct Queues {
|
||||
pub(crate) video_queue: Vec<Video>,
|
||||
pub(crate) playlists_queue: Vec<Playlist>,
|
||||
pub(crate) added_queue: Vec<String>,
|
||||
}
|
||||
#[derive(Deserialize, Serialize, PartialEq, Default)]
|
||||
pub enum VideoDownloadQuality {
|
||||
#[default]
|
||||
|
||||
Reference in New Issue
Block a user