fabric/utils/misc.h
fabric/utils/misc.h
Namespaces
| Name |
|---|
| Syntalos |
Source code
/*
* Copyright (C) 2016-2026 Matthias Klumpp <matthias@tenstral.net>
*
* Licensed under the GNU Lesser General Public License Version 3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the license, or
* (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this software. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <expected>
#include <QStringList>
namespace Syntalos
{
// Conversion helpers to convert a bunch of random stuff into QString
// This is especially useful for supporting Qt versions < 6.9, which
// didn't accept QUtf8StringView-style arguments yet in some places.
inline const QString &qstr(const QString &s) noexcept
{
return s;
}
inline QString qstr(QStringView s)
{
return s.toString();
}
inline QString qstr(const char *s)
{
return QString::fromUtf8(s);
}
inline QString qstr(std::string_view s)
{
return QString::fromUtf8(s.data(), static_cast<qsizetype>(s.size()));
}
inline QString qstr(const std::string &s)
{
return QString::fromUtf8(s.data(), static_cast<qsizetype>(s.size()));
}
QString createRandomString(int len);
QString simplifyStrForModuleName(const QString &s);
[[nodiscard]] QString simplifyStrForFileBasename(const QString &s, bool lowerCase = true, uint maxLen = 60);
[[nodiscard]] std::string simplifyStrForFileBasename(const std::string &s, bool lowerCase = true, uint maxLen = 60);
QStringList qStringSplitLimit(
const QString &str,
const QChar &sep,
int maxSplit,
Qt::CaseSensitivity cs = Qt::CaseSensitive);
QString syntalosVersionFull();
QString syntalosVersion();
bool isInFlatpakSandbox();
QString appDataRootDir();
QString tempDirRoot();
QString tempDirLargeRoot();
QString findHostFile(const QString &path);
bool hostUdevRuleExists(const QString &ruleFilename);
bool isBinaryInPath(const QString &binaryName);
void delay(int waitMsec);
QByteArray blake3HashForData(const QByteArray &data);
auto blake3HashForFile(const QString &filename) -> std::expected<QByteArray, QString>;
QString formatByteSize(qint64 bytes);
QString formatApproxDuration(double seconds);
} // namespace Syntalos
Updated on 2026-09-06 at 20:30:11 +0000