mirror of
https://git.outfoxxed.me/quickshell/quickshell.git
synced 2026-02-23 03:33:57 +11:00
parent
ea79eaceb0
commit
1e8cc2e78d
5 changed files with 36 additions and 8 deletions
|
|
@ -27,12 +27,19 @@ QsPaths* QsPaths::instance() {
|
|||
return instance;
|
||||
}
|
||||
|
||||
void QsPaths::init(QString shellId, QString pathId, QString dataOverride, QString stateOverride) {
|
||||
void QsPaths::init(
|
||||
QString shellId,
|
||||
QString pathId,
|
||||
QString dataOverride,
|
||||
QString stateOverride,
|
||||
QString cacheOverride
|
||||
) {
|
||||
auto* instance = QsPaths::instance();
|
||||
instance->shellId = std::move(shellId);
|
||||
instance->pathId = std::move(pathId);
|
||||
instance->shellDataOverride = std::move(dataOverride);
|
||||
instance->shellStateOverride = std::move(stateOverride);
|
||||
instance->shellCacheOverride = std::move(cacheOverride);
|
||||
}
|
||||
|
||||
QDir QsPaths::crashDir(const QString& id) {
|
||||
|
|
@ -316,9 +323,16 @@ QDir QsPaths::shellStateDir() {
|
|||
|
||||
QDir QsPaths::shellCacheDir() {
|
||||
if (this->shellCacheState == DirState::Unknown) {
|
||||
auto dir = QDir(QStandardPaths::writableLocation(QStandardPaths::CacheLocation));
|
||||
dir = QDir(dir.filePath("by-shell"));
|
||||
dir = QDir(dir.filePath(this->shellId));
|
||||
QDir dir;
|
||||
if (this->shellCacheOverride.isEmpty()) {
|
||||
dir = QDir(QStandardPaths::writableLocation(QStandardPaths::CacheLocation));
|
||||
dir = QDir(dir.filePath("by-shell"));
|
||||
dir = QDir(dir.filePath(this->shellId));
|
||||
} else {
|
||||
auto basedir = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation);
|
||||
dir = QDir(this->shellCacheOverride.replace("$BASE", basedir));
|
||||
}
|
||||
|
||||
this->mShellCacheDir = dir;
|
||||
|
||||
qCDebug(logPaths) << "Initialized cache path:" << dir.path();
|
||||
|
|
|
|||
|
|
@ -17,7 +17,13 @@ QDataStream& operator>>(QDataStream& stream, InstanceLockInfo& info);
|
|||
class QsPaths {
|
||||
public:
|
||||
static QsPaths* instance();
|
||||
static void init(QString shellId, QString pathId, QString dataOverride, QString stateOverride);
|
||||
static void init(
|
||||
QString shellId,
|
||||
QString pathId,
|
||||
QString dataOverride,
|
||||
QString stateOverride,
|
||||
QString cacheOverride
|
||||
);
|
||||
static QDir crashDir(const QString& id);
|
||||
static QString basePath(const QString& id);
|
||||
static QString ipcPath(const QString& id);
|
||||
|
|
@ -65,4 +71,5 @@ private:
|
|||
|
||||
QString shellDataOverride;
|
||||
QString shellStateOverride;
|
||||
QString shellCacheOverride;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -127,18 +127,21 @@ class QuickshellGlobal: public QObject {
|
|||
/// Usually `~/.local/share/quickshell/by-shell/<shell-id>`
|
||||
///
|
||||
/// Can be overridden using `//@ pragma DataDir $BASE/path` in the root qml file, where `$BASE`
|
||||
/// corrosponds to `$XDG_DATA_HOME` (usually `~/.local/share`).
|
||||
/// corresponds to `$XDG_DATA_HOME` (usually `~/.local/share`).
|
||||
Q_PROPERTY(QString dataDir READ dataDir CONSTANT);
|
||||
/// The per-shell state directory.
|
||||
///
|
||||
/// Usually `~/.local/state/quickshell/by-shell/<shell-id>`
|
||||
///
|
||||
/// Can be overridden using `//@ pragma StateDir $BASE/path` in the root qml file, where `$BASE`
|
||||
/// corrosponds to `$XDG_STATE_HOME` (usually `~/.local/state`).
|
||||
/// corresponds to `$XDG_STATE_HOME` (usually `~/.local/state`).
|
||||
Q_PROPERTY(QString stateDir READ stateDir CONSTANT);
|
||||
/// The per-shell cache directory.
|
||||
///
|
||||
/// Usually `~/.cache/quickshell/by-shell/<shell-id>`
|
||||
///
|
||||
/// Can be overridden using `//@ pragma CacheDir $BASE/path` in the root qml file, where `$BASE`
|
||||
/// corresponds to `$XDG_CACHE_HOME` (usually `~/.cache`).
|
||||
Q_PROPERTY(QString cacheDir READ cacheDir CONSTANT);
|
||||
// clang-format on
|
||||
QML_SINGLETON;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue