forked from quickshell/quickshell
refactor: move settings to their own object
This commit is contained in:
parent
62f99f5754
commit
4ef4cba4ee
8 changed files with 107 additions and 78 deletions
|
@ -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;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue