From 71fa8d9bb8363f267b019eb1a7b86cde95a8899d Mon Sep 17 00:00:00 2001 From: Yashu Mittal Date: Tue, 31 Dec 2019 15:43:58 +0530 Subject: [PATCH 1/9] Define main config variables names Here's the list of configuration variables added: * APP_NAME * APP_VERSION * GITHUB_URL * GITHUB_URL_LICENSE * GITHUB_URL_ISSUES * GITUHB_URL_RELEASE_NOTES * DISCORD_INVITE_URL * WINDOW_DEFAULT_HEIGHT * WINDOW_DEFAULT_WIDTH * ICON --- src/main/config.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/main/config.js diff --git a/src/main/config.js b/src/main/config.js new file mode 100644 index 00000000..c0317788 --- /dev/null +++ b/src/main/config.js @@ -0,0 +1,23 @@ +const { app } = require("electron"); + +/** + * Applications Configuration + **/ +module.exports = { + APP_NAME: "Thermal", + APP_VERSION: app.getVersion(), + + THERMAL_URL_WEBSITE: "https://thermal.codecarrot.net/", + GITHUB_URL: "https://www.github.com/gitthermal/thermal", + GITHUB_URL_LICENSE: + "https://github.com/gitthermal/thermal/blob/master/LICENCE", + GITHUB_URL_ISSUES: + "https://github.com/gitthermal/thermal/issues/new?assignees=&labels=🐞+Bug&template=bug_report.md", + GITHUB_URL_RELEASE_NOTES: "https://github.com/gitthermal/thermal/releases", + DISCORD_INVITE_URL: "https://discord.gg/DcSNmts", + + WINDOW_DEFAULT_HEIGHT: 800, + WINDOW_DEFAULT_WIDTH: 1200, + + ICON: "../../build/icons/256x256.png" +}; From a99bc7c189636356566578a586dd413c6306bd1e Mon Sep 17 00:00:00 2001 From: Yashu Mittal Date: Tue, 31 Dec 2019 15:59:08 +0530 Subject: [PATCH 2/9] Use config variables for width and height of BrowserWindow() --- src/main/index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/index.js b/src/main/index.js index 8372788d..15835766 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -4,6 +4,8 @@ import { app, BrowserWindow } from "electron"; import * as Sentry from "@sentry/electron"; import packageJson from "../../package.json"; +const CONFIG = require("./config"); + Sentry.init({ dsn: "https://c3fb5f4c94aa4921a71b5fb887e1cfac@sentry.io/1422446", environment: process.env.NODE_ENV, @@ -31,10 +33,8 @@ function createWindow() { * Initial window options */ mainWindow = new BrowserWindow({ - height: 563, - useContentSize: true, - width: 1000, - frame: false, + height: CONFIG.WINDOW_DEFAULT_HEIGHT, + width: CONFIG.WINDOW_DEFAULT_WIDTH, webPreferences: { devTools: true, nodeIntegration: true From d4974436e3cb75453668d054e87e0247b4013c8f Mon Sep 17 00:00:00 2001 From: Yashu Mittal Date: Tue, 31 Dec 2019 16:00:06 +0530 Subject: [PATCH 3/9] openDevTools is default set to `true` --- src/main/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/index.js b/src/main/index.js index 15835766..28b01537 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -36,7 +36,6 @@ function createWindow() { height: CONFIG.WINDOW_DEFAULT_HEIGHT, width: CONFIG.WINDOW_DEFAULT_WIDTH, webPreferences: { - devTools: true, nodeIntegration: true } }); From ad10996743162afe8b7da81b9310599e939e2ca4 Mon Sep 17 00:00:00 2001 From: Yashu Mittal Date: Tue, 31 Dec 2019 16:00:55 +0530 Subject: [PATCH 4/9] Template menu for darwin platform only --- src/main/index.js | 8 ++ src/main/menu.js | 188 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 196 insertions(+) create mode 100644 src/main/menu.js diff --git a/src/main/index.js b/src/main/index.js index 28b01537..55a6f619 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -4,6 +4,7 @@ import { app, BrowserWindow } from "electron"; import * as Sentry from "@sentry/electron"; import packageJson from "../../package.json"; +const buildMenu = require("./menu"); const CONFIG = require("./config"); Sentry.init({ @@ -35,6 +36,8 @@ function createWindow() { mainWindow = new BrowserWindow({ height: CONFIG.WINDOW_DEFAULT_HEIGHT, width: CONFIG.WINDOW_DEFAULT_WIDTH, + titleBarStyle: "hidden", + webPreferences: { nodeIntegration: true } @@ -48,10 +51,15 @@ function createWindow() { } app.on("ready", () => { + if (process.platform === "darwin") { + buildMenu(); + } createWindow(); }); app.on("window-all-closed", () => { + // On OS X it is common for applications and their menu bar + // to stay active until the user quits explicitly with Cmd + Q if (process.platform !== "darwin") { app.quit(); } diff --git a/src/main/menu.js b/src/main/menu.js new file mode 100644 index 00000000..8bdf367c --- /dev/null +++ b/src/main/menu.js @@ -0,0 +1,188 @@ +const { Menu, shell, dialog } = require("electron"); +const CONFIG = require("./config"); + +/** + * Menu template + */ + +const template = [ + { + label: CONFIG.APP_NAME, + submenu: [ + { + label: `About ${CONFIG.APP_NAME}`, + click() { + showAboutDialog(); + } + }, + { + label: "Preferences", + click() { + console.log("Open preferences page."); + } + }, + { type: "separator" }, + { + label: "Release notes", + click() { + shell.openExternal(CONFIG.GITHUB_URL_RELEASE_NOTES); + } + }, + { + label: "License", + click() { + shell.openExternal(CONFIG.GITHUB_URL_LICENSE); + } + }, + { type: "separator" }, + { + label: "Check for updates...", + click() { + showUpdatesDialog(); + } + }, + { type: "separator" }, + { role: "hide" }, + { role: "hideOthers" }, + { role: "unhide" }, + { type: "separator" }, + { role: "quit" } + ] + }, + { + label: "File", + submenu: [ + { + label: "Select repository" + }, + { type: "separator" }, + { + label: "New repository" + }, + { type: "separator" }, + { + label: "Add local repository" + }, + { + label: "Clone repository" + } + ] + }, + { + label: "View", + submenu: [ + { + label: "Toggle Full Screen", + accelerator: (() => { + if (process.platform === "darwin") { + return "Ctrl+Command+F"; + } else { + return "F11"; + } + })(), + click: function (focusedWindow) { + if (focusedWindow) { + focusedWindow.setFullScreen(!focusedWindow.isFullScreen()); + } + } + }, + { + label: "Toggle Developer Tools", + accelerator: (function () { + if (process.platform === "darwin") { + return "Alt+Command+I"; + } else { + return "Ctrl+Shift+I"; + } + })(), + click: function (item, focusedWindow) { + if (focusedWindow) { + focusedWindow.toggleDevTools(); + } + } + } + ] + }, + { + label: "Window", + role: "window", + submenu: [ + { + label: "Minimize", + accelerator: "CmdOrCtrl+M", + role: "minimize" + }, + { + label: "Reload", + accelerator: "CmdOrCtrl+R", + role: "reload" + }, + { + label: "Force Reload", + accelerator: "CmdOrCtrl+Shift+R", + role: "forceReload" + }, + { + label: "Close", + accelerator: "CmdOrCtrl+W", + role: "close" + } + ] + }, + { + label: "Help", + submenu: [ + { + label: "Learn more", + click() { + shell.openExternal(CONFIG.THERMAL_URL_WEBSITE); + } + }, + { type: "separator" }, + { + label: "Report an issue", + click() { + shell.openExternal(CONFIG.GITHUB_URL_ISSUES); + } + }, + { + label: "Contact support", + click() { + shell.openExternal(CONFIG.DISCORD_INVITE_URL); + } + } + ] + } +]; + +/** + * Create menu + */ +function createMenu() { + const menu = Menu.buildFromTemplate(template); + return Menu.setApplicationMenu(menu); +} + +/** + * About dialog box + */ +function showAboutDialog() { + dialog.showMessageBox({ + type: "info", + title: `About ${CONFIG.APP_NAME}`, + message: `${CONFIG.APP_NAME} ${CONFIG.APP_VERSION}`, + detail: "All-in-one place to manage your Git repository." + }); +} + +function showUpdatesDialog() { + dialog.showMessageBox({ + type: "info", + title: "Check for updates", + message: `${CONFIG.APP_NAME} updates`, + detail: + "You can stay up to day with updates by checking the releases page on Thermal GitHub repository." + }); +} + +module.exports = createMenu; From a77e2d9e5d924c0ebdcddfd3b3f4f8175d5a4dbf Mon Sep 17 00:00:00 2001 From: Yashu Mittal Date: Wed, 1 Jan 2020 10:53:24 +0530 Subject: [PATCH 5/9] Show menubar.vue only on windows & linux --- src/renderer/App.vue | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/renderer/App.vue b/src/renderer/App.vue index d41bc300..5a84cef9 100644 --- a/src/renderer/App.vue +++ b/src/renderer/App.vue @@ -1,6 +1,6 @@