Add zoom controls back and open settings

This commit is contained in:
smartfridge 2022-08-24 17:25:12 +02:00
parent 6c59564256
commit 77b5455139
12 changed files with 145 additions and 59 deletions

View file

@ -254,36 +254,3 @@ select {
white-space: nowrap; white-space: nowrap;
outline: none !important; outline: none !important;
} }
.acTheme {
height: 15em !important;
}
.acCSP {
height: 10em !important;
}
.acPatches {
height: 10em !important;
}
.acWebsocket {
height: 10em !important;
}
.acMobileMode {
height: 11em !important;
}
.acAltPaste {
height: 11em !important;
}
.acChannel {
height: 21em !important;
}
.acClientMod {
height: 18em !important;
}
.acCordwood {
height: 8em !important;
}
.acPrfmMode {
height: 10em !important;
}
.acTray {
height: 8em !important;
}

View file

@ -0,0 +1,33 @@
.acTheme {
height: 15em !important;
}
.acCSP {
height: 10em !important;
}
.acPatches {
height: 10em !important;
}
.acWebsocket {
height: 10em !important;
}
.acMobileMode {
height: 11em !important;
}
.acAltPaste {
height: 11em !important;
}
.acChannel {
height: 21em !important;
}
.acClientMod {
height: 18em !important;
}
.acCordwood {
height: 8em !important;
}
.acPrfmMode {
height: 10em !important;
}
.acTray {
height: 8em !important;
}

View file

