From 0140356d99f28261f8d59f37adb624832ab3fe80 Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Sat, 14 Jun 2025 14:45:04 -0700 Subject: [PATCH] core/qmlglobal!: rename shellRoot to configDir + add configPath --- src/core/qmlglobal.cpp | 14 ++++++++------ src/core/qmlglobal.hpp | 6 ++++-- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/core/qmlglobal.cpp b/src/core/qmlglobal.cpp index 71626be6..cbddee40 100644 --- a/src/core/qmlglobal.cpp +++ b/src/core/qmlglobal.cpp @@ -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; } diff --git a/src/core/qmlglobal.hpp b/src/core/qmlglobal.hpp index 83a97186..afb2f7e0 100644 --- a/src/core/qmlglobal.hpp +++ b/src/core/qmlglobal.hpp @@ -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);