fix: column index desync after reorder
This commit is contained in:
@@ -1,11 +1,7 @@
|
||||
#include "tickingservice.hpp"
|
||||
#include <QFile>
|
||||
#include <QDir>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonValue>
|
||||
#include <QFileSystemWatcher>
|
||||
#include <QTimer>
|
||||
|
||||
#include "config/dashboard.hpp"
|
||||
#include "config/rootnodes.hpp"
|
||||
|
||||
namespace ZShell::services {
|
||||
|
||||
@@ -17,53 +13,13 @@ TickingService::TickingService(QObject* parent)
|
||||
updateTriggered();
|
||||
});
|
||||
|
||||
QString configPath =
|
||||
QDir::homePath() + QStringLiteral("/.config/zshell/config.json");
|
||||
|
||||
auto reloadConfig = [this, configPath]() {
|
||||
QFile file(configPath);
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
return;
|
||||
}
|
||||
QJsonDocument doc = QJsonDocument::fromJson(file.readAll());
|
||||
if (doc.isNull()) {
|
||||
return;
|
||||
}
|
||||
QJsonObject dashboard = doc.object().value("dashboard").toObject();
|
||||
if (dashboard.contains("resourceUpdateInterval")) {
|
||||
applyInterval(
|
||||
dashboard.value("resourceUpdateInterval").toInt(1000));
|
||||
}
|
||||
};
|
||||
|
||||
reloadConfig();
|
||||
|
||||
static auto* watcher = new QFileSystemWatcher();
|
||||
if (!watcher->files().contains(configPath)) {
|
||||
QObject::connect(
|
||||
watcher,
|
||||
&QFileSystemWatcher::fileChanged,
|
||||
this,
|
||||
[this, configPath]() {
|
||||
QTimer::singleShot(100, this, [this, configPath]() {
|
||||
QFile file(configPath);
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
return;
|
||||
}
|
||||
QJsonDocument doc = QJsonDocument::fromJson(file.readAll());
|
||||
if (doc.isNull()) {
|
||||
return;
|
||||
}
|
||||
QJsonObject dashboard =
|
||||
doc.object().value("dashboard").toObject();
|
||||
if (dashboard.contains("resourceUpdateInterval")) {
|
||||
applyInterval(dashboard.value("resourceUpdateInterval")
|
||||
.toInt(1000));
|
||||
}
|
||||
});
|
||||
});
|
||||
watcher->addPath(configPath);
|
||||
}
|
||||
auto* dash = ZShell::config::ConfigSingleton::instance()->dashboard();
|
||||
applyInterval(dash->resourceUpdateInterval());
|
||||
QObject::connect(
|
||||
dash,
|
||||
&ZShell::config::Dashboard::resourceUpdateIntervalChanged,
|
||||
this,
|
||||
[this, dash] { applyInterval(dash->resourceUpdateInterval()); });
|
||||
}
|
||||
|
||||
int TickingService::updateInterval() const {
|
||||
|
||||
Reference in New Issue
Block a user