And clippy lints too
parent
34f548748a
commit
5dd4841e55
|
@ -69,6 +69,7 @@ impl Application for DelyriumApp {
|
|||
},
|
||||
Message::PasteSent => {
|
||||
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_pasted_len = clip_text.chars()
|
||||
.filter(|c| *c != '\r' && *c != '\n')
|
||||
|
@ -138,7 +139,7 @@ impl Application for DelyriumApp {
|
|||
(
|
||||
keyboard::KeyCode::V,
|
||||
keyboard::Modifiers { control, .. }
|
||||
) if control == true => {
|
||||
) if control => {
|
||||
Some(Message::PasteSent)
|
||||
}
|
||||
_ => { None }
|
||||
|
|
|
@ -36,9 +36,9 @@ impl Editor {
|
|||
let theme = cover.as_ref()
|
||||
.map(|cover| {
|
||||
Theme::from_palette(
|
||||
Palette::generate(&cover)
|
||||
Palette::generate(cover)
|
||||
)
|
||||
}).unwrap_or_else(|| Theme::default());
|
||||
}).unwrap_or_else(Theme::default);
|
||||
|
||||
let cover = cover.expect("TODO");
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ const COLORS: [Color; 6] = [
|
|||
Color { r: 0., g: 0., b: 1., a: 1. },
|
||||
Color { r: 1., g: 0., b: 1., a: 1. },
|
||||
];*/
|
||||
#[allow(clippy::eq_op)]
|
||||
const COLORS: [Color; 6] = [
|
||||
Color { r: 255./255., g: 129./255., b: 126./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"),
|
||||
};
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
|
||||
pub struct FileSelector {
|
||||
tick: usize,
|
||||
}
|
||||
|
@ -62,17 +63,9 @@ impl FileSelector {
|
|||
}
|
||||
}
|
||||
|
||||
impl Default for FileSelector {
|
||||
fn default() -> Self {
|
||||
FileSelector {
|
||||
tick: 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Program<Message> for FileSelector {
|
||||
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_H: f32 = 50.;
|
||||
|
@ -130,7 +123,6 @@ impl Program<Message> for FileSelector {
|
|||
bounds.x + bounds.width * 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>{
|
||||
#[allow(clippy::zero_prefixed_literal)]
|
||||
format.metadata()
|
||||
.current()
|
||||
.into_iter()
|
||||
// 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)))
|
||||
.max_by_key(|(usage, _)|
|
||||
usage.map(|usage| match usage {
|
||||
|
|
|
@ -22,7 +22,7 @@ pub enum LyricEvent {
|
|||
}
|
||||
|
||||
impl LyricEvent {
|
||||
fn to_msg(self, line_no: usize) -> Message {
|
||||
fn into_msg(self, line_no: usize) -> Message {
|
||||
Message::LyricEvent {
|
||||
kind: self,
|
||||
line_no,
|
||||
|
@ -116,8 +116,7 @@ impl Lyrics {
|
|||
self.lines
|
||||
.iter_mut()
|
||||
.enumerate()
|
||||
.filter(|(_, l)| l.is_selected())
|
||||
.next()
|
||||
.find(|(_, l)| l.is_selected())
|
||||
.expect("no line currently selected")
|
||||
}
|
||||
|
||||
|
@ -180,24 +179,24 @@ impl Lyric {
|
|||
&mut self.timestamp_state,
|
||||
"",
|
||||
&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)
|
||||
.size(size - 5)
|
||||
.width(Length::Units(97))
|
||||
.on_submit(LyricEvent::LineAdvanced.to_msg(line_no))
|
||||
.on_submit(LyricEvent::LineAdvanced.into_msg(line_no))
|
||||
.into();
|
||||
|
||||
let text_input = TextInput::new(
|
||||
&mut self.main_state,
|
||||
placeholder,
|
||||
&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)
|
||||
.size(size)
|
||||
.width(Length::Fill)
|
||||
.on_submit(LyricEvent::LineAdvanced.to_msg(line_no))
|
||||
.on_submit(LyricEvent::LineAdvanced.into_msg(line_no))
|
||||
.into();
|
||||
|
||||
let l_bracket = Text::new("[")
|
||||
|
@ -303,7 +302,7 @@ impl Lyric {
|
|||
while
|
||||
digit_counts[section] > MIN_DIGIT_COUNTS[section]
|
||||
&& if section == 2 {
|
||||
raw.chars().next_back().unwrap() == '0'
|
||||
raw.ends_with('0')
|
||||
} else {
|
||||
raw.chars().nth(i).unwrap() == '0'
|
||||
}
|
||||
|
|
|
@ -89,6 +89,6 @@ impl Palette {
|
|||
.unwrap()
|
||||
.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> {
|
||||
|
||||
let song = Decoder::new_from_format_reader(song)
|
||||
.map_err(PlayerError::DecoderError)?
|
||||
.map_err(PlayerError::Decoder)?
|
||||
.buffered();
|
||||
|
||||
let duration = Duration::from_secs(150);
|
||||
|
@ -74,10 +74,10 @@ impl Player {
|
|||
Some(result) // We'll report this error
|
||||
})
|
||||
.transpose()
|
||||
.map_err(PlayerError::StreamError)?
|
||||
.map_err(PlayerError::Stream)?
|
||||
.map(|(stream, handle)| Sink::try_new(&handle).map(|sink| (sink, stream)))
|
||||
.transpose()
|
||||
.map_err(PlayerError::PlayError)?;
|
||||
.map_err(PlayerError::Play)?;
|
||||
|
||||
Ok(self.sink.as_ref().map(|(s, _)| s))
|
||||
}
|
||||
|
@ -274,17 +274,17 @@ impl Player {
|
|||
|
||||
#[derive(Debug)]
|
||||
pub enum PlayerError {
|
||||
DecoderError(rodio::decoder::DecoderError),
|
||||
PlayError(rodio::PlayError),
|
||||
StreamError(rodio::StreamError),
|
||||
Decoder(rodio::decoder::DecoderError),
|
||||
Play(rodio::PlayError),
|
||||
Stream(rodio::StreamError),
|
||||
}
|
||||
|
||||
impl fmt::Display for PlayerError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self {
|
||||
Self::DecoderError(e) => write!(f, "Could not decode the provided song: {}", e),
|
||||
Self::PlayError(e) => write!(f, "Problem playing to the audio output: {}", e),
|
||||
Self::StreamError(e) => write!(f, "Problem connecting to the audio output: {}", e),
|
||||
Self::Decoder(e) => write!(f, "Could not decode the provided song: {}", e),
|
||||
Self::Play(e) => write!(f, "Problem playing to the audio output: {}", e),
|
||||
Self::Stream(e) => write!(f, "Problem connecting to the audio output: {}", e),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue