diff options
author | Martin Negyokru <negyokru@inf.u-szeged.hu> | 2022-04-07 16:55:44 +0200 |
---|---|---|
committer | Martin Negyokru <negyokru@inf.u-szeged.hu> | 2023-02-01 17:10:14 +0100 |
commit | 7f5f2d4f75f594a70d1be7ea4559e5c2ac1f560e (patch) | |
tree | 0c1ec1396f06fb5a9e6958a518c98a9a6f357829 /examples/webenginequick/lifecycle/utils.h | |
parent | 1d0b015d7fcbe8629b4db1aacdac35dec317dc9d (diff) | |
download | qtwebengine-7f5f2d4f75f594a70d1be7ea4559e5c2ac1f560e.tar.gz |
Fix navigation error for incomplete URLs in webenginequick examples
Use QUrl::fromUserInput in lifecycle and webengineaction examples.
Task-number: QTBUG-96010
Pick-to: 6.5
Change-Id: I69cbcb1db31b0766d05f751b4aede11092d078d5
Reviewed-by: Peter Varga <pvarga@inf.u-szeged.hu>
Diffstat (limited to 'examples/webenginequick/lifecycle/utils.h')
-rw-r--r-- | examples/webenginequick/lifecycle/utils.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/examples/webenginequick/lifecycle/utils.h b/examples/webenginequick/lifecycle/utils.h new file mode 100644 index 000000000..d9a803907 --- /dev/null +++ b/examples/webenginequick/lifecycle/utils.h @@ -0,0 +1,25 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +#ifndef UTILS_H +#define UTILS_H + +#include <QtCore/QFileInfo> +#include <QtCore/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 |