18#include <QAbstractSpinBox>
20#include <QApplication>
23#include <QStandardPaths>
25static inline bool clipLineToEdge(qreal& t0, qreal& t1, qreal p, qreal q)
41 qreal x1 = line.
x1(), x2 = line.
x2(), dx = line.
dx(), y1 = line.
y1(), y2 = line.
y2(), dy = line.
dy();
43 if ((t0 == 0 && t1 == 1 && ((x1 < left && x2 < left) ||
44 (x1 > right && x2 > right) ||
45 (y1 < top && y2 < top) ||
46 (y1 > bottom && y2 > bottom))) ||
47 !clipLineToEdge(t0, t1, -dx, x1 - left) ||
48 !clipLineToEdge(t0, t1, dx, right - x1) ||
49 !clipLineToEdge(t0, t1, -dy, y1 - top) ||
50 !clipLineToEdge(t0, t1, dy, bottom - y1)) {
55 return {line.
x1() + line.
dx() * t0,
56 line.
y1() + line.
dy() * t0,
57 line.
x1() + line.
dx() * t1,
58 line.
y1() + line.
dy() * t1};
108quint64 imageSize(
const QImage& img)
110#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
119 static const char alphanum[] =
"0123456789abcdefghijklmnopqrstuvwxyz";
120 const int alphanumLen =
sizeof(alphanum);
122 if (len > 128) len = 128;
125 for (
int i = 0; i < len; ++i)
127 s[i] = alphanum[rand() % (alphanumLen - 1)];
140 while (!existingSubpath.isRoot() && !existingSubpath.exists() && !existingSubpath.isSymbolicLink())
143 existingSubpath.setFile(existingSubpath.dir().absolutePath());
147 QString canonicalPath = existingSubpath.canonicalFilePath();
166 QString canonicalDataDirPath = closestCanonicalPath(dataDirPath);
167 QString canonicalFilePath = closestCanonicalPath(
QDir(dataDirPath).filePath(filePath));
170 if (canonicalDataDirPath.
isEmpty() || canonicalFilePath.
isEmpty())
172 qWarning() <<
"validateDataPath: failed to resolve canonical path for:" << filePath;
179 if (!canonicalDataDirPath.
endsWith(
'/'))
180 canonicalDataDirPath.
append(
'/');
183#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
188 if (canonicalFilePath.
startsWith(canonicalDataDirPath, cs))
190 return canonicalFilePath;
195 qWarning() <<
"validateDataPath: rejected path outside data directory:" << filePath;
QString applicationDirPath()
QString absolutePath() const const
QString filePath(const QString &fileName) const const
QString relativeFilePath(const QString &fileName) const const
int byteCount() const const
int sizeInBytes() const const
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QString findExecutable(const QString &executableName, const QStringList &paths)
QString & append(QChar ch)
bool endsWith(const QString &s, Qt::CaseSensitivity cs) const const
QString fromUtf8(const char *str, int size)
bool isEmpty() const const
bool startsWith(const QString &s, Qt::CaseSensitivity cs) const const
QTextStream & left(QTextStream &stream)
QTextStream & right(QTextStream &stream)