@ -47,7 +47,7 @@
} }
} }
setTimeout(() => { setTimeout(() => {
window.armcordinternal.splashEnd(); window.armcord.splashEnd();
switch (window.armcord.channel) { switch (window.armcord.channel) {
case "stable": case "stable":
window.location.replace("https://discord.com/app"); window.location.replace("https://discord.com/app");

View file

@ -1,7 +1,15 @@
//ipc stuff //ipc stuff
import {app, ipcMain, shell, desktopCapturer} from "electron"; import {app, ipcMain, shell, desktopCapturer} from "electron";
import {mainWindow} from "./window"; import {mainWindow} from "./window";
import {setConfigBulk, getVersion, getConfig, setLang, getLang, getWindowState, packageVersion} from "./utils"; import {
setConfigBulk,
getVersion,
getConfig,
setLang,
getLang,
getWindowState,
packageVersion, getDisplayVersion
} from "./utils";
import {customTitlebar} from "./main"; import {customTitlebar} from "./main";
import {createSettingsWindow} from "./settings/main"; import {createSettingsWindow} from "./settings/main";
export function registerIpc() { export function registerIpc() {
@ -44,10 +52,13 @@ export function registerIpc() {
ipcMain.on("get-app-version", (event) => { ipcMain.on("get-app-version", (event) => {
event.returnValue = getVersion(); event.returnValue = getVersion();
}); });
ipcMain.on("displayVersion", (event) => {
event.returnValue = getDisplayVersion();
});
ipcMain.on("get-package-version", (event) => { ipcMain.on("get-package-version", (event) => {
event.returnValue = packageVersion; event.returnValue = packageVersion;
}); });
ipcMain.on("splashEnd", async (event, arg) => { ipcMain.on("splashEnd", async () => {
try { try {
var width = (await getWindowState("width")) ?? 800; var width = (await getWindowState("width")) ?? 800;
var height = (await getWindowState("height")) ?? 600; var height = (await getWindowState("height")) ?? 600;

View file

@ -1,6 +1,7 @@
import {Menu, app, clipboard, globalShortcut} from "electron"; import {Menu, app, clipboard, globalShortcut} from "electron";
import {mainWindow} from "./window"; import {mainWindow} from "./window";
import {getConfig} from "./utils"; import {getConfig} from "./utils";
import {createSettingsWindow} from "./settings/main";
function paste(contents: any) { function paste(contents: any) {
const contentTypes = clipboard.availableFormats().toString(); const contentTypes = clipboard.availableFormats().toString();
@ -51,6 +52,13 @@ export async function setMenu() {
mainWindow.webContents.openDevTools(); mainWindow.webContents.openDevTools();
} }
}, },
{
label: "Open settings",
accelerator: "CmdOrCtrl+Shift+'",
click: function () {
createSettingsWindow();
}
},
{ {
label: "Quit", label: "Quit",
accelerator: "CmdOrCtrl+Q", accelerator: "CmdOrCtrl+Q",
@ -77,6 +85,13 @@ export async function setMenu() {
}, },
{label: "Select All", accelerator: "CmdOrCtrl+A", role: "selectAll"} {label: "Select All", accelerator: "CmdOrCtrl+A", role: "selectAll"}
] ]
},
{
label: "Zoom",
submenu: [
{label: "Zoom in", accelerator: "CmdOrCtrl+Plus", role: "zoomIn"},
{label: "Zoom out", accelerator: "CmdOrCtrl+-", role: "zoomOut"},
]
} }
]; ];

View file

@ -23,13 +23,13 @@ contextBridge.exposeInMainWorld("armcord", {
version: ipcRenderer.sendSync("get-app-version", "app-version"), version: ipcRenderer.sendSync("get-app-version", "app-version"),
packageVersion: ipcRenderer.sendSync("get-package-version", "app-version"), packageVersion: ipcRenderer.sendSync("get-package-version", "app-version"),
getDisplayMediaSelector: getDisplayMediaSelector, getDisplayMediaSelector: getDisplayMediaSelector,
splashEnd: () => ipcRenderer.send("splashEnd"),
openSettingsWindow: () => ipcRenderer.send("openSettingsWindow") openSettingsWindow: () => ipcRenderer.send("openSettingsWindow")
}); });
//to be only used inside armcord internal setup/splash etc //to be only used inside armcord internal setup/splash etc
if (window.location.href.indexOf("splash.html") > -1 || window.location.href.indexOf("setup.html") > -1) { if (window.location.href.indexOf("splash.html") > -1 || window.location.href.indexOf("setup.html") > -1) {
contextBridge.exposeInMainWorld("armcordinternal", { contextBridge.exposeInMainWorld("armcordinternal", {
restart: () => ipcRenderer.send("restart"), restart: () => ipcRenderer.send("restart"),
saveSettings: (...args: any) => ipcRenderer.send("saveSettings", ...args), saveSettings: (...args: any) => ipcRenderer.send("saveSettings", ...args)
splashEnd: () => ipcRenderer.send("splashEnd")
}); });
} }

View file

@ -7,7 +7,7 @@ import {injectHummusTitlebar, injectTitlebar} from "./titlebar";
import {sleep, addStyle, injectJS, addScript} from "../utils"; import {sleep, addStyle, injectJS, addScript} from "../utils";
import {ipcRenderer} from "electron"; import {ipcRenderer} from "electron";
import {injectMobileStuff} from "./mobile"; import {injectMobileStuff} from "./mobile";
var version = ipcRenderer.sendSync("get-app-version", "app-version"); var version = ipcRenderer.sendSync("displayVersion");
var channel = ipcRenderer.sendSync("channel"); var channel = ipcRenderer.sendSync("channel");
async function updateLang() { async function updateLang() {
if (window.location.href.indexOf("setup.html") > -1) { if (window.location.href.indexOf("setup.html") > -1) {

View file

@ -15,6 +15,23 @@
<div class="saveBar"> <div class="saveBar">
<button id="settings-save" class="center">Save Settings</button> <button id="settings-save" class="center">Save Settings</button>
</div> </div>
<div class="switch acTheme">
<select name="theme" id="theme" class="left dropdown">
<option value="default">Default</option>
<option value="native">Native</option>
</select>
<p class="header" id="settings-theme">ArmCord theme</p>
<p class="description">
ArmCord "themes" manage apps behaviour and looks.
<br />
<b>Default</b> - this is how ArmCord looks when you first launch it. It includes recreation of Discord's
custom titlebar and ArmCord specific styles injected into Discord.
<br />
<b>Native</b> - uses native titlebar of OS you're currently running (e.g Windows 7/10). Functions more
similar to actual Discord app on Linux.
</p>
</div>
<br />
<div class="switch acCSP"> <div class="switch acCSP">
<label class="header2">ArmCord CSP</label> <label class="header2">ArmCord CSP</label>
<input class="tgl tgl-light left" id="csp" type="checkbox" /> <input class="tgl tgl-light left" id="csp" type="checkbox" />
@ -133,17 +150,10 @@
<script> <script>
async function loadLang() { async function loadLang() {
document.getElementById("settings-save").innerHTML = await settings.getLang("settings-save"); document.getElementById("settings-save").innerHTML = await settings.getLang("settings-save");
document.getElementById("settings-mod").innerHTML = await settings.getLang("settings-mod");
document.getElementById("settings-channel").innerHTML = await settings.getLang("settings-channel"); document.getElementById("settings-channel").innerHTML = await settings.getLang("settings-channel");
document.getElementById("settings-invitewebsocket").innerHTML = await settings.getLang(
"settings-invitewebsocket"
);
document.getElementById("settings-patches").innerHTML = await settings.getLang("settings-patches"); document.getElementById("settings-patches").innerHTML = await settings.getLang("settings-patches");
document.getElementById("settings-tray").innerHTML = await settings.getLang("settings-tray"); document.getElementById("settings-tray").innerHTML = await settings.getLang("settings-tray");
document.getElementById("settings-mobileMode").innerHTML = await settings.getLang("settings-mobileMode");
document.getElementById("settings-theme").innerHTML = await settings.getLang("settings-theme"); document.getElementById("settings-theme").innerHTML = await settings.getLang("settings-theme");
//select stuff
document.getElementById("mod").options[3].text = await settings.getLang("settings-none");
document.getElementById("prfmMode").options[2].text = await settings.getLang("settings-none"); document.getElementById("prfmMode").options[2].text = await settings.getLang("settings-none");
document.getElementById("prfmMode").options[1].text = await settings.getLang("settings-prfmMode-battery"); document.getElementById("prfmMode").options[1].text = await settings.getLang("settings-prfmMode-battery");
document.getElementById("prfmMode").options[0].text = await settings.getLang( document.getElementById("prfmMode").options[0].text = await settings.getLang(
@ -158,18 +168,26 @@
async function loadSettings() { async function loadSettings() {
document.getElementById("csp").checked = await settings.get("armcordCSP"); document.getElementById("csp").checked = await settings.get("armcordCSP");
document.getElementById("tray").checked = await settings.get("minimizeToTray"); document.getElementById("tray").checked = await settings.get("minimizeToTray");
document.getElementById("websocket").checked = await settings.get("inviteWebsocket");
document.getElementById("alternativePaste").checked = await settings.get("alternativePaste"); document.getElementById("alternativePaste").checked = await settings.get("alternativePaste");
document.getElementById("mobile").checked = await settings.get("mobileMode");
document.getElementById("patches").value = await settings.get("automaticPatches"); document.getElementById("patches").value = await settings.get("automaticPatches");
document.getElementById("mod").value = await settings.get("mods"); if ((await settings.get("mods")) == "cordwood") {
document.getElementById("cordwood").checked = true;
} else {
document.getElementById("cordwood").checked = false;
}
document.getElementById("channel").value = await settings.get("channel"); document.getElementById("channel").value = await settings.get("channel");
document.getElementById("theme").value = await settings.get("windowStyle"); document.getElementById("theme").value = await settings.get("windowStyle");
document.getElementById("prfmMode").value = await settings.get("performanceMode"); document.getElementById("prfmMode").value = await settings.get("performanceMode");
document.getElementById("trayIcon").value = await settings.get("trayIcon"); document.getElementById("trayIcon").value = await settings.get("trayIcon");
} }
loadSettings(); loadSettings();
document.getElementById("settings-save").addEventListener("click", function () { document.getElementById("settings-save").addEventListener("click", async function () {
var cordwood;
if (document.getElementById("cordwood").checked) {
cordwood = true;
} else {
cordwood = false;
}
settings.save({ settings.save({
windowStyle: document.getElementById("theme").value, windowStyle: document.getElementById("theme").value,
channel: document.getElementById("channel").value, channel: document.getElementById("channel").value,
@ -177,22 +195,25 @@
minimizeToTray: document.getElementById("tray").checked, minimizeToTray: document.getElementById("tray").checked,
alternativePaste: document.getElementById("alternativePaste").checked, alternativePaste: document.getElementById("alternativePaste").checked,
automaticPatches: document.getElementById("patches").checked, automaticPatches: document.getElementById("patches").checked,
mods: document.getElementById("mod").value, mods: cordwood,
mobileMode: document.getElementById("mobile").checked, mobileMode: await settings.get("mobileMode"),
inviteWebsocket: document.getElementById("websocket").checked, inviteWebsocket: await settings.get("inviteWebsocket"),
performanceMode: document.getElementById("prfmMode").value, performanceMode: document.getElementById("prfmMode").value,
trayIcon: document.getElementById("trayIcon").value, trayIcon: document.getElementById("trayIcon").value,
doneSetup: true doneSetup: true
}); });
}); });
document.getElementById("settings-pluginsFolder").addEventListener("click", function () { document.getElementById("settings-pluginsFolder").addEventListener("click", async function () {
settings.openPluginsFolder(); settings.openPluginsFolder();
await new Promise((r) => setTimeout(r, 2000));
}); });
document.getElementById("settings-themesFolder").addEventListener("click", function () { document.getElementById("settings-themesFolder").addEventListener("click", async function () {
settings.openThemesFolder(); settings.openThemesFolder();
await new Promise((r) => setTimeout(r, 2000));
}); });
document.getElementById("settings-storageFolder").addEventListener("click", function () { document.getElementById("settings-storageFolder").addEventListener("click", async function () {
settings.openStorageFolder(); settings.openStorageFolder();
await new Promise((r) => setTimeout(r, 2000));
}); });
document.getElementById("settings-copyDebugInfo").addEventListener("click", function () { document.getElementById("settings-copyDebugInfo").addEventListener("click", function () {
settings.copyDebugInfo(); settings.copyDebugInfo();

View file

@ -1,5 +1,5 @@
import {BrowserWindow, shell, ipcMain, app, clipboard} from "electron"; import {BrowserWindow, shell, ipcMain, app, clipboard} from "electron";
import {getConfig, setConfigBulk, Settings, getLang, getVersion, getConfigLocation} from "../utils"; import {getConfig, setConfigBulk, Settings, getLang, getVersion, getConfigLocation, getLangName} from "../utils";
import path from "path"; import path from "path";
import os from "os"; import os from "os";
import fs from "fs"; import fs from "fs";
@ -50,6 +50,9 @@ export function createSettingsWindow() {
ipcMain.on("openPluginsFolder", (event) => { ipcMain.on("openPluginsFolder", (event) => {
shell.openPath(pluginsPath); shell.openPath(pluginsPath);
}); });
ipcMain.on("getLangName", async (event) => {
event.returnValue = await getLangName();
});
ipcMain.handle("getSetting", (event, toGet: string) => { ipcMain.handle("getSetting", (event, toGet: string) => {
return getConfig(toGet); return getConfig(toGet);
}); });

View file

@ -1,4 +1,7 @@
import {contextBridge, ipcRenderer} from "electron"; import {contextBridge, ipcRenderer} from "electron";
import path from "path";
import {addStyle} from "../utils";
import fs from "fs";
console.log("ArmCord Settings"); console.log("ArmCord Settings");
contextBridge.exposeInMainWorld("settings", { contextBridge.exposeInMainWorld("settings", {
@ -16,3 +19,7 @@ contextBridge.exposeInMainWorld("settings", {
openStorageFolder: () => ipcRenderer.send("openStorageFolder"), openStorageFolder: () => ipcRenderer.send("openStorageFolder"),
copyDebugInfo: () => ipcRenderer.send("copyDebugInfo") copyDebugInfo: () => ipcRenderer.send("copyDebugInfo")
}); });
if (ipcRenderer.sendSync("getLangName") == "en-US") {
const cssPath = path.join(__dirname, "../", "/content/css/settingsEng.css");
addStyle(fs.readFileSync(cssPath, "utf8"));
}

View file

@ -57,6 +57,9 @@ export function setup() {
export var packageVersion = require("../package.json").version; export var packageVersion = require("../package.json").version;
export function getVersion() { export function getVersion() {
return packageVersion;
}
export function getDisplayVersion() {
//Checks if the app version # has 4 sections (3.1.0.0) instead of 3 (3.1.0) / Shitty way to check if Kernel Mod is installed //Checks if the app version # has 4 sections (3.1.0.0) instead of 3 (3.1.0) / Shitty way to check if Kernel Mod is installed
if ((app.getVersion() == packageVersion) == false) { if ((app.getVersion() == packageVersion) == false) {
return `${packageVersion} [Kernel Mod]`; return `${packageVersion} [Kernel Mod]`;
@ -157,7 +160,25 @@ export async function getLang(object: string) {
return parsed[object]; return parsed[object];
} }
} }
export async function getLangName() {
if (language == undefined) {
try {
const userDataPath = app.getPath("userData");
const storagePath = path.join(userDataPath, "/storage/");
const langConfigFile = storagePath + "lang.json";
let rawdata = fs.readFileSync(langConfigFile, "utf-8");
let parsed = JSON.parse(rawdata);
language = parsed["lang"];
} catch (e) {
console.log("Language config file doesn't exist. Fallback to English.");
language = "en-US";
}
}
if (language.length == 2) {
language = language + "-" + language.toUpperCase();
}
return language;
}
//ArmCord Window State manager //ArmCord Window State manager
export interface WindowState { export interface WindowState {
width: number; width: number;

View file

@ -4,7 +4,15 @@
// I'm sorry for this mess but I'm not sure how to fix it. // I'm sorry for this mess but I'm not sure how to fix it.
import {BrowserWindow, shell, app, dialog} from "electron"; import {BrowserWindow, shell, app, dialog} from "electron";
import path from "path"; import path from "path";
import {checkIfConfigIsBroken, firstRun, getConfig, contentPath, setConfig, setLang, setWindowState} from "./utils"; import {
checkIfConfigIsBroken,
firstRun,
getConfig,
contentPath,
setConfig,
setLang,
setWindowState
} from "./utils";
import {registerIpc} from "./ipc"; import {registerIpc} from "./ipc";
import {setMenu} from "./menu"; import {setMenu} from "./menu";
import * as fs from "fs"; import * as fs from "fs";