File indexing completed on 2024-05-19 04:58:02
0001 // SPDX-FileCopyrightText: 2020 Jonah BrĂ¼chert <jbb@kaidan.im> 0002 // 0003 // SPDX-License-Identifier: GPL-2.0-or-later 0004 0005 #pragma once 0006 0007 #include <QObject> 0008 #include <QQuickItem> 0009 #include <QQuickWebEngineProfile> 0010 #include <QWebEngineUrlRequestInterceptor> 0011 0012 class QQuickWebEngineDownloadRequest; 0013 using DownloadItem = QQuickWebEngineDownloadRequest; 0014 0015 class QWebEngineNotification; 0016 class QQuickItem; 0017 class QWebEngineUrlRequestInterceptor; 0018 0019 class AngelfishWebProfile : public QQuickWebEngineProfile 0020 { 0021 Q_OBJECT 0022 0023 Q_PROPERTY(QQuickItem *questionLoader MEMBER m_questionLoader NOTIFY questionLoaderChanged) 0024 Q_PROPERTY(QWebEngineUrlRequestInterceptor *urlInterceptor WRITE setUrlInterceptor READ urlInterceptor NOTIFY urlInterceptorChanged) 0025 0026 public: 0027 explicit AngelfishWebProfile(QObject *parent = nullptr); 0028 0029 Q_SIGNAL void questionLoaderChanged(); 0030 Q_SIGNAL void urlInterceptorChanged(); 0031 0032 QWebEngineUrlRequestInterceptor *urlInterceptor() const; 0033 void setUrlInterceptor(QWebEngineUrlRequestInterceptor *urlRequestInterceptor); 0034 0035 private: 0036 void handleDownload(DownloadItem *downloadItem); 0037 void handleDownloadFinished(DownloadItem *downloadItem); 0038 void showNotification(QWebEngineNotification *webNotification); 0039 0040 QQuickItem *m_questionLoader; 0041 0042 // A valid property needs a read function, and there is no getter in QQuickWebEngineProfile 0043 // so store a pointer ourselves 0044 QWebEngineUrlRequestInterceptor *m_urlInterceptor; 0045 };