autostart apps removal
This commit is contained in:
@@ -34,11 +34,15 @@
|
||||
</Button>
|
||||
</template>
|
||||
|
||||
<template name="AutoStartApp">
|
||||
<Button id="${id}" color="#AA3333" height="32" tooltip="${translation}_HELP" padding="4" gap="8" >
|
||||
<sprite src_builtin="${icon}" height="24" width="24" />
|
||||
<label align="left" translation="${translation}" weight="bold" min_width="200" />
|
||||
</Button>
|
||||
<template name="AutostartApp">
|
||||
<div id="${id}_root" flex_direction="row">
|
||||
<Button id="${id}" color="#AA3333" height="24" padding="4" margin_top="-2" margin_bottom="-2" >
|
||||
<sprite src_builtin="dashboard/close.svg" height="20" width="20" />
|
||||
</Button>
|
||||
<div padding_left="8" >
|
||||
<label align="left" text="${text}" weight="bold" overflow="hidden"/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<elements>
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<rectangle macro="group_box" id="icon_parent" padding="16" color="#0033aa66" color2="#00000022" gradient="vertical" justify_content="center">
|
||||
|
||||
</rectangle>
|
||||
<div flex_direction="column" gap="8" flex_grow="1">
|
||||
<div flex_direction="column" gap="8" flex_grow="1" max_width="720">
|
||||
<label id="label_title" weight="bold" size="32" overflow="hidden" />
|
||||
<Subtext label_id="label_exec" overflow="hidden" />
|
||||
<Separator />
|
||||
@@ -61,4 +61,4 @@
|
||||
</div>
|
||||
</div>
|
||||
</elements>
|
||||
</layout>
|
||||
</layout>
|
||||
|
||||
@@ -96,7 +96,8 @@
|
||||
"XR_CLICK_SENSITIVITY_HELP": "Analog trigger sensitivity",
|
||||
"XR_CLICK_SENSITIVITY_RELEASE": "XR release sensitivity",
|
||||
"XR_CLICK_SENSITIVITY_RELEASE_HELP": "Must be lower than click",
|
||||
"XWAYLAND_BY_DEFAULT": "Run apps in Compatibility mode by default"
|
||||
"XWAYLAND_BY_DEFAULT": "Run apps in Compatibility mode by default",
|
||||
"AUTOSTART_APPS": "Apps to run on startup"
|
||||
},
|
||||
"APPLICATION_LAUNCHER": "Application launcher",
|
||||
"APPLICATION_STARTED": "Application started",
|
||||
|
||||
@@ -30,12 +30,13 @@ enum Task {
|
||||
ClearSavedState,
|
||||
DeleteAllConfigs,
|
||||
RestartSoftware,
|
||||
RemoveAutostartApp(Rc<str>),
|
||||
}
|
||||
|
||||
pub struct TabSettings<T> {
|
||||
#[allow(dead_code)]
|
||||
pub state: ParserState,
|
||||
|
||||
app_button_ids: Vec<Rc<str>>,
|
||||
context_menu: ContextMenu,
|
||||
|
||||
tasks: Tasks<Task>,
|
||||
@@ -91,6 +92,15 @@ impl<T> Tab<T> for TabSettings<T> {
|
||||
blueprint: Blueprint::Cells(cells),
|
||||
});
|
||||
}
|
||||
Task::RemoveAutostartApp(button_id) => {
|
||||
if let Some(idx) = self.app_button_ids.iter().position(|x| button_id.eq(x)) {
|
||||
config.autostart_apps.remove(idx);
|
||||
changed = true;
|
||||
if let Ok(widget) = self.state.get_widget_id(&format!("{button_id}_root")) {
|
||||
frontend.layout.remove_widget(widget);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -539,7 +549,7 @@ macro_rules! dropdown {
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! button {
|
||||
macro_rules! danger_button {
|
||||
($mp:expr, $root:expr, $translation:expr, $icon:expr, $task:expr) => {
|
||||
let id = $mp.idx.to_string();
|
||||
$mp.idx += 1;
|
||||
@@ -564,6 +574,34 @@ macro_rules! button {
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! autostart_app {
|
||||
($mp:expr, $root:expr, $text:expr, $ids:expr) => {
|
||||
let id = $mp.idx.to_string();
|
||||
$mp.idx += 1;
|
||||
|
||||
let mut params: HashMap<Rc<str>, Rc<str>> = HashMap::new();
|
||||
params.insert(Rc::from("id"), Rc::from(id.as_ref()));
|
||||
params.insert(Rc::from("text"), Rc::from($text.as_str()));
|
||||
|
||||
$mp
|
||||
.parser_state
|
||||
.instantiate_template($mp.doc_params, "AutostartApp", $mp.layout, $root, params)?;
|
||||
|
||||
let btn = $mp.parser_state.fetch_component_as::<ComponentButton>(&id)?;
|
||||
let id: Rc<str> = Rc::from(id);
|
||||
|
||||
$ids.push(id.clone());
|
||||
|
||||
btn.on_click(Box::new({
|
||||
let tasks = $mp.tasks.clone();
|
||||
move |_common, _e| {
|
||||
tasks.push(Task::RemoveAutostartApp(id.clone()));
|
||||
Ok(())
|
||||
}
|
||||
}));
|
||||
};
|
||||
}
|
||||
|
||||
struct MacroParams<'a> {
|
||||
layout: &'a mut Layout,
|
||||
parser_state: &'a mut ParserState,
|
||||
@@ -645,29 +683,39 @@ impl<T> TabSettings<T> {
|
||||
checkbox!(mp, c, SettingType::DoubleCursorFix);
|
||||
checkbox!(mp, c, SettingType::ScreenRenderDown);
|
||||
|
||||
let c = category!(mp, root, "APP_SETTINGS.TROUBLESHOOTING", "dashboard/blocks.svg")?;
|
||||
button!(
|
||||
let mut app_button_ids = vec![];
|
||||
|
||||
if !mp.config.autostart_apps.is_empty() {
|
||||
let c = category!(mp, root, "APP_SETTINGS.AUTOSTART_APPS", "dashboard/apps.svg")?;
|
||||
|
||||
for app in &mp.config.autostart_apps {
|
||||
autostart_app!(mp, c, app.name, app_button_ids);
|
||||
}
|
||||
}
|
||||
|
||||
let c = category!(mp, root, "APP_SETTINGS.TROUBLESHOOTING", "dashboard/cpu.svg")?;
|
||||
danger_button!(
|
||||
mp,
|
||||
c,
|
||||
"APP_SETTINGS.CLEAR_PIPEWIRE_TOKENS",
|
||||
"dashboard/display.svg",
|
||||
Task::ClearPipewireTokens
|
||||
);
|
||||
button!(
|
||||
danger_button!(
|
||||
mp,
|
||||
c,
|
||||
"APP_SETTINGS.CLEAR_SAVED_STATE",
|
||||
"dashboard/binary.svg",
|
||||
Task::ClearSavedState
|
||||
);
|
||||
button!(
|
||||
danger_button!(
|
||||
mp,
|
||||
c,
|
||||
"APP_SETTINGS.DELETE_ALL_CONFIGS",
|
||||
"dashboard/circle.svg",
|
||||
Task::DeleteAllConfigs
|
||||
);
|
||||
button!(
|
||||
danger_button!(
|
||||
mp,
|
||||
c,
|
||||
"APP_SETTINGS.RESTART_SOFTWARE",
|
||||
@@ -676,6 +724,7 @@ impl<T> TabSettings<T> {
|
||||
);
|
||||
|
||||
Ok(Self {
|
||||
app_button_ids,
|
||||
tasks: mp.tasks,
|
||||
state: parser_state,
|
||||
marker: PhantomData,
|
||||
|
||||
Reference in New Issue
Block a user