✨ 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(
|
WallReel::Core::Config::Manager::Manager(
|
||||||
const QDir& configDir,
|
const QDir& configDir,
|
||||||
|
const QDir& picturesDir,
|
||||||
const QStringList& searchDirs,
|
const QStringList& searchDirs,
|
||||||
const QString& configPath,
|
const QString& configPath,
|
||||||
QObject* parent)
|
QObject* parent)
|
||||||
@@ -35,6 +36,12 @@ WallReel::Core::Config::Manager::Manager(
|
|||||||
m_wallpaperConfig.dirs.append({dir, false});
|
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 ...");
|
WR_DEBUG("Loading wallpapers ...");
|
||||||
_loadWallpapers();
|
_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 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 searchDirs Additional directories to search for wallpapers (not recursive)
|
||||||
* @param configPath Optional path to a specific configuration file (overrides the default config path)
|
* @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
|
* @param parent QObject parent
|
||||||
*
|
*
|
||||||
* @note The constructor will load the configuration and scan for wallpapers immediately.
|
* @note The constructor will load the configuration and scan for wallpapers immediately.
|
||||||
*/
|
*/
|
||||||
Manager(
|
Manager(
|
||||||
const QDir& configDir,
|
const QDir& configDir,
|
||||||
|
const QDir& picturesDir,
|
||||||
const QStringList& searchDirs = {},
|
const QStringList& searchDirs = {},
|
||||||
const QString& configPath = "",
|
const QString& configPath = "",
|
||||||
QObject* parent = nullptr);
|
QObject* parent = nullptr);
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ class Bootstrap {
|
|||||||
}
|
}
|
||||||
configMgr = new Config::Manager(
|
configMgr = new Config::Manager(
|
||||||
Utils::getConfigDir(),
|
Utils::getConfigDir(),
|
||||||
|
Utils::getPicturesDir(),
|
||||||
options.appendDirs,
|
options.appendDirs,
|
||||||
options.configPath);
|
options.configPath);
|
||||||
|
|
||||||
@@ -59,11 +60,11 @@ class Bootstrap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Cache::Manager* cacheMgr;
|
Cache::Manager* cacheMgr{};
|
||||||
Config::Manager* configMgr;
|
Config::Manager* configMgr{};
|
||||||
Image::Manager* imageMgr;
|
Image::Manager* imageMgr{};
|
||||||
Palette::Manager* paletteMgr;
|
Palette::Manager* paletteMgr{};
|
||||||
Service::Manager* ServiceMgr;
|
Service::Manager* ServiceMgr{};
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace WallReel::Core::Provider
|
} // namespace WallReel::Core::Provider
|
||||||
|
|||||||
@@ -171,6 +171,14 @@ inline QDir getCacheDir() {
|
|||||||
return QDir(cacheDir);
|
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
|
} // namespace WallReel::Core::Utils
|
||||||
|
|
||||||
#endif // WALLREEL_MISC_HPP
|
#endif // WALLREEL_MISC_HPP
|
||||||
|
|||||||
Reference in New Issue
Block a user