Add alternative paste setting

This commit is contained in:
smartfridge 2022-07-14 20:37:03 +02:00
parent a1f91d4d89
commit 3e2efad943
4 changed files with 34 additions and 9 deletions

View file

@ -116,8 +116,8 @@
windowStyle: "default",
channel: "stable",
armcordCSP: true,
autoLaunch: true,
minimizeToTray: true,
alternativePaste: false,
automaticPatches: false,
mods: "cumcord",
inviteWebsocket: true,
@ -153,6 +153,7 @@
mobileMode: false,
automaticPatches: false,
performanceMode: "none",
alternativePaste: false,
trayIcon: "ac_plug_colored",
mods: options.mod,
inviteWebsocket: true
@ -168,6 +169,7 @@
automaticPatches: false,
mobileMode: false,
mods: "none",
alternativePaste: false,
performanceMode: "none",
trayIcon: "ac_plug_colored",
inviteWebsocket: true

View file

@ -1,5 +1,6 @@
import { Menu, app, clipboard, globalShortcut } from "electron";
import {mainWindow} from "./window";
import {getConfig} from "./utils";
function paste(contents: any) {
const contentTypes = clipboard.availableFormats().toString();
@ -9,12 +10,21 @@ function paste(contents: any) {
}
contents.paste();
}
export function setMenu() {
export async function setMenu() {
if (await getConfig("alternativePaste") == true) {
mainWindow.on("focus", function () {
console.log("[Window state manager] Focus")
globalShortcut.register("CmdOrCtrl+V", function () {
if (mainWindow.isFocused()) {
paste(mainWindow.webContents)
}
})
})
mainWindow.on("blur", function () {
console.log("[Window state manager] Defocus")
globalShortcut.unregister("CmdOrCtrl+V")
})
}
var template: Electron.MenuItemConstructorOptions[] = [{
label: "ArmCord",
submenu: [
@ -39,9 +49,11 @@ export function setMenu() {
{type: "separator"},
{label: "Cut", accelerator: "CmdOrCtrl+X", role: "cut"},
{label: "Copy", accelerator: "CmdOrCtrl+C", role: "copy"},
{label: "Paste", accelerator: "CmdOrCtrl+V", click: function () {
{
label: "Paste", accelerator: "CmdOrCtrl+V", click: function () {
paste(mainWindow.webContents)
}},
}
},
{label: "Select All", accelerator: "CmdOrCtrl+A", role: "selectAll"}
]
}

View file

@ -70,6 +70,13 @@
<p class="description2">short description, describing this great feature</p>
</div>
<br />
<div class="switch">
<label class="header2" id="settings-alternativePaste">Alternative paste</label>
<input class="tgl tgl-light left" id="alternativePaste" type="checkbox" />
<label class="tgl-btn left" for="alternativePaste"></label>
<p class="description2">to be used on gnome DE or when accelerator doesn't work on platform of choice</p>
</div>
<br />
<div class="switch">
<select name="channel" id="channel" class="left dropdown">
<option value="stable">Stable</option>
@ -147,6 +154,7 @@
document.getElementById("csp").checked = await settings.get("armcordCSP");
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("mobile").checked = await settings.get("mobileMode");
document.getElementById("patches").value = await settings.get("automaticPatches");
document.getElementById("mod").value = await settings.get("mods");
@ -162,6 +170,7 @@
channel: document.getElementById("channel").value,
armcordCSP: document.getElementById("csp").checked,
minimizeToTray: document.getElementById("tray").checked,
alternativePaste: document.getElementById("alternativePaste").checked,
automaticPatches: document.getElementById("patches").checked,
mods: document.getElementById("mod").value,
mobileMode: document.getElementById("mobile").checked,

View file

@ -39,6 +39,7 @@ export function setup() {
armcordCSP: true,
minimizeToTray: true,
automaticPatches: false,
alternativePaste: false,
mods: "cumcord",
performanceMode: "none",
inviteWebsocket: true,
@ -182,6 +183,7 @@ export interface Settings {
armcordCSP: boolean;
minimizeToTray: boolean;
automaticPatches: boolean;
alternativePaste: boolean;
mods: string;
mobileMode: boolean,
performanceMode: string;