Add option to start hidden
- New option hideOnLaunch in prefrences/general/other - New args --hidden and --show to override hideOnLaunch Resolves #2660
This commit is contained in:
parent
973210bce4
commit
18833bc5d4
|
@ -19,7 +19,8 @@ const state = (): GeneralState => {
|
||||||
hideAllAttachments: false
|
hideAllAttachments: false
|
||||||
},
|
},
|
||||||
other: {
|
other: {
|
||||||
launch: false
|
launch: false,
|
||||||
|
hideOnLaunch: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
loading: false
|
loading: false
|
||||||
|
|
|
@ -15,7 +15,8 @@ describe('Preferences/General', () => {
|
||||||
hideAllAttachments: false
|
hideAllAttachments: false
|
||||||
},
|
},
|
||||||
other: {
|
other: {
|
||||||
launch: false
|
launch: false,
|
||||||
|
hideOnLaunch: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
loading: false
|
loading: false
|
||||||
|
|
|
@ -172,7 +172,8 @@
|
||||||
},
|
},
|
||||||
"other": {
|
"other": {
|
||||||
"title": "Other options",
|
"title": "Other options",
|
||||||
"launch": "Launch app on login"
|
"launch": "Launch app on login",
|
||||||
|
"hideOnLaunch": "Hide window on launch"
|
||||||
},
|
},
|
||||||
"reset": {
|
"reset": {
|
||||||
"button": "Reset preferences"
|
"button": "Reset preferences"
|
||||||
|
|
|
@ -24,7 +24,8 @@ const timeline: Timeline = {
|
||||||
}
|
}
|
||||||
|
|
||||||
const other: Other = {
|
const other: Other = {
|
||||||
launch: false
|
launch: false,
|
||||||
|
hideOnLaunch: false
|
||||||
}
|
}
|
||||||
|
|
||||||
const general: General = {
|
const general: General = {
|
||||||
|
|
|
@ -51,6 +51,7 @@ import ProxyConfiguration from './proxy'
|
||||||
import confirm from './timelines'
|
import confirm from './timelines'
|
||||||
import { EnabledTimelines } from '~/src/types/enabledTimelines'
|
import { EnabledTimelines } from '~/src/types/enabledTimelines'
|
||||||
import { Menu as MenuPreferences } from '~/src/types/preference'
|
import { Menu as MenuPreferences } from '~/src/types/preference'
|
||||||
|
import { General as GeneralPreferences } from '~/src/types/preference'
|
||||||
import { LocalMarker } from '~/src/types/localMarker'
|
import { LocalMarker } from '~/src/types/localMarker'
|
||||||
import Marker from './marker'
|
import Marker from './marker'
|
||||||
import newDB from './database'
|
import newDB from './database'
|
||||||
|
@ -225,6 +226,12 @@ const getMenuPreferences = async (): Promise<MenuPreferences> => {
|
||||||
return conf.menu
|
return conf.menu
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getGeneralPreferences = async (): Promise<GeneralPreferences> => {
|
||||||
|
const preferences = new Preferences(preferencesDBPath)
|
||||||
|
const conf = await preferences.load()
|
||||||
|
return conf.general
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set application menu
|
* Set application menu
|
||||||
* @return Whether the menu bar is auto hide.
|
* @return Whether the menu bar is auto hide.
|
||||||
|
@ -281,6 +288,11 @@ async function createWindow() {
|
||||||
*/
|
*/
|
||||||
const spellcheck = await getSpellChecker()
|
const spellcheck = await getSpellChecker()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get general preferences
|
||||||
|
*/
|
||||||
|
const generalPreferences = await getGeneralPreferences()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load system theme color for dark mode
|
* Load system theme color for dark mode
|
||||||
*/
|
*/
|
||||||
|
@ -391,6 +403,15 @@ async function createWindow() {
|
||||||
mainWindow!.setSkipTaskbar(true)
|
mainWindow!.setSkipTaskbar(true)
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Minimize to tray immediately if "hide on launch" selected
|
||||||
|
// or if --hidden arg is passed
|
||||||
|
if ((generalPreferences.other.hideOnLaunch || args.hidden) && !args.show) {
|
||||||
|
mainWindow.once('show', () => {
|
||||||
|
mainWindow!.hide()
|
||||||
|
mainWindow!.setSkipTaskbar(true)
|
||||||
|
})
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
mainWindow.on('closed', () => {
|
mainWindow.on('closed', () => {
|
||||||
mainWindow = null
|
mainWindow = null
|
||||||
|
@ -409,6 +430,8 @@ Usage
|
||||||
|
|
||||||
Options
|
Options
|
||||||
--help show help
|
--help show help
|
||||||
|
--hidden start Whalebird hidden to tray
|
||||||
|
--show start Whalebird with a window
|
||||||
`)
|
`)
|
||||||
process.exit(0)
|
process.exit(0)
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,9 @@
|
||||||
<el-form-item for="launch" :label="$t('preferences.general.other.launch')">
|
<el-form-item for="launch" :label="$t('preferences.general.other.launch')">
|
||||||
<el-switch id="launch" v-model="other_launch" active-color="#13ce66"> </el-switch>
|
<el-switch id="launch" v-model="other_launch" active-color="#13ce66"> </el-switch>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<el-form-item for="hideOnLaunch" :label="$t('preferences.general.other.hideOnLaunch')">
|
||||||
|
<el-switch id="hideOnLaunch" v-model="other_hideOnLaunch" active-color="#13ce66"> </el-switch>
|
||||||
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
<el-form class="reset section">
|
<el-form class="reset section">
|
||||||
<el-button type="info" @click="reset">{{ $t('preferences.general.reset.button') }}</el-button>
|
<el-button type="info" @click="reset">{{ $t('preferences.general.reset.button') }}</el-button>
|
||||||
|
@ -99,6 +102,13 @@ export default defineComponent({
|
||||||
launch: value
|
launch: value
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
const other_hideOnLaunch = computed({
|
||||||
|
get: () => store.state.Preferences.General.general.other.hideOnLaunch,
|
||||||
|
set: (value: boolean) =>
|
||||||
|
store.dispatch(`${space}/${ACTION_TYPES.UPDATE_OTHER}`, {
|
||||||
|
hideOnLaunch: value
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
store.dispatch(`${space}/${ACTION_TYPES.LOAD_GENERAL}`).catch(() => {
|
store.dispatch(`${space}/${ACTION_TYPES.LOAD_GENERAL}`).catch(() => {
|
||||||
|
@ -133,6 +143,7 @@ export default defineComponent({
|
||||||
timeline_nsfw,
|
timeline_nsfw,
|
||||||
timeline_hide_attachments,
|
timeline_hide_attachments,
|
||||||
other_launch,
|
other_launch,
|
||||||
|
other_hideOnLaunch,
|
||||||
reset
|
reset
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,8 @@ const state = (): GeneralState => ({
|
||||||
hideAllAttachments: false
|
hideAllAttachments: false
|
||||||
},
|
},
|
||||||
other: {
|
other: {
|
||||||
launch: false
|
launch: false,
|
||||||
|
hideOnLaunch: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
loading: false
|
loading: false
|
||||||
|
|
|
@ -7,6 +7,7 @@ import { Proxy } from '~/src/types/proxy'
|
||||||
|
|
||||||
export type Other = {
|
export type Other = {
|
||||||
launch: boolean
|
launch: boolean
|
||||||
|
hideOnLaunch: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export type General = {
|
export type General = {
|
||||||
|
|
Loading…
Reference in New Issue