Skip to content

Commit

Permalink
feature: add setting: closeAppWindowWhenLastWorkspaceTabIsClosed
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksey-hoffman committed Sep 11, 2021
1 parent 9e08e4e commit c2e1328
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 10 deletions.
1 change: 0 additions & 1 deletion src/shortcuts.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ export default {
iconSize: '20px',
action: {
name: 'CLOSE_CURRENT_TAB',
options: 'selected'
},
shortcut: 'Ctrl + W',
description: 'Close current tab / window'
Expand Down
30 changes: 21 additions & 9 deletions src/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,9 @@ export default new Vuex.Store({
showHiddenDirItems: false,
openDirItemWithSingleClick: false,
openDirItemSecondClickDelay: 500,
tabs: {
closeAppWindowWhenLastWorkspaceTabIsClosed: false
}
},
tips: [
{
Expand Down Expand Up @@ -2750,6 +2753,9 @@ export default new Vuex.Store({
dispatch('DESELECT_ALL_DIR_ITEMS')
}
},
CLOSE_APP_WINDOW (store) {
electron.ipcRenderer.send('handle:close-app', store.state.storageData.settings.windowCloseButtonAction)
},
CLOSE_ALL_TABS_IN_CURRENT_WORKSPACE ({ commit, dispatch, getters }) {
let tabs = [...getters.selectedWorkspace.tabs]
tabs = []
Expand All @@ -2761,15 +2767,21 @@ export default new Vuex.Store({
if (currentDirTab) {
store.dispatch('CLOSE_TAB', currentDirTab)
}
if (tabs.length === 0) {
eventHub.$emit('notification', {
action: 'update-by-type',
type: 'current-workspace-has-no-tabs',
timeout: 3000,
type: '',
closeButton: true,
title: 'Current workspace has no tabs'
})
if (store.getters.selectedWorkspace.tabs.length === 0) {
// Close app window if needed
if (store.state.storageData.settings.navigator.tabs.closeAppWindowWhenLastWorkspaceTabIsClosed) {
store.dispatch('CLOSE_APP_WINDOW')
}
else {
eventHub.$emit('notification', {
action: 'update-by-type',
type: 'current-workspace-has-no-tabs',
timeout: 3000,
type: '',
closeButton: true,
title: 'Current workspace has no tabs'
})
}
}
},
CLOSE_TAB (store, tab) {
Expand Down
27 changes: 27 additions & 0 deletions src/views/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,31 @@ Copyright © 2021 - present Aleksey Hoffman. All rights reserved.
</section-settings>
</v-tab-item>

<!-- tab::tabs & workspaces -->
<v-tab-item transition="fade-in" reverse-transition="fade-in">
<!-- section::window-controls -->
<section-settings
class="content-area__content-card__section"
:header="{
icon: {
name: 'mdi-tab',
},
title: 'Tabs'
}"
>
<template v-slot:content>
<div class="text--sub-title-1 mt-2">
Options
</div>
<v-switch
class="my-0"
v-model="closeAppWindowWhenLastWorkspaceTabIsClosed"
label="Close app window when all current workspace tabs are closed"
></v-switch>
</template>
</section-settings>
</v-tab-item>

<!-- tab::input -->
<v-tab-item transition="fade-in" reverse-transition="fade-in">
<section-settings
Expand Down Expand Up @@ -1420,6 +1445,7 @@ export default {
settingsTabs: [
{ text: 'General' },
{ text: 'UI appearance' },
{ text: 'Tabs & workspaces' },
{ text: 'Input' },
{ text: 'Search' },
{ text: 'Data & storage' },
Expand Down Expand Up @@ -1450,6 +1476,7 @@ export default {
windowCloseButtonAction: 'storageData.settings.windowCloseButtonAction',
themeType: 'storageData.settings.theme.type',
navigatorLayout: 'storageData.settings.navigatorLayout',
closeAppWindowWhenLastWorkspaceTabIsClosed: 'storageData.settings.navigator.tabs.closeAppWindowWhenLastWorkspaceTabIsClosed',
navigatorShowHiddenDirItems: 'storageData.settings.navigator.showHiddenDirItems',
navigatorOpenDirItemWithSingleClick: 'storageData.settings.navigator.openDirItemWithSingleClick',
dirItemHoverEffect: 'storageData.settings.dirItemHoverEffect',
Expand Down

0 comments on commit c2e1328

Please sign in to comment.