some clippy fixes
This commit is contained in:
parent
3b1a0c4207
commit
46abd9dd7a
13 changed files with 54 additions and 85 deletions
|
|
@ -211,7 +211,7 @@ pub async fn update_image_in_db(
|
||||||
.map(std::string::ToString::to_string)
|
.map(std::string::ToString::to_string)
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
let mut db = db.detach();
|
let mut db = db.detach();
|
||||||
let id = image.id.clone();
|
let id = image.id;
|
||||||
if let Err(e) = query!("SELECT id FROM images where id = $1", id)
|
if let Err(e) = query!("SELECT id FROM images where id = $1", id)
|
||||||
.fetch_one(&mut db)
|
.fetch_one(&mut db)
|
||||||
.await
|
.await
|
||||||
|
|
|
||||||
|
|
@ -318,7 +318,7 @@ pub async fn update_presentation_in_db(
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
let html = presentation.kind == PresKind::Html;
|
let html = presentation.kind == PresKind::Html;
|
||||||
let mut db = db.detach();
|
let mut db = db.detach();
|
||||||
let id = presentation.id.clone();
|
let id = presentation.id;
|
||||||
if let Err(e) =
|
if let Err(e) =
|
||||||
query!("SELECT id FROM presentations where id = $1", id)
|
query!("SELECT id FROM presentations where id = $1", id)
|
||||||
.fetch_one(&mut db)
|
.fetch_one(&mut db)
|
||||||
|
|
|
||||||
|
|
@ -246,7 +246,7 @@ pub async fn update_video_in_db(
|
||||||
.map(std::string::ToString::to_string)
|
.map(std::string::ToString::to_string)
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
let mut db = db.detach();
|
let mut db = db.detach();
|
||||||
let id = video.id.clone();
|
let id = video.id;
|
||||||
if let Err(e) = query!("SELECT id FROM videos where id = $1", id)
|
if let Err(e) = query!("SELECT id FROM videos where id = $1", id)
|
||||||
.fetch_one(&mut db)
|
.fetch_one(&mut db)
|
||||||
.await
|
.await
|
||||||
|
|
|
||||||
|
|
@ -765,7 +765,7 @@ impl cosmic::Application for App {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
song_editor::Action::UpdateSong(song) => {
|
song_editor::Action::UpdateSong(song) => {
|
||||||
if let Some(_) = &mut self.library {
|
if self.library.is_some() {
|
||||||
self.update(Message::Library(
|
self.update(Message::Library(
|
||||||
library::Message::UpdateSong(song),
|
library::Message::UpdateSong(song),
|
||||||
))
|
))
|
||||||
|
|
@ -786,7 +786,7 @@ impl cosmic::Application for App {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
image_editor::Action::UpdateImage(image) => {
|
image_editor::Action::UpdateImage(image) => {
|
||||||
if let Some(_) = &mut self.library {
|
if self.library.is_some() {
|
||||||
self.update(Message::Library(
|
self.update(Message::Library(
|
||||||
library::Message::UpdateImage(image),
|
library::Message::UpdateImage(image),
|
||||||
))
|
))
|
||||||
|
|
@ -807,7 +807,7 @@ impl cosmic::Application for App {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
video_editor::Action::UpdateVideo(video) => {
|
video_editor::Action::UpdateVideo(video) => {
|
||||||
if let Some(_) = &mut self.library {
|
if self.library.is_some() {
|
||||||
self.update(Message::Library(
|
self.update(Message::Library(
|
||||||
library::Message::UpdateVideo(video),
|
library::Message::UpdateVideo(video),
|
||||||
))
|
))
|
||||||
|
|
@ -1732,8 +1732,7 @@ where
|
||||||
moved_item_overlay: Color::from(
|
moved_item_overlay: Color::from(
|
||||||
t.cosmic().primary.base,
|
t.cosmic().primary.base,
|
||||||
)
|
)
|
||||||
.scale_alpha(0.2)
|
.scale_alpha(0.2),
|
||||||
.into(),
|
|
||||||
ghost_border: Border {
|
ghost_border: Border {
|
||||||
width: 1.0,
|
width: 1.0,
|
||||||
color: t.cosmic().secondary.base.into(),
|
color: t.cosmic().secondary.base.into(),
|
||||||
|
|
|
||||||
|
|
@ -73,8 +73,7 @@ impl ImageEditor {
|
||||||
.image
|
.image
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|v| v.id)
|
.map(|v| v.id)
|
||||||
.unwrap_or_default()
|
.unwrap_or_default();
|
||||||
.clone();
|
|
||||||
let task = Task::perform(
|
let task = Task::perform(
|
||||||
pick_image(),
|
pick_image(),
|
||||||
move |image_result| {
|
move |image_result| {
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ use cosmic::{
|
||||||
},
|
},
|
||||||
Element, Task,
|
Element, Task,
|
||||||
};
|
};
|
||||||
use miette::{miette, IntoDiagnostic, Result};
|
use miette::{IntoDiagnostic, Result};
|
||||||
use rapidfuzz::distance::levenshtein;
|
use rapidfuzz::distance::levenshtein;
|
||||||
use sqlx::{migrate, SqlitePool};
|
use sqlx::{migrate, SqlitePool};
|
||||||
use tracing::{debug, error, warn};
|
use tracing::{debug, error, warn};
|
||||||
|
|
@ -156,13 +156,13 @@ impl<'a> Library {
|
||||||
LibraryKind::Video => {
|
LibraryKind::Video => {
|
||||||
return Action::Task(Task::perform(
|
return Action::Task(Task::perform(
|
||||||
add_videos(),
|
add_videos(),
|
||||||
|videos| Message::AddVideos(videos),
|
Message::AddVideos,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
LibraryKind::Image => {
|
LibraryKind::Image => {
|
||||||
return Action::Task(Task::perform(
|
return Action::Task(Task::perform(
|
||||||
add_images(),
|
add_images(),
|
||||||
|images| Message::AddImages(images),
|
Message::AddImages,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
LibraryKind::Presentation => {
|
LibraryKind::Presentation => {
|
||||||
|
|
@ -248,13 +248,12 @@ impl<'a> Library {
|
||||||
let Some(first_item) = self
|
let Some(first_item) = self
|
||||||
.selected_items
|
.selected_items
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|items| {
|
.and_then(|items| {
|
||||||
items
|
items
|
||||||
.iter()
|
.iter()
|
||||||
.next()
|
.next()
|
||||||
.map(|(_, index)| index)
|
.map(|(_, index)| index)
|
||||||
})
|
})
|
||||||
.flatten()
|
|
||||||
else {
|
else {
|
||||||
let Some(item) = item else {
|
let Some(item) = item else {
|
||||||
return Action::None;
|
return Action::None;
|
||||||
|
|
@ -270,9 +269,9 @@ impl<'a> Library {
|
||||||
self.selected_items = self
|
self.selected_items = self
|
||||||
.selected_items
|
.selected_items
|
||||||
.clone()
|
.clone()
|
||||||
.and_then(|mut items| {
|
.map(|mut items| {
|
||||||
items.push((kind, id));
|
items.push((kind, id));
|
||||||
Some(items)
|
items
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else if first_item > &index {
|
} else if first_item > &index {
|
||||||
|
|
@ -280,9 +279,9 @@ impl<'a> Library {
|
||||||
self.selected_items = self
|
self.selected_items = self
|
||||||
.selected_items
|
.selected_items
|
||||||
.clone()
|
.clone()
|
||||||
.and_then(|mut items| {
|
.map(|mut items| {
|
||||||
items.push((kind, id));
|
items.push((kind, id));
|
||||||
Some(items)
|
items
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -908,25 +907,21 @@ impl<'a> Library {
|
||||||
error!(?e);
|
error!(?e);
|
||||||
Task::none()
|
Task::none()
|
||||||
} else {
|
} else {
|
||||||
let task =
|
|
||||||
Task::future(self.db.acquire())
|
Task::future(self.db.acquire())
|
||||||
.and_then(move |db| {
|
.and_then(move |db| {
|
||||||
Task::perform(
|
Task::perform(
|
||||||
songs::remove_from_db(
|
songs::remove_from_db(
|
||||||
db, song.id,
|
db, song.id,
|
||||||
),
|
),
|
||||||
|r| {
|
|r| {
|
||||||
match r {
|
if let Err(e) = r {
|
||||||
Err(e) => {
|
error!(?e)
|
||||||
error!(?e)
|
|
||||||
}
|
|
||||||
_ => (),
|
|
||||||
}
|
}
|
||||||
Message::None
|
Message::None
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
});
|
})
|
||||||
task
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Task::none()
|
Task::none()
|
||||||
|
|
@ -943,25 +938,21 @@ impl<'a> Library {
|
||||||
error!(?e);
|
error!(?e);
|
||||||
Task::none()
|
Task::none()
|
||||||
} else {
|
} else {
|
||||||
let task =
|
|
||||||
Task::future(self.db.acquire())
|
Task::future(self.db.acquire())
|
||||||
.and_then(move |db| {
|
.and_then(move |db| {
|
||||||
Task::perform(
|
Task::perform(
|
||||||
videos::remove_from_db(
|
videos::remove_from_db(
|
||||||
db, video.id,
|
db, video.id,
|
||||||
),
|
),
|
||||||
|r| {
|
|r| {
|
||||||
match r {
|
if let Err(e) = r {
|
||||||
Err(e) => {
|
error!(?e)
|
||||||
error!(?e)
|
|
||||||
}
|
|
||||||
_ => (),
|
|
||||||
}
|
}
|
||||||
Message::None
|
Message::None
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
});
|
})
|
||||||
task
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Task::none()
|
Task::none()
|
||||||
|
|
@ -978,25 +969,21 @@ impl<'a> Library {
|
||||||
error!(?e);
|
error!(?e);
|
||||||
Task::none()
|
Task::none()
|
||||||
} else {
|
} else {
|
||||||
let task =
|
|
||||||
Task::future(self.db.acquire())
|
Task::future(self.db.acquire())
|
||||||
.and_then(move |db| {
|
.and_then(move |db| {
|
||||||
Task::perform(
|
Task::perform(
|
||||||
images::remove_from_db(
|
images::remove_from_db(
|
||||||
db, image.id,
|
db, image.id,
|
||||||
),
|
),
|
||||||
|r| {
|
|r| {
|
||||||
match r {
|
if let Err(e) = r {
|
||||||
Err(e) => {
|
error!(?e)
|
||||||
error!(?e)
|
|
||||||
}
|
|
||||||
_ => (),
|
|
||||||
}
|
}
|
||||||
Message::None
|
Message::None
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
});
|
})
|
||||||
task
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Task::none()
|
Task::none()
|
||||||
|
|
@ -1014,8 +1001,8 @@ impl<'a> Library {
|
||||||
error!(?e);
|
error!(?e);
|
||||||
Task::none()
|
Task::none()
|
||||||
} else {
|
} else {
|
||||||
let task =
|
|
||||||
Task::future(self.db.acquire())
|
Task::future(self.db.acquire())
|
||||||
.and_then(move |db| {
|
.and_then(move |db| {
|
||||||
Task::perform(
|
Task::perform(
|
||||||
presentations::remove_from_db(
|
presentations::remove_from_db(
|
||||||
|
|
@ -1023,17 +1010,13 @@ impl<'a> Library {
|
||||||
presentation.id,
|
presentation.id,
|
||||||
),
|
),
|
||||||
|r| {
|
|r| {
|
||||||
match r {
|
if let Err(e) = r {
|
||||||
Err(e) => {
|
error!(?e)
|
||||||
error!(?e)
|
|
||||||
}
|
|
||||||
_ => (),
|
|
||||||
}
|
}
|
||||||
Message::None
|
Message::None
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
});
|
})
|
||||||
task
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Task::none()
|
Task::none()
|
||||||
|
|
@ -1041,7 +1024,7 @@ impl<'a> Library {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
if tasks.len() > 0 {
|
if !tasks.is_empty() {
|
||||||
self.selected_items = None;
|
self.selected_items = None;
|
||||||
}
|
}
|
||||||
Action::Task(Task::batch(tasks))
|
Action::Task(Task::batch(tasks))
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ use cosmic::{
|
||||||
iced_widget::{column, row},
|
iced_widget::{column, row},
|
||||||
theme,
|
theme,
|
||||||
widget::{
|
widget::{
|
||||||
self, button, container, horizontal_space, icon, text,
|
button, container, horizontal_space, icon, text,
|
||||||
text_input, Space,
|
text_input, Space,
|
||||||
},
|
},
|
||||||
Element, Task,
|
Element, Task,
|
||||||
|
|
@ -83,8 +83,7 @@ impl PresentationEditor {
|
||||||
.presentation
|
.presentation
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|v| v.id)
|
.map(|v| v.id)
|
||||||
.unwrap_or_default()
|
.unwrap_or_default();
|
||||||
.clone();
|
|
||||||
let task = Task::perform(
|
let task = Task::perform(
|
||||||
pick_presentation(),
|
pick_presentation(),
|
||||||
move |presentation_result| {
|
move |presentation_result| {
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ use crate::{
|
||||||
|
|
||||||
const REFERENCE_WIDTH: f32 = 1920.0;
|
const REFERENCE_WIDTH: f32 = 1920.0;
|
||||||
static DEFAULT_SLIDE: LazyLock<Slide> =
|
static DEFAULT_SLIDE: LazyLock<Slide> =
|
||||||
LazyLock::new(|| Slide::default());
|
LazyLock::new(Slide::default);
|
||||||
|
|
||||||
// #[derive(Default, Clone, Debug)]
|
// #[derive(Default, Clone, Debug)]
|
||||||
pub(crate) struct Presenter {
|
pub(crate) struct Presenter {
|
||||||
|
|
@ -155,11 +155,9 @@ impl Presenter {
|
||||||
items.iter().fold(0, |a, item| a + item.slides.len());
|
items.iter().fold(0, |a, item| a + item.slides.len());
|
||||||
|
|
||||||
let slide =
|
let slide =
|
||||||
items.get(0).map(|item| item.slides.get(0)).flatten();
|
items.first().and_then(|item| item.slides.first());
|
||||||
let audio = items
|
let audio = items.first()
|
||||||
.get(0)
|
.and_then(|item| item.slides.first().map(|slide| slide.audio()))
|
||||||
.map(|item| item.slides.get(0).map(|slide| slide.audio()))
|
|
||||||
.flatten()
|
|
||||||
.flatten();
|
.flatten();
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
|
|
@ -179,7 +177,7 @@ impl Presenter {
|
||||||
.expect("Can't open default rodio stream");
|
.expect("Can't open default rodio stream");
|
||||||
(
|
(
|
||||||
Arc::new(Sink::connect_new(
|
Arc::new(Sink::connect_new(
|
||||||
&stream_handle.mixer(),
|
stream_handle.mixer(),
|
||||||
)),
|
)),
|
||||||
stream_handle,
|
stream_handle,
|
||||||
)
|
)
|
||||||
|
|
@ -219,8 +217,7 @@ impl Presenter {
|
||||||
if let Some(slide) = self
|
if let Some(slide) = self
|
||||||
.service
|
.service
|
||||||
.get(item_index)
|
.get(item_index)
|
||||||
.map(|item| item.slides.get(slide_index))
|
.and_then(|item| item.slides.get(slide_index))
|
||||||
.flatten()
|
|
||||||
{
|
{
|
||||||
self.current_item = item_index;
|
self.current_item = item_index;
|
||||||
self.current_slide_index = slide_index;
|
self.current_slide_index = slide_index;
|
||||||
|
|
@ -473,7 +470,7 @@ impl Presenter {
|
||||||
);
|
);
|
||||||
|
|
||||||
let container = slide_view(
|
let container = slide_view(
|
||||||
&slide,
|
slide,
|
||||||
&self.video,
|
&self.video,
|
||||||
true,
|
true,
|
||||||
false,
|
false,
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ use cosmic::{
|
||||||
event, mouse, Event, Length, Point, Rectangle, Vector,
|
event, mouse, Event, Length, Point, Rectangle, Vector,
|
||||||
},
|
},
|
||||||
iced_core::{
|
iced_core::{
|
||||||
self, image::Renderer, layout, renderer, widget::Tree,
|
self, layout, renderer, widget::Tree,
|
||||||
Clipboard, Shell,
|
Clipboard, Shell,
|
||||||
},
|
},
|
||||||
widget::Widget,
|
widget::Widget,
|
||||||
|
|
@ -196,8 +196,7 @@ impl<Message: Clone + 'static>
|
||||||
// We ignore motion if we do not possess drag content by now.
|
// We ignore motion if we do not possess drag content by now.
|
||||||
if let Some(left_pressed_position) =
|
if let Some(left_pressed_position) =
|
||||||
state.left_pressed_position
|
state.left_pressed_position
|
||||||
{
|
&& position
|
||||||
if position
|
|
||||||
.distance(left_pressed_position)
|
.distance(left_pressed_position)
|
||||||
> self.drag_threshold
|
> self.drag_threshold
|
||||||
{
|
{
|
||||||
|
|
@ -217,7 +216,6 @@ impl<Message: Clone + 'static>
|
||||||
state.left_pressed_position =
|
state.left_pressed_position =
|
||||||
None;
|
None;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if !cursor.is_over(layout.bounds()) {
|
if !cursor.is_over(layout.bounds()) {
|
||||||
state.hovered = false;
|
state.hovered = false;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -308,12 +308,12 @@ impl SongEditor {
|
||||||
fn slide_preview(&self) -> Element<Message> {
|
fn slide_preview(&self) -> Element<Message> {
|
||||||
if let Some(slides) = &self.song_slides {
|
if let Some(slides) = &self.song_slides {
|
||||||
let slides: Vec<Element<Message>> = slides
|
let slides: Vec<Element<Message>> = slides
|
||||||
.into_iter()
|
.iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(index, slide)| {
|
.map(|(index, slide)| {
|
||||||
container(
|
container(
|
||||||
slide_view(
|
slide_view(
|
||||||
&slide,
|
slide,
|
||||||
if index == 0 {
|
if index == 0 {
|
||||||
&self.video
|
&self.video
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -94,8 +94,7 @@ impl VideoEditor {
|
||||||
.core_video
|
.core_video
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|v| v.id)
|
.map(|v| v.id)
|
||||||
.unwrap_or_default()
|
.unwrap_or_default();
|
||||||
.clone();
|
|
||||||
let task = Task::perform(
|
let task = Task::perform(
|
||||||
pick_video(),
|
pick_video(),
|
||||||
move |video_result| {
|
move |video_result| {
|
||||||
|
|
|
||||||
|
|
@ -468,8 +468,7 @@ where
|
||||||
Action::Picking { index, origin } => {
|
Action::Picking { index, origin } => {
|
||||||
if let Some(cursor_position) =
|
if let Some(cursor_position) =
|
||||||
cursor.position()
|
cursor.position()
|
||||||
{
|
&& cursor_position.distance(origin)
|
||||||
if cursor_position.distance(origin)
|
|
||||||
> self.deadband_zone
|
> self.deadband_zone
|
||||||
{
|
{
|
||||||
// Start dragging
|
// Start dragging
|
||||||
|
|
@ -488,7 +487,6 @@ where
|
||||||
event_status =
|
event_status =
|
||||||
event::Status::Captured;
|
event::Status::Captured;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Action::Dragging { origin, index, .. } => {
|
Action::Dragging { origin, index, .. } => {
|
||||||
if let Some(cursor_position) =
|
if let Some(cursor_position) =
|
||||||
|
|
@ -903,8 +901,7 @@ pub fn default(theme: &Theme) -> Style {
|
||||||
Style {
|
Style {
|
||||||
scale: 1.05,
|
scale: 1.05,
|
||||||
moved_item_overlay: Color::from(theme.cosmic().primary.base)
|
moved_item_overlay: Color::from(theme.cosmic().primary.base)
|
||||||
.scale_alpha(0.2)
|
.scale_alpha(0.2),
|
||||||
.into(),
|
|
||||||
ghost_border: Border {
|
ghost_border: Border {
|
||||||
width: 1.0,
|
width: 1.0,
|
||||||
color: theme.cosmic().secondary.base.into(),
|
color: theme.cosmic().secondary.base.into(),
|
||||||
|
|
|
||||||
|
|
@ -454,8 +454,7 @@ where
|
||||||
Action::Picking { index, origin } => {
|
Action::Picking { index, origin } => {
|
||||||
if let Some(cursor_position) =
|
if let Some(cursor_position) =
|
||||||
cursor.position()
|
cursor.position()
|
||||||
{
|
&& cursor_position.distance(origin)
|
||||||
if cursor_position.distance(origin)
|
|
||||||
> self.deadband_zone
|
> self.deadband_zone
|
||||||
{
|
{
|
||||||
// Start dragging
|
// Start dragging
|
||||||
|
|
@ -474,7 +473,6 @@ where
|
||||||
event_status =
|
event_status =
|
||||||
event::Status::Captured;
|
event::Status::Captured;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Action::Dragging { origin, index, .. } => {
|
Action::Dragging { origin, index, .. } => {
|
||||||
if let Some(cursor_position) =
|
if let Some(cursor_position) =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue