Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
254 changes: 43 additions & 211 deletions Cargo.lock

Large diffs are not rendered by default.

44 changes: 40 additions & 4 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ pub enum Page {
FileSearch,
ClipboardHistory,
EmojiSearch,
Settings,
}

impl std::fmt::Display for Page {
Expand All @@ -46,6 +47,7 @@ impl std::fmt::Display for Page {
Page::FileSearch => "File search",
Page::EmojiSearch => "Emoji search",
Page::ClipboardHistory => "Clipboard history",
Page::Settings => "Settings",
})
}
}
Expand All @@ -70,15 +72,18 @@ pub enum Move {
/// The message type that iced uses for actions that can do something
#[derive(Debug, Clone)]
pub enum Message {
WriteConfig,
UpdateAvailable,
ResizeWindow(Id, f32),
OpenWindow,
OpenToSettings,
SearchQueryChanged(String, Id),
KeyPressed(u32),
FocusTextInput(Move),
HideWindow(Id),
RunFunction(Function),
OpenFocused,
SetConfig(SetConfigFields),
ReturnFocus,
EscKeyPressed(Id),
ClearSearchResults,
Expand All @@ -97,6 +102,37 @@ pub enum Message {
DebouncedSearch(Id),
}

#[derive(Debug, Clone)]
pub enum SetConfigFields {
ToDefault,
ToggleHotkey(String),
ClipboardHotkey(String),
PlaceHolder(String),
SearchUrl(String),
HapticFeedback(bool),
ShowMenubarIcon(bool),
// Modes(HashMap<String, String>),
// Aliases(HashMap<String, String>),
// SearchDirs(Vec<String>),
DebounceDelay(u64),
SetThemeFields(SetConfigThemeFields),
SetBufferFields(SetConfigBufferFields),
}

#[derive(Debug, Clone)]
pub enum SetConfigThemeFields {
TextColor(f32, f32, f32),
BackgroundColor(f32, f32, f32),
ShowIcons(bool),
Font(String),
}

#[derive(Debug, Clone)]
pub enum SetConfigBufferFields {
ClearOnHide(bool),
ClearOnEnter(bool),
}

/// The window settings for rustcast
pub fn default_settings() -> Settings {
Settings {
Expand Down Expand Up @@ -173,10 +209,10 @@ impl ToApps for HashMap<String, String> {
impl DebouncePolicy for Page {
fn debounce_delay(&self, config: &Config) -> Option<Duration> {
match self {
Page::Main => None,
Page::FileSearch => Some(Duration::from_millis(config.debounce_delay)),
Page::ClipboardHistory => None,
Page::EmojiSearch => Some(Duration::from_millis(config.debounce_delay)),
Page::Main | Page::ClipboardHistory | Page::Settings => None,
Page::FileSearch | Page::EmojiSearch => {
Some(Duration::from_millis(config.debounce_delay))
}
}
}
}
2 changes: 1 addition & 1 deletion src/app/apps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ impl App {
},
App {
ranking: 0,
open_command: AppCommand::Function(Function::OpenPrefPane),
open_command: AppCommand::Message(Message::SwitchToPage(Page::Settings)),
desc: RUSTCAST_DESC_NAME.to_string(),
icons: icons.clone(),
display_name: "Open RustCast Preferences".to_string(),
Expand Down
6 changes: 4 additions & 2 deletions src/app/menubar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use tray_icon::{
use crate::{
app::{Message, tile::ExtSender},
config::Config,
utils::{open_settings, open_url},
utils::open_url,
};

const DISCORD_LINK: &str = "https://discord.gg/bDfNYPbnC5";
Expand Down Expand Up @@ -124,7 +124,9 @@ fn init_event_handler(sender: ExtSender, hotkey_id: u32) {
open_url("https://github.com/unsecretised/rustcast/discussions/new?category=q-a");
}
"open_preferences" => {
open_settings();
runtime.spawn(async move {
sender.clone().try_send(Message::OpenToSettings).unwrap();
});
}
"open_github_page" => {
open_url("https://github.com/unsecretised/rustcast");
Expand Down
Loading
Loading