fix #1098 and some related stuff

This commit is contained in:
Martin Rotter 2023-09-12 20:16:51 +02:00
parent a015fec578
commit 3f645ef2bd
3 changed files with 19 additions and 9 deletions

View File

@ -175,11 +175,9 @@ Application::Application(const QString& id, int& argc, char** argv, const QStrin
#if defined(USE_WEBENGINE) #if defined(USE_WEBENGINE)
m_webFactory->urlIinterceptor()->load(); m_webFactory->urlIinterceptor()->load();
const QString web_data_root = userDataFolder() + QDir::separator() + QSL("web"); m_webFactory->engineProfile()->setCachePath(cacheFolder() + QDir::separator() + QSL("web") + QDir::separator() + QSL("cache"));
m_webFactory->engineProfile()->setCachePath(web_data_root + QDir::separator() + QSL("cache"));
m_webFactory->engineProfile()->setHttpCacheType(QWebEngineProfile::HttpCacheType::DiskHttpCache); m_webFactory->engineProfile()->setHttpCacheType(QWebEngineProfile::HttpCacheType::DiskHttpCache);
m_webFactory->engineProfile()->setPersistentStoragePath(web_data_root + QDir::separator() + QSL("storage")); m_webFactory->engineProfile()->setPersistentStoragePath(userDataFolder() + QDir::separator() + QSL("web") + QDir::separator() + QSL("storage"));
m_webFactory->loadCustomCss(userDataFolder() + QDir::separator() + QSL("web") + QDir::separator() + m_webFactory->loadCustomCss(userDataFolder() + QDir::separator() + QSL("web") + QDir::separator() +
QSL("user-styles.css")); QSL("user-styles.css"));
@ -509,6 +507,14 @@ QString Application::userDataFolder() {
} }
} }
QString Application::cacheFolder() {
#if defined(Q_OS_LINUX)
return QStandardPaths::writableLocation(QStandardPaths::StandardLocation::CacheLocation);
#else
return userDataFolder();
#endif
}
QString Application::replaceDataUserDataFolderPlaceholder(QString text) const { QString Application::replaceDataUserDataFolderPlaceholder(QString text) const {
auto user_data_folder = qApp->userDataFolder(); auto user_data_folder = qApp->userDataFolder();

View File

@ -147,6 +147,8 @@ class RSSGUARD_DLLSPEC Application : public SingleApplication {
// NOTE: Use this to get correct path under which store user data. // NOTE: Use this to get correct path under which store user data.
QString userDataFolder(); QString userDataFolder();
QString cacheFolder();
QString replaceDataUserDataFolderPlaceholder(QString text) const; QString replaceDataUserDataFolderPlaceholder(QString text) const;
QStringList replaceDataUserDataFolderPlaceholder(QStringList texts) const; QStringList replaceDataUserDataFolderPlaceholder(QStringList texts) const;

View File

@ -64,6 +64,11 @@ int main(int argc, char* argv[]) {
QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8")); QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));
#endif #endif
// Set some names.
QCoreApplication::setApplicationName(QSL(APP_NAME));
QCoreApplication::setApplicationVersion(QSL(APP_VERSION));
QCoreApplication::setOrganizationDomain(QSL(APP_URL));
// Instantiate base application object. // Instantiate base application object.
Application application(QSL(APP_LOW_NAME), argc, argv, raw_cli_args); Application application(QSL(APP_LOW_NAME), argc, argv, raw_cli_args);
@ -84,11 +89,8 @@ int main(int argc, char* argv[]) {
qRegisterMetaType<QList<Label*>>("QList<Label*>"); qRegisterMetaType<QList<Label*>>("QList<Label*>");
qRegisterMetaType<Label*>("Label*"); qRegisterMetaType<Label*>("Label*");
// These settings needs to be set before any QSettings object. // Set window icon, particularly for Linux/Wayland.
Application::setApplicationName(QSL(APP_NAME)); QGuiApplication::setWindowIcon(qApp->desktopAwareIcon());
Application::setApplicationVersion(QSL(APP_VERSION));
Application::setOrganizationDomain(QSL(APP_URL));
Application::setWindowIcon(qApp->desktopAwareIcon());
qApp->reactOnForeignNotifications(); qApp->reactOnForeignNotifications();