fix: re-add lost changes
This commit is contained in:
@@ -1,20 +1,20 @@
|
||||
qml_module(ZShell-blobs
|
||||
URI ZShell.Blobs
|
||||
SOURCES
|
||||
blobgroup.cpp
|
||||
blobshape.cpp
|
||||
blobrect.cpp
|
||||
blobinvertedrect.cpp
|
||||
blobmaterial.cpp
|
||||
LIBRARIES
|
||||
Qt::Quick
|
||||
SOURCES
|
||||
blobgroup.cpp
|
||||
blobshape.cpp
|
||||
blobrect.cpp
|
||||
blobinvertedrect.cpp
|
||||
blobmaterial.cpp
|
||||
LIBRARIES
|
||||
Qt::Quick
|
||||
)
|
||||
|
||||
qt_add_shaders(ZShell-blobs "blob_shaders"
|
||||
BATCHABLE OPTIMIZED NOHLSL NOMSL
|
||||
BATCHABLE OPTIMIZED NOHLSL NOMSL
|
||||
GLSL "300es,330"
|
||||
PREFIX "/"
|
||||
FILES
|
||||
shaders/blob.frag
|
||||
shaders/blob.vert
|
||||
PREFIX "/"
|
||||
FILES
|
||||
shaders/blob.frag
|
||||
shaders/blob.vert
|
||||
)
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
qml_module(ZShell-config
|
||||
URI ZShell.Config
|
||||
INCLUDE_PREFIX config
|
||||
DEPENDENCIES
|
||||
ZShell.Settings
|
||||
SOURCES
|
||||
confignode.hpp confignode.cpp
|
||||
configobject.hpp configobject.cpp
|
||||
configlist.hpp configlist.cpp
|
||||
config.hpp config.cpp
|
||||
rootnodes.hpp rootnodes.cpp
|
||||
common.hpp common.cpp
|
||||
migration.hpp migration.cpp
|
||||
anim.hpp anim.cpp
|
||||
fontbuilder.hpp fontbuilder.cpp
|
||||
@@ -31,6 +27,8 @@ qml_module(ZShell-config
|
||||
services.hpp
|
||||
sidebar.hpp
|
||||
utilities.hpp
|
||||
DEPENDENCIES
|
||||
ZShell.Settings
|
||||
)
|
||||
|
||||
target_link_libraries(ZShell-config PUBLIC
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
#include "dock.hpp"
|
||||
#include "general.hpp"
|
||||
#include "launcher.hpp"
|
||||
#include "llm.hpp"
|
||||
#include "lock.hpp"
|
||||
#include "notifs.hpp"
|
||||
#include "osd.hpp"
|
||||
@@ -43,7 +42,6 @@ class ConfigRoot : public settings::RootNode {
|
||||
CONFIG_SUBOBJECT(Dock, dock)
|
||||
CONFIG_SUBOBJECT(General, general)
|
||||
CONFIG_SUBOBJECT(Launcher, launcher)
|
||||
CONFIG_SUBOBJECT(Llm, llm)
|
||||
CONFIG_SUBOBJECT(Lock, lock)
|
||||
CONFIG_SUBOBJECT(Notifs, notifs)
|
||||
CONFIG_SUBOBJECT(Osd, osd)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
qml_module(ZShell-models
|
||||
URI ZShell.Models
|
||||
SOURCES
|
||||
filesystemmodel.hpp filesystemmodel.cpp
|
||||
LIBRARIES
|
||||
Qt::Gui
|
||||
Qt::Concurrent
|
||||
URI ZShell.Models
|
||||
SOURCES
|
||||
filesystemmodel.hpp filesystemmodel.cpp
|
||||
LIBRARIES
|
||||
Qt::Gui
|
||||
Qt::Concurrent
|
||||
)
|
||||
|
||||
+151
-6
@@ -5,13 +5,17 @@
|
||||
#include <QtQuick/qquickwindow.h>
|
||||
#include <qcontainerfwd.h>
|
||||
#include <qdir.h>
|
||||
#include <qdiriterator.h>
|
||||
#include <qfileinfo.h>
|
||||
#include <qfuturewatcher.h>
|
||||
#include <qjsprimitivevalue.h>
|
||||
#include <qloggingcategory.h>
|
||||
#include <qregularexpression.h>
|
||||
#include <qqmlengine.h>
|
||||
#include <qfile.h>
|
||||
|
||||
#include "util/metaenum.hpp"
|
||||
|
||||
Q_LOGGING_CATEGORY(lcZUtils, "ZShell.cutils", QtInfoMsg)
|
||||
|
||||
namespace ZShell {
|
||||
@@ -171,13 +175,112 @@ 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);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
template <typename Predicate>
|
||||
QQuickItem* findChildDfs(QQuickItem* root, Predicate&& match) {
|
||||
const auto children = root->childItems();
|
||||
for (QQuickItem* const child : children) {
|
||||
if (match(child)) {
|
||||
return child;
|
||||
}
|
||||
if (QQuickItem* const found = findChildDfs(child, match)) {
|
||||
return found;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
template <typename Predicate>
|
||||
void findChildrenDfs(
|
||||
QQuickItem* root, Predicate&& match, QList<QQuickItem*>& out) {
|
||||
const auto children = root->childItems();
|
||||
for (QQuickItem* const child : children) {
|
||||
if (match(child)) {
|
||||
out.append(child);
|
||||
}
|
||||
findChildrenDfs(child, match, out);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
QQuickItem* ZUtils::findChild(QQuickItem* root, const QString& name) {
|
||||
if (!root) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return findChildDfs(root, [&name](const QQuickItem* item) {
|
||||
return item->objectName() == name;
|
||||
});
|
||||
}
|
||||
|
||||
QList<QQuickItem*> ZUtils::findChildren(QQuickItem* root, const QString& name) {
|
||||
QList<QQuickItem*> children;
|
||||
if (root) {
|
||||
findChildrenDfs(
|
||||
root,
|
||||
[&name](const QQuickItem* item) {
|
||||
return item->objectName() == name;
|
||||
},
|
||||
children);
|
||||
}
|
||||
return children;
|
||||
}
|
||||
|
||||
QList<QQuickItem*> ZUtils::findChildrenMatching(
|
||||
QQuickItem* root, const QString& pattern) {
|
||||
QList<QQuickItem*> children;
|
||||
if (root) {
|
||||
const QRegularExpression re(pattern);
|
||||
findChildrenDfs(
|
||||
root,
|
||||
[&re](const QQuickItem* item) {
|
||||
return re.match(item->objectName()).hasMatch();
|
||||
},
|
||||
children);
|
||||
}
|
||||
return children;
|
||||
}
|
||||
|
||||
#ifndef ZSHELL_VERSION
|
||||
@@ -192,4 +295,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
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
#include <qcontainerfwd.h>
|
||||
#include <qobject.h>
|
||||
#include <qqmlintegration.h>
|
||||
#include <qtmetamacros.h>
|
||||
#include <qvariant.h>
|
||||
|
||||
namespace ZShell {
|
||||
|
||||
@@ -32,7 +34,24 @@ class ZUtils : public QObject {
|
||||
|
||||
Q_INVOKABLE static qreal clamp(qreal value, qreal min, qreal max);
|
||||
|
||||
Q_INVOKABLE static QString settingsIndex();
|
||||
Q_INVOKABLE static QString enumToString(
|
||||
QObject* target,
|
||||
const QString& property,
|
||||
const QVariant& value = QVariant());
|
||||
|
||||
Q_INVOKABLE static QString gitRevision();
|
||||
Q_INVOKABLE static QString readTextFile(const QString& path);
|
||||
Q_INVOKABLE static bool writeTextFile(
|
||||
const QString& path, const QString& text);
|
||||
Q_INVOKABLE static QStringList listFiles(
|
||||
const QString& dir, const QString& suffix);
|
||||
|
||||
Q_INVOKABLE static QQuickItem* findChild(
|
||||
QQuickItem* root, const QString& name);
|
||||
Q_INVOKABLE static QList<QQuickItem*> findChildren(
|
||||
QQuickItem* root, const QString& name);
|
||||
Q_INVOKABLE static QList<QQuickItem*> findChildrenMatching(
|
||||
QQuickItem* root, const QString& pattern);
|
||||
|
||||
[[nodiscard]] QString version() const;
|
||||
[[nodiscard]] QString qtVersion() const;
|
||||
|
||||
Reference in New Issue
Block a user