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
1 change: 1 addition & 0 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ pub enum SetConfigFields {
ClipboardHotkey(String),
PlaceHolder(String),
SearchUrl(String),
ClipboardHistory(bool),
HapticFeedback(bool),
ShowMenubarIcon(bool),
SetPage(MainPage),
Expand Down
18 changes: 18 additions & 0 deletions src/app/pages/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,23 @@ pub fn settings_page(config: Config) -> Element<'static, Message> {
notice_item(theme.clone(), "Which search engine to use (%s = query)"),
]);

let theme_clone = theme.clone();
let clipboard_history = Row::from_iter([
settings_hint_text(theme.clone(), "Enable Clipboard history"),
checkbox(config.clone().cbhist)
.style(move |_, _| settings_checkbox_style(&theme_clone))
.on_toggle(|input| Message::SetConfig(SetConfigFields::ClipboardHistory(input)))
.into(),
notice_item(
theme.clone(),
"If you want your clipboard history to be stored",
),
])
.align_y(Alignment::Center)
.spacing(SETTINGS_ITEM_COL_SPACING * 2)
.padding(SETTINGS_ITEM_PADDING)
.height(SETTINGS_ITEM_HEIGHT);

let theme_clone = theme.clone();
let current_delay = config.debounce_delay;
let debounce = settings_item_column([
Expand Down Expand Up @@ -396,6 +413,7 @@ pub fn settings_page(config: Config) -> Element<'static, Message> {
debounce.into(),
haptic.into(),
tray_icon.into(),
clipboard_history.into(),
auto_suggest.into(),
show_scrollbar.into(),
clear_on_hide.into(),
Expand Down
24 changes: 20 additions & 4 deletions src/app/tile/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,9 +345,20 @@ pub fn handle_update(tile: &mut Tile, message: Message) -> Task<Message> {
}

Message::SwitchToPage(page) => {
tile.page = page;
let task = match tile.page {
Page::ClipboardHistory | Page::Settings => window::latest().map(|x| {
let task = match &page {
Page::ClipboardHistory => {
if !tile.config.cbhist {
return Task::none();
}
window::latest().map(|x| {
let id = x.unwrap();
Message::ResizeWindow(
id,
((7 * 55) + 35 + DEFAULT_WINDOW_HEIGHT as usize) as f32,
)
})
}
Page::Settings => window::latest().map(|x| {
let id = x.unwrap();
Message::ResizeWindow(
id,
Expand All @@ -357,6 +368,8 @@ pub fn handle_update(tile: &mut Tile, message: Message) -> Task<Message> {
_ => Task::none(),
};

tile.page = page;

let refresh_empty_main_query = if tile.page == Page::Main {
window::latest()
.map(|x| x.unwrap())
Expand Down Expand Up @@ -477,6 +490,9 @@ pub fn handle_update(tile: &mut Tile, message: Message) -> Task<Message> {
}

Message::EditClipboardHistory(action) => {
if !tile.config.cbhist {
return Task::none();
}
match action {
Editable::Create(content) => {
if !tile.clipboard_content.contains(&content) {
Expand Down Expand Up @@ -606,6 +622,7 @@ pub fn handle_update(tile: &mut Tile, message: Message) -> Task<Message> {
match config {
SetConfigFields::ToggleHotkey(hk) => final_config.toggle_hotkey = hk,
SetConfigFields::ClipboardHotkey(hk) => final_config.clipboard_hotkey = hk,
SetConfigFields::ClipboardHistory(cbhist) => final_config.cbhist = cbhist,
SetConfigFields::Modes(Editable::Create((key, value))) => {
final_config.modes.insert(key, value);
}
Expand Down Expand Up @@ -935,7 +952,6 @@ fn execute_query(tile: &mut Tile, id: Id) -> Task<Message> {
}
"cbhist" => {
task = task.chain(Task::done(Message::SwitchToPage(Page::ClipboardHistory)));
tile.page = Page::ClipboardHistory;
}
"main" => {
if tile.page != Page::Main {
Expand Down
2 changes: 2 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pub struct Config {
pub placeholder: String,
pub search_url: String,
pub haptic_feedback: bool,
pub cbhist: bool,
pub show_trayicon: bool,
pub shells: Vec<Shelly>,
pub modes: HashMap<String, String>,
Expand All @@ -44,6 +45,7 @@ impl Default for Config {
theme: Theme::default(),
placeholder: String::from("Time to be productive!"),
search_url: "https://duckduckgo.com/search?q=%s".to_string(),
cbhist: true,
haptic_feedback: false,
show_trayicon: true,
main_page: MainPage::default(),
Expand Down
Loading