refactor: move settings to their own object

This commit is contained in:
outfoxxed 2024-03-04 01:31:31 -08:00
parent 62f99f5754
commit 4ef4cba4ee
Signed by: outfoxxed
GPG key ID: 4C88A185FB89301E
8 changed files with 107 additions and 78 deletions

View file

@ -5,38 +5,17 @@
#include <qqmlengine.h>
#include <qtmetamacros.h>
#include "qmlglobal.hpp"
#include "reload.hpp"
class ShellConfig {
Q_GADGET;
Q_PROPERTY(bool watchFiles MEMBER mWatchFiles);
Q_PROPERTY(QString workingDirectory WRITE setWorkingDirectory);
public:
bool mWatchFiles = true;
void setWorkingDirectory(const QString& workingDirectory);
};
///! Root config element
class ShellRoot: public ReloadPropagator {
Q_OBJECT;
/// If `config.watchFiles` is true the configuration will be reloaded whenever it changes.
/// Defaults to true.
///
/// `config.workingDirectory` corrosponds to [Quickshell.workingDirectory](../quickshell#prop.workingDirectory).
Q_PROPERTY(ShellConfig config READ config WRITE setConfig NOTIFY configChanged);
Q_PROPERTY(QuickshellSettings* settings READ settings CONSTANT);
QML_ELEMENT;
public:
explicit ShellRoot(QObject* parent = nullptr): ReloadPropagator(parent) {}
void setConfig(ShellConfig config);
[[nodiscard]] ShellConfig config() const;
signals:
void configChanged();
private:
ShellConfig mConfig;
[[nodiscard]] QuickshellSettings* settings() const;
};