summaryrefslogtreecommitdiffstats
path: root/tests/manual/touchmocking/utils.h
diff options
context:
space:
mode:
Diffstat (limited to 'tests/manual/touchmocking/utils.h')
-rw-r--r--tests/manual/touchmocking/utils.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/manual/touchmocking/utils.h b/tests/manual/touchmocking/utils.h
new file mode 100644
index 000000000..12d493d3f
--- /dev/null
+++ b/tests/manual/touchmocking/utils.h
@@ -0,0 +1,25 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+#ifndef UTILS_H
+#define UTILS_H
+
+#include <QFileInfo>
+#include <QUrl>
+
+class Utils : public QObject
+{
+ Q_OBJECT
+public:
+ Q_INVOKABLE static QUrl fromUserInput(const QString &userInput);
+};
+
+inline QUrl Utils::fromUserInput(const QString &userInput)
+{
+ QFileInfo fileInfo(userInput);
+ if (fileInfo.exists())
+ return QUrl::fromLocalFile(fileInfo.absoluteFilePath());
+ return QUrl::fromUserInput(userInput);
+}
+
+#endif // UTILS_H