diff --git a/ferrum-addon/addon.d.ts b/ferrum-addon/addon.d.ts index 1447123..79f8261 100644 --- a/ferrum-addon/addon.d.ts +++ b/ferrum-addon/addon.d.ts @@ -186,6 +186,8 @@ export interface ViewOptions { shownPlaylistFolders: Array /** Empty is treated as default */ columns: Array + /** Auto update checking */ + noAutoUpdate: boolean skipUpdatingToVersion?: string } export declare function load_view_options(): ViewOptions diff --git a/src-native/view_options.rs b/src-native/view_options.rs index 12d1b32..02ded5c 100644 --- a/src-native/view_options.rs +++ b/src-native/view_options.rs @@ -15,6 +15,9 @@ pub struct ViewOptions { pub shown_playlist_folders: Vec, /// Empty is treated as default pub columns: Vec, + /// Auto update checking + #[serde(default)] + pub no_auto_update: bool, pub skip_updating_to_version: Option, } impl ViewOptions { @@ -24,6 +27,7 @@ impl ViewOptions { Err(_) => ViewOptions { shown_playlist_folders: Vec::new(), columns: Vec::new(), + no_auto_update: false, skip_updating_to_version: None, }, } diff --git a/src/App.svelte b/src/App.svelte index ed747e9..e73887c 100755 --- a/src/App.svelte +++ b/src/App.svelte @@ -22,6 +22,7 @@ import { navigate_back, navigate_forward } from './lib/router' import './lib/router' import CheckForUpdates from './components/CheckForUpdates.svelte' + import Settings from './components/Settings.svelte' ipc_renderer.invoke('app_loaded').catch(() => { ipc_renderer.invoke('showMessageBox', false, { @@ -110,6 +111,15 @@ } } + let show_settings = false + onDestroy( + ipc_listen('show_settings', () => { + if ($modal_count === 0) { + show_settings = true + } + }), + ) + let show_itunes_import = false onDestroy( ipc_listen('itunesImport', () => { @@ -217,6 +227,7 @@ {/if} + {#if $current_list} {/if} @@ -226,7 +237,9 @@ {#if show_itunes_import} (show_itunes_import = false)} /> {/if} - +{#if show_settings} + (show_settings = false)} /> +{/if} diff --git a/src/components/CheckForUpdates.svelte b/src/components/CheckForUpdates.svelte index 0642af4..5081c90 100644 --- a/src/components/CheckForUpdates.svelte +++ b/src/components/CheckForUpdates.svelte @@ -8,7 +8,7 @@ check() async function check() { - if (is_dev || !window.navigator.onLine) { + if (!window.navigator.onLine || view_options.noAutoUpdate) { return } const result = await ipc_renderer.invoke('check_for_updates') @@ -58,7 +58,9 @@ >
- + {/if} diff --git a/src/components/Settings.svelte b/src/components/Settings.svelte new file mode 100644 index 0000000..c46d0ba --- /dev/null +++ b/src/components/Settings.svelte @@ -0,0 +1,34 @@ + + + + + +
+ +
+ + + + +
diff --git a/src/electron/menubar.ts b/src/electron/menubar.ts index bd0f315..7801020 100644 --- a/src/electron/menubar.ts +++ b/src/electron/menubar.ts @@ -21,6 +21,14 @@ export function init_menu_bar(app: App, main_window: BrowserWindow) { submenu: [ { role: 'about' }, { type: 'separator' }, + { + label: 'Settings...', + accelerator: 'CmdOrCtrl+,', + click() { + web_contents.send('show_settings') + }, + }, + { type: 'separator' }, { role: 'services' }, { type: 'separator' }, { role: 'hide' }, @@ -37,13 +45,13 @@ export function init_menu_bar(app: App, main_window: BrowserWindow) { { label: 'New Playlist', accelerator: 'CmdOrCtrl+N', - click: () => { + click() { web_contents.send('newPlaylist', 'root', false) }, }, { label: 'New Playlist Folder', - click: () => { + click() { web_contents.send('newPlaylist', 'root', true) }, }, @@ -51,18 +59,27 @@ export function init_menu_bar(app: App, main_window: BrowserWindow) { { label: 'Import...', accelerator: 'CmdOrCtrl+O', - click: () => { + click() { web_contents.send('import') }, }, { type: 'separator' }, { label: 'Import iTunes Library...', - click: () => { + click() { web_contents.send('itunesImport') }, }, { type: 'separator' }, + { + label: 'Settings...', + accelerator: 'CmdOrCtrl+,', + click() { + web_contents.send('show_settings') + }, + visible: !is.mac, + }, + { type: 'separator', visible: !is.mac }, is.mac ? { role: 'close' } : { role: 'quit' }, ], }, @@ -87,7 +104,7 @@ export function init_menu_bar(app: App, main_window: BrowserWindow) { menu.push({ label: 'Filter', accelerator: 'CmdOrCtrl+F', - click: () => { + click() { web_contents.send('filter') }, }) @@ -100,14 +117,14 @@ export function init_menu_bar(app: App, main_window: BrowserWindow) { { label: 'Play Next', accelerator: '', - click: () => { + click() { web_contents.send('selected_tracks_action', 'Play Next') }, }, { label: 'Add to Queue', accelerator: '', - click: () => { + click() { web_contents.send('selected_tracks_action', 'Add to Queue') }, }, @@ -115,7 +132,7 @@ export function init_menu_bar(app: App, main_window: BrowserWindow) { { label: 'Get Info', accelerator: 'CmdOrCtrl+I', - click: () => { + click() { web_contents.send('selected_tracks_action', 'Get Info') }, }, @@ -127,7 +144,7 @@ export function init_menu_bar(app: App, main_window: BrowserWindow) { else return 'Reveal in File Manager' })(), accelerator: 'Shift+CmdOrCtrl+R', - click: () => { + click() { web_contents.send('selected_tracks_action', 'reveal_track_file') }, }, @@ -135,14 +152,14 @@ export function init_menu_bar(app: App, main_window: BrowserWindow) { { label: 'Remove from Playlist', accelerator: '', - click: () => { + click() { web_contents.send('selected_tracks_action', 'Remove from Playlist') }, }, { label: 'Delete from Library', accelerator: 'CmdOrCtrl+Backspace', - click: () => { + click() { web_contents.send('selected_tracks_action', 'Delete from Library') }, }, @@ -156,7 +173,7 @@ export function init_menu_bar(app: App, main_window: BrowserWindow) { id: 'Show Queue', type: 'checkbox', accelerator: 'CmdOrCtrl+U', - click: () => { + click() { web_contents.send('Show Queue') }, }, @@ -164,7 +181,7 @@ export function init_menu_bar(app: App, main_window: BrowserWindow) { label: 'Toggle Quick Nav', type: 'checkbox', accelerator: 'CmdOrCtrl+K', - click: () => { + click() { web_contents.send('ToggleQuickNav') }, }, @@ -194,21 +211,21 @@ export function init_menu_bar(app: App, main_window: BrowserWindow) { { label: 'Pause', // no accelerator because it's unreliable - click: () => { + click() { web_contents.send('playPause') }, }, { label: 'Next', accelerator: 'CmdOrCtrl+Right', - click: () => { + click() { web_contents.send('Next') }, }, { label: 'Previous', accelerator: 'CmdOrCtrl+Left', - click: () => { + click() { web_contents.send('Previous') }, }, @@ -218,7 +235,7 @@ export function init_menu_bar(app: App, main_window: BrowserWindow) { id: 'Shuffle', type: 'checkbox', accelerator: 'CmdOrCtrl+S', - click: () => { + click() { web_contents.send('Shuffle') }, }, @@ -227,7 +244,7 @@ export function init_menu_bar(app: App, main_window: BrowserWindow) { id: 'Repeat', type: 'checkbox', accelerator: 'CmdOrCtrl+R', - click: () => { + click() { web_contents.send('Repeat') }, }, @@ -236,7 +253,7 @@ export function init_menu_bar(app: App, main_window: BrowserWindow) { id: 'Volume Up', label: 'Volume Up', accelerator: 'CmdOrCtrl+Up', - click: () => { + click() { web_contents.send('volumeUp') }, }, @@ -244,7 +261,7 @@ export function init_menu_bar(app: App, main_window: BrowserWindow) { id: 'Volume Down', label: 'Volume Down', accelerator: 'CmdOrCtrl+Down', - click: () => { + click() { web_contents.send('volumeDown') }, }, @@ -257,7 +274,7 @@ export function init_menu_bar(app: App, main_window: BrowserWindow) { id: 'Back', label: 'Back', accelerator: 'CmdOrCtrl+[', - click: () => { + click() { web_contents.send('Back') }, }, @@ -265,7 +282,7 @@ export function init_menu_bar(app: App, main_window: BrowserWindow) { id: 'Forward', label: 'Forward', accelerator: 'CmdOrCtrl+]', - click: () => { + click() { web_contents.send('Forward') }, }, @@ -274,7 +291,7 @@ export function init_menu_bar(app: App, main_window: BrowserWindow) { id: 'Select Next List', label: 'Select Next List', accelerator: 'Ctrl+Tab', - click: () => { + click() { web_contents.send('Select Next List') }, }, @@ -282,7 +299,7 @@ export function init_menu_bar(app: App, main_window: BrowserWindow) { id: 'Select Previous List', label: 'Select Previous List', accelerator: 'Ctrl+Shift+Tab', - click: () => { + click() { web_contents.send('Select Previous List') }, }, diff --git a/src/electron/typed_ipc.ts b/src/electron/typed_ipc.ts index aedb900..d7abb72 100644 --- a/src/electron/typed_ipc.ts +++ b/src/electron/typed_ipc.ts @@ -103,6 +103,7 @@ type Events = { gonnaQuit: () => void newPlaylist: (id: string, isFolder: boolean) => void + show_settings: () => void itunesImport: () => void import: () => void filter: () => void