Skip to content

Commit

Permalink
Make preferences and log in small, force preference to stay always on…
Browse files Browse the repository at this point in the history
… top
  • Loading branch information
Samuel Oldham committed Sep 27, 2024
1 parent 620fb27 commit b718257
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 44 deletions.
6 changes: 3 additions & 3 deletions psst-gui/src/delegate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ impl Delegate {
}
}

fn show_preferences(&mut self, config: &Config, ctx: &mut DelegateCtx) {
fn show_preferences(&mut self, ctx: &mut DelegateCtx) {
match self.preferences_window {
Some(id) => {
ctx.submit_command(commands::SHOW_WINDOW.to(id));
}
None => {
let window = ui::preferences_window(config);
let window = ui::preferences_window();
self.preferences_window.replace(window.id);
ctx.new_window(window);
}
Expand Down Expand Up @@ -113,7 +113,7 @@ impl AppDelegate<AppState> for Delegate {
self.show_account_setup(ctx);
Handled::Yes
} else if cmd.is(commands::SHOW_PREFERENCES) {
self.show_preferences(&data.config, ctx);
self.show_preferences(ctx);
Handled::Yes
} else if cmd.is(cmd::CLOSE_ALL_WINDOWS) {
self.close_all_windows(ctx);
Expand Down
48 changes: 8 additions & 40 deletions psst-gui/src/ui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,40 +74,17 @@ pub fn main_window(config: &Config) -> WindowDesc<AppState> {
}
}

pub fn preferences_window(config: &Config) -> WindowDesc<AppState> {
pub fn preferences_window() -> WindowDesc<AppState> {
// Change this
let win_size = (theme::grid(50.0), theme::grid(55.0));

// On Windows, the window size includes the titlebar.
let win_size = if cfg!(target_os = "windows") {
const WINDOWS_TITLEBAR_OFFSET: f64 = 56.0;
(win_size.0, win_size.1 + WINDOWS_TITLEBAR_OFFSET)
} else {
win_size
};

let mut win = WindowDesc::new(preferences_widget())
let win = WindowDesc::new(preferences_widget())
.title("Preferences")
.window_size(win_size)
.resizable(false)
.show_title(false)
.set_always_on_top(true)
.transparent_titlebar(true);

if config.kiosk_mode {
if let Some(monitor) = druid::Screen::get_monitors().first() {
let work_area = monitor.virtual_work_rect();
win = win
.window_size(work_area.size())
.set_position(druid::Point::new(0.0, 0.0));
}

win = win
.set_window_state(WindowState::Maximized)
.resizable(false)
.set_always_on_top(true)
.show_titlebar(false);
} else {
win = win.window_size(win_size)
.resizable(false)
}
if cfg!(target_os = "macos") {
win.menu(menu::main_menu)
} else {
Expand All @@ -130,21 +107,12 @@ pub fn account_setup_window() -> WindowDesc<AppState> {
}

pub fn kiosk_setup_window() -> WindowDesc<AppState> {
let mut win = WindowDesc::new(kiosk_setup_widget())
let win = WindowDesc::new(kiosk_setup_widget())
.title("Setup")
.resizable(false)
.show_title(false)
.set_window_state(WindowState::Maximized)
.show_titlebar(false)
.window_size((theme::grid(50.0), theme::grid(45.0)))
.transparent_titlebar(true);

if let Some(monitor) = druid::Screen::get_monitors().first() {
let work_area = monitor.virtual_work_rect();
win = win
.window_size(work_area.size())
.set_position(druid::Point::new(0.0, 0.0))
.resizable(false);
}

if cfg!(target_os = "macos") {
win.menu(menu::main_menu)
} else {
Expand Down
2 changes: 1 addition & 1 deletion psst-gui/src/ui/preferences.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,9 +430,9 @@ impl<W: Widget<AppState>> Controller<AppState, W> for Authenticate {
ctx.submit_command(cmd::SESSION_CONNECT);
}
AccountTab::KioskSetup => {
ctx.submit_command(cmd::SHOW_MAIN);
ctx.submit_command(commands::CLOSE_WINDOW);
ctx.submit_command(commands::SHOW_PREFERENCES);
ctx.submit_command(cmd::SHOW_MAIN);
}
}
}
Expand Down

0 comments on commit b718257

Please sign in to comment.