create config dir if it doesn't exist

This commit is contained in:
Malte Jürgens 2023-02-19 00:35:09 +01:00
parent 8a8690fe53
commit f73524de27
No known key found for this signature in database
GPG key ID: D29FBD5F93C0CFC3
3 changed files with 8 additions and 6 deletions

View file

@ -55,11 +55,9 @@ void DiscordPage::setupPermissions() {
void DiscordPage::setupUserStyles() {
qDebug(userstylesLog).noquote()
<< "Looking for userstyles in"
<< QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation);
m_userStylesFile = new QFile(
QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) +
"/userstyles.css");
<< "Looking for userstyles in" << m_configLocation;
m_userStylesFile =
new QFile(m_configLocation.absoluteFilePath("userstyles.css"));
if (m_userStylesFile->exists()) {
qDebug(userstylesLog).noquote()
<< "Found userstyles:" << m_userStylesFile->fileName();
@ -119,6 +117,8 @@ void DiscordPage::fetchUserStyles() {
qDebug(userstylesLog) << "Injecting userstyles";
m_userScript.setProperty("userstyles", m_userStylesContent);
m_userScript.setProperty("loadingMessage", "");
if (!m_configLocation.exists())
m_configLocation.mkpath(".");
m_userStylesFile->open(QIODevice::WriteOnly);
m_userStylesFile->write(m_userStylesContent.toUtf8());
m_userStylesFile->close();

View file

@ -2,6 +2,7 @@
#include "userscript.h"
#include <QDir>
#include <QFile>
#include <QNetworkAccessManager>
#include <QWebEngineFullScreenRequest>
@ -20,6 +21,8 @@ private:
QFile *m_userStylesFile;
QString m_userStylesContent;
QNetworkAccessManager m_networkAccessManager;
const QDir m_configLocation =
QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation);
void setupPermissions();
void setupUserStyles();
void fetchUserStyles();

@ -1 +0,0 @@
Subproject commit 62b2acebe6806c7b0e2ca6a43c6b2419a627b8dc