✨ feat: default to user's Picture directory if no dirs or paths are specified & 🔧 fix: segfault on --clear-cache
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user