mirror of
https://github.com/garraflavatra/rolens.git
synced 2025-01-18 21:17:59 +00:00
Menus and keyboard shortcuts
This commit is contained in:
parent
4cefc33bd4
commit
29e93dcab1
@ -8,6 +8,7 @@
|
|||||||
import Remove from './remove.svelte';
|
import Remove from './remove.svelte';
|
||||||
import Stats from './stats.svelte';
|
import Stats from './stats.svelte';
|
||||||
import Update from './update.svelte';
|
import Update from './update.svelte';
|
||||||
|
import { EventsOn } from '../../../../wailsjs/runtime/runtime';
|
||||||
|
|
||||||
export let collection;
|
export let collection;
|
||||||
export let hostKey;
|
export let hostKey;
|
||||||
@ -23,6 +24,8 @@
|
|||||||
collection.key = collectionKey;
|
collection.key = collectionKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EventsOn('OpenCollectionTab', name => (tab = name || tab));
|
||||||
|
|
||||||
async function catchQuery(event) {
|
async function catchQuery(event) {
|
||||||
tab = 'find';
|
tab = 'find';
|
||||||
await tick();
|
await tick();
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
import CollectionDetail from './collection/index.svelte';
|
import CollectionDetail from './collection/index.svelte';
|
||||||
import HostDetail from './hostdetail.svelte';
|
import HostDetail from './hostdetail.svelte';
|
||||||
import Icon from '../../components/icon.svelte';
|
import Icon from '../../components/icon.svelte';
|
||||||
|
import { EventsOn } from '../../../wailsjs/runtime/runtime';
|
||||||
|
|
||||||
export let hosts = {};
|
export let hosts = {};
|
||||||
export let activeHostKey = '';
|
export let activeHostKey = '';
|
||||||
@ -72,6 +73,9 @@
|
|||||||
busy.end();
|
busy.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EventsOn('CreateHost', createHost);
|
||||||
|
EventsOn('CreateDatabase', () => newDb = {});
|
||||||
|
EventsOn('CreateCollection', () => newColl = {});
|
||||||
onMount(getHosts);
|
onMount(getHosts);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import {defineConfig} from 'vite'
|
import { defineConfig } from 'vite';
|
||||||
import {svelte} from '@sveltejs/vite-plugin-svelte'
|
import { svelte } from '@sveltejs/vite-plugin-svelte';
|
||||||
|
|
||||||
// https://vitejs.dev/config/
|
// https://vitejs.dev/config/
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [svelte()]
|
plugins: [ svelte() ],
|
||||||
})
|
});
|
||||||
|
@ -21,34 +21,43 @@ func (a *App) Startup(ctx context.Context) {
|
|||||||
a.ctx = ctx
|
a.ctx = ctx
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func menuEventEmitter(a *App, eventName string, data ...interface{}) func(cd *menu.CallbackData) {
|
||||||
|
return func(cd *menu.CallbackData) {
|
||||||
|
wailsRuntime.EventsEmit(a.ctx, eventName, data...)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (a *App) Menu() *menu.Menu {
|
func (a *App) Menu() *menu.Menu {
|
||||||
appMenu := menu.NewMenu()
|
appMenu := menu.NewMenu()
|
||||||
|
|
||||||
aboutMenu := appMenu.AddSubmenu("About")
|
aboutMenu := appMenu.AddSubmenu("About")
|
||||||
aboutMenu.AddText("About…", nil, func(cd *menu.CallbackData) {
|
aboutMenu.AddText("About…", nil, menuEventEmitter(a, "OpenAboutModal"))
|
||||||
wailsRuntime.EventsEmit(a.ctx, "OpenAboutModal")
|
aboutMenu.AddText("Prefrences…", keys.CmdOrCtrl(","), menuEventEmitter(a, "OpenPrefrences"))
|
||||||
})
|
|
||||||
aboutMenu.AddText("Prefrences…", keys.CmdOrCtrl(","), func(cd *menu.CallbackData) {
|
|
||||||
wailsRuntime.EventsEmit(a.ctx, "OpenPrefrences")
|
|
||||||
})
|
|
||||||
aboutMenu.AddSeparator()
|
aboutMenu.AddSeparator()
|
||||||
aboutMenu.AddText("Quit", keys.CmdOrCtrl("q"), func(cd *menu.CallbackData) {
|
aboutMenu.AddText("Quit", keys.CmdOrCtrl("q"), func(cd *menu.CallbackData) { wailsRuntime.Quit(a.ctx) })
|
||||||
wailsRuntime.Quit(a.ctx)
|
|
||||||
})
|
|
||||||
|
|
||||||
// fileMenu := appMenu.AddSubmenu("File")
|
|
||||||
// fileMenu.AddText("Hosts…", keys.CmdOrCtrl("k"), func(cd *menu.CallbackData) {
|
|
||||||
// wailsRuntime.EventsEmit(a.ctx, "OpenHostsModal")
|
|
||||||
// })
|
|
||||||
|
|
||||||
if runtime.GOOS == "darwin" {
|
if runtime.GOOS == "darwin" {
|
||||||
appMenu.Append(menu.EditMenu())
|
appMenu.Append(menu.EditMenu())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hostMenu := appMenu.AddSubmenu("Host")
|
||||||
|
hostMenu.AddText("New host", keys.CmdOrCtrl("y"), menuEventEmitter(a, "CreateHost"))
|
||||||
|
|
||||||
|
databaseMenu := appMenu.AddSubmenu("Database")
|
||||||
|
databaseMenu.AddText("New database", keys.CmdOrCtrl("u"), menuEventEmitter(a, "CreateDatabase"))
|
||||||
|
|
||||||
|
collectionMenu := appMenu.AddSubmenu("Collection")
|
||||||
|
collectionMenu.AddText("New collection", keys.CmdOrCtrl("i"), menuEventEmitter(a, "CreateCollection"))
|
||||||
|
collectionMenu.AddSeparator()
|
||||||
|
collectionMenu.AddText("Stats", keys.Combo("h", keys.CmdOrCtrlKey, keys.OptionOrAltKey), menuEventEmitter(a, "OpenCollectionTab", "stats"))
|
||||||
|
collectionMenu.AddText("Find", keys.Combo("f", keys.CmdOrCtrlKey, keys.OptionOrAltKey), menuEventEmitter(a, "OpenCollectionTab", "find"))
|
||||||
|
collectionMenu.AddText("Insert", keys.Combo("i", keys.CmdOrCtrlKey, keys.OptionOrAltKey), menuEventEmitter(a, "OpenCollectionTab", "insert"))
|
||||||
|
collectionMenu.AddText("Update", keys.Combo("u", keys.CmdOrCtrlKey, keys.OptionOrAltKey), menuEventEmitter(a, "OpenCollectionTab", "update"))
|
||||||
|
collectionMenu.AddText("Remove", keys.Combo("r", keys.CmdOrCtrlKey, keys.OptionOrAltKey), menuEventEmitter(a, "OpenCollectionTab", "remove"))
|
||||||
|
collectionMenu.AddText("Indexes", keys.Combo("x", keys.CmdOrCtrlKey, keys.OptionOrAltKey), menuEventEmitter(a, "OpenCollectionTab", "indexes"))
|
||||||
|
|
||||||
helpMenu := appMenu.AddSubmenu("Help")
|
helpMenu := appMenu.AddSubmenu("Help")
|
||||||
helpMenu.AddText("User guide", nil, func(cd *menu.CallbackData) {
|
helpMenu.AddText("User guide", nil, func(cd *menu.CallbackData) { wailsRuntime.BrowserOpenURL(a.ctx, "") })
|
||||||
wailsRuntime.BrowserOpenURL(a.ctx, "")
|
|
||||||
})
|
|
||||||
|
|
||||||
return appMenu
|
return appMenu
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user