1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 02:36:34 +01:00

Added documentation for ExtensionScheme API

This commit is contained in:
Anmol Gautam 2018-07-17 22:14:33 +05:30
parent dfb7efee5e
commit c322fdb068
3 changed files with 45 additions and 6 deletions

View File

@ -24,9 +24,15 @@
class QmlExtensionSchemeHandler;
/**
* @brief The QmlExtensionScheme class, exposed to QML as ExtensionScheme
*/
class QmlExtensionScheme : public QObject, public QQmlParserStatus
{
Q_OBJECT
/**
* @brief extension scheme handle name
*/
Q_PROPERTY(QString name READ name WRITE setName)
public:
explicit QmlExtensionScheme(QObject *parent = nullptr);
@ -34,6 +40,10 @@ public:
void classBegin() {}
void componentComplete();
Q_SIGNALS:
/**
* @brief The signal emitted when the request to the scheme handle is started
* @param request of the type [QmlWebEngineUrlRequestJob](@ref QmlWebEngineUrlRequestJob)
*/
void requestStarted(QmlWebEngineUrlRequestJob *request);
private:
QString m_name;

View File

@ -26,6 +26,10 @@ QmlWebEngineUrlRequestJob::QmlWebEngineUrlRequestJob(QWebEngineUrlRequestJob *jo
{
}
/**
* @brief Fails the request with the error
* @param error
*/
void QmlWebEngineUrlRequestJob::fail(QmlWebEngineUrlRequestJob::Error error)
{
if (!m_job) {
@ -34,6 +38,10 @@ void QmlWebEngineUrlRequestJob::fail(QmlWebEngineUrlRequestJob::Error error)
m_job->fail(QWebEngineUrlRequestJob::Error(error));
}
/**
* @brief Redirects the request to the url
* @param urlString, represents the url to which the request is to be redirected
*/
void QmlWebEngineUrlRequestJob::redirect(const QString &urlString)
{
if (!m_job) {
@ -42,6 +50,12 @@ void QmlWebEngineUrlRequestJob::redirect(const QString &urlString)
return m_job->redirect(QUrl::fromEncoded(urlString.toUtf8()));
}
/**
* @brief Replies to the request
* @param A JavaScript object containing
* - content: String representing the reply data
* - contentType: String representing the contentType of reply data
*/
void QmlWebEngineUrlRequestJob::reply(const QVariantMap &map)
{
if (!m_job) {

View File

@ -19,20 +19,35 @@
#include <QWebEngineUrlRequestJob>
/**
* @brief The QmlWebEngineUrlRequestJob class
*/
class QmlWebEngineUrlRequestJob : public QObject
{
Q_OBJECT
/**
* @brief initiator of the QWebEngineUrlRequestJob
*/
Q_PROPERTY(QString initiator READ initiator CONSTANT)
/**
* @brief request url of the QWebEngineUrlRequestJob
*/
Q_PROPERTY(QString requestUrl READ requestUrl CONSTANT)
/**
* @brief request method of the QWebEngineUrlRequestJob
*/
Q_PROPERTY(QString requestMethod READ requestMethod CONSTANT)
public:
/**
* @brief The Error enum, exposes QWebEngineUrlRequestJob::Error to QML
*/
enum Error {
NoError = QWebEngineUrlRequestJob::NoError,
UrlNotFound = QWebEngineUrlRequestJob::UrlNotFound,
UrlInvaild = QWebEngineUrlRequestJob::UrlInvalid,
RequestAborted = QWebEngineUrlRequestJob::RequestAborted,
RequestDenied = QWebEngineUrlRequestJob::RequestDenied,
RequestFailed = QWebEngineUrlRequestJob::RequestFailed
NoError = QWebEngineUrlRequestJob::NoError, //! No error
UrlNotFound = QWebEngineUrlRequestJob::UrlNotFound, //! Url not found error
UrlInvaild = QWebEngineUrlRequestJob::UrlInvalid, //! Url invalid error
RequestAborted = QWebEngineUrlRequestJob::RequestAborted, //! Request aborted
RequestDenied = QWebEngineUrlRequestJob::RequestDenied, //! Request denied
RequestFailed = QWebEngineUrlRequestJob::RequestFailed //! Request failed
};
Q_ENUMS(Error)
explicit QmlWebEngineUrlRequestJob(QWebEngineUrlRequestJob *job = nullptr, QObject *parent = nullptr);