Skip to content

Commit faea76c

Browse files
authored
Merge pull request #283 from memohnsen/settings-ui
2 parents 515bfa2 + 66451b6 commit faea76c

9 files changed

Lines changed: 484 additions & 468 deletions

File tree

src/app.rs

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ pub const FILE_SEARCH_BATCH_SIZE: u32 = 10;
3131
/// The rustcast descriptor name to be put for all rustcast commands
3232
pub const RUSTCAST_DESC_NAME: &str = "Utility";
3333

34-
/// The different pages that rustcast can have / has
34+
/// The different pages that rustcast can have / has within the launcher
35+
/// Settings is notably missing since this opens as a new window outside the launcher
3536
#[derive(Debug, Clone, PartialEq)]
3637
pub enum Page {
3738
Main,
3839
FileSearch,
3940
ClipboardHistory,
4041
EmojiSearch,
41-
Settings,
4242
}
4343

4444
/// The settings panel tabs
@@ -94,7 +94,6 @@ impl std::fmt::Display for Page {
9494
Page::FileSearch => "File search",
9595
Page::EmojiSearch => "Emoji search",
9696
Page::ClipboardHistory => "Clipboard history",
97-
Page::Settings => "Settings",
9897
})
9998
}
10099
}
@@ -127,7 +126,7 @@ pub enum Editable<T> {
127126
#[derive(Debug, Clone)]
128127
pub enum Message {
129128
UriReceived(String),
130-
WriteConfig(bool),
129+
WriteConfig,
131130
SaveRanking,
132131
ToggleAutoStartup(bool),
133132
LoadRanking,
@@ -136,7 +135,6 @@ pub enum Message {
136135
ResizeWindow(Id, f32),
137136
OpenWindow,
138137
OpenResult(u32),
139-
OpenToSettings,
140138
SearchQueryChanged(String, Id),
141139
KeyPressed(Shortcut),
142140
FocusTextInput(Move),
@@ -169,6 +167,8 @@ pub enum Message {
169167
DebouncedSearch(Id),
170168
ThemeModeChanged(bool),
171169
SimulatePaste(i32),
170+
OpenSettingsWindow,
171+
SettingsWindowOpened(window::Id),
172172
}
173173

174174
#[derive(Debug, Clone)]
@@ -228,6 +228,23 @@ pub fn default_settings() -> Settings {
228228
}
229229
}
230230

231+
pub fn settings_window_settings() -> window::Settings {
232+
Settings {
233+
resizable: false,
234+
decorations: true,
235+
minimizable: false,
236+
level: window::Level::AlwaysOnTop,
237+
transparent: false,
238+
blur: false,
239+
size: iced::Size {
240+
width: 900.,
241+
height: 600.,
242+
},
243+
position: window::Position::Centered,
244+
..Default::default()
245+
}
246+
}
247+
231248
/// A Trait to define that a struct can be converted to an app
232249
pub trait ToApp {
233250
/// Convert self into an app
@@ -287,7 +304,7 @@ impl ToApps for HashMap<String, String> {
287304
impl DebouncePolicy for Page {
288305
fn debounce_delay(&self, config: &Config) -> Option<Duration> {
289306
match self {
290-
Page::Main | Page::ClipboardHistory | Page::Settings => None,
307+
Page::Main | Page::ClipboardHistory => None,
291308
Page::FileSearch | Page::EmojiSearch => {
292309
Some(Duration::from_millis(config.debounce_delay))
293310
}
@@ -306,7 +323,6 @@ mod tests {
306323
assert_eq!(Page::FileSearch.to_string(), "File search");
307324
assert_eq!(Page::ClipboardHistory.to_string(), "Clipboard history");
308325
assert_eq!(Page::EmojiSearch.to_string(), "Emoji search");
309-
assert_eq!(Page::Settings.to_string(), "Settings");
310326
}
311327

312328
#[test]
@@ -318,7 +334,6 @@ mod tests {
318334

319335
assert_eq!(Page::Main.debounce_delay(&config), None);
320336
assert_eq!(Page::ClipboardHistory.debounce_delay(&config), None);
321-
assert_eq!(Page::Settings.debounce_delay(&config), None);
322337
assert_eq!(
323338
Page::FileSearch.debounce_delay(&config),
324339
Some(Duration::from_millis(123))

src/app/apps.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ impl App {
128128
},
129129
App {
130130
ranking: 0,
131-
open_command: AppCommand::Message(Message::SwitchToPage(Page::Settings)),
131+
open_command: AppCommand::Message(Message::OpenSettingsWindow),
132132
desc: RUSTCAST_DESC_NAME.to_string(),
133133
icons: icons.clone(),
134134
display_name: "Open RustCast Preferences".to_string(),

src/app/menubar.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,10 @@ fn init_event_handler(sender: ExtSender, shortcut: Shortcut) {
128128
}
129129
"open_preferences" => {
130130
runtime.spawn(async move {
131-
sender.clone().try_send(Message::OpenToSettings).unwrap();
131+
sender
132+
.clone()
133+
.try_send(Message::OpenSettingsWindow)
134+
.unwrap();
132135
});
133136
}
134137
"open_github_page" => {

0 commit comments

Comments
 (0)