File indexing completed on 2024-04-28 04:59:48

0001 // SPDX-FileCopyrightText: 2024 Tobias Fella <tobias.fella@kde.org>
0002 // SPDX-License-Identifier: LGPL-2.0-or-later
0003 
0004 #pragma once
0005 
0006 #include <QObject>
0007 #include <QQmlEngine>
0008 
0009 class ProxyController : public QObject
0010 {
0011     Q_OBJECT
0012     QML_ELEMENT
0013     QML_SINGLETON
0014 
0015 public:
0016     static ProxyController &instance()
0017     {
0018         static ProxyController _instance;
0019         return _instance;
0020     }
0021     static ProxyController *create(QQmlEngine *engine, QJSEngine *)
0022     {
0023         engine->setObjectOwnership(&instance(), QQmlEngine::CppOwnership);
0024         return &instance();
0025     }
0026 
0027     /**
0028      * @brief Sets the QNetworkProxy for the application.
0029      *
0030      * @sa QNetworkProxy::setApplicationProxy
0031      */
0032     Q_INVOKABLE void setApplicationProxy();
0033 
0034 private:
0035     explicit ProxyController(QObject *parent = nullptr);
0036 };