This commit is contained in:
Steve Biedermann 2024-10-08 17:55:54 +02:00
parent 8a07184fd2
commit 94bcff177e
1 changed files with 12 additions and 17 deletions

View File

@ -87,8 +87,7 @@ impl State {
#[tokio::main]
async fn main() -> Result<(), String> {
let win = WindowConfig::new()
.set_always_on_top(true)
.set_vsync(true)
.set_vsync(false)
.set_lazy_loop(true)
.set_transparent(true)
.set_high_dpi(true);
@ -105,25 +104,12 @@ async fn main() -> Result<(), String> {
}
fn update(app: &mut App, state: &mut State) {
if app.keyboard.is_down(KeyCode::Escape) {
let (x, y) = app.window().screen_size();
app.window().set_position(x + 10000, y + 10000);
}
if let Ok(event) = state.tray_data.menu_channel.try_recv() {
if let Ok(event) = MenuEvent::receiver().try_recv() {
if event.id == state.tray_data.quit_i.id() {
state.tray_data.tray_icon.take();
app.exit();
}
}
if let Ok(event) = state.tray_data.tray_channel.try_recv() {
if let TrayIconEvent::DoubleClick {
button: MouseButton::Left,
..
} = event
{
app.window().set_position(0, 0);
}
}
}
fn event(_app: &mut App, _assets: &mut Assets, state: &mut State, evt: Event) {
@ -147,12 +133,13 @@ fn event(_app: &mut App, _assets: &mut Assets, state: &mut State, evt: Event) {
}
}
fn draw(_app: &mut App, gfx: &mut Graphics, plugins: &mut Plugins, state: &mut State) {
fn draw(app: &mut App, gfx: &mut Graphics, plugins: &mut Plugins, state: &mut State) {
let mut output = plugins.egui(|ctx| {
egui::SidePanel::left("side_panel").show(ctx, |ui| {
ui.collapsing("Logs", |ui| {
egui::ScrollArea::vertical().show(ui, |ui| {
let mut to_swap = None;
let mut to_delete = None;
let history_len = state.log_history.len();
for (i, log) in state.log_history.iter().enumerate() {
let path_text = log.path.to_string_lossy().to_string();
@ -164,6 +151,10 @@ fn draw(_app: &mut App, gfx: &mut Graphics, plugins: &mut Plugins, state: &mut S
_ = Command::new("notepad.exe").arg(&path_text).spawn();
ui.close_menu();
}
if ui.button("Remove").clicked() {
to_delete = Some(i);
ui.close_menu();
}
});
if label.clicked() {
_ = Command::new("C:\\tools\\fast-log-viewer\\fast_log_viewer.exe")
@ -181,6 +172,10 @@ fn draw(_app: &mut App, gfx: &mut Graphics, plugins: &mut Plugins, state: &mut S
}
state.save();
}
if let Some(i) = to_delete {
_ = state.log_history.shift_remove_index(i);
state.save();
}
})
})
});