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); webclass.vencordSend(event, args);
}, },
sendSync: (event: string, ...args: any[]) => { sendSync: (event: string, ...args: any[]) => {
if (event === "VencordGetSettings") return "{}"; if (event === "VencordGetSettings") {
else throw new Error("Synchroneous IPC not implemented"); console.log("stub: IPC VencordGetSettings");
return "{}";
} else throw new Error("Synchroneous IPC not implemented");
}, },
on(event: string, listener: () => {}) { on(event: string, listener: () => {}) {
// TODO quickCss // TODO quickCss
@ -30,11 +32,9 @@ window.VencordNative = {
off(event: string, listener: () => {}) { off(event: string, listener: () => {}) {
// not used for now // not used for now
}, },
invoke: invoke: async (event: string, ...args: any[]) => {
(event: string, ...args: any[]) => await prepareWebclass();
async () => { return webclass.vencordSend(event, args);
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 "webclass.h"
#include <QDesktopServices> #include <QDesktopServices>
#include <QDir>
#include <QFile>
#include <QStandardPaths>
#include <QUrl> #include <QUrl>
QVariant WebClass::vencordSend(QString event, QVariantList args) { QVariant WebClass::vencordSend(QString event, QVariantList args) {
@ -8,11 +11,20 @@ QVariant WebClass::vencordSend(QString event, QVariantList args) {
return true; return true;
} }
if (event == "VencordGetSettingsDir") { if (event == "VencordGetSettingsDir") {
return "~/.config/discord-screenaudio/vencord"; return QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation);
} }
if (event == "VencordGetQuickCss") { if (event == "VencordGetQuickCss") {
// TODO QString filename =
return ""; 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") { if (event == "VencordGetSettings") {
return m_vencordSettings; return m_vencordSettings;