Skip to content

Commit

Permalink
Add Quit button from application.
Browse files Browse the repository at this point in the history
  • Loading branch information
Yoyo San committed Apr 2, 2020
1 parent 41a7036 commit bb3ac56
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 6 deletions.
Binary file modified src-electron/icons/icon.icns
Binary file not shown.
Binary file modified src-electron/icons/icon.ico
Binary file not shown.
2 changes: 1 addition & 1 deletion src-electron/main-process/electron-main-menu-template.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const menuTemplate = [
submenu: [
{
label: 'Settings',
accelerator: 'CmdorCtrl+,',
accelerator: 'CmdOrCtrl+,',
click () {
mainWindow.webContents.send('show-settings')
}
Expand Down
13 changes: 11 additions & 2 deletions src-electron/main-process/electron-main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { app, BrowserWindow, nativeTheme, Menu } from 'electron'
import { app, BrowserWindow, nativeTheme, Menu, ipcMain } from 'electron'
import { menuTemplate } from './electron-main-menu-template'

try {
Expand All @@ -19,12 +19,15 @@ if (process.env.PROD) {
export let mainWindow
const menu = Menu.buildFromTemplate(menuTemplate)

/**
* app events
*/
app.on('ready', () => {
/**
* Initial window options
*/
mainWindow = new BrowserWindow({
width: 1000,
width: 1025,
height: 600,
minWidth: 800,
minHeight: 500,
Expand Down Expand Up @@ -52,3 +55,9 @@ app.on('window-all-closed', () => {
app.quit()
})

/**
* ipc events
*/
ipcMain.on('quit-app', () => {
app.quit()
})
35 changes: 32 additions & 3 deletions src/layouts/Layout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
href="https://github.com/training-yoyosan/awesome-todo"
target="_blank"
color="red"
label="Fork me on Github"/>
label="Fork me"/>
<q-btn
label="Dismiss"
icon="close"
class="q-ml-sm"
@click="dismissBanner = true"/>
</template>
Expand Down Expand Up @@ -79,6 +79,23 @@
:key="link.title"
v-bind="link"
/>

<q-item
v-if="$q.platform.is.electron"
clickable
@click="quitApp"
class="text-grey-5 absolute-bottom"
>
<q-item-section
avatar
>
<q-icon name="power_settings_new" />
</q-item-section>

<q-item-section>
<q-item-label>Quit</q-item-label>
</q-item-section>
</q-item>
</q-list>
</q-drawer>

Expand Down Expand Up @@ -125,7 +142,19 @@ export default {
},
methods: {
...mapActions('auth', ['logoutUser'])
...mapActions('auth', ['logoutUser']),
quitApp () {
if (this.$q.platform.is.electron) {
this.$q.dialog({
title: 'Confirm',
message: 'Would you like to quit the application?',
cancel: true,
persistent: true
}).onOk(() => {
require('electron').ipcRenderer.send('quit-app')
})
}
}
}
}
</script>
Expand Down

0 comments on commit bb3ac56

Please sign in to comment.