From 8501b39fcee6643ff666ae8399fd006c9f31fc36 Mon Sep 17 00:00:00 2001 From: Uyanide Date: Sat, 28 Feb 2026 23:20:42 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20default=20to=20user's=20Pic?= =?UTF-8?q?ture=20directory=20if=20no=20dirs=20or=20paths=20are=20specifie?= =?UTF-8?q?d=20&=20=F0=9F=94=A7=20fix:=20segfault=20on=20--clear-cache?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WallReel/Core/Config/manager.cpp | 7 +++++++ WallReel/Core/Config/manager.hpp | 2 ++ WallReel/Core/Provider/bootstrap.hpp | 11 ++++++----- WallReel/Core/Utils/misc.hpp | 8 ++++++++ 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/WallReel/Core/Config/manager.cpp b/WallReel/Core/Config/manager.cpp index 61b62fe..7c08912 100644 --- a/WallReel/Core/Config/manager.cpp +++ b/WallReel/Core/Config/manager.cpp @@ -17,6 +17,7 @@ WALLREEL_DECLARE_SENDER("ConfigManager") WallReel::Core::Config::Manager::Manager( const QDir& configDir, + const QDir& picturesDir, const QStringList& searchDirs, const QString& configPath, QObject* parent) @@ -35,6 +36,12 @@ WallReel::Core::Config::Manager::Manager( m_wallpaperConfig.dirs.append({dir, false}); } } + // Add Pictures directory as default search directory if no dirs or paths are specified above + if (m_wallpaperConfig.dirs.isEmpty() && m_wallpaperConfig.paths.isEmpty()) { + QString picturesPath = picturesDir.absolutePath(); + WR_INFO(QString("No search directories specified, using Pictures directory: %1").arg(picturesPath)); + m_wallpaperConfig.dirs.append({picturesPath, true}); + } WR_DEBUG("Loading wallpapers ..."); _loadWallpapers(); diff --git a/WallReel/Core/Config/manager.hpp b/WallReel/Core/Config/manager.hpp index 248e922..46c62e0 100644 --- a/WallReel/Core/Config/manager.hpp +++ b/WallReel/Core/Config/manager.hpp @@ -26,12 +26,14 @@ class Manager : public QObject { * @param configDir The directory where the configuration file is located (should be the default location, i.e. $XDG_CONFIG_HOME/$appName) * @param searchDirs Additional directories to search for wallpapers (not recursive) * @param configPath Optional path to a specific configuration file (overrides the default config path) + * @param picturesDir The pictures directory (default location for user wallpapers) * @param parent QObject parent * * @note The constructor will load the configuration and scan for wallpapers immediately. */ Manager( const QDir& configDir, + const QDir& picturesDir, const QStringList& searchDirs = {}, const QString& configPath = "", QObject* parent = nullptr); diff --git a/WallReel/Core/Provider/bootstrap.hpp b/WallReel/Core/Provider/bootstrap.hpp index 0c8d4b1..4c1d4c8 100644 --- a/WallReel/Core/Provider/bootstrap.hpp +++ b/WallReel/Core/Provider/bootstrap.hpp @@ -26,6 +26,7 @@ class Bootstrap { } configMgr = new Config::Manager( Utils::getConfigDir(), + Utils::getPicturesDir(), options.appendDirs, options.configPath); @@ -59,11 +60,11 @@ class Bootstrap { } private: - Cache::Manager* cacheMgr; - Config::Manager* configMgr; - Image::Manager* imageMgr; - Palette::Manager* paletteMgr; - Service::Manager* ServiceMgr; + Cache::Manager* cacheMgr{}; + Config::Manager* configMgr{}; + Image::Manager* imageMgr{}; + Palette::Manager* paletteMgr{}; + Service::Manager* ServiceMgr{}; }; } // namespace WallReel::Core::Provider diff --git a/WallReel/Core/Utils/misc.hpp b/WallReel/Core/Utils/misc.hpp index d11cb86..d3fa83d 100644 --- a/WallReel/Core/Utils/misc.hpp +++ b/WallReel/Core/Utils/misc.hpp @@ -171,6 +171,14 @@ inline QDir getCacheDir() { return QDir(cacheDir); } +inline QDir getPicturesDir() { + auto picturesDir = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation); + if (picturesDir.isEmpty()) { + picturesDir = QDir::homePath() + QDir::separator() + "Pictures"; + } + return QDir(picturesDir); +} + } // namespace WallReel::Core::Utils #endif // WALLREEL_MISC_HPP