chore: split cmake into multiple files and fix settings searching regex + add enabled option to llm
C++ / fmt (pull_request) Successful in 4s
JS/TS / fmt (pull_request) Failing after 17s
JS/TS / lint (pull_request) Successful in 19s
Python / static (pull_request) Successful in 1m11s
Rust / fmt (pull_request) Successful in 1m3s
Rust / build (pull_request) Successful in 2m26s
Rust / clippy (pull_request) Failing after 16m40s
Python / verify (pull_request) Failing after 17m52s
C++ / clang-tidy (pull_request) Failing after 18m0s
C++ / build (pull_request) Failing after 18m2s

This commit is contained in:
2026-09-01 14:30:04 +02:00
parent 2150859847
commit ef2fb95fab
20 changed files with 855 additions and 641 deletions
+82 -6
View File
@@ -5,6 +5,7 @@
#include <QtQuick/qquickwindow.h>
#include <qcontainerfwd.h>
#include <qdir.h>
#include <qdiriterator.h>
#include <qfileinfo.h>
#include <qfuturewatcher.h>
#include <qjsprimitivevalue.h>
@@ -12,6 +13,8 @@
#include <qqmlengine.h>
#include <qfile.h>
#include "util/metaenum.hpp"
Q_LOGGING_CATEGORY(lcZUtils, "ZShell.cutils", QtInfoMsg)
namespace ZShell {
@@ -171,13 +174,44 @@ qreal ZUtils::clamp(qreal value, qreal min, qreal max) {
return qBound(min, value, max);
}
QString ZUtils::settingsIndex() {
QFile file(QStringLiteral(":/qt/qml/ZShell/settings-index.json"));
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
qCWarning(lcZUtils) << "Failed to open embedded settings index";
return QString();
QString ZUtils::enumToString(
QObject* target, const QString& property, const QVariant& value) {
if (!target) {
qCWarning(lcZUtils) << "enumToString: a target is required";
return {};
}
return QString::fromUtf8(file.readAll());
const auto* meta = target->metaObject();
const auto index = meta->indexOfProperty(property.toUtf8().constData());
if (index < 0) {
qCWarning(lcZUtils)
<< "enumToString:" << target << "has no property" << property;
return {};
}
const auto prop = meta->property(index);
const auto metaEnum = prop.isEnumType()
? prop.enumerator()
: util::metaEnumFor(prop.metaType());
if (!metaEnum.isValid() || metaEnum.is64Bit()) {
qCWarning(lcZUtils) << "enumToString: property" << property << "of"
<< target << "is not a supported enum";
return {};
}
const auto val = value.isValid() ? value : prop.read(target);
const auto* key = util::enumKeyFor(metaEnum, val);
if (!key) {
qCWarning(
lcZUtils,
"enumToString: no enumerator of %s::%s has the value %lld",
metaEnum.scope(),
metaEnum.name(),
val.toLongLong());
return {};
}
return QString::fromUtf8(key);
}
#ifndef ZSHELL_VERSION
@@ -192,4 +226,46 @@ QString ZUtils::qtVersion() const {
return QStringLiteral(QT_VERSION_STR);
}
QString ZUtils::gitRevision() {
#ifdef GIT_REVISION
return QStringLiteral(GIT_REVISION);
#else
return QString();
#endif
}
QString ZUtils::readTextFile(const QString& path) {
QFile file(path);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
return QString();
}
return QString::fromUtf8(file.readAll());
}
bool ZUtils::writeTextFile(const QString& path, const QString& text) {
const QFileInfo info(path);
if (!QDir().mkpath(info.absolutePath())) {
qCWarning(lcZUtils) << "Failed to create directory for" << path;
return false;
}
QFile file(path);
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
qCWarning(lcZUtils) << "Failed to open" << path << "for writing";
return false;
}
return file.write(text.toUtf8()) >= 0;
}
QStringList ZUtils::listFiles(const QString& dir, const QString& suffix) {
QStringList out;
QDirIterator it(dir, QDirIterator::Subdirectories);
while (it.hasNext()) {
const QString path = it.next();
if (it.fileInfo().isFile() && path.endsWith(suffix)) {
out.append(path);
}
}
return out;
}
} // namespace ZShell