update
This commit is contained in:
parent
8a07184fd2
commit
94bcff177e
29
src/main.rs
29
src/main.rs
|
|
@ -87,8 +87,7 @@ impl State {
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), String> {
|
async fn main() -> Result<(), String> {
|
||||||
let win = WindowConfig::new()
|
let win = WindowConfig::new()
|
||||||
.set_always_on_top(true)
|
.set_vsync(false)
|
||||||
.set_vsync(true)
|
|
||||||
.set_lazy_loop(true)
|
.set_lazy_loop(true)
|
||||||
.set_transparent(true)
|
.set_transparent(true)
|
||||||
.set_high_dpi(true);
|
.set_high_dpi(true);
|
||||||
|
|
@ -105,25 +104,12 @@ async fn main() -> Result<(), String> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update(app: &mut App, state: &mut State) {
|
fn update(app: &mut App, state: &mut State) {
|
||||||
if app.keyboard.is_down(KeyCode::Escape) {
|
if let Ok(event) = MenuEvent::receiver().try_recv() {
|
||||||
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 event.id == state.tray_data.quit_i.id() {
|
if event.id == state.tray_data.quit_i.id() {
|
||||||
state.tray_data.tray_icon.take();
|
state.tray_data.tray_icon.take();
|
||||||
app.exit();
|
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) {
|
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| {
|
let mut output = plugins.egui(|ctx| {
|
||||||
egui::SidePanel::left("side_panel").show(ctx, |ui| {
|
egui::SidePanel::left("side_panel").show(ctx, |ui| {
|
||||||
ui.collapsing("Logs", |ui| {
|
ui.collapsing("Logs", |ui| {
|
||||||
egui::ScrollArea::vertical().show(ui, |ui| {
|
egui::ScrollArea::vertical().show(ui, |ui| {
|
||||||
let mut to_swap = None;
|
let mut to_swap = None;
|
||||||
|
let mut to_delete = None;
|
||||||
let history_len = state.log_history.len();
|
let history_len = state.log_history.len();
|
||||||
for (i, log) in state.log_history.iter().enumerate() {
|
for (i, log) in state.log_history.iter().enumerate() {
|
||||||
let path_text = log.path.to_string_lossy().to_string();
|
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();
|
_ = Command::new("notepad.exe").arg(&path_text).spawn();
|
||||||
ui.close_menu();
|
ui.close_menu();
|
||||||
}
|
}
|
||||||
|
if ui.button("Remove").clicked() {
|
||||||
|
to_delete = Some(i);
|
||||||
|
ui.close_menu();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
if label.clicked() {
|
if label.clicked() {
|
||||||
_ = Command::new("C:\\tools\\fast-log-viewer\\fast_log_viewer.exe")
|
_ = 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();
|
state.save();
|
||||||
}
|
}
|
||||||
|
if let Some(i) = to_delete {
|
||||||
|
_ = state.log_history.shift_remove_index(i);
|
||||||
|
state.save();
|
||||||
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue