Skip to content

Commit 074f107

Browse files
authored
Merge pull request #276 from RustCastLabs/better-settings-UI
Better settings UI
2 parents d6ff197 + 4da29b5 commit 074f107

8 files changed

Lines changed: 1030 additions & 479 deletions

File tree

src/app.rs

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::collections::HashMap;
33

44
use crate::app::apps::{App, AppCommand, ICNS_ICON};
55
use crate::commands::Function;
6-
use crate::config::{Config, MainPage, Shelly};
6+
use crate::config::{Config, MainPage, Shelly, ThemeMode};
77
use crate::debounce::DebouncePolicy;
88
use crate::platform::macos::launching::Shortcut;
99
use crate::utils::icns_data_to_handle;
@@ -41,6 +41,51 @@ pub enum Page {
4141
Settings,
4242
}
4343

44+
/// The settings panel tabs
45+
#[derive(Debug, Clone, Copy, PartialEq)]
46+
pub enum SettingsTab {
47+
General,
48+
Appearance,
49+
Commands,
50+
}
51+
52+
/// Actions that open a native file dialog
53+
#[derive(Debug, Clone)]
54+
pub enum FileDialogAction {
55+
PickModeFile(String),
56+
EditSearchDir(String),
57+
AddSearchDir,
58+
}
59+
60+
/// Config fields that can be individually reset to default
61+
#[derive(Debug, Clone, Copy, PartialEq)]
62+
pub enum ResetField {
63+
ToggleHotkey,
64+
ClipboardHotkey,
65+
Placeholder,
66+
SearchUrl,
67+
DebounceDelay,
68+
StartAtLogin,
69+
AutoUpdate,
70+
HapticFeedback,
71+
ShowMenubarIcon,
72+
ClipboardHistory,
73+
MainPage,
74+
ShowScrollbar,
75+
ClearOnHide,
76+
ClearOnEnter,
77+
ShowIcons,
78+
Font,
79+
EventDuration,
80+
TextColor,
81+
BackgroundColor,
82+
ThemeMode,
83+
Aliases,
84+
Modes,
85+
SearchDirs,
86+
ShellCommands,
87+
}
88+
4489
impl std::fmt::Display for Page {
4590
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4691
f.write_str(match self.to_owned() {
@@ -98,8 +143,11 @@ pub enum Message {
98143
RunFunction(Function),
99144
OpenFocused,
100145
SetConfig(SetConfigFields),
101-
OpenFileDialogue(String),
146+
OpenFileDialog(FileDialogAction),
147+
FileDialogResult(Option<Box<Message>>),
102148
ReturnFocus,
149+
SwitchSettingsTab(SettingsTab),
150+
ResetField(ResetField),
103151
EscKeyPressed(Id),
104152
UpdateEvents,
105153
ClearSearchResults,
@@ -119,6 +167,7 @@ pub enum Message {
119167
SetFileSearchSender(tokio::sync::watch::Sender<(String, Vec<String>)>),
120168
DebouncedSearch(Id),
121169
CheckEventTap,
170+
ThemeModeChanged(bool),
122171
}
123172

124173
#[derive(Debug, Clone)]
@@ -151,6 +200,7 @@ pub enum SetConfigThemeFields {
151200
BackgroundColor(f32, f32, f32),
152201
ShowIcons(bool),
153202
Font(String),
203+
ThemeMode(ThemeMode),
154204
}
155205

156206
#[derive(Debug, Clone)]

0 commit comments

Comments
 (0)