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

View File

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

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