mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-11-24 05:29:51 +03:00
Add a shortcut and menu item to access settings
Co-authored-by: Louis <h1ghbre4k3r@dev.bre4k3r.de>
This commit is contained in:
parent
c83dec6bca
commit
58ea9879ba
17
app/src/lib/components/GlobalSettingsMenuAction.svelte
Normal file
17
app/src/lib/components/GlobalSettingsMenuAction.svelte
Normal 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>
|
@ -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 {
|
||||
|
@ -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"),
|
||||
|
Loading…
Reference in New Issue
Block a user