Skip to content

Commit

Permalink
add close to tray in settings
Browse files Browse the repository at this point in the history
  • Loading branch information
MedaiP90 committed Feb 16, 2024
1 parent 9635aa5 commit cb46b10
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ export default {
outline() {
this.persistSettings();
},
closeToTray() {
this.persistSettings();
},
clientId() {
this.persistSettings();
},
Expand Down
8 changes: 7 additions & 1 deletion src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,14 @@ app.on("activate", () => {
// Some APIs can only be used after this event occurs.
app.on("ready", async () => createWindow());

app.on("before-quit", () => {
app.on("before-quit", (event) => {
event.preventDefault();

if (win) win.destroy();
if (tray) tray.destroy();

app.removeAllListeners();
app.exit();
});

// Exit cleanly on request from parent process in development mode.
Expand Down
3 changes: 3 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ Vue.mixin({
outline() {
return this.$store.getters.getOutline;
},
closeToTray() {
return this.$store.getters.getCloseToTray;
},
darkTheme() {
return (this.theme || "light") === "dark";
},
Expand Down
4 changes: 4 additions & 0 deletions src/store/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const settingsVuexModule = {
state: {
theme: "light",
outline: false,
closeTray: true,
primaryColor: {
text: "Indie Indigo",
value: { light: "#3F51B5", dark: "#5C6BC0" },
Expand All @@ -18,6 +19,7 @@ const settingsVuexModule = {
mutations: {
setTheme: (state, theme) => (state.theme = theme),
setOutline: (state, outline) => (state.outline = outline),
setCloseToTray: (state, tray) => (state.closeTray = tray),
setPrimaryColor: (state, primary) => (state.primaryColor = primary),
setClientId: (state, clientId) => (state.clientId = clientId),
setKeepalive: (state, keepalive) => (state.keepalive = keepalive),
Expand All @@ -27,6 +29,7 @@ const settingsVuexModule = {
setAllSettings: (state, data) => {
state.theme = data.theme || "light";
state.outline = data.outline;
state.closeTray = data.closeTray ?? true;
// eslint-disable-next-line prettier/prettier
state.primaryColor = data.primaryColor || {
text: "Indie Indigo",
Expand All @@ -44,6 +47,7 @@ const settingsVuexModule = {
getAllSettings: (state) => state,
getTheme: (state) => state.theme,
getOutline: (state) => state.outline,
getCloseToTray: (state) => state.closeTray,
getPrimaryColor: (state) => state.primaryColor,
getClientId: (state) => state.clientId,
getKeepalive: (state) => state.keepalive,
Expand Down
23 changes: 22 additions & 1 deletion src/views/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,20 @@
</v-list-item>

<v-list-item>
<v-switch v-model="selectedOutline" label="Outlined fields" inset />
<v-list-item-content class="px-3">
<div class="d-flex justify-space-between" style="gap: 1em">
<v-switch
v-model="selectedOutline"
label="Outlined fields"
inset
/>
<v-switch
v-model="selectedCloseToTray"
label="Close to system tray"
inset
/>
</div>
</v-list-item-content>
</v-list-item>

<v-divider class="mx-3" />
Expand Down Expand Up @@ -396,6 +409,14 @@ export default {
this.$store.commit("setOutline", newValue);
},
},
selectedCloseToTray: {
get() {
return this.$store.getters.getCloseToTray;
},
set(newValue) {
this.$store.commit("setCloseToTray", newValue);
},
},
selectedColor: {
get() {
return this.$store.getters.getPrimaryColor;
Expand Down

0 comments on commit cb46b10

Please sign in to comment.