diff --git a/main.js b/main.js index 47bd343..f4f2e80 100644 --- a/main.js +++ b/main.js @@ -1,15 +1,15 @@ // Modules to control application life and create native browser window -const { app, BrowserWindow, session } = require('electron') +const { app, BrowserWindow, session, Tray, Menu } = require('electron') const path = require('path') require("v8-compile-cache"); require("./utils/updater"); let mainWindow -require("./menu.js") function createWindow() { mainWindow = new BrowserWindow({ width: 800, height: 600, - icon: __dirname + '/discord.ico', + icon: __dirname + "/discord.ico", + title: "ArmCord", frame: false, webPreferences: { preload: path.join(__dirname, "preload.js"), @@ -17,21 +17,59 @@ function createWindow() { nodeIntegration: false, }, }); + var appIcon = new Tray(__dirname + "/discord.ico"); mainWindow.webContents.userAgent = - "Mozilla/5.0 (X12; TempleOS MIPS) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36"; //to set + "Mozilla/5.0 (X12; FreeBSD x86) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36"; //fake useragent mainWindow.loadFile("index.html"); + mainWindow.focus(); mainWindow.webContents.on("new-window", function (e, url) { e.preventDefault(); require("electron").shell.openExternal(url); }); // Open the DevTools. // mainWindow.webContents.openDevTools() + var contextMenu = Menu.buildFromTemplate([ + { + label: "Show App", + click: function () { + mainWindow.show(); + }, + }, + { + label: "Support Discord Server", + click: function () { + mainWindow.loadURL("https://discord.gg/F25bc4RYDt"); + }, + }, + { + label: "Quit", + click: function () { + app.isQuiting = true; + app.quit(); + }, + }, + ]); - mainWindow.on("closed", () => { + appIcon.setContextMenu(contextMenu); + + // Emitted when the window is closed. + mainWindow.on("close", function (event) { mainWindow = null; }); + + mainWindow.on("minimize", function (event) { + event.preventDefault(); + mainWindow.hide(); + }); + + mainWindow.on("show", function () { + appIcon.setHighlightMode("always"); + }); } + + + // This method will be called when Electron has finished // initialization and is ready to create browser windows. // Some APIs can only be used after this event occurs. diff --git a/menu.js b/menu.js deleted file mode 100644 index 832832f..0000000 --- a/menu.js +++ /dev/null @@ -1,107 +0,0 @@ -const { app, Menu } = require("electron"); - -const isMac = process.platform === "darwin"; - -const template = [ - // { role: 'appMenu' } - ...(isMac - ? [ - { - label: app.name, - submenu: [ - { role: "about" }, - { type: "separator" }, - { role: "services" }, - { type: "separator" }, - { role: "hide" }, - { role: "hideothers" }, - { role: "unhide" }, - { type: "separator" }, - { role: "quit" }, - ], - }, - ] - : []), - // { role: 'fileMenu' } - { - label: "File", - submenu: [isMac ? { role: "close" } : { role: "quit" }], - }, - // { role: 'editMenu' } - { - label: "Edit", - submenu: [ - { role: "undo" }, - { role: "redo" }, - { type: "separator" }, - { role: "cut" }, - { role: "copy" }, - { role: "paste" }, - ...(isMac - ? [ - { role: "pasteAndMatchStyle" }, - { role: "delete" }, - { role: "selectAll" }, - { type: "separator" }, - { - label: "Speech", - submenu: [{ role: "startSpeaking" }, { role: "stopSpeaking" }], - }, - ] - : [{ role: "delete" }, { type: "separator" }, { role: "selectAll" }]), - ], - }, - // { role: 'viewMenu' } - { - label: "View", - submenu: [ - { role: "reload" }, - { role: "forceReload" }, - { role: "toggleDevTools" }, - { type: "separator" }, - { role: "resetZoom" }, - { role: "zoomIn" }, - { role: "zoomOut" }, - { type: "separator" }, - { role: "togglefullscreen" }, - ], - }, - // { role: 'windowMenu' } - { - label: "Window", - submenu: [ - { role: "minimize" }, - { role: "zoom" }, - ...(isMac - ? [ - { type: "separator" }, - { role: "front" }, - { type: "separator" }, - { role: "window" }, - ] - : [{ role: "close" }]), - ], - }, - { - role: "help", - submenu: [ - { - label: "Learn More", - click: async () => { - const { shell } = require("electron"); - await shell.openExternal("https://github.com/smartfrigde/armcord"); - }, - }, - { - label: "Support Server", - click: async () => { - const { shell } = require("electron"); - await shell.openExternal("https://discord.gg/F25bc4RYDt"); - }, - }, - ], - }, -]; - -const menu = Menu.buildFromTemplate(template); -Menu.setApplicationMenu(menu); diff --git a/package.json b/package.json index 31c9c08..9f48864 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "armcord", - "version": "2.2.0", + "version": "2.3.0", "description": "ArmCord is a Discord client made for ARM Linux that allows you to customize your experience.", "main": "main.js", "scripts": { diff --git a/preload.js b/preload.js index ea50ec3..a98f193 100644 --- a/preload.js +++ b/preload.js @@ -5,6 +5,7 @@ const { remote } = require("electron"); window.addEventListener('DOMContentLoaded', () => { new customTitlebar.Titlebar({ backgroundColor: customTitlebar.Color.fromHex("#202225"), + menu: false, }); /**