mirror of
https://github.com/chylex/Nextcloud-Desktop.git
synced 2025-04-09 19:15:43 +02:00
add a network access factory to qml engine
ensure network access made via qml are using our user agent Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
This commit is contained in:
parent
1d704d9352
commit
12c6d6e3bd
src/gui
@ -22,6 +22,7 @@
|
||||
#include "wheelhandler.h"
|
||||
#include "tray/unifiedsearchresultimageprovider.h"
|
||||
#include "configfile.h"
|
||||
#include "accessmanager.h"
|
||||
|
||||
#include <QCursor>
|
||||
#include <QGuiApplication>
|
||||
@ -59,6 +60,8 @@ void Systray::setTrayEngine(QQmlApplicationEngine *trayEngine)
|
||||
{
|
||||
_trayEngine = trayEngine;
|
||||
|
||||
_trayEngine->setNetworkAccessManagerFactory(&_accessManagerFactory);
|
||||
|
||||
_trayEngine->addImportPath("qrc:/qml/theme");
|
||||
_trayEngine->addImageProvider("avatars", new ImageProvider);
|
||||
_trayEngine->addImageProvider(QLatin1String("svgimage-custom-color"), new OCC::Ui::SvgImageProvider);
|
||||
@ -505,4 +508,14 @@ QPoint Systray::calcTrayIconCenter() const
|
||||
#endif
|
||||
}
|
||||
|
||||
AccessManagerFactory::AccessManagerFactory()
|
||||
: QQmlNetworkAccessManagerFactory()
|
||||
{
|
||||
}
|
||||
|
||||
QNetworkAccessManager* AccessManagerFactory::create(QObject *parent)
|
||||
{
|
||||
return new AccessManager(parent);
|
||||
}
|
||||
|
||||
} // namespace OCC
|
||||
|
@ -20,6 +20,8 @@
|
||||
#include "accountmanager.h"
|
||||
#include "tray/usermodel.h"
|
||||
|
||||
#include <QQmlNetworkAccessManagerFactory>
|
||||
|
||||
class QScreen;
|
||||
class QQmlApplicationEngine;
|
||||
class QQuickWindow;
|
||||
@ -28,6 +30,14 @@ class QQuickWindow;
|
||||
|
||||
namespace OCC {
|
||||
|
||||
class AccessManagerFactory : public QQmlNetworkAccessManagerFactory
|
||||
{
|
||||
public:
|
||||
AccessManagerFactory();
|
||||
|
||||
QNetworkAccessManager* create(QObject *parent) override;
|
||||
};
|
||||
|
||||
#ifdef Q_OS_OSX
|
||||
bool canOsXSendUserNotification();
|
||||
void sendOsXUserNotification(const QString &title, const QString &message);
|
||||
@ -105,6 +115,8 @@ private:
|
||||
bool _isOpen = false;
|
||||
bool _syncIsPaused = true;
|
||||
QPointer<QQmlApplicationEngine> _trayEngine;
|
||||
|
||||
AccessManagerFactory _accessManagerFactory;
|
||||
};
|
||||
|
||||
} // namespace OCC
|
||||
|
Loading…
Reference in New Issue
Block a user