C++ / fmt (pull_request) Successful in 4s
JS/TS / fmt (pull_request) Successful in 22s
JS/TS / lint (pull_request) Successful in 27s
Python / fmt (pull_request) Successful in 33s
Python / lint (pull_request) Successful in 32s
Python / test (pull_request) Successful in 1m3s
Python / typecheck (pull_request) Failing after 1m4s
Rust / fmt (pull_request) Successful in 41s
Rust / build (pull_request) Successful in 1m39s
C++ / build (pull_request) Successful in 2m33s
Rust / clippy (pull_request) Successful in 1m18s
Python / buildcheck (pull_request) Successful in 2m23s
C++ / clang-tidy (pull_request) Successful in 3m56s
109 lines
2.4 KiB
C++
109 lines
2.4 KiB
C++
#pragma once
|
|
|
|
#include "configobject.hpp"
|
|
|
|
#include <QByteArray>
|
|
#include <QFileSystemWatcher>
|
|
#include <QFuture>
|
|
#include <QMutex>
|
|
#include <QTimer>
|
|
#include <qqmlregistration.h>
|
|
#include <QtConcurrent/QtConcurrent>
|
|
|
|
class QQmlEngine;
|
|
class QJSEngine;
|
|
|
|
namespace ZShell::config {
|
|
|
|
class Appearance;
|
|
class Background;
|
|
class Bar;
|
|
class Clipboard;
|
|
class Colors;
|
|
class Dashboard;
|
|
class Dock;
|
|
class General;
|
|
class Launcher;
|
|
class Lock;
|
|
class Notifs;
|
|
class Osd;
|
|
class Screenshot;
|
|
class Services;
|
|
class Sidebar;
|
|
class Utilities;
|
|
|
|
class Config : public ConfigObject {
|
|
Q_OBJECT
|
|
QML_ELEMENT
|
|
QML_SINGLETON
|
|
|
|
Q_MOC_INCLUDE("appearance.hpp")
|
|
Q_MOC_INCLUDE("background.hpp")
|
|
Q_MOC_INCLUDE("bar.hpp")
|
|
Q_MOC_INCLUDE("clipboard.hpp")
|
|
Q_MOC_INCLUDE("colors.hpp")
|
|
Q_MOC_INCLUDE("dashboard.hpp")
|
|
Q_MOC_INCLUDE("dock.hpp")
|
|
Q_MOC_INCLUDE("general.hpp")
|
|
Q_MOC_INCLUDE("launcher.hpp")
|
|
Q_MOC_INCLUDE("lock.hpp")
|
|
Q_MOC_INCLUDE("notifs.hpp")
|
|
Q_MOC_INCLUDE("osd.hpp")
|
|
Q_MOC_INCLUDE("screenshot.hpp")
|
|
Q_MOC_INCLUDE("services.hpp")
|
|
Q_MOC_INCLUDE("sidebar.hpp")
|
|
Q_MOC_INCLUDE("utilities.hpp")
|
|
|
|
CONFIG_SUBOBJECT(Appearance, appearance)
|
|
CONFIG_SUBOBJECT(Background, background)
|
|
CONFIG_SUBOBJECT(Bar, bar)
|
|
CONFIG_SUBOBJECT(Clipboard, clipboard)
|
|
CONFIG_SUBOBJECT(Colors, colors)
|
|
CONFIG_SUBOBJECT(Dashboard, dashboard)
|
|
CONFIG_SUBOBJECT(Dock, dock)
|
|
CONFIG_SUBOBJECT(General, general)
|
|
CONFIG_SUBOBJECT(Launcher, launcher)
|
|
CONFIG_SUBOBJECT(Lock, lock)
|
|
CONFIG_SUBOBJECT(Notifs, notifs)
|
|
CONFIG_SUBOBJECT(Osd, osd)
|
|
CONFIG_SUBOBJECT(Screenshot, screenshot)
|
|
CONFIG_SUBOBJECT(Services, services)
|
|
CONFIG_SUBOBJECT(Sidebar, sidebar)
|
|
CONFIG_SUBOBJECT(Utilities, utilities)
|
|
|
|
public:
|
|
explicit Config(QObject* parent = nullptr);
|
|
static Config* create(QQmlEngine*, QJSEngine*);
|
|
|
|
Q_INVOKABLE void load();
|
|
Q_INVOKABLE void saveNow();
|
|
Q_INVOKABLE void reloadAsync();
|
|
|
|
private Q_SLOTS:
|
|
void scheduleSave();
|
|
void flushAsync();
|
|
void onWatcherEvent(const QString& path);
|
|
|
|
private:
|
|
QString filePath() const;
|
|
bool writeAtomically(const QByteArray& data);
|
|
void updateWatch();
|
|
void loadSync();
|
|
void loadAsync();
|
|
void connectAutoSave(ConfigNode* node);
|
|
|
|
QTimer m_saveTimer;
|
|
QTimer m_reloadTimer;
|
|
QFileSystemWatcher m_watcher;
|
|
|
|
QMutex m_writeMutex;
|
|
QByteArray m_lastWriteHash;
|
|
|
|
bool m_reloadPending = false;
|
|
bool m_loading = false;
|
|
bool m_firstLoadDone = false;
|
|
QFuture<void> m_loadFuture;
|
|
};
|
|
|
|
} // namespace ZShell::config
|