core/qmlglobal!: rename shellRoot to configDir + add configPath

This commit is contained in:
outfoxxed 2025-06-14 14:45:04 -07:00
parent 71fe3d9165
commit 0140356d99
Signed by untrusted user: outfoxxed
GPG key ID: 4C88A185FB89301E
2 changed files with 12 additions and 8 deletions

View file

@ -177,12 +177,6 @@ void QuickshellGlobal::reload(bool hard) {
root->reloadGraph(hard);
}
QString QuickshellGlobal::shellRoot() const {
auto* generation = EngineGeneration::findObjectGeneration(this);
// already canonical
return generation->rootPath.path();
}
QString QuickshellGlobal::workingDirectory() const { // NOLINT
return QuickshellSettings::instance()->workingDirectory();
}
@ -213,6 +207,10 @@ void QuickshellGlobal::onClipboardChanged(QClipboard::Mode mode) {
if (mode == QClipboard::Clipboard) emit this->clipboardTextChanged();
}
QString QuickshellGlobal::configDir() const {
return EngineGeneration::findObjectGeneration(this)->rootPath.path();
}
QString QuickshellGlobal::dataDir() const { // NOLINT
return QsPaths::instance()->shellDataDir().path();
}
@ -225,6 +223,10 @@ QString QuickshellGlobal::cacheDir() const { // NOLINT
return QsPaths::instance()->shellCacheDir().path();
}
QString QuickshellGlobal::configPath(const QString& path) const {
return this->configDir() % '/' % path;
}
QString QuickshellGlobal::dataPath(const QString& path) const {
return this->dataDir() % '/' % path;
}

View file

@ -104,7 +104,7 @@ class QuickshellGlobal: public QObject {
///
/// The root directory is the folder containing the entrypoint to your shell, often referred
/// to as `shell.qml`.
Q_PROPERTY(QString shellRoot READ shellRoot CONSTANT);
Q_PROPERTY(QString configDir READ configDir CONSTANT);
/// Quickshell's working directory. Defaults to whereever quickshell was launched from.
Q_PROPERTY(QString workingDirectory READ workingDirectory WRITE setWorkingDirectory NOTIFY workingDirectoryChanged);
/// If true then the configuration will be reloaded whenever any files change.
@ -167,6 +167,8 @@ public:
/// Setting the `fallback` parameter of `iconPath` will attempt to load the fallback
/// icon if the requested one could not be loaded.
Q_INVOKABLE static QString iconPath(const QString& icon, const QString& fallback);
/// Equivalent to `${Quickshell.configDir}/${path}`
Q_INVOKABLE [[nodiscard]] QString configPath(const QString& path) const;
/// Equivalent to `${Quickshell.dataDir}/${path}`
Q_INVOKABLE [[nodiscard]] QString dataPath(const QString& path) const;
/// Equivalent to `${Quickshell.stateDir}/${path}`
@ -182,7 +184,7 @@ public:
void clearReloadPopupInhibit() { this->mInhibitReloadPopup = false; }
[[nodiscard]] bool isReloadPopupInhibited() const { return this->mInhibitReloadPopup; }
[[nodiscard]] QString shellRoot() const;
[[nodiscard]] QString configDir() const;
[[nodiscard]] QString workingDirectory() const;
void setWorkingDirectory(QString workingDirectory);