aboutsummaryrefslogtreecommitdiff
path: root/src/schemes/NullSchemeHandler.hpp
blob: bc05076e4579dc8385a00f692b79ebc1d2213e86 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#pragma once

#include <QWebEngineUrlRequestJob>
#include <QWebEngineUrlSchemeHandler>
#include <QtCore>
#include <qcontainerfwd.h>
#include <qdebug.h>
#include <qurlquery.h>

// TODO: Install doc dir and pass this path during build
#define NULL_DOCS_DIR "./doc"

class NullSchemeHandler : public QWebEngineUrlSchemeHandler {
  Q_OBJECT

public:
  static NullSchemeHandler &instance() {
    static NullSchemeHandler handler;
    return handler;
  }

  void requestStarted(QWebEngineUrlRequestJob *job) override;

private:
  NullSchemeHandler() = default;

  QByteArray read_static_docs_file(const QString &path);
  QByteArray read_index_html();
  QByteArray get_content_type(const QString &path);
};