aboutsummaryrefslogtreecommitdiff
path: root/geminiwebpage.cpp
blob: 1cbd130ca2e4c478b28f52dc1a1b484ba2e8d1ca (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
#include "geminiwebpage.hpp"
#include "browsertab.hpp"

GeminiWebPage::GeminiWebPage(MainWindow * container) :
    QWebEnginePage(),
    main_window(container)
{

}

bool GeminiWebPage::acceptNavigationRequest(const QUrl &url, QWebEnginePage::NavigationType type, bool isMainFrame)
{
    switch(type)
    {
    // link navigation
    case QWebEnginePage::NavigationTypeLinkClicked: {
        bool result = false;
        emit this->navigationRequest(url, result);
        return result;
    }

    // manual navigation
    case QWebEnginePage::NavigationTypeTyped:
        return true;

    // we do this by hand!
    case QWebEnginePage::NavigationTypeFormSubmitted:
    case QWebEnginePage::NavigationTypeBackForward:
    case QWebEnginePage::NavigationTypeReload:
        return false;

    // forbidden by default
    case QWebEnginePage::NavigationTypeOther:
    case QWebEnginePage::NavigationTypeRedirect:
        return false;
    }
}

QWebEnginePage *GeminiWebPage::createWindow(QWebEnginePage::WebWindowType type)
{
    auto tab = main_window->addEmptyTab(true);

    return &tab->page;
}