nosignal-shell/plugin/src/Caelestia/Config/configscope.hpp
2026-04-12 22:38:36 +10:00

45 lines
1.1 KiB
C++

#pragma once
#include <qqmlintegration.h>
#include <qquickitem.h>
namespace caelestia::config {
class GlobalConfig;
class TokenConfig;
class ConfigScope : public QQuickItem {
Q_OBJECT
Q_MOC_INCLUDE("config.hpp")
Q_MOC_INCLUDE("tokens.hpp")
QML_ELEMENT
Q_PROPERTY(QString screen READ screen WRITE setScreen NOTIFY screenChanged)
Q_PROPERTY(caelestia::config::GlobalConfig* config READ config NOTIFY configChanged)
Q_PROPERTY(caelestia::config::TokenConfig* tokens READ tokens NOTIFY tokensChanged)
public:
explicit ConfigScope(QQuickItem* parent = nullptr);
[[nodiscard]] QString screen() const;
void setScreen(const QString& screen);
[[nodiscard]] GlobalConfig* config() const;
[[nodiscard]] TokenConfig* tokens() const;
static ConfigScope* find(QObject* object);
signals:
void screenChanged();
void configChanged();
void tokensChanged();
private:
void resolveConfig();
QString m_screen;
GlobalConfig* m_config = nullptr;
TokenConfig* m_tokens = nullptr;
};
} // namespace caelestia::config