Compare commits

...

9 Commits

Author SHA1 Message Date
Malte Jürgens e3d87e8202 v1.7.0
-----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEA093du9eDGE9L3k00p+9X5PAz8MFAmPsN6oACgkQ0p+9X5PA
 z8O8pg//UBo01WAv4NwK17gLIMMjwbXIcWCcC46RaJKo0gBSJy9wFvHCQfR3qLb4
 AJDlfnbSkkJ5w3xnEruUwmgbTkBOWnxYUX/Uaq2jI7JfxYWi1AdMINg0E7GirLqs
 T1AraC5bjaIlrfohgspi9BYw8g2fBE/doQKrUC5a4vTwPYmjZZmCOkwILPTKx8Ig
 L5CmBQPnpOMtfOvwyM7h3I4FT32M2WwW79gW9XYKNf3kiXDRqqTQODMzU0iNjHq3
 STDu3lrCgpdEyNuBsZQilfCWTPCVHTggYQGv0Brv+YPRE/ELzcfFuqqQcpvZC843
 hobJIuCNfCfJN7Bu6gc2RUfNZkDQUj7Ar62j+J7PS5CVfQjpwomfeDeX94vaq8hK
 JWret1lHzabbBmeEcX41wq/WcHMGfFzk30PlLK3f1EQqdu/QUvprXV3pQDWkrqdn
 gtamTz3TIxUBWd2dbC8oaOQLB9YKPLCJy+zbPNObNMII5PU3nmHSFMafTefjjiwA
 x1t5hwxwM6ND+YsDU3XTvMVLo87enQgnNhsfQyrIRPqaIRerB02w2j++b2SCluX1
 npsJhVK/ND9aih+x/dopMXDqJTVJhLqH31KOaRz2l7KTAubY/c8gVSnVBKDTp4ez
 /RuOjBys5qXNKU/RRn9cA09xuXCkDZK7WBtHpU6vqKmEuP18ND4=
 =vRVO
 -----END PGP SIGNATURE-----
gpgsig -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEA093du9eDGE9L3k00p+9X5PAz8MFAmPw5voACgkQ0p+9X5PA
 z8PoCg//T+mXN0/wp0/nh8T44nptqBDy28RJzzWrbxyNLx5uazU0Nq97jToiY3QI
 3XnjtqN1pv+6DQeBKpJcHX3jsUQOXXqDWeVR4gsqjBe3w54mgRTUmzFUcnUsERud
 D/HI04vV2Z2+ky5opS3eQFhy9sVPwGvEMZRTsSNMkGYESGzvOzl3SXCDW4ftNm8Q
 9Qu11BlxYxu4NNKBtvbDPVICcXk2YRdjBBQ8dN66nyrHLa3AO/tbOP9mh8mLJuDB
 WjEaG29+Xpsx5l9woLg0JakGyf2HkYuHG/G/oEUknsCJ7/MUb0iknwFWy9BdaiO+
 Dnh4ABoK0PGDpzHAR5OUomyvAfOd8AOXcFaOztT/NJ6Tj1RNZgbPKbsS+wJxYzGN
 x8xsUXhGIY/y9EqEcKolRh3JKMihtvdVjfOaeRFse0juNErewsurSx+oxcSS8jj/
 ULABMR/SpDp+h0j9HGexqNnI7htGe2egabRIMUfqfN/kKO4i5onvTbq7gpIaak6B
 W3BAzPnAes81VKgcLIcEqrPBSTuAxb1L3tNeKU3dHMeFQz2P6p3CFx/UPObIdwzv
 GdX6hzQKIg/IGh+5i31Heyh6wB1e5FhEUKxqDrE1wVOPVDkP6bHlZEW0lI2feSYM
 xjk1/w5onEOKiXvXkgC64f7wZY/VCXOaa3Ptp2hZSLuypDgNxdY=
 =D7Pe
 -----END PGP SIGNATURE-----

Merge tag 'v1.7.0' into vencord

v1.7.0
2023-02-18 15:55:54 +01:00
Malte Jürgens 700d576ff8
update vencord 2023-02-18 15:46:56 +01:00
Malte Jürgens 906deee580
vencord fixes 2022-10-25 20:27:22 +02:00
Malte Jürgens 9d9e57df1e
add about message again 2022-10-25 20:25:47 +02:00
Malte Jürgens 9eae8bbe4f
further work on vencord 2022-10-22 23:56:49 +02:00
Malte Jürgens 0493a76117
working 2022-10-15 00:15:19 +02:00
Malte Jürgens 100f9bf58e
testing 2022-10-14 23:16:34 +02:00
Malte Jürgens 1eda9d75b0
Merge branch 'master' into vencord 2022-10-11 22:21:14 +02:00
Malte Jürgens f750b76068
testing vencord 2022-10-11 19:51:09 +02:00
11 changed files with 613 additions and 2 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
/build
.vscode
/submodules/Vencord

View File

@ -0,0 +1,43 @@
let webclass;
const promise = new Promise((resolve) => {
setTimeout(() => {
new QWebChannel(qt.webChannelTransport, function (channel) {
webclass = channel.objects.webclass;
resolve();
});
});
});
async function prepareWebclass() {
if (!webclass) await promise;
}
window.VencordNative = {
getVersions: () => ({}),
ipc: {
send: async (event: string, ...args: any[]) => {
await prepareWebclass();
webclass.vencordSend(event, args);
},
sendSync: (event: string, ...args: any[]) => {
// We need this hack because Vencord requires its settings right when it starts
if (event === "VencordGetSettings") {
return window.discordScreenaudioVencordSettings || "{}";
} else throw new Error("Synchroneous IPC not implemented");
},
on(event: string, listener: () => {}) {
// TODO quickCss
},
off(event: string, listener: () => {}) {
// not used for now
},
invoke: async (event: string, ...args: any[]) => {
await prepareWebclass();
if (event === "VencordSetSettings") {
window.discordScreenaudioVencordSettings = args[0];
}
return webclass.vencordSend(event, args);
},
},
};

14
assets/vencord/plugin.js Normal file
View File

@ -0,0 +1,14 @@
import definePlugin from "../utils/types";
export default definePlugin({
name: "discord-screenaudio",
authors: [
{
name: "maltejur",
id: 205966226709676032n,
},
],
required: true,
description: "UI patches for discord-screenaudio.",
patches: [],
});

View File

@ -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>

410
assets/vencord/vencord.js Normal file

File diff suppressed because one or more lines are too long

View File

@ -2,6 +2,7 @@
<RCC>
<qresource>
<file>assets/userscript.js</file>
<file>assets/vencord/vencord.js</file>
<file>assets/de.shorsh.discord-screenaudio.png</file>
</qresource>
</RCC>

39
scripts/build_vencord.sh Executable file
View File

@ -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

View File

@ -34,6 +34,19 @@ DiscordPage::DiscordPage(QWidget *parent) : QWebEnginePage(parent) {
injectFile(&DiscordPage::injectScript, "userscript.js",
":/assets/userscript.js");
injectFile(&DiscordPage::injectScript, "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();
}
@ -210,7 +223,9 @@ void DiscordPage::javaScriptConsoleMessage(
}
}
qDebug(discordLog) << (ansi + lines[0].trimmed() + "\033[0m " +
lines[endOfStyles].trimmed())
((lines.length() > endOfStyles)
? lines[endOfStyles].trimmed()
: ""))
.toUtf8()
.constData();
for (auto line : lines.mid(endOfStyles + 1)) {

View File

@ -1,6 +1,8 @@
#pragma once
#include "streamdialog.h"
#include "userscript.h"
#include "virtmic.h"
#include <QWebEngineFullScreenRequest>
#include <QWebEnginePage>

View File

@ -4,6 +4,10 @@
#include <QApplication>
#include <QDebug>
#include <QDesktopServices>
#include <QDir>
#include <QFile>
#include <QStandardPaths>
#include <QTimer>
#ifdef KXMLGUI
@ -162,4 +166,69 @@ void UserScript::showStreamDialog() {
else
m_streamDialog->activateWindow();
m_streamDialog->updateTargets();
}
}
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);
}

View File

@ -40,6 +40,7 @@ private:
KShortcutsDialog *m_shortcutsDialog;
#endif
#endif
QString m_vencordSettings;
void setupHelpMenu();
void setupShortcutsDialog();
void setupStreamDialog();
@ -62,6 +63,7 @@ public Q_SLOTS:
void showStreamDialog();
void stopVirtmic();
void startVirtmic(QString target);
QVariant vencordSend(QString event, QVariantList args);
private Q_SLOTS:
void startStream(bool video, bool audio, int width, int height, int frameRate,