And clippy lints too
This commit is contained in:
parent
34f548748a
commit
5dd4841e55
|
@ -69,6 +69,7 @@ impl Application for DelyriumApp {
|
||||||
},
|
},
|
||||||
Message::PasteSent => {
|
Message::PasteSent => {
|
||||||
if let Some(lyrics) = self.lyrics_component.as_mut() {
|
if let Some(lyrics) = self.lyrics_component.as_mut() {
|
||||||
|
#[allow(clippy::or_fun_call)] // This is a const
|
||||||
let clip_text = clipboard.read().unwrap_or(String::new());
|
let clip_text = clipboard.read().unwrap_or(String::new());
|
||||||
let clip_pasted_len = clip_text.chars()
|
let clip_pasted_len = clip_text.chars()
|
||||||
.filter(|c| *c != '\r' && *c != '\n')
|
.filter(|c| *c != '\r' && *c != '\n')
|
||||||
|
@ -138,7 +139,7 @@ impl Application for DelyriumApp {
|
||||||
(
|
(
|
||||||
keyboard::KeyCode::V,
|
keyboard::KeyCode::V,
|
||||||
keyboard::Modifiers { control, .. }
|
keyboard::Modifiers { control, .. }
|
||||||
) if control == true => {
|
) if control => {
|
||||||
Some(Message::PasteSent)
|
Some(Message::PasteSent)
|
||||||
}
|
}
|
||||||
_ => { None }
|
_ => { None }
|
||||||
|
|
|
@ -36,9 +36,9 @@ impl Editor {
|
||||||
let theme = cover.as_ref()
|
let theme = cover.as_ref()
|
||||||
.map(|cover| {
|
.map(|cover| {
|
||||||
Theme::from_palette(
|
Theme::from_palette(
|
||||||
Palette::generate(&cover)
|
Palette::generate(cover)
|
||||||
)
|
)
|
||||||
}).unwrap_or_else(|| Theme::default());
|
}).unwrap_or_else(Theme::default);
|
||||||
|
|
||||||
let cover = cover.expect("TODO");
|
let cover = cover.expect("TODO");
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@ const COLORS: [Color; 6] = [
|
||||||
Color { r: 0., g: 0., b: 1., a: 1. },
|
Color { r: 0., g: 0., b: 1., a: 1. },
|
||||||
Color { r: 1., g: 0., b: 1., a: 1. },
|
Color { r: 1., g: 0., b: 1., a: 1. },
|
||||||
];*/
|
];*/
|
||||||
|
#[allow(clippy::eq_op)]
|
||||||
const COLORS: [Color; 6] = [
|
const COLORS: [Color; 6] = [
|
||||||
Color { r: 255./255., g: 129./255., b: 126./255., a: 1. },
|
Color { r: 255./255., g: 129./255., b: 126./255., a: 1. },
|
||||||
Color { r: 239./255., g: 190./255., b: 125./255., a: 1. },
|
Color { r: 239./255., g: 190./255., b: 125./255., a: 1. },
|
||||||
|
@ -44,7 +45,7 @@ const FONT_MR_PIXEL: Font = Font::External {
|
||||||
bytes: include_bytes!("../fonts/mister-pixel/mister-pixel.otf"),
|
bytes: include_bytes!("../fonts/mister-pixel/mister-pixel.otf"),
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
|
||||||
pub struct FileSelector {
|
pub struct FileSelector {
|
||||||
tick: usize,
|
tick: usize,
|
||||||
}
|
}
|
||||||
|
@ -62,17 +63,9 @@ impl FileSelector {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for FileSelector {
|
|
||||||
fn default() -> Self {
|
|
||||||
FileSelector {
|
|
||||||
tick: 0,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Program<Message> for FileSelector {
|
impl Program<Message> for FileSelector {
|
||||||
fn draw(&self, bounds: Rectangle, _cursor: Cursor) -> Vec<Geometry> {
|
fn draw(&self, bounds: Rectangle, _cursor: Cursor) -> Vec<Geometry> {
|
||||||
let offset_per_index = MAX_TICKS / &COLORS.len();
|
let offset_per_index = MAX_TICKS / COLORS.len();
|
||||||
|
|
||||||
const TEXT_RECT_W: f32 = 350.;
|
const TEXT_RECT_W: f32 = 350.;
|
||||||
const TEXT_RECT_H: f32 = 50.;
|
const TEXT_RECT_H: f32 = 50.;
|
||||||
|
@ -130,7 +123,6 @@ impl Program<Message> for FileSelector {
|
||||||
bounds.x + bounds.width * 0.5,
|
bounds.x + bounds.width * 0.5,
|
||||||
bounds.y + bounds.height * 0.5,
|
bounds.y + bounds.height * 0.5,
|
||||||
),
|
),
|
||||||
..Default::default()
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -39,11 +39,12 @@ pub fn load_song(path: &Path) -> Result<ProbeResult, LoadError> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn extract_cover(format: &mut dyn FormatReader) -> Option<DynamicImage>{
|
pub fn extract_cover(format: &mut dyn FormatReader) -> Option<DynamicImage>{
|
||||||
|
#[allow(clippy::zero_prefixed_literal)]
|
||||||
format.metadata()
|
format.metadata()
|
||||||
.current()
|
.current()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
// Replace this whole closure with MetadataRef::usage once we update
|
// Replace this whole closure with MetadataRef::usage once we update
|
||||||
.flat_map(|meta| meta.visuals().iter().map(|v|(v.data.clone(), v.usage.clone())).collect::<Vec<_>>())
|
.flat_map(|meta| meta.visuals().iter().map(|v|(v.data.clone(), v.usage)).collect::<Vec<_>>())
|
||||||
.filter_map(|(data, usage)| image::load_from_memory(&data).ok().map(|img| (usage, img)))
|
.filter_map(|(data, usage)| image::load_from_memory(&data).ok().map(|img| (usage, img)))
|
||||||
.max_by_key(|(usage, _)|
|
.max_by_key(|(usage, _)|
|
||||||
usage.map(|usage| match usage {
|
usage.map(|usage| match usage {
|
||||||
|
|
|
@ -22,7 +22,7 @@ pub enum LyricEvent {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LyricEvent {
|
impl LyricEvent {
|
||||||
fn to_msg(self, line_no: usize) -> Message {
|
fn into_msg(self, line_no: usize) -> Message {
|
||||||
Message::LyricEvent {
|
Message::LyricEvent {
|
||||||
kind: self,
|
kind: self,
|
||||||
line_no,
|
line_no,
|
||||||
|
@ -116,8 +116,7 @@ impl Lyrics {
|
||||||
self.lines
|
self.lines
|
||||||
.iter_mut()
|
.iter_mut()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.filter(|(_, l)| l.is_selected())
|
.find(|(_, l)| l.is_selected())
|
||||||
.next()
|
|
||||||
.expect("no line currently selected")
|
.expect("no line currently selected")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,24 +179,24 @@ impl Lyric {
|
||||||
&mut self.timestamp_state,
|
&mut self.timestamp_state,
|
||||||
"",
|
"",
|
||||||
&self.timestamp_raw,
|
&self.timestamp_raw,
|
||||||
move|new_value| LyricEvent::TimestampChanged(new_value).to_msg(line_no),
|
move|new_value| LyricEvent::TimestampChanged(new_value).into_msg(line_no),
|
||||||
)
|
)
|
||||||
.style(theme)
|
.style(theme)
|
||||||
.size(size - 5)
|
.size(size - 5)
|
||||||
.width(Length::Units(97))
|
.width(Length::Units(97))
|
||||||
.on_submit(LyricEvent::LineAdvanced.to_msg(line_no))
|
.on_submit(LyricEvent::LineAdvanced.into_msg(line_no))
|
||||||
.into();
|
.into();
|
||||||
|
|
||||||
let text_input = TextInput::new(
|
let text_input = TextInput::new(
|
||||||
&mut self.main_state,
|
&mut self.main_state,
|
||||||
placeholder,
|
placeholder,
|
||||||
&self.value,
|
&self.value,
|
||||||
move|new_value| LyricEvent::LyricChanged(new_value).to_msg(line_no),
|
move|new_value| LyricEvent::LyricChanged(new_value).into_msg(line_no),
|
||||||
)
|
)
|
||||||
.style(theme)
|
.style(theme)
|
||||||
.size(size)
|
.size(size)
|
||||||
.width(Length::Fill)
|
.width(Length::Fill)
|
||||||
.on_submit(LyricEvent::LineAdvanced.to_msg(line_no))
|
.on_submit(LyricEvent::LineAdvanced.into_msg(line_no))
|
||||||
.into();
|
.into();
|
||||||
|
|
||||||
let l_bracket = Text::new("[")
|
let l_bracket = Text::new("[")
|
||||||
|
@ -303,7 +302,7 @@ impl Lyric {
|
||||||
while
|
while
|
||||||
digit_counts[section] > MIN_DIGIT_COUNTS[section]
|
digit_counts[section] > MIN_DIGIT_COUNTS[section]
|
||||||
&& if section == 2 {
|
&& if section == 2 {
|
||||||
raw.chars().next_back().unwrap() == '0'
|
raw.ends_with('0')
|
||||||
} else {
|
} else {
|
||||||
raw.chars().nth(i).unwrap() == '0'
|
raw.chars().nth(i).unwrap() == '0'
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,6 +89,6 @@ impl Palette {
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.0;
|
.0;
|
||||||
|
|
||||||
return &self.raw_colors[max_index];
|
&self.raw_colors[max_index]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ impl Player {
|
||||||
pub fn new(song: Box<dyn FormatReader>) -> Result<Self, PlayerError> {
|
pub fn new(song: Box<dyn FormatReader>) -> Result<Self, PlayerError> {
|
||||||
|
|
||||||
let song = Decoder::new_from_format_reader(song)
|
let song = Decoder::new_from_format_reader(song)
|
||||||
.map_err(PlayerError::DecoderError)?
|
.map_err(PlayerError::Decoder)?
|
||||||
.buffered();
|
.buffered();
|
||||||
|
|
||||||
let duration = Duration::from_secs(150);
|
let duration = Duration::from_secs(150);
|
||||||
|
@ -74,10 +74,10 @@ impl Player {
|
||||||
Some(result) // We'll report this error
|
Some(result) // We'll report this error
|
||||||
})
|
})
|
||||||
.transpose()
|
.transpose()
|
||||||
.map_err(PlayerError::StreamError)?
|
.map_err(PlayerError::Stream)?
|
||||||
.map(|(stream, handle)| Sink::try_new(&handle).map(|sink| (sink, stream)))
|
.map(|(stream, handle)| Sink::try_new(&handle).map(|sink| (sink, stream)))
|
||||||
.transpose()
|
.transpose()
|
||||||
.map_err(PlayerError::PlayError)?;
|
.map_err(PlayerError::Play)?;
|
||||||
|
|
||||||
Ok(self.sink.as_ref().map(|(s, _)| s))
|
Ok(self.sink.as_ref().map(|(s, _)| s))
|
||||||
}
|
}
|
||||||
|
@ -274,17 +274,17 @@ impl Player {
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum PlayerError {
|
pub enum PlayerError {
|
||||||
DecoderError(rodio::decoder::DecoderError),
|
Decoder(rodio::decoder::DecoderError),
|
||||||
PlayError(rodio::PlayError),
|
Play(rodio::PlayError),
|
||||||
StreamError(rodio::StreamError),
|
Stream(rodio::StreamError),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for PlayerError {
|
impl fmt::Display for PlayerError {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
Self::DecoderError(e) => write!(f, "Could not decode the provided song: {}", e),
|
Self::Decoder(e) => write!(f, "Could not decode the provided song: {}", e),
|
||||||
Self::PlayError(e) => write!(f, "Problem playing to the audio output: {}", e),
|
Self::Play(e) => write!(f, "Problem playing to the audio output: {}", e),
|
||||||
Self::StreamError(e) => write!(f, "Problem connecting to the audio output: {}", e),
|
Self::Stream(e) => write!(f, "Problem connecting to the audio output: {}", e),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue