Add a shortcut and menu item to access settings

Co-authored-by: Louis <h1ghbre4k3r@dev.bre4k3r.de>
This commit is contained in:
Caleb Owens 2024-06-17 11:05:47 +02:00
parent c83dec6bca
commit 58ea9879ba
No known key found for this signature in database
3 changed files with 26 additions and 0 deletions

View File

@ -0,0 +1,17 @@
<script lang="ts">
import { listen } from '$lib/backend/ipc';
import { onMount } from 'svelte';
import { goto } from '$app/navigation';
onMount(() => {
const unsubscribeSettings = listen<string>('menu://global/settings/clicked', () => {
if (!window.location.pathname.startsWith('/settings/')) {
goto(`/settings/`);
}
});
return () => {
unsubscribeSettings();
};
});
</script>

View File

@ -10,6 +10,7 @@
import { PromptService } from '$lib/backend/prompt';
import { UpdaterService } from '$lib/backend/updater';
import AppUpdater from '$lib/components/AppUpdater.svelte';
import GlobalSettingsMenuAction from '$lib/components/GlobalSettingsMenuAction.svelte';
import PromptModal from '$lib/components/PromptModal.svelte';
import ShareIssueModal from '$lib/components/ShareIssueModal.svelte';
import { GitHubService } from '$lib/github/service';
@ -101,6 +102,7 @@
<ToastController />
<AppUpdater />
<PromptModal />
<GlobalSettingsMenuAction />
<style lang="postcss">
.app-root {

View File

@ -72,6 +72,8 @@ pub fn build(_package_info: &PackageInfo) -> Menu {
AboutMetadata::default(),
))
.add_native_item(MenuItem::Separator)
.add_item(CustomMenuItem::new("global/settings", "Settings").accelerator("Cmd+,"))
.add_native_item(MenuItem::Separator)
.add_native_item(MenuItem::Services)
.add_native_item(MenuItem::Separator)
.add_native_item(MenuItem::Hide)
@ -227,6 +229,11 @@ pub fn handle_event<R: Runtime>(event: &WindowMenuEvent<R>) {
return;
}
if event.menu_item_id() == "global/settings" {
emit(event.window(), "menu://global/settings/clicked");
return;
}
'open_link: {
let result = match event.menu_item_id() {
"help/documentation" => open::that("https://docs.gitbutler.com"),