feat: remove file prefix on signals
This commit is contained in:
parent
746d1af826
commit
9b1b33a388
2 changed files with 10 additions and 9 deletions
|
|
@ -268,14 +268,15 @@ void ConfigObject::setupFileBackend(const QString& path) {
|
||||||
if (!file.open(QIODevice::WriteOnly)) {
|
if (!file.open(QIODevice::WriteOnly)) {
|
||||||
qCWarning(lcConfig, "Failed to write %s", qUtf8Printable(m_filePath));
|
qCWarning(lcConfig, "Failed to write %s", qUtf8Printable(m_filePath));
|
||||||
if (auto* root = qobject_cast<RootConfig*>(this))
|
if (auto* root = qobject_cast<RootConfig*>(this))
|
||||||
emit root->fileSaveFailed(QStringLiteral("Failed to open file for writing"));
|
emit root->saveFailed(QStringLiteral("Failed to open file for writing"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto json = toJsonObject();
|
auto json = toJsonObject();
|
||||||
file.write(QJsonDocument(json).toJson(QJsonDocument::Indented));
|
file.write(QJsonDocument(json).toJson(QJsonDocument::Indented));
|
||||||
|
file.close();
|
||||||
if (auto* root = qobject_cast<RootConfig*>(this))
|
if (auto* root = qobject_cast<RootConfig*>(this))
|
||||||
emit root->fileSaved();
|
emit root->saved();
|
||||||
});
|
});
|
||||||
|
|
||||||
m_cooldownTimer->setSingleShot(true);
|
m_cooldownTimer->setSingleShot(true);
|
||||||
|
|
@ -355,9 +356,9 @@ void ConfigObject::onFileChanged() {
|
||||||
bool ok = reloadFromFile();
|
bool ok = reloadFromFile();
|
||||||
if (auto* root = qobject_cast<RootConfig*>(this)) {
|
if (auto* root = qobject_cast<RootConfig*>(this)) {
|
||||||
if (ok)
|
if (ok)
|
||||||
emit root->fileLoaded();
|
emit root->loaded();
|
||||||
else
|
else
|
||||||
emit root->fileLoadFailed(QStringLiteral("Failed to load config file"));
|
emit root->loadFailed(QStringLiteral("Failed to load config file"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -373,7 +374,7 @@ void RootConfig::save() {
|
||||||
|
|
||||||
void RootConfig::reload() {
|
void RootConfig::reload() {
|
||||||
if (reloadFromFile())
|
if (reloadFromFile())
|
||||||
emit fileLoaded();
|
emit loaded();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace caelestia::config
|
} // namespace caelestia::config
|
||||||
|
|
|
||||||
|
|
@ -126,10 +126,10 @@ public:
|
||||||
Q_INVOKABLE void reload();
|
Q_INVOKABLE void reload();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void fileLoaded();
|
void loaded();
|
||||||
void fileLoadFailed(const QString& error);
|
void loadFailed(const QString& error);
|
||||||
void fileSaved();
|
void saved();
|
||||||
void fileSaveFailed(const QString& error);
|
void saveFailed(const QString& error);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace caelestia::config
|
} // namespace caelestia::config
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue