a lot more linting fixes

This commit is contained in:
Chris Cochrun 2026-02-15 12:57:26 -06:00
parent 0d7e5b9285
commit 81e2734e8a
6 changed files with 53 additions and 56 deletions

View file

@ -124,17 +124,16 @@ fn main() -> Result<()> {
}
};
let settings;
if args.ui {
let settings = if args.ui {
debug!(target: "lumina", "main view");
settings = Settings::default().debug(false).is_daemon(true);
Settings::default().debug(false).is_daemon(true)
} else {
debug!("window view");
settings = Settings::default()
Settings::default()
.debug(false)
.no_main_window(true)
.is_daemon(true);
}
.is_daemon(true)
};
cosmic::app::run::<App>(settings, (args, config_handler, config))
.map_err(|e| miette!("Invalid things... {}", e))
@ -144,6 +143,7 @@ fn main() -> Result<()> {
// Theme::dark()
// }
#[allow(clippy::struct_excessive_bools)]
struct App {
core: Core,
nav_model: nav_bar::Model,
@ -275,6 +275,8 @@ impl cosmic::Application for App {
fn core_mut(&mut self) -> &mut Core {
&mut self.core
}
#[allow(clippy::too_many_lines)]
fn init(
core: Core,
input: Self::Flags,
@ -289,7 +291,10 @@ impl cosmic::Application for App {
let mut windows = vec![];
if input.0.ui {
windows.push(core.main_window_id().unwrap());
windows.push(
core.main_window_id()
.expect("should be a window here"),
);
}
let (config_handler, settings) = (input.1, input.2);
@ -662,7 +667,7 @@ impl cosmic::Application for App {
iced::keyboard::Event::ModifiersChanged(
modifiers,
) => Some(Message::ModifiersPressed(modifiers)),
_ => None,
iced::keyboard::Event::KeyPressed { .. } => None,
},
iced::Event::Mouse(_event) => None,
iced::Event::Window(window_event) => {
@ -715,6 +720,7 @@ impl cosmic::Application for App {
None
}
#[allow(clippy::too_many_lines)]
fn dialog(&self) -> Option<Element<'_, Self::Message>> {
let cosmic::cosmic_theme::Spacing {
space_xxs,
@ -870,6 +876,7 @@ impl cosmic::Application for App {
}
}
#[allow(clippy::too_many_lines)]
fn update(&mut self, message: Message) -> Task<Message> {
match message {
Message::Key(key, modifiers) => {
@ -1033,7 +1040,6 @@ impl cosmic::Application for App {
}
self.current_item =
(item_index, slide_index);
Task::batch(tasks)
} else {
// debug!("Slides are not longer");
if self
@ -1055,8 +1061,8 @@ impl cosmic::Application for App {
self.current_item =
(item_index + 1, 0);
}
Task::batch(tasks)
}
Task::batch(tasks)
} else {
Task::none()
}
@ -1447,10 +1453,7 @@ impl cosmic::Application for App {
self.presenter.update_items(self.service.clone());
Task::none()
}
Message::Search(query) => {
self.search_query = query.clone();
self.search(query)
}
Message::Search(query) => self.search(query),
Message::UpdateSearchResults(items) => {
self.search_results = items;
Task::none()
@ -1593,6 +1596,7 @@ impl cosmic::Application for App {
}
// Main window view
#[allow(clippy::too_many_lines)]
fn view(&self) -> Element<Message> {
let cosmic::cosmic_theme::Spacing {
space_none,

View file

@ -1,4 +1,5 @@
#![allow(clippy::similar_names)]
#![allow(clippy::too_many_lines)]
use std::{
fmt::Display,
io::{self},
@ -61,6 +62,9 @@ use crate::{
},
};
// This should get refactored into holding a state machine
// then each state of what is being edited can be caught by the compiler
#[allow(clippy::struct_excessive_bools)]
#[derive(Debug)]
pub struct SongEditor {
pub song: Option<Song>,
@ -165,12 +169,11 @@ impl Display for Face {
0..=100 => " Thin",
101..=200 => " Extra Light",
201..=300 => " Light",
301..=500 => "",
501..=600 => " Semi Bold",
601..=700 => " Bold",
701..=800 => " Extra Bold",
801..=1000 => " Black",
_ => "",
301..=500 | _ => "",
};
let style = match self.0.style {
fontdb::Style::Normal => "",
@ -273,6 +276,7 @@ impl SongEditor {
importing: false,
}
}
pub fn update(&mut self, message: Message) -> Action {
match message {
Message::ChangeSong(song) => {
@ -366,7 +370,7 @@ impl SongEditor {
map.into_iter()
.sorted()
.map(|(verse_name, lyric)| {
VerseEditor::new(verse_name, lyric)
VerseEditor::new(verse_name, &lyric)
})
.collect()
});
@ -387,10 +391,8 @@ impl SongEditor {
cosmic::iced::font::Style::Normal => {
*font_style = Style::Italic;
}
cosmic::iced::font::Style::Italic => {
*font_style = Style::Normal;
}
cosmic::iced::font::Style::Oblique => {
cosmic::iced::font::Style::Italic
| cosmic::iced::font::Style::Oblique => {
*font_style = Style::Normal;
}
}
@ -406,10 +408,10 @@ impl SongEditor {
if let Some(font_weight) = &mut song.font_weight {
match font_weight {
Weight::Normal => {
*font_weight = Weight::Bold
*font_weight = Weight::Bold;
}
Weight::Bold => {
*font_weight = Weight::Normal
*font_weight = Weight::Normal;
}
_ => *font_weight = Weight::Normal,
}
@ -424,14 +426,14 @@ impl SongEditor {
if let Ok(size) = size.parse() {
self.font_size = size;
if let Some(song) = &mut self.song {
song.font_size = Some(size as i32);
song.font_size = i32::try_from(size).ok();
let song = song.to_owned();
return Action::Task(self.update_song(song));
}
}
}
Message::ChangeTitle(title) => {
self.title = title.clone();
self.title.clone_from(&title);
if let Some(song) = &mut self.song {
song.title = title;
let song = song.to_owned();
@ -439,7 +441,7 @@ impl SongEditor {
}
}
Message::ChangeVerseOrder(verse_order) => {
self.verse_order = verse_order.clone();
self.verse_order.clone_from(&verse_order);
if let Some(mut song) = self.song.clone() {
let verse_order = verse_order
.split(' ')
@ -465,7 +467,7 @@ impl SongEditor {
}
Message::ChangeAuthor(author) => {
debug!(author);
self.author = author.clone();
self.author.clone_from(&author);
if let Some(mut song) = self.song.clone() {
song.author = Some(author);
return Action::Task(self.update_song(song));
@ -642,8 +644,7 @@ impl SongEditor {
self.editing_verse_order = !self.editing_verse_order;
}
Message::AddVerse((verse, lyric)) => {
let verse_editor =
VerseEditor::new(verse, lyric.clone());
let verse_editor = VerseEditor::new(verse, &lyric);
if let Some(verses) = self.verses.as_mut() {
verses.push(verse_editor);
}
@ -715,7 +716,6 @@ impl SongEditor {
}
}
Message::ChipReorder(event) => match event {
draggable::DragEvent::Picked { index: _ } => (),
draggable::DragEvent::Dropped {
index,
target_index,
@ -730,7 +730,8 @@ impl SongEditor {
return Action::Task(self.update_song(song));
}
}
draggable::DragEvent::Canceled { index: _ } => (),
draggable::DragEvent::Picked { .. }
| draggable::DragEvent::Canceled { .. } => (),
},
Message::DraggingChipStart => {
self.dragging_verse_chip = !self.dragging_verse_chip;
@ -1070,9 +1071,7 @@ impl SongEditor {
)
};
let mut verse_order_row;
if self.dragging_verse_chip {
let mut verse_order_row = if self.dragging_verse_chip {
let ending_dnd_dest = dnd_destination(
horizontal_space().height(19),
vec!["application/verse".into()],
@ -1087,7 +1086,7 @@ impl SongEditor {
Message::ChipDroppedEnd((data, mime))
},
);
verse_order_row = row![
row![
scrollable(verse_order_items)
.direction(
Direction::Horizontal(Scrollbar::new())
@ -1095,9 +1094,9 @@ impl SongEditor {
.spacing(space_s),
ending_dnd_dest
]
.width(Length::Fill);
.width(Length::Fill)
} else {
verse_order_row = row![
row![
scrollable(verse_order_items)
.direction(
Direction::Horizontal(Scrollbar::new())
@ -1105,8 +1104,8 @@ impl SongEditor {
.width(Length::Fill)
.spacing(space_s),
]
.width(Length::Fill);
}
.width(Length::Fill)
};
verse_order_row =
verse_order_row.push(verse_chips_edit_toggle);

View file

@ -2,7 +2,9 @@ use cosmic::iced::Point;
pub use self::column::column;
pub use self::row::row;
#[allow(clippy::all)]
pub mod column;
#[allow(clippy::all)]
pub mod row;
#[derive(Debug, Clone)]

View file

@ -22,6 +22,7 @@
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#![allow(clippy::all)]
use cosmic::Theme;
use cosmic::iced::advanced::layout::{self, Layout};
use cosmic::iced::advanced::widget::{Operation, Tree, Widget, tree};

View file

@ -1,3 +1,6 @@
#[allow(clippy::unwrap_used)]
#[allow(clippy::nursery)]
#[allow(clippy::pedantic)]
pub mod draggable;
pub mod slide_text;
pub mod verse_editor;

View file

@ -40,10 +40,10 @@ pub enum Action {
impl VerseEditor {
#[must_use]
pub fn new(verse: VerseName, lyric: String) -> Self {
pub fn new(verse: VerseName, lyric: &str) -> Self {
Self {
verse_name: verse,
lyric: lyric.clone(),
lyric: lyric.to_string(),
content: text_editor::Content::with_text(&lyric),
editing_verse_name: false,
verse_name_combo: combo_box::State::new(
@ -58,7 +58,7 @@ impl VerseEditor {
match action {
text_editor::Action::Edit(_edit) => {
let lyrics = self.content.text();
self.lyric = lyrics.clone();
self.lyric.clone_from(&lyrics);
let verse = self.verse_name;
Action::UpdateVerse((verse, lyrics))
}
@ -142,11 +142,8 @@ impl VerseEditor {
.color(t.cosmic().accent.hover);
match s {
text_editor::Status::Active => base_style,
text_editor::Status::Hovered => {
base_style.border = hovered_border;
base_style
}
text_editor::Status::Focused => {
text_editor::Status::Hovered
| text_editor::Status::Focused => {
base_style.border = hovered_border;
base_style
}
@ -165,13 +162,4 @@ impl VerseEditor {
.class(theme::Container::Card)
.into()
}
// TODO not done yet. This doesn't work, need to find a way to either reset the
// cursor position or not make new widgets
pub fn set_cursor_position(&mut self, position: (usize, usize)) {
self.content.perform(text_editor::Action::Click(Point::new(
position.0 as f32,
position.1 as f32,
)));
}
}