diff --git a/assets/userscript.js b/assets/userscript.js
index 1b2cd8f..28aaa7e 100644
--- a/assets/userscript.js
+++ b/assets/userscript.js
@@ -99,7 +99,7 @@ function createSwitch(text, enabled, onClick) {
container.appendChild(svg);
function setSvgDisabled() {
- svg.innerHTML = `
`;
+ svg.innerHTML = ``;
}
function setSvgEnabled() {
@@ -302,6 +302,17 @@ setInterval(() => {
)
);
+ section.appendChild(
+ createSwitch(
+ "Start discord-screenaudio hidden to tray",
+ window.discordScreenaudioStartHidden,
+ (hidden) => {
+ window.discordScreenaudioStartHidden = hidden;
+ console.log(`!discord-screenaudio-starthidden-${hidden}`);
+ }
+ )
+ );
+
const divider = document.createElement("div");
divider.className = "divider-3nqZNm marginTop40-Q4o1tS";
diff --git a/src/discordpage.cpp b/src/discordpage.cpp
index 3b63111..01a699e 100644
--- a/src/discordpage.cpp
+++ b/src/discordpage.cpp
@@ -57,11 +57,16 @@ DiscordPage::DiscordPage(QWidget *parent) : QWebEnginePage(parent) {
injectScriptText("vars.js",
QString("window.discordScreenaudioVersion = '%1'; "
- "window.discordScreenaudioTrayEnabled = %2;")
+ "window.discordScreenaudioTrayEnabled = %2; "
+ "window.discordScreenaudioStartHidden = %3;")
.arg(QApplication::applicationVersion())
.arg(MainWindow::instance()
->settings()
->value("trayIcon", false)
+ .toBool())
+ .arg(MainWindow::instance()
+ ->settings()
+ ->value("startHidden", false)
.toBool()));
#ifdef KXMLGUI
@@ -230,6 +235,10 @@ void DiscordPage::javaScriptConsoleMessage(
MainWindow::instance()->setTrayIcon(true);
} else if (message == "!discord-screenaudio-tray-false") {
MainWindow::instance()->setTrayIcon(false);
+ } else if (message == "!discord-screenaudio-starthidden-true") {
+ MainWindow::instance()->settings()->setValue("startHidden", true);
+ } else if (message == "!discord-screenaudio-starthidden-false") {
+ MainWindow::instance()->settings()->setValue("startHidden", false);
} else if (message.startsWith("dsa: ")) {
qDebug(userscriptLog) << message.mid(5).toUtf8().constData();
} else {
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index f60df7c..092ec18 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -14,6 +14,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -34,6 +35,11 @@ MainWindow::MainWindow(bool useNotifySend, QWidget *parent)
setupTrayIcon();
resize(1000, 700);
showMaximized();
+ if (m_settings->value("trayIcon", false).toBool() &&
+ m_settings->value("startHidden", false).toBool()) {
+ hide();
+ QTimer::singleShot(0, [=]() { hide(); });
+ }
}
void MainWindow::setupWebView() {