mirror of
https://github.com/house-of-vanity/khm.git
synced 2025-08-21 14:27:14 +00:00
Works with egui
This commit is contained in:
32
Cargo.lock
generated
32
Cargo.lock
generated
@@ -1055,36 +1055,6 @@ dependencies = [
|
||||
"error-code",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cocoa"
|
||||
version = "0.25.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f6140449f97a6e97f9511815c5632d84c8aacf8ac271ad77c559218161a1373c"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"block",
|
||||
"cocoa-foundation",
|
||||
"core-foundation 0.9.4",
|
||||
"core-graphics",
|
||||
"foreign-types 0.5.0",
|
||||
"libc",
|
||||
"objc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cocoa-foundation"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8c6234cbb2e4c785b456c0644748b1ac416dd045799740356f8363dfe00c93f7"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"block",
|
||||
"core-foundation 0.9.4",
|
||||
"core-graphics-types",
|
||||
"libc",
|
||||
"objc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "codespan-reporting"
|
||||
version = "0.11.1"
|
||||
@@ -2708,7 +2678,6 @@ dependencies = [
|
||||
"base64 0.21.7",
|
||||
"chrono",
|
||||
"clap",
|
||||
"cocoa",
|
||||
"dirs 5.0.1",
|
||||
"eframe",
|
||||
"egui",
|
||||
@@ -2718,7 +2687,6 @@ dependencies = [
|
||||
"log",
|
||||
"notify",
|
||||
"notify-debouncer-mini",
|
||||
"objc",
|
||||
"regex",
|
||||
"reqwest",
|
||||
"rust-embed",
|
||||
|
@@ -30,6 +30,3 @@ egui = "0.29"
|
||||
winit = "0.30"
|
||||
env_logger = "0.11"
|
||||
|
||||
[target.'cfg(target_os = "macos")'.dependencies]
|
||||
cocoa = "0.25"
|
||||
objc = "0.2.7"
|
||||
|
1
src/gui/icons.rs.bak
Normal file
1
src/gui/icons.rs.bak
Normal file
@@ -0,0 +1 @@
|
||||
// No icon loading functions needed - using programmatically generated icons
|
@@ -1,3 +1,4 @@
|
||||
use eframe::egui;
|
||||
use log::{debug, error, info};
|
||||
use notify::RecursiveMode;
|
||||
use notify_debouncer_mini::{new_debouncer, DebounceEventResult};
|
||||
|
@@ -1,4 +1,5 @@
|
||||
use dirs::home_dir;
|
||||
use eframe::egui;
|
||||
use log::{debug, error, info};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::fs;
|
||||
@@ -21,8 +22,8 @@ impl Default for KhmSettings {
|
||||
flow: String::new(),
|
||||
known_hosts: "~/.ssh/known_hosts".to_string(),
|
||||
basic_auth: String::new(),
|
||||
in_place: false,
|
||||
auto_sync_interval_minutes: 60, // Default to 1 hour
|
||||
in_place: true,
|
||||
auto_sync_interval_minutes: 60,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -57,17 +58,6 @@ pub fn save_settings(settings: &KhmSettings) -> Result<(), std::io::Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
mod macos;
|
||||
#[cfg(target_os = "macos")]
|
||||
pub use macos::run_settings_window;
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
mod cross;
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
pub use cross::run_settings_window;
|
||||
|
||||
// Helper function to expand tilde in path
|
||||
pub fn expand_path(path: &str) -> String {
|
||||
if path.starts_with("~/") {
|
||||
if let Some(home) = home_dir() {
|
||||
@@ -76,3 +66,86 @@ pub fn expand_path(path: &str) -> String {
|
||||
}
|
||||
path.to_string()
|
||||
}
|
||||
|
||||
struct KhmSettingsWindow {
|
||||
settings: KhmSettings,
|
||||
auto_sync_interval_str: String,
|
||||
}
|
||||
|
||||
impl eframe::App for KhmSettingsWindow {
|
||||
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
ui.heading("KHM Settings");
|
||||
ui.separator();
|
||||
|
||||
ui.horizontal(|ui| {
|
||||
ui.label("Host URL:");
|
||||
ui.text_edit_singleline(&mut self.settings.host);
|
||||
});
|
||||
|
||||
ui.horizontal(|ui| {
|
||||
ui.label("Flow Name:");
|
||||
ui.text_edit_singleline(&mut self.settings.flow);
|
||||
});
|
||||
|
||||
ui.horizontal(|ui| {
|
||||
ui.label("Known Hosts:");
|
||||
ui.text_edit_singleline(&mut self.settings.known_hosts);
|
||||
});
|
||||
|
||||
ui.horizontal(|ui| {
|
||||
ui.label("Basic Auth:");
|
||||
ui.text_edit_singleline(&mut self.settings.basic_auth);
|
||||
});
|
||||
|
||||
ui.horizontal(|ui| {
|
||||
ui.label("Auto sync interval (min):");
|
||||
ui.text_edit_singleline(&mut self.auto_sync_interval_str);
|
||||
// Parse the string and update settings
|
||||
if let Ok(value) = self.auto_sync_interval_str.parse::<u32>() {
|
||||
self.settings.auto_sync_interval_minutes = value;
|
||||
}
|
||||
});
|
||||
|
||||
ui.checkbox(&mut self.settings.in_place, "Update known_hosts file in-place after sync");
|
||||
|
||||
ui.separator();
|
||||
|
||||
ui.horizontal(|ui| {
|
||||
if ui.button("Save").clicked() {
|
||||
if let Err(e) = save_settings(&self.settings) {
|
||||
error!("Failed to save KHM settings: {}", e);
|
||||
} else {
|
||||
info!("KHM settings saved successfully");
|
||||
}
|
||||
ctx.send_viewport_cmd(egui::ViewportCommand::Close);
|
||||
}
|
||||
|
||||
if ui.button("Cancel").clicked() {
|
||||
ctx.send_viewport_cmd(egui::ViewportCommand::Close);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
pub fn run_settings_window() {
|
||||
let settings = load_settings();
|
||||
let auto_sync_interval_str = settings.auto_sync_interval_minutes.to_string();
|
||||
|
||||
let options = eframe::NativeOptions {
|
||||
viewport: egui::ViewportBuilder::default()
|
||||
.with_title("KHM Settings")
|
||||
.with_inner_size([450.0, 385.0]),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let _ = eframe::run_native(
|
||||
"KHM Settings",
|
||||
options,
|
||||
Box::new(|_cc| Ok(Box::new(KhmSettingsWindow {
|
||||
settings,
|
||||
auto_sync_interval_str,
|
||||
}))),
|
||||
);
|
||||
}
|
||||
|
BIN
static/.DS_Store
vendored
Normal file
BIN
static/.DS_Store
vendored
Normal file
Binary file not shown.
BIN
static/icon-settings.png
Normal file
BIN
static/icon-settings.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
BIN
static/icon-tray.png
Normal file
BIN
static/icon-tray.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 24 KiB |
Reference in New Issue
Block a user