This commit is contained in:
Malte Jürgens 2022-10-15 00:15:19 +02:00
parent 100f9bf58e
commit 0493a76117
No known key found for this signature in database
GPG Key ID: D29FBD5F93C0CFC3
3 changed files with 34 additions and 22 deletions

View File

@ -21,8 +21,10 @@ window.VencordNative = {
webclass.vencordSend(event, args);
},
sendSync: (event: string, ...args: any[]) => {
if (event === "VencordGetSettings") return "{}";
else throw new Error("Synchroneous IPC not implemented");
if (event === "VencordGetSettings") {
console.log("stub: IPC VencordGetSettings");
return "{}";
} else throw new Error("Synchroneous IPC not implemented");
},
on(event: string, listener: () => {}) {
// TODO quickCss
@ -30,11 +32,9 @@ window.VencordNative = {
off(event: string, listener: () => {}) {
// not used for now
},
invoke:
(event: string, ...args: any[]) =>
async () => {
await prepareWebclass();
return webclass.vencordSend(event, args);
},
invoke: async (event: string, ...args: any[]) => {
await prepareWebclass();
return webclass.vencordSend(event, args);
},
},
};

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,9 @@
#include "webclass.h"
#include <QDesktopServices>
#include <QDir>
#include <QFile>
#include <QStandardPaths>
#include <QUrl>
QVariant WebClass::vencordSend(QString event, QVariantList args) {
@ -8,11 +11,20 @@ QVariant WebClass::vencordSend(QString event, QVariantList args) {
return true;
}
if (event == "VencordGetSettingsDir") {
return "~/.config/discord-screenaudio/vencord";
return QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation);
}
if (event == "VencordGetQuickCss") {
// TODO
return "";
QString filename =
QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) +
"/vencord/quickCss.css";
if (QFile::exists(filename)) {
QFile file(filename);
file.open(QIODevice::ReadOnly);
auto content = file.readAll();
file.close();
return QString(content);
} else
return "";
}
if (event == "VencordGetSettings") {
return m_vencordSettings;