summaryrefslogtreecommitdiffstats
path: root/src/yuzu/applets/web_browser.h
blob: 98388658636004594948c390c4e5c321920dc126 (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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright 2018 yuzu Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.

#pragma once

#include <functional>
#include <QObject>

#ifdef YUZU_USE_QT_WEB_ENGINE
#include <QWebEngineView>
#endif

#include "core/frontend/applets/web_browser.h"

class GMainWindow;

#ifdef YUZU_USE_QT_WEB_ENGINE

QString GetNXShimInjectionScript();

class NXInputWebEngineView : public QWebEngineView {
public:
    explicit NXInputWebEngineView(QWidget* parent = nullptr);

protected:
    void keyPressEvent(QKeyEvent* event) override;
    void keyReleaseEvent(QKeyEvent* event) override;
};

#endif

class QtWebBrowser final : public QObject, public Core::Frontend::WebBrowserApplet {
    Q_OBJECT

public:
    explicit QtWebBrowser(GMainWindow& main_window);
    ~QtWebBrowser() override;

    void OpenPage(std::string_view url, std::function<void()> unpack_romfs_callback,
                  std::function<void()> finished_callback) const override;

signals:
    void MainWindowOpenPage(std::string_view filename, std::string_view additional_args) const;

private:
    void MainWindowUnpackRomFS();
    void MainWindowFinishedBrowsing();

    mutable std::function<void()> unpack_romfs_callback;
    mutable std::function<void()> finished_callback;
};