Vencord presetup
This commit is contained in:
parent
73d49795ea
commit
89c9a6651e
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,85 @@
|
||||||
|
/*
|
||||||
|
* Vencord, a modification for Discord's desktop app
|
||||||
|
* Copyright (c) 2022 Vendicated and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/// <reference path="../src/modules.d.ts" />
|
||||||
|
/// <reference path="../src/globals.d.ts" />
|
||||||
|
|
||||||
|
import monacoHtml from "~fileContent/../src/components/monacoWin.html";
|
||||||
|
import * as DataStore from "../src/api/DataStore";
|
||||||
|
import { debounce } from "../src/utils";
|
||||||
|
import { getTheme, Theme } from "../src/utils/discord";
|
||||||
|
|
||||||
|
// Discord deletes this so need to store in variable
|
||||||
|
const { localStorage } = window;
|
||||||
|
|
||||||
|
// listeners for ipc.on
|
||||||
|
const cssListeners = new Set<(css: string) => void>();
|
||||||
|
const NOOP = () => { };
|
||||||
|
const NOOP_ASYNC = async () => { };
|
||||||
|
|
||||||
|
const setCssDebounced = debounce((css: string) => VencordNative.quickCss.set(css));
|
||||||
|
|
||||||
|
// probably should make this less cursed at some point
|
||||||
|
window.VencordNative = {
|
||||||
|
native: {
|
||||||
|
getVersions: () => ({}),
|
||||||
|
openExternal: async (url) => void open(url, "_blank")
|
||||||
|
},
|
||||||
|
|
||||||
|
updater: {
|
||||||
|
getRepo: async () => ({ ok: true, value: "https://github.com/Vendicated/Vencord" }),
|
||||||
|
getUpdates: async () => ({ ok: true, value: [] }),
|
||||||
|
update: async () => ({ ok: true, value: false }),
|
||||||
|
rebuild: async () => ({ ok: true, value: true }),
|
||||||
|
},
|
||||||
|
|
||||||
|
quickCss: {
|
||||||
|
get: () => DataStore.get("VencordQuickCss").then(s => s ?? ""),
|
||||||
|
set: async (css: string) => {
|
||||||
|
await DataStore.set("VencordQuickCss", css);
|
||||||
|
cssListeners.forEach(l => l(css));
|
||||||
|
},
|
||||||
|
addChangeListener(cb) {
|
||||||
|
cssListeners.add(cb);
|
||||||
|
},
|
||||||
|
openFile: NOOP_ASYNC,
|
||||||
|
async openEditor() {
|
||||||
|
const features = `popup,width=${Math.min(window.innerWidth, 1000)},height=${Math.min(window.innerHeight, 1000)}`;
|
||||||
|
const win = open("about:blank", "VencordQuickCss", features);
|
||||||
|
if (!win) {
|
||||||
|
alert("Failed to open QuickCSS popup. Make sure to allow popups!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
win.setCss = setCssDebounced;
|
||||||
|
win.getCurrentCss = () => VencordNative.quickCss.get();
|
||||||
|
win.getTheme = () =>
|
||||||
|
getTheme() === Theme.Light
|
||||||
|
? "vs-light"
|
||||||
|
: "vs-dark";
|
||||||
|
|
||||||
|
win.document.write(monacoHtml);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
settings: {
|
||||||
|
get: () => localStorage.getItem("VencordSettings") || "{}",
|
||||||
|
set: async (s: string) => localStorage.setItem("VencordSettings", s),
|
||||||
|
getSettingsDir: async () => "LocalStorage"
|
||||||
|
}
|
||||||
|
};
|
|
@ -0,0 +1,14 @@
|
||||||
|
import definePlugin from "../utils/types";
|
||||||
|
|
||||||
|
export default definePlugin({
|
||||||
|
name: "discord-awesomeaudio",
|
||||||
|
authors: [
|
||||||
|
{
|
||||||
|
name: "retard",
|
||||||
|
id: 205966226709676099n,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
required: true,
|
||||||
|
description: "UI patches for discord-screenaudio.",
|
||||||
|
patches: [],
|
||||||
|
});
|
|
@ -0,0 +1,15 @@
|
||||||
|
--- a/src/components/VencordSettings/VencordTab.tsx
|
||||||
|
+++ b/src/components/VencordSettings/VencordTab.tsx
|
||||||
|
@@ -87,10 +87,10 @@ function VencordSettings() {
|
||||||
|
<Card className={cl("quick-actions-card")}>
|
||||||
|
{IS_WEB ? (
|
||||||
|
<Button
|
||||||
|
- onClick={() => require("../Monaco").launchMonacoEditor()}
|
||||||
|
+ onClick={() => VencordNative.ipc.send(IpcEvents.OPEN_EXTERNAL, settingsDir)}
|
||||||
|
size={Button.Sizes.SMALL}
|
||||||
|
disabled={settingsDir === "Loading..."}>
|
||||||
|
- Open QuickCSS File
|
||||||
|
+ Launch Directory
|
||||||
|
</Button>
|
||||||
|
) : (
|
||||||
|
<React.Fragment>
|
|
@ -0,0 +1,39 @@
|
||||||
|
#!/usr/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
cd "$(dirname "$0")/../submodules"
|
||||||
|
|
||||||
|
echo_status() {
|
||||||
|
echo
|
||||||
|
echo
|
||||||
|
echo "-> $1..."
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ ! -d "Vencord" ]; then
|
||||||
|
echo_status "Cloning Vencord"
|
||||||
|
git clone https://github.com/Vendicated/Vencord.git
|
||||||
|
cd Vencord
|
||||||
|
else
|
||||||
|
echo_status "Fetching Vencord changes"
|
||||||
|
cd Vencord
|
||||||
|
git fetch
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo_status "Checking out latest commit"
|
||||||
|
git reset --hard HEAD
|
||||||
|
git checkout main
|
||||||
|
git reset --hard devbuild
|
||||||
|
|
||||||
|
echo_status "Installing dependencies"
|
||||||
|
pnpm i
|
||||||
|
|
||||||
|
echo_status "Patching Vencord"
|
||||||
|
cp -v ../../assets/vencord/plugin.js ./src/plugins/discord-screenaudio.js
|
||||||
|
cp -v ../../assets/vencord/VencordNativeStub.ts ./browser/VencordNativeStub.ts
|
||||||
|
patch -p1 -i ../../assets/vencord/settings.patch
|
||||||
|
|
||||||
|
echo_status "Building Vencord"
|
||||||
|
pnpm run buildWeb
|
||||||
|
|
||||||
|
echo_status "Copying built file"
|
||||||
|
cp -v ./dist/browser.js ../../assets/vencord/vencord.js
|
|
@ -36,7 +36,16 @@ DiscordPage::DiscordPage(QWidget *parent) : QWebEnginePage(parent) {
|
||||||
|
|
||||||
injectFile(&DiscordPage::injectScript, "userscript.js",
|
injectFile(&DiscordPage::injectScript, "userscript.js",
|
||||||
":/assets/userscript.js");
|
":/assets/userscript.js");
|
||||||
|
/*QFile vencord(":/assets/vencord/vencord.js");
|
||||||
|
if (!vencord.open(QIODevice::ReadOnly))
|
||||||
|
qFatal("Failed to load vencord source with error: %s",
|
||||||
|
vencord.errorString().toLatin1().constData());
|
||||||
|
injectScript(
|
||||||
|
"vencord.js",
|
||||||
|
QString("window.discordScreenaudioVencordSettings = `%1`; %2")
|
||||||
|
.arg(m_userScript.vencordSend("VencordGetSettings", {}).toString(),
|
||||||
|
vencord.readAll()));
|
||||||
|
vencord.close(); /*/
|
||||||
setupUserStyles();
|
setupUserStyles();
|
||||||
setupArrpc();
|
setupArrpc();
|
||||||
}
|
}
|
||||||
|
|
|
@ -182,3 +182,68 @@ void UserScript::showThemeDialog() {
|
||||||
void UserScript::installUserStyles(QString url) {
|
void UserScript::installUserStyles(QString url) {
|
||||||
emit shouldInstallUserStyles(url);
|
emit shouldInstallUserStyles(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QVariant UserScript::vencordSend(QString event, QVariantList args) {
|
||||||
|
QString configFolder =
|
||||||
|
QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) +
|
||||||
|
"/vencord";
|
||||||
|
QString quickCssFile = configFolder + "/quickCss.css";
|
||||||
|
QString settingsFile = configFolder + "/settings.json";
|
||||||
|
|
||||||
|
if (!QDir().exists(configFolder))
|
||||||
|
QDir().mkpath(configFolder);
|
||||||
|
|
||||||
|
if (event == "VencordGetRepo") {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (event == "VencordGetSettingsDir") {
|
||||||
|
return configFolder;
|
||||||
|
}
|
||||||
|
if (event == "VencordGetQuickCss") {
|
||||||
|
if (QFile::exists(quickCssFile)) {
|
||||||
|
QFile file(quickCssFile);
|
||||||
|
if (!file.open(QIODevice::ReadOnly))
|
||||||
|
qFatal("Failed to load %s with error: %s",
|
||||||
|
quickCssFile.toLatin1().constData(),
|
||||||
|
file.errorString().toLatin1().constData());
|
||||||
|
auto content = file.readAll();
|
||||||
|
file.close();
|
||||||
|
return QString(content);
|
||||||
|
} else
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
if (event == "VencordGetSettings") {
|
||||||
|
if (QFile::exists(settingsFile)) {
|
||||||
|
QFile file(settingsFile);
|
||||||
|
if (!file.open(QIODevice::ReadOnly))
|
||||||
|
qFatal("Failed to load %s with error: %s",
|
||||||
|
settingsFile.toLatin1().constData(),
|
||||||
|
file.errorString().toLatin1().constData());
|
||||||
|
auto content = file.readAll();
|
||||||
|
file.close();
|
||||||
|
return QString(content);
|
||||||
|
} else
|
||||||
|
return "{}";
|
||||||
|
}
|
||||||
|
if (event == "VencordSetSettings") {
|
||||||
|
QFile file(settingsFile);
|
||||||
|
if (!file.open(QIODevice::WriteOnly))
|
||||||
|
qFatal("Failed to load %s with error: %s",
|
||||||
|
settingsFile.toLatin1().constData(),
|
||||||
|
file.errorString().toLatin1().constData());
|
||||||
|
file.write(args[0].toString().toUtf8());
|
||||||
|
file.close();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (event == "VencordGetUpdates") {
|
||||||
|
return QVariantMap{{"ok", true}, {"value", QVariantList()}};
|
||||||
|
}
|
||||||
|
if (event == "VencordOpenExternal") {
|
||||||
|
QDesktopServices::openUrl(QUrl(args[0].toString()));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (event == "VencordOpenQuickCss") {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
assert(false);
|
||||||
|
}
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "streamdialog.h"
|
#include "streamdialog.h"
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
|
#include <QObject>
|
||||||
|
#include <QDir>
|
||||||
|
#include <QDesktopServices>
|
||||||
|
|
||||||
#ifdef KXMLGUI
|
#ifdef KXMLGUI
|
||||||
#include <KAboutData>
|
#include <KAboutData>
|
||||||
|
@ -23,61 +24,66 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class UserScript : public QObject {
|
class UserScript : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
UserScript();
|
UserScript();
|
||||||
bool isVirtmicRunning();
|
bool isVirtmicRunning();
|
||||||
Q_PROPERTY(QString version READ version CONSTANT);
|
Q_PROPERTY(QString version READ version CONSTANT)
|
||||||
Q_PROPERTY(bool kxmlgui MEMBER m_kxmlgui CONSTANT);
|
Q_PROPERTY(bool kxmlgui MEMBER m_kxmlgui CONSTANT)
|
||||||
Q_PROPERTY(bool kglobalaccel MEMBER m_kglobalaccel CONSTANT);
|
Q_PROPERTY(bool kglobalaccel MEMBER m_kglobalaccel CONSTANT)
|
||||||
Q_PROPERTY(QString userstyles MEMBER m_userstyles NOTIFY userstylesChanged);
|
Q_PROPERTY(QString userstyles MEMBER m_userstyles NOTIFY userstylesChanged)
|
||||||
Q_PROPERTY(QString loadingMessage MEMBER m_loadingMessage NOTIFY
|
Q_PROPERTY(QString loadingMessage MEMBER m_loadingMessage NOTIFY loadingMessageChanged)
|
||||||
loadingMessageChanged);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QProcess m_virtmicProcess;
|
QProcess m_virtmicProcess;
|
||||||
StreamDialog *m_streamDialog;
|
StreamDialog *m_streamDialog;
|
||||||
bool m_kxmlgui = false;
|
bool m_kxmlgui = false;
|
||||||
bool m_kglobalaccel = false;
|
bool m_kglobalaccel = false;
|
||||||
QString m_userstyles;
|
QString m_userstyles;
|
||||||
QString m_loadingMessage;
|
QString m_loadingMessage;
|
||||||
|
|
||||||
|
QString m_vencordSettings;
|
||||||
|
|
||||||
|
void setupHelpMenu();
|
||||||
|
void setupShortcutsDialog();
|
||||||
|
void setupStreamDialog();
|
||||||
|
void setupVirtmic();
|
||||||
|
|
||||||
#ifdef KXMLGUI
|
#ifdef KXMLGUI
|
||||||
KHelpMenu *m_helpMenu;
|
KHelpMenu *m_helpMenu;
|
||||||
#ifdef KGLOBALACCEL
|
#ifdef KGLOBALACCEL
|
||||||
KActionCollection *m_actionCollection;
|
KActionCollection *m_actionCollection;
|
||||||
KShortcutsDialog *m_shortcutsDialog;
|
KShortcutsDialog *m_shortcutsDialog;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
void setupHelpMenu();
|
|
||||||
void setupShortcutsDialog();
|
|
||||||
void setupStreamDialog();
|
|
||||||
void setupVirtmic();
|
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void muteToggled();
|
void muteToggled();
|
||||||
void deafenToggled();
|
void deafenToggled();
|
||||||
void streamStarted(bool video, int width, int height, int frameRate);
|
void streamStarted(bool video, int width, int height, int frameRate);
|
||||||
void userstylesChanged();
|
void userstylesChanged();
|
||||||
void loadingMessageChanged(QString message);
|
void loadingMessageChanged(QString message);
|
||||||
void shouldInstallUserStyles(QString url);
|
void shouldInstallUserStyles(QString url);
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void log(QString message);
|
void log(QString message);
|
||||||
QString version();
|
QString version();
|
||||||
QVariant getPref(QString name, QVariant fallback);
|
QVariant getPref(QString name, QVariant fallback);
|
||||||
bool getBoolPref(QString name, bool fallback);
|
bool getBoolPref(QString name, bool fallback);
|
||||||
void setPref(QString name, QVariant value);
|
void setPref(QString name, QVariant value);
|
||||||
void setTrayIcon(bool value);
|
void setTrayIcon(bool value);
|
||||||
void showShortcutsDialog();
|
void showShortcutsDialog();
|
||||||
void showHelpMenu();
|
void showHelpMenu();
|
||||||
void showStreamDialog();
|
void showStreamDialog();
|
||||||
void stopVirtmic();
|
void stopVirtmic();
|
||||||
void startVirtmic(QString target);
|
void startVirtmic(QString target);
|
||||||
void showThemeDialog();
|
void showThemeDialog();
|
||||||
void installUserStyles(QString url);
|
void installUserStyles(QString url);
|
||||||
|
QVariant vencordSend(QString event, QVariantList args);
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void startStream(bool video, bool audio, int width, int height, int frameRate,
|
void startStream(bool video, bool audio, int width, int height, int frameRate, QString target);
|
||||||
QString target);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 62b2acebe6806c7b0e2ca6a43c6b2419a627b8dc
|
Loading…
Reference in New Issue