close tab command

This commit is contained in:
Jan Prochazka
2021-09-28 08:26:17 +02:00
parent a03682fc8a
commit e7634a2521
3 changed files with 24 additions and 2 deletions

View File

@@ -51,7 +51,8 @@ function buildMenu() {
commandItem('group.save'), commandItem('group.save'),
commandItem('group.saveAs'), commandItem('group.saveAs'),
{ type: 'separator' }, { type: 'separator' },
{ role: 'close' }, commandItem('tabs.closeTab'),
commandItem('file.exit'),
], ],
}, },
{ {

View File

@@ -266,6 +266,15 @@ if (hasPermission('settings/change')) {
}); });
} }
if (electron) {
registerCommand({
id: 'file.exit',
category: 'File',
name: 'Exit',
onClick: () => electron.remote.getCurrentWindow().close(),
});
}
export function registerFileCommands({ export function registerFileCommands({
idPrefix, idPrefix,
category, category,

View File

@@ -33,6 +33,9 @@
})) }))
); );
}; };
const closeCurrentTab = () => {
closeTab(getActiveTabId());
};
const closeWithSameDb = closeTabFunc( const closeWithSameDb = closeTabFunc(
(x, active) => (x, active) =>
_.get(x, 'props.conid') == _.get(active, 'props.conid') && _.get(x, 'props.conid') == _.get(active, 'props.conid') &&
@@ -96,6 +99,15 @@
onClick: closeAll, onClick: closeAll,
}); });
registerCommand({
id: 'tabs.closeTab',
category: 'Tabs',
name: 'Close tab',
keyText: 'Ctrl+W',
testEnabled: () => getOpenedTabs().filter(x => !x.closedTime).length >= 1,
onClick: closeCurrentTab,
});
registerCommand({ registerCommand({
id: 'tabs.addToFavorites', id: 'tabs.addToFavorites',
category: 'Tabs', category: 'Tabs',
@@ -120,7 +132,7 @@
import FavoriteModal from '../modals/FavoriteModal.svelte'; import FavoriteModal from '../modals/FavoriteModal.svelte';
import { showModal } from '../modals/modalTools'; import { showModal } from '../modals/modalTools';
import { currentDatabase, getActiveTab, getOpenedTabs, openedTabs, activeTabId } from '../stores'; import { currentDatabase, getActiveTab, getOpenedTabs, openedTabs, activeTabId, getActiveTabId } from '../stores';
import tabs from '../tabs'; import tabs from '../tabs';
import { setSelectedTab } from '../utility/common'; import { setSelectedTab } from '../utility/common';
import contextMenu from '../utility/contextMenu'; import contextMenu from '../utility/contextMenu